Browse Source

Add option parameter availability_zone

Signed-off-by: Ling FaKe <lingfake@huawei.com>
LingFaKe 3 years ago
parent
commit
e10e42cbb7
2 changed files with 13 additions and 4 deletions
  1. 5
    4
      drivers/openstack/client.go
  2. 8
    0
      drivers/openstack/openstack.go

+ 5
- 4
drivers/openstack/client.go View File

@@ -54,10 +54,11 @@ type GenericClient struct {
54 54
 
55 55
 func (c *GenericClient) CreateInstance(d *Driver) (string, error) {
56 56
 	serverOpts := servers.CreateOpts{
57
-		Name:           d.MachineName,
58
-		FlavorRef:      d.FlavorId,
59
-		ImageRef:       d.ImageId,
60
-		SecurityGroups: d.SecurityGroups,
57
+		Name:             d.MachineName,
58
+		FlavorRef:        d.FlavorId,
59
+		ImageRef:         d.ImageId,
60
+		SecurityGroups:   d.SecurityGroups,
61
+		AvailabilityZone: d.AvailabilityZone,
61 62
 	}
62 63
 	if d.NetworkId != "" {
63 64
 		serverOpts.Networks = []servers.Network{

+ 8
- 0
drivers/openstack/openstack.go View File

@@ -25,6 +25,7 @@ type Driver struct {
25 25
 	TenantName       string
26 26
 	TenantId         string
27 27
 	Region           string
28
+	AvailabilityZone string
28 29
 	EndpointType     string
29 30
 	MachineName      string
30 31
 	MachineId        string
@@ -111,6 +112,12 @@ func GetCreateFlags() []cli.Flag {
111 112
 			Usage:  "OpenStack region name",
112 113
 			Value:  "",
113 114
 		},
115
+		cli.StringFlag{
116
+			EnvVar: "OS_AVAILABILITY_ZONE",
117
+			Name:   "openstack-availability-zone",
118
+			Usage:  "OpenStack availability zone",
119
+			Value:  "",
120
+		},
114 121
 		cli.StringFlag{
115 122
 			EnvVar: "OS_ENDPOINT_TYPE",
116 123
 			Name:   "openstack-endpoint-type",
@@ -241,6 +248,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
241 248
 	d.TenantName = flags.String("openstack-tenant-name")
242 249
 	d.TenantId = flags.String("openstack-tenant-id")
243 250
 	d.Region = flags.String("openstack-region")
251
+	d.AvailabilityZone = flags.String("openstack-availability-zone")
244 252
 	d.EndpointType = flags.String("openstack-endpoint-type")
245 253
 	d.FlavorId = flags.String("openstack-flavor-id")
246 254
 	d.FlavorName = flags.String("openstack-flavor-name")

Loading…
Cancel
Save