Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v1] [db/v1/instance]: adding support for availability_zone for a db instance #2875

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions openstack/db/v1/instances/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func (opts NetworkOpts) ToMap() (map[string]interface{}, error) {

// CreateOpts is the struct responsible for configuring a new database instance.
type CreateOpts struct {
// The availability zone of the instance.
AvailabilityZone string `json:"availability_zone,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 @@ -87,6 +89,10 @@ func (opts CreateOpts) ToInstanceCreateMap() (map[string]interface{}, error) {
"flavorRef": opts.FlavorRef,
}

if opts.AvailabilityZone != "" {
instance["availability_zone"] = opts.AvailabilityZone
}

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 @@ -104,6 +104,7 @@ var instanceGet = `
var createReq = `
{
"instance": {
"availability_zone": "us-east1",
"databases": [
{
"character_set": "utf8",
Expand Down
10 changes: 6 additions & 4 deletions openstack/db/v1/instances/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ func TestCreate(t *testing.T) {
HandleCreate(t)

opts := instances.CreateOpts{
Name: "json_rack_instance",
FlavorRef: "1",
AvailabilityZone: "us-east1",
Name: "json_rack_instance",
FlavorRef: "1",
Databases: db.BatchCreateOpts{
{CharSet: "utf8", Collate: "utf8_general_ci", Name: "sampledb"},
{Name: "nextround"},
Expand Down Expand Up @@ -48,8 +49,9 @@ func TestCreateWithFault(t *testing.T) {
HandleCreateWithFault(t)

opts := instances.CreateOpts{
Name: "json_rack_instance",
FlavorRef: "1",
AvailabilityZone: "us-east1",
Name: "json_rack_instance",
FlavorRef: "1",
Databases: db.BatchCreateOpts{
{CharSet: "utf8", Collate: "utf8_general_ci", Name: "sampledb"},
{Name: "nextround"},
Expand Down