Browse Source

Add environment varibles for OpenStack flags

Some flags for the OpenStack driver did not have
a corresponding environment variable.

Among others, this is needed to run bats core tests
with the OpenStack driver.

Signed-off-by: Guillaume Giamarchi <guillaume.giamarchi@gmail.com>
Guillaume Giamarchi 3 years ago
parent
commit
a93aabadff
2 changed files with 72 additions and 60 deletions
  1. 25
    25
      docs/drivers/openstack.md
  2. 47
    35
      drivers/openstack/openstack.go

+ 25
- 25
docs/drivers/openstack.md View File

@@ -41,28 +41,28 @@ Options:
41 41
 
42 42
 Environment variables and default values:
43 43
 
44
-| CLI option                       | Environment variable   | Default |
45
-|----------------------------------|------------------------|---------|
46
-| `--openstack-auth-url`           | `OS_AUTH_URL`          | -       |
47
-| `--openstack-flavor-name`        | -                      | -       |
48
-| `--openstack-flavor-id`          | -                      | -       |
49
-| `--openstack-image-name`         | -                      | -       |
50
-| `--openstack-image-id`           | -                      | -       |
51
-| `--openstack-insecure`           | -                      | -       |
52
-| `--openstack-domain-name`        | `OS_DOMAIN_NAME`       | -       |
53
-| `--openstack-domain-id`          | `OS_DOMAIN_ID`         | -       |
54
-| `--openstack-username`           | `OS_USERNAME`          | -       |
55
-| `--openstack-password`           | `OS_PASSWORD`          | -       |
56
-| `--openstack-tenant-name`        | `OS_TENANT_NAME`       | -       |
57
-| `--openstack-tenant-id`          | `OS_TENANT_ID`         | -       |
58
-| `--openstack-region`             | `OS_REGION_NAME`       | -       |
59
-| `--openstack-availability-zone`  | `OS_AVAILABILITY_ZONE` | -       |
60
-| `--openstack-endpoint-type`      | `OS_ENDPOINT_TYPE`     | -       |
61
-| `--openstack-net-name`           | -                      | -       |
62
-| `--openstack-net-id`             | -                      | -       |
63
-| `--openstack-sec-groups`         | -                      | -       |
64
-| `--openstack-floatingip-pool`    | -                      | -       |
65
-| `--openstack-ip-version`         | `OS_IP_VERSION`        | `4`     |
66
-| `--openstack-ssh-user`           | -                      | `root`  |
67
-| `--openstack-ssh-port`           | -                      | `22`    |
68
-| `--openstack-active-timeout`     | -                      | `200`   |
44
+| CLI option                       | Environment variable   | Default     |
45
+|----------------------------------|------------------------|-------------|
46
+| `--openstack-auth-url`           | `OS_AUTH_URL`          | -           |
47
+| `--openstack-flavor-name`        | `OS_FLAVOR_NAME`       | -           |
48
+| `--openstack-flavor-id`          | `OS_FLAVOR_ID`         | -           |
49
+| `--openstack-image-name`         | `OS_IMAGE_NAME`        | -           |
50
+| `--openstack-image-id`           | `OS_IMAGE_ID`          | -           |
51
+| `--openstack-insecure`           | `OS_INSECURE`          | `false`     |
52
+| `--openstack-domain-name`        | `OS_DOMAIN_NAME`       | -           |
53
+| `--openstack-domain-id`          | `OS_DOMAIN_ID`         | -           |
54
+| `--openstack-username`           | `OS_USERNAME`          | -           |
55
+| `--openstack-password`           | `OS_PASSWORD`          | -           |
56
+| `--openstack-tenant-name`        | `OS_TENANT_NAME`       | -           |
57
+| `--openstack-tenant-id`          | `OS_TENANT_ID`         | -           |
58
+| `--openstack-region`             | `OS_REGION_NAME`       | -           |
59
+| `--openstack-availability-zone`  | `OS_AVAILABILITY_ZONE` | -           |
60
+| `--openstack-endpoint-type`      | `OS_ENDPOINT_TYPE`     | `publicURL` |
61
+| `--openstack-net-name`           | `OS_NETWORK_NAME`      | -           |
62
+| `--openstack-net-id`             | `OS_NETWORK_ID`        | -           |
63
+| `--openstack-sec-groups`         | `OS_SECURITY_GROUPS`   | -           |
64
+| `--openstack-floatingip-pool`    | `OS_FLOATINGIP_POOL`   | -           |
65
+| `--openstack-ip-version`         | `OS_IP_VERSION`        | `4`         |
66
+| `--openstack-ssh-user`           | `OS_SSH_USER`          | `root`      |
67
+| `--openstack-ssh-port`           | `OS_SSH_PORT`          | `22`        |
68
+| `--openstack-active-timeout`     | `OS_ACTIVE_TIMEOUT`    | `200`       |

+ 47
- 35
drivers/openstack/openstack.go View File

@@ -64,8 +64,9 @@ func GetCreateFlags() []cli.Flag {
64 64
 			Value:  "",
65 65
 		},
66 66
 		cli.BoolFlag{
67
-			Name:  "openstack-insecure",
68
-			Usage: "Disable TLS credential checking.",
67
+			EnvVar: "OS_INSECURE",
68
+			Name:   "openstack-insecure",
69
+			Usage:  "Disable TLS credential checking.",
69 70
 		},
70 71
 		cli.StringFlag{
71 72
 			EnvVar: "OS_DOMAIN_ID",
@@ -122,44 +123,52 @@ func GetCreateFlags() []cli.Flag {
122 123
 			Value:  "",
123 124
 		},
124 125
 		cli.StringFlag{
125
-			Name:  "openstack-flavor-id",
126
-			Usage: "OpenStack flavor id to use for the instance",
127
-			Value: "",
126
+			EnvVar: "OS_FLAVOR_ID",
127
+			Name:   "openstack-flavor-id",
128
+			Usage:  "OpenStack flavor id to use for the instance",
129
+			Value:  "",
128 130
 		},
129 131
 		cli.StringFlag{
130
-			Name:  "openstack-flavor-name",
131
-			Usage: "OpenStack flavor name to use for the instance",
132
-			Value: "",
132
+			EnvVar: "OS_FLAVOR_NAME",
133
+			Name:   "openstack-flavor-name",
134
+			Usage:  "OpenStack flavor name to use for the instance",
135
+			Value:  "",
133 136
 		},
134 137
 		cli.StringFlag{
135
-			Name:  "openstack-image-id",
136
-			Usage: "OpenStack image id to use for the instance",
137
-			Value: "",
138
+			EnvVar: "OS_IMAGE_ID",
139
+			Name:   "openstack-image-id",
140
+			Usage:  "OpenStack image id to use for the instance",
141
+			Value:  "",
138 142
 		},
139 143
 		cli.StringFlag{
140
-			Name:  "openstack-image-name",
141
-			Usage: "OpenStack image name to use for the instance",
142
-			Value: "",
144
+			EnvVar: "OS_IMAGE_NAME",
145
+			Name:   "openstack-image-name",
146
+			Usage:  "OpenStack image name to use for the instance",
147
+			Value:  "",
143 148
 		},
144 149
 		cli.StringFlag{
145
-			Name:  "openstack-net-id",
146
-			Usage: "OpenStack network id the machine will be connected on",
147
-			Value: "",
150
+			EnvVar: "OS_NETWORK_ID",
151
+			Name:   "openstack-net-id",
152
+			Usage:  "OpenStack network id the machine will be connected on",
153
+			Value:  "",
148 154
 		},
149 155
 		cli.StringFlag{
150
-			Name:  "openstack-net-name",
151
-			Usage: "OpenStack network name the machine will be connected on",
152
-			Value: "",
156
+			EnvVar: "OS_NETWORK_NAME",
157
+			Name:   "openstack-net-name",
158
+			Usage:  "OpenStack network name the machine will be connected on",
159
+			Value:  "",
153 160
 		},
154 161
 		cli.StringFlag{
155
-			Name:  "openstack-sec-groups",
156
-			Usage: "OpenStack comma separated security groups for the machine",
157
-			Value: "",
162
+			EnvVar: "OS_SECURITY_GROUPS",
163
+			Name:   "openstack-sec-groups",
164
+			Usage:  "OpenStack comma separated security groups for the machine",
165
+			Value:  "",
158 166
 		},
159 167
 		cli.StringFlag{
160
-			Name:  "openstack-floatingip-pool",
161
-			Usage: "OpenStack floating IP pool to get an IP from to assign to the instance",
162
-			Value: "",
168
+			EnvVar: "OS_FLOATINGIP_POOL",
169
+			Name:   "openstack-floatingip-pool",
170
+			Usage:  "OpenStack floating IP pool to get an IP from to assign to the instance",
171
+			Value:  "",
163 172
 		},
164 173
 		cli.IntFlag{
165 174
 			EnvVar: "OS_IP_VERSION",
@@ -168,19 +177,22 @@ func GetCreateFlags() []cli.Flag {
168 177
 			Value:  4,
169 178
 		},
170 179
 		cli.StringFlag{
171
-			Name:  "openstack-ssh-user",
172
-			Usage: "OpenStack SSH user",
173
-			Value: defaultSSHUser,
180
+			EnvVar: "OS_SSH_USER",
181
+			Name:   "openstack-ssh-user",
182
+			Usage:  "OpenStack SSH user",
183
+			Value:  defaultSSHUser,
174 184
 		},
175 185
 		cli.IntFlag{
176
-			Name:  "openstack-ssh-port",
177
-			Usage: "OpenStack SSH port",
178
-			Value: defaultSSHPort,
186
+			EnvVar: "OS_SSH_PORT",
187
+			Name:   "openstack-ssh-port",
188
+			Usage:  "OpenStack SSH port",
189
+			Value:  defaultSSHPort,
179 190
 		},
180 191
 		cli.IntFlag{
181
-			Name:  "openstack-active-timeout",
182
-			Usage: "OpenStack active timeout",
183
-			Value: defaultActiveTimeout,
192
+			EnvVar: "OS_ACTIVE_TIMEOUT",
193
+			Name:   "openstack-active-timeout",
194
+			Usage:  "OpenStack active timeout",
195
+			Value:  defaultActiveTimeout,
184 196
 		},
185 197
 	}
186 198
 }

Loading…
Cancel
Save