Skip to content

Commit

Permalink
Merge pull request gophercloud#2882 from nikParasyr/db_instance_config
Browse files Browse the repository at this point in the history
db/v1/instance: Add configuration to createOpts
  • Loading branch information
EmilienM authored Feb 12, 2024
2 parents 2033f25 + 086cd1b commit c287220
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions openstack/db/v1/instances/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ func (opts NetworkOpts) ToMap() (map[string]interface{}, error) {
type CreateOpts struct {
// The availability zone of the instance.
AvailabilityZone string `json:"availability_zone,omitempty"`
// ID of the configuration group that you want to attach to the instance.
Configuration string `json:"configuration,omitempty"`
// Either the integer UUID (in string form) of the flavor, or its URI
// reference as specified in the response from the List() call. Required.
FlavorRef string
Expand Down Expand Up @@ -93,6 +95,10 @@ func (opts CreateOpts) ToInstanceCreateMap() (map[string]interface{}, error) {
instance["availability_zone"] = opts.AvailabilityZone
}

if opts.Configuration != "" {
instance["configuration"] = opts.Configuration
}

if opts.Name != "" {
instance["name"] = opts.Name
}
Expand Down
1 change: 1 addition & 0 deletions openstack/db/v1/instances/testing/fixtures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ var createReq = `
{
"instance": {
"availability_zone": "us-east1",
"configuration": "4a78b397-c355-4127-be45-56230b2ab74e",
"databases": [
{
"character_set": "utf8",
Expand Down
2 changes: 2 additions & 0 deletions openstack/db/v1/instances/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func TestCreate(t *testing.T) {

opts := instances.CreateOpts{
AvailabilityZone: "us-east1",
Configuration: "4a78b397-c355-4127-be45-56230b2ab74e",
Name: "json_rack_instance",
FlavorRef: "1",
Databases: db.BatchCreateOpts{
Expand Down Expand Up @@ -50,6 +51,7 @@ func TestCreateWithFault(t *testing.T) {

opts := instances.CreateOpts{
AvailabilityZone: "us-east1",
Configuration: "4a78b397-c355-4127-be45-56230b2ab74e",
Name: "json_rack_instance",
FlavorRef: "1",
Databases: db.BatchCreateOpts{
Expand Down

0 comments on commit c287220

Please sign in to comment.