kitchen-openstack 2.0.0 → 2.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ffac59814629b9ac383483ecfe3cf01cf682589
4
- data.tar.gz: 3f6a0e8daba0499e3e0033975757e3640b7e07b6
3
+ metadata.gz: da74b5aca0c6e35157b769c798e4dedf61763f5c
4
+ data.tar.gz: 8af292a126a2aff03f0840018710961cf4a71ad8
5
5
  SHA512:
6
- metadata.gz: 6fa59ace07457afc636b39a2f3b61af484f8ad8463d47c18ec100bb65ed5959f6cda5b5ac795b5b5196296dec163d177b65aa6ac9de31a3ede2c26cc6e690f44
7
- data.tar.gz: 2d67d31f55ae30bc95d82d1f94bc9e5d58087f228641567e85484d90d645bb38d65d2b38028dffc588a417dc7e02e9b2c55e20277d97a29a6c54957635a3809d
6
+ metadata.gz: cf9bf596c2e143855267fc9ebebf283ffc07822181d137a79174c66973bc1940956aaadaf64e5f9c08b164c5c4cb73a612c10928561be0bff5244959b10575cc
7
+ data.tar.gz: 7b95de0644e858e60f0750bb58e0657363d045fd53e6df8b4db242c8a4c933eae5488a6653ab0fa370f7d0cdf8697bf6570c5131bc25f5979d7d3541c6a64902
@@ -1,3 +1,14 @@
1
+ # 2.1.0.pre / 2015-XX-XX
2
+
3
+ ### New Features
4
+
5
+ * PR [#106][] - The ability to bootstrap on only a private network paired with [@thomascate][] and [@BobbyRyterski][]
6
+
7
+ ### Bug Fixes
8
+
9
+ * PR [#106][] - Updated the README with better formatting
10
+ * PR [#111][] - Updated README.
11
+
1
12
  # 2.0.0 / 2015-09-30
2
13
 
3
14
  ### New Features
@@ -16,7 +27,7 @@
16
27
 
17
28
  ### Improvements
18
29
 
19
- * Updates to the readme PR [#102][] - from [@BobbyRyterski][]
30
+ * PR [#102][] - Updates to the readme - from [@BobbyRyterski][]
20
31
 
21
32
  # 1.8.1 / 2015-07-22
22
33
 
@@ -171,7 +182,8 @@ certain specified NICs; via [@monsterzz][]
171
182
 
172
183
  * Initial release! Woo!
173
184
 
174
-
185
+ [#111]: https://github.com/test-kitchen/kitchen-openstack/pull/111
186
+ [#106]: https://github.com/test-kitchen/kitchen-openstack/pull/106
175
187
  [#104]: https://github.com/test-kitchen/kitchen-openstack/pull/104
176
188
  [#102]: https://github.com/test-kitchen/kitchen-openstack/pull/102
177
189
  [#100]: https://github.com/test-kitchen/kitchen-openstack/pull/100
@@ -213,6 +225,7 @@ certain specified NICs; via [@monsterzz][]
213
225
  [#7]: https://github.com/test-kitchen/kitchen-openstack/pull/7
214
226
  [#2]: https://github.com/test-kitchen/kitchen-openstack/pull/2
215
227
 
228
+ [@thomascate]: https://github.com/thomascate
216
229
  [@jmahowald]: https://github.com/jmahowald
217
230
  [@dpetzel]: https://github.com/dpetzel
218
231
  [@BobbyRyterski]: https://github.com/BobbyRyterski
@@ -1,6 +1,8 @@
1
1
  Author:: Jonathan Hartman (<j@p4nt5.com>)
2
+ Author:: JJ Asghar (<jj@chef.io>)
2
3
 
3
4
  Copyright (c) 2013 Jonathan Hartman
5
+ Copyright (c) 2015 Chef Software, Inc
4
6
 
5
7
  Licensed under the Apache License, Version 2.0 (the "License");
6
8
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -1,55 +1,60 @@
1
+ # <a name="title"></a> Kitchen::OpenStack: A Test Kitchen Driver for OpenStack
2
+
1
3
  [![Gem Version](https://img.shields.io/gem/v/kitchen-openstack.svg)][gem]
2
4
  [![Build Status](https://img.shields.io/travis/test-kitchen/kitchen-openstack.svg)][travis]
3
5
  [![Code Climate](https://img.shields.io/codeclimate/github/test-kitchen/kitchen-openstack.svg)][codeclimate]
4
6
  [![Coverage Status](https://img.shields.io/coveralls/test-kitchen/kitchen-openstack.svg)][coveralls]
5
7
  [![Dependency Status](https://img.shields.io/gemnasium/test-kitchen/kitchen-openstack.svg)][gemnasium]
6
8
 
7
- [gem]: https://rubygems.org/gems/kitchen-openstack
8
- [travis]: https://travis-ci.org/test-kitchen/kitchen-openstack
9
- [codeclimate]: https://codeclimate.com/github/test-kitchen/kitchen-openstack
10
- [coveralls]: https://coveralls.io/r/test-kitchen/kitchen-openstack
11
- [gemnasium]: https://gemnasium.com/test-kitchen/kitchen-openstack
9
+ A [Test Kitchen][kitchen_ci] Driver for [OpenStack][openstack_web].
10
+
11
+ This driver uses the [fog gem][fog_web] to provision and destroy nova instances. Use an OpenStack cloud for your infrastructure testing!
12
12
 
13
- # Kitchen::OpenStack
13
+ Shamelessly copied from [Fletcher Nichol](https://github.com/fnichol)'s awesome work on an [EC2 driver](https://github.com/test-kitchen/kitchen-ec2), and [Adam Leff](https://github.com/adamleff)'s amazing work on an [VRO driver](https://github.com/chef-partners/kitchen-vro).
14
14
 
15
- An OpenStack Nova driver for Test Kitchen 1.0!
15
+ ## Requirements
16
16
 
17
- Shamelessly copied from [Fletcher Nichol](https://github.com/fnichol)'s
18
- awesome work on an [EC2 driver](https://github.com/test-kitchen/kitchen-ec2),
19
- and [Adam Leff](https://github.com/adamleff)'s
20
- amazing work on an [VRO driver](https://github.com/chef-partners/kitchen-vro).
17
+ There are **no** external system requirements for this driver. However you will need access to an OpenStack cloud.
21
18
 
22
- ## Installation
19
+ ## Installation and Setup
23
20
 
24
21
  Add this line to your application's Gemfile:
25
22
 
26
- gem 'kitchen-openstack'
23
+ ```ruby
24
+ gem 'kitchen-openstack'
25
+ ```
27
26
 
28
27
  And then execute:
29
28
 
30
- $ bundle
29
+ ```bash
30
+ $ bundle
31
+ ```
31
32
 
32
33
  Or install it yourself as:
33
34
 
34
- $ gem install kitchen-openstack
35
-
36
- Or if using [chefdk](https://downloads.chef.io/chef-dk) install with:
35
+ ```bash
36
+ $ gem install kitchen-openstack
37
+ ```
37
38
 
38
- $ chef gem install kitchen-openstack
39
+ Or if using [chefdk][chefdk_dl] install with:
39
40
 
40
- ## Usage
41
+ ```bash
42
+ $ chef gem install kitchen-openstack
43
+ ```
41
44
 
42
- Provide, at a minimum, the required driver options in your `.kitchen.yml` file:
45
+ ## Minimum Configuration
43
46
 
44
47
  ```yaml
45
48
  driver:
46
49
  name: openstack
47
50
  openstack_username: [YOUR OPENSTACK USERNAME]
48
- openstack_api_key: [YOUR OPENSTACK API KEY] # AKA your OPENSTACK PASSWORD
51
+ openstack_api_key: [YOUR OPENSTACK API KEY] # AKA your OpenStack Password
49
52
  openstack_auth_url: [YOUR OPENSTACK AUTH URL]
50
53
  require_chef_omnibus: [e.g. 'true' or a version number if you need Chef]
51
54
  image_ref: [SERVER IMAGE ID]
52
55
  flavor_ref: [SERVER FLAVOR ID]
56
+ transport:
57
+ username: ubuntu # For a Ubuntu Box
53
58
  ```
54
59
 
55
60
  The `image_ref` and `flavor_ref` options can be specified as an exact id,
@@ -58,81 +63,54 @@ an exact name, or as a regular expression matching the name of the image or flav
58
63
  All of Fog's `openstack` options (`openstack_domain_name`, `openstack_project_name`,
59
64
  ...) are supported. This includes support for the OpenStack Identity v3 API.
60
65
 
61
- Test Kitchen 1.4 supports multiple transports, and transports can be configure globally:
66
+ ## General Configuration
62
67
 
63
- ```yaml
64
- transport:
65
- username: ubuntu
66
- password: mysecretpassword
67
- ```
68
+ ### name
68
69
 
69
- ... or per-platform:
70
+ **Required** Tell test-kitchen what driver to use. ;)
70
71
 
71
- ```yaml
72
- platforms:
73
- name: ubuntu-14.04
74
- transport:
75
- password: myrootpassword
76
- name: windows-2012r2
77
- password: myadministratorpassword
78
- ```
72
+ ### openstack\_username
79
73
 
80
- Transports also control key based authentication:
74
+ **Required** Your OpenStack username.
81
75
 
82
- ```yaml
83
- transport:
84
- username: ubuntu
85
- ssh_key: /path/to/key # probably the same as private_key_path
86
- ```
76
+ ### openstack\_api\_key
77
+
78
+ **Required** Your OpenStack API Key, aka your OpenStack password.
79
+
80
+ ### openstack\_auth\_url
87
81
 
88
- See issues [#77](https://github.com/test-kitchen/kitchen-openstack/issues/77)
89
- and [#101](https://github.com/test-kitchen/kitchen-openstack/issues/101)
90
- for more information on using SSH keys.
91
-
92
- By default, a unique server name will be generated and the current user's SSH
93
- key will be used (with an RSA key taking precedence over a DSA), though that
94
- behavior can be overridden with additional options:
95
-
96
- server_name: [A UNIQUE SERVER NAME]
97
- server_name_prefix: [STATIC PREFIX FOR RANDOM SERVER NAME]
98
- private_key_path: [PATH TO YOUR PRIVATE SSH KEY]
99
- public_key_path: [PATH TO YOUR SSH PUBLIC KEY]
100
- username: [SSH USER]
101
- password: [SSH PASSWORD]
102
- port: [SSH PORT]
103
- key_name: [SSH KEY NAME]
104
- openstack_tenant: [YOUR OPENSTACK TENANT NAME]
105
- openstack_region: [A VALID OPENSTACK REGION]
106
- availability_zone: [AN OPENSTACK AVAILABILITY ZONE]
107
- openstack_service_name: [YOUR OPENSTACK COMPUTE SERVICE NAME]
108
- openstack_network_name: [YOUR OPENSTACK NETWORK NAME USED TO CONNECT]
109
- security_groups:
110
- - [A LIST OF...]
111
- - [...SECURITY GROUPS TO JOIN]
112
- network_ref:
113
- - [OPENSTACK NETWORK NAMES OR...]
114
- - [...ID TO CREATE INSTANCE WITH]
115
- no_ssh_tcp_check: [DEFAULTS TO false, SKIPS TCP CHECK WHEN true]
116
- no_ssh_tcp_check_sleep: [NUM OF SECONDS TO SLEEP IF no_ssh_tcp_check IS SET]
117
- block_device_mapping:
118
- make_volume: [DEFAULTS TO false, MAKES A NEW VOLUME WHEN true]
119
- snapshot_id: [WHEN SET WILL MAKE VOLUME FROM VOLUME SNAPSHOT]
120
- volume_id: [WILL ATTACH VOLUME WHEN SET]
121
- volume_size: [THE SIZE OF THE VOLUME TO BE ATTACHED/MADE]
122
- device_name: [SET TO vda UNLESS YOU KNOW WHAT YOU ARE DOING]
123
- availability_zone: [THE BLOCK STORAGE AVAILABILITY ZONE, DEFAULTS TO nova]
124
- volume_type: [THE VOLUME TYPE, THIS IS OPTIONAL]
125
- delete_on_termination: [WILL DELETE VOLUME ON INSTANCE DESTROY WHEN true, OTHERWISE SET TO false]
126
- winrm_wait: [DEFAULTS TO 0, BUT THIS HELPS CONFIRM WINRM IS IN A GOOD STATE BEFORE TRYING TO CONNECT]
82
+ **Required** Your OpenStack auth url.
83
+
84
+ ### require\_chef_omnibus
85
+
86
+ **Required** Set to `true` otherwise the specific version of Chef omnibus you want installed.
87
+
88
+ ### image\_ref
89
+
90
+ **Required** Server Image ID.
91
+
92
+ ### flavor\_ref
93
+
94
+ **Required** Server Flavor ID.
95
+
96
+ ### server\_name
127
97
 
128
98
  If a `server_name_prefix` is specified then this prefix will be used when
129
99
  generating random names of the form `<NAME PREFIX>-<RANDOM STRING>` e.g.
130
100
  `myproject-asdfghjk`. If both `server_name_prefix` and `server_name` are
131
101
  specified then the `server_name` takes precedence.
132
102
 
133
- `winrm_wait` is a workaround to deal with how WinRM comes up during machine
134
- creation. With `cloud-init` running on most OpenStack instances having this
135
- wait makes sure that the machine is in a good state to work with.
103
+ ### server\_name\_prefix
104
+
105
+ If you want to have a static prefix for a random server name.
106
+
107
+ ### private\_key\_path
108
+
109
+ The path to your private ssh key.
110
+
111
+ ### public\_key\_path
112
+
113
+ The path to your public ssh key.
136
114
 
137
115
  If a `key_name` is provided it will be used instead of any
138
116
  `public_key_path` that is specified.
@@ -143,12 +121,144 @@ OpenStack key. If you do key injection via `cloud-init` like this issue:
143
121
  [#77](https://github.com/test-kitchen/kitchen-openstack/issues/77) the best
144
122
  way is to make a "dummy-key."
145
123
 
146
- A specific `floating_ip` or the ID of a `floating_ip_pool` can be provided to
147
- bind a floating IP to the node. Any floating IP will be the IP used for
148
- Test Kitchen's SSH calls to the node.
124
+ ### username
125
+
126
+ **Deprecated** SSH User name, you should be using transport now.
127
+
128
+ ### password
129
+
130
+ **Deprecated** SSH password, you should be using transport now.
131
+
132
+ ### port
133
+
134
+ Set the SSH port for the remote access.
135
+
136
+ ### openstack\_tenant
137
+
138
+ Your OpenStack tenant id.
139
+
140
+ ### openstack\_region
141
+
142
+ Your OpenStack region id.
143
+
144
+ ### availability\_zone
145
+
146
+ Your OpenStack availablity zone.
147
+
148
+ ### openstack\_service\_name
149
+
150
+ Your OpenStack compute service name.
151
+
152
+ ### openstack\_network\_name
153
+
154
+ Your OpenStack network name used to connect to, if you have only private network
155
+ connections you want declare this.
156
+
157
+ ### server\_wait
158
+
159
+ `server_wait` is a workaround to deal with how some VMs with `cloud-init`.
160
+ Some clouds need this some, most OpenStack instances don't. This is a stop gap
161
+ wait makes sure that the machine is in a good state to work with. Ideally the
162
+ transport layer in Test-Kitchen will have a more intelligent way to deal with this.
163
+ You may want to add this for **WinRM** instances due to the multiple restarts that
164
+ happen on creation and boot. A good default is `300` seconds to make sure it's
165
+ in a good state.
166
+
167
+ The default is `0`.
168
+
169
+ ### security\_groups
170
+
171
+ A list of `security_groups` to join:
172
+
173
+ ```yaml
174
+ security_groups:
175
+ - [A LIST OF...]
176
+ - [...SECURITY GROUPS TO JOIN]
177
+ ```
178
+
179
+ ### network\_ref
180
+
181
+ **Deprecated** A list of network names or ids to create instances with.
182
+
183
+ ```yaml
184
+ network_ref:
185
+ - [OPENSTACK NETWORK NAMES OR...]
186
+ - [...ID TO CREATE INSTANCE WITH]
187
+ ```
188
+
189
+ ### no\_ssh\_tcp\_check
190
+
191
+ **Deprecated** You should be using transport now. This will skip the ssh check to automatically connect.
192
+
193
+ The default is `false`.
194
+
195
+ ### no\_ssh\_tcp\_check\_sleep
149
196
 
150
- floating_ip: [A SPECIFIC FLOATING IP TO ASSIGN]
151
- floating_ip_pool: [AN OPENSTACK POOL NAME TO ASSIGN THE NEXT IP FROM]
197
+ **Deprecated** You should be using transport now. This will sleep for so many seconds. `no_ssh_tcp_check` needs
198
+ to be set to `true`.
199
+
200
+ ## Disk Configuration
201
+
202
+ ### <a name="config-block_device_mappings"></a> block\_device\_mappings
203
+
204
+ #### make\_volume
205
+
206
+ Makes a new volume when set to `true`.
207
+
208
+ The default is `false`.
209
+
210
+ #### snapshot\_id
211
+
212
+ When set, will make a volume from that snapshot id.
213
+
214
+ #### volume\_id
215
+
216
+ When set, will attach the volume id.
217
+
218
+ #### device\_name
219
+
220
+ Set this to `vda` unless you really know what you are doing.
221
+
222
+ #### availability\_zone
223
+
224
+ The block storage availability zone.
225
+
226
+ The default is `nova`.
227
+
228
+ #### volume\_type
229
+
230
+ The volume type, this is optional.
231
+
232
+ #### delete\_on\_termination
233
+
234
+ This will delete the volume on the instance when `destroy` happens, if set to true.
235
+ Otherwise set this to `false`.
236
+
237
+ #### Example
238
+
239
+ ```yaml
240
+ block_device_mappings:
241
+ make_volume: true
242
+ snapshot_id: 00000-111111-0000222-000
243
+ device_name: vda
244
+ availability_zone: nova
245
+ delete_on_termination: false
246
+ ```
247
+
248
+ ## Network and Communication Configuration
249
+
250
+ ### floating\_ip
251
+
252
+ A specific `floating_ip` can be provided to bind a floating IP to the node.
253
+ Any floating IP will be the IP used for Test Kitchen's Remote calls to the node.
254
+
255
+ ### floating\_ip\_pool
256
+
257
+ A `floating_ip_pool` can be provided to acquire the first free floating ip from
258
+ the pool to attach to the instance. It will be the IP used for Test Kitchen's
259
+ Remote calls to the node.
260
+
261
+ ### \[public\|private\]\_ip\_order
152
262
 
153
263
  In some complex network scenarios you can have several IP addresses designated
154
264
  as public or private. Use `public_ip_order` or `private_ip_order` to control
@@ -168,20 +278,26 @@ to use second `10.0.1.1` IP address you need to specify
168
278
 
169
279
  ```yaml
170
280
  private_ip_order: 1
171
-
172
281
  ```
173
282
  assuming that test network is configured as private.
174
283
 
284
+
285
+ ### network\_ref
286
+
175
287
  The `network_ref` option can be specified as an exact id, an exact name,
176
288
  or as a regular expression matching the name of the network. You can pass one
177
289
 
178
- network_ref: MYNET1
290
+ ```yaml
291
+ network_ref: MYNET1
292
+ ```
179
293
 
180
294
  or many networks
181
295
 
182
- network_ref:
183
- - MYNET1
184
- - MYNET2
296
+ ```yaml
297
+ network_ref:
298
+ - MYNET1
299
+ - MYNET2
300
+ ```
185
301
 
186
302
  The `openstack_network_name` is used to select IP address for SSH connection.
187
303
  It's recommended to specify this option in case of multiple networks used for
@@ -190,16 +306,94 @@ instance to provide more control over network connectivity.
190
306
  Please note that `network_ref` relies on Network Services (`Fog::Network`) and
191
307
  it can be unavailable in your OpenStack installation.
192
308
 
193
- disable_ssl_validation: true
309
+
310
+ ### disable\_ssl\_validation
311
+
312
+ ```yaml
313
+ disable_ssl_validation: true
314
+ ```
194
315
 
195
316
  Only disable SSL cert validation if you absolutely know what you are doing,
196
317
  but are stuck with an OpenStack deployment without valid SSL certs.
197
318
 
198
- ## Contributing
319
+ ## Example
320
+
321
+ The following could be used in a `.kitchen.yml` or in a `.kitchen.local.yml`
322
+ to override default configuration.
323
+
324
+ ```yaml
325
+ ---
326
+ driver:
327
+ name: openstack
328
+ openstack_username: [YOUR OPENSTACK USERNAME]
329
+ openstack_api_key: [YOUR OPENSTACK API KEY] # AKA your OPENSTACK PASSWORD
330
+ openstack_auth_url: [YOUR OPENSTACK AUTH URL]
331
+ require_chef_omnibus: [e.g. 'true' or a version number if you need Chef]
332
+ image_ref: [SERVER IMAGE ID]
333
+ flavor_ref: [SERVER FLAVOR ID]
334
+
335
+ transport:
336
+ ssh_key: /path/to/id_rsa # probably the same as private_key_path
337
+ connection_timeout: 10
338
+ connection_retries: 5
339
+ username: ubuntu
340
+ password: mysecreatpassword
199
341
 
200
- 1. Fork it
342
+ platforms:
343
+ - name: ubuntu-14.04
344
+ - name: ubuntu-15.04
345
+ - name: centos-7
346
+ transport:
347
+ username: centos
348
+ - name: windows-2012r2
349
+ transport:
350
+ password: myadministratorpassword
351
+
352
+ suites:
353
+ # ...
354
+ ```
355
+
356
+ ## <a name="development"></a> Development
357
+
358
+ * Source hosted at [GitHub][repo]
359
+ * Report issues/questions/feature requests on [GitHub Issues][issues]
360
+
361
+ Pull requests are very welcome! Make sure your patches are well tested.
362
+ Ideally create a topic branch for every separate change you make. For
363
+ example:
364
+
365
+ 1. Fork the repo
201
366
  2. Create your feature branch (`git checkout -b my-new-feature`)
202
- 3. Run style checks and RSpec tests (`bundle exec rake`)
203
- 4. Commit your changes (`git commit -am 'Add some feature'`)
367
+ 3. Run the tests and rubocop, `bundle exec rake spec` and `bundle exec rake rubocop`
368
+ 4. Commit your changes (`git commit -am 'Added some feature'`)
204
369
  5. Push to the branch (`git push origin my-new-feature`)
205
370
  6. Create new Pull Request
371
+
372
+ ## <a name="authors"></a> Authors
373
+
374
+ Created by [Jonathan Hartman][author] (<j@p4nt5.com>)
375
+ and maintained by [JJ Asghar][maintainer] (<jj@chef.io>)
376
+
377
+ ## <a name="license"></a> License
378
+
379
+ Apache 2.0 (see [LICENSE][license])
380
+
381
+
382
+ [gem]: https://rubygems.org/gems/kitchen-openstack
383
+ [travis]: https://travis-ci.org/test-kitchen/kitchen-openstack
384
+ [codeclimate]: https://codeclimate.com/github/test-kitchen/kitchen-openstack
385
+ [coveralls]: https://coveralls.io/r/test-kitchen/kitchen-openstack
386
+ [gemnasium]: https://gemnasium.com/test-kitchen/kitchen-openstack
387
+
388
+ [author]: https://github.com/RoboticCheese
389
+ [maintainer]: https://github.com/jjasghar
390
+ [issues]: https://github.com/test-kitchen/kitchen-openstack/issues
391
+ [license]: https://github.com/test-kitchen/kitchen-openstack/blob/master/LICENSE.txt
392
+ [repo]: https://github.com/test-kitchen/kitchen-openstack
393
+ [driver_usage]: https://github.com/test-kitchen/kitchen-openstack
394
+ [chef_omnibus_dl]: http://www.chef.io/chef/install/
395
+ [chefdk_dl]: https://downloads.chef.io/chef-dk
396
+ [kitchen_ci]: http://kitchen.ci
397
+
398
+ [openstack_web]: http://www.openstack.org
399
+ [fog_web]: http://fog.io
@@ -102,6 +102,7 @@ module Kitchen
102
102
  elsif config[:floating_ip_pool]
103
103
  attach_ip_from_pool(server, config[:floating_ip_pool])
104
104
  end
105
+ state[:hostname] = get_ip(server)
105
106
  wait_for_server(state)
106
107
  setup_ssh(server, state) if bourne_shell?
107
108
  add_ohai_hint(state)
@@ -159,7 +160,6 @@ module Kitchen
159
160
 
160
161
  def create_server
161
162
  server_def = init_configuration
162
-
163
163
  if config[:network_ref]
164
164
  networks = [].concat([config[:network_ref]])
165
165
  server_def[:nics] = networks.flatten.map do |net|
@@ -303,14 +303,26 @@ module Kitchen
303
303
  end
304
304
 
305
305
  def get_ip(server)
306
- unless config[:floating_ip].nil?
306
+ if config[:floating_ip]
307
307
  debug "Using floating ip: #{config[:floating_ip]}"
308
308
  return config[:floating_ip]
309
309
  end
310
+
311
+ # make sure we have the latest info
312
+ info 'Waiting for network information to be available...'
313
+ begin
314
+ w = server.wait_for { !addresses.empty? }
315
+ debug "Waited #{w[:duration]} seconds for network information."
316
+ rescue Fog::Errors::TimeoutError
317
+ raise ActionFailed, 'Could not get network information (timed out)'
318
+ end
319
+
320
+ # should also work for private networks
310
321
  if config[:openstack_network_name]
311
322
  debug "Using configured net: #{config[:openstack_network_name]}"
312
323
  return server.addresses[config[:openstack_network_name]].first['addr']
313
324
  end
325
+
314
326
  pub, priv = get_public_private_ips(server)
315
327
  priv ||= server.ip_addresses unless pub
316
328
  pub, priv = parse_ips(pub, priv)
@@ -381,10 +393,9 @@ module Kitchen
381
393
  end
382
394
 
383
395
  def wait_for_server(state)
384
- state[:hostname] = get_ip(state)
385
- if config[:winrm_wait]
386
- info "Sleeping for #{config[:winrm_wait]} seconds to let WinRM start up..." # rubocop:disable Metrics/LineLength
387
- countdown(config[:winrm_wait])
396
+ if config[:server_wait]
397
+ info "Sleeping for #{config[:server_wait]} seconds to let your server to start up..." # rubocop:disable Metrics/LineLength
398
+ countdown(config[:server_wait])
388
399
  end
389
400
  info 'Waiting for server to be ready...'
390
401
  instance.transport.connection(state).wait_until_ready
@@ -21,6 +21,6 @@ module Kitchen
21
21
  #
22
22
  # @author Jonathan Hartman <j@p4nt5.com>
23
23
  module Driver
24
- OPENSTACK_VERSION = '2.0.0'
24
+ OPENSTACK_VERSION = '2.1.0.pre'
25
25
  end
26
26
  end
@@ -197,6 +197,7 @@ describe Kitchen::Driver::Openstack do
197
197
  allow(d).to receive(:do_ssh_setup).and_return(true)
198
198
  allow(d).to receive(:sleep)
199
199
  allow(d).to receive(:wait_for_ssh_key_access).and_return('SSH key authetication successful') # rubocop:disable Metrics/LineLength
200
+ allow(d).to receive(:disable_ssl_validation).and_return(false)
200
201
  d
201
202
  end
202
203
 
@@ -211,28 +212,6 @@ describe Kitchen::Driver::Openstack do
211
212
  end
212
213
  end
213
214
 
214
- context 'when executed with a bourne shell' do
215
- before do
216
- allow(driver).to receive(:bourne_shell?).and_return(true)
217
- end
218
-
219
- it 'executes the ssh setup' do
220
- expect(driver).to receive(:setup_ssh)
221
- driver.create(state)
222
- end
223
- end
224
-
225
- context 'when executed in a non-bourne shell' do
226
- before do
227
- allow(driver).to receive(:bourne_shell?).and_return(false)
228
- end
229
-
230
- it 'does not execute the ssh setup' do
231
- expect(driver).not_to receive(:setup_ssh)
232
- driver.create(state)
233
- end
234
- end
235
-
236
215
  context 'when a server is already created' do
237
216
  it 'does not create a new instance' do
238
217
  state[:server_id] = '123'
@@ -874,7 +853,8 @@ describe Kitchen::Driver::Openstack do
874
853
  double(addresses: addresses,
875
854
  public_ip_addresses: public_ip_addresses,
876
855
  private_ip_addresses: private_ip_addresses,
877
- ip_addresses: ip_addresses)
856
+ ip_addresses: ip_addresses,
857
+ wait_for: { duration: 0 })
878
858
  end
879
859
 
880
860
  context 'both public and private IPs' do
@@ -930,15 +910,23 @@ describe Kitchen::Driver::Openstack do
930
910
  end
931
911
  end
932
912
 
913
+ context 'when a floating ip is provided' do
914
+ let(:config) { { floating_ip: '1.2.3.4' } }
915
+
916
+ it 'returns the floating ip and skips reloading' do
917
+ allow(driver).to receive(:config).and_return(config)
918
+
919
+ expect(server).to_not receive(:wait_for)
920
+ expect(driver.send(:get_ip, server)).to eq('1.2.3.4')
921
+ end
922
+ end
923
+
933
924
  context 'an OpenStack deployment without the floating IP extension' do
934
- let(:server) do
935
- s = double('server')
936
- allow(s).to receive(:addresses).and_return(addresses)
937
- allow(s).to receive(:public_ip_addresses).and_raise(
925
+ before do
926
+ allow(server).to receive(:public_ip_addresses).and_raise(
938
927
  Fog::Compute::OpenStack::NotFound)
939
- allow(s).to receive(:private_ip_addresses).and_raise(
928
+ allow(server).to receive(:private_ip_addresses).and_raise(
940
929
  Fog::Compute::OpenStack::NotFound)
941
- s
942
930
  end
943
931
 
944
932
  context 'both public and private IPs in the addresses hash' do
@@ -955,6 +943,22 @@ describe Kitchen::Driver::Openstack do
955
943
  end
956
944
  end
957
945
 
946
+ context 'when openstack_network_name is provided' do
947
+ let(:addresses) do
948
+ {
949
+ 'public' => [{ 'addr' => '6.6.6.6' }, { 'addr' => '7.7.7.7' }],
950
+ 'private' => [{ 'addr' => '8.8.8.8' }, { 'addr' => '9.9.9.9' }]
951
+ }
952
+ end
953
+ let(:config) { { openstack_network_name: 'public' } }
954
+
955
+ it 'should respond with the first address from the addresses' do
956
+ allow(driver).to receive(:config).and_return(config)
957
+
958
+ expect(driver.send(:get_ip, server)).to eq('6.6.6.6')
959
+ end
960
+ end
961
+
958
962
  context 'only public IPs in the address hash' do
959
963
  let(:addresses) do
960
964
  { 'public' => [{ 'addr' => '6.6.6.6' }, { 'addr' => '7.7.7.7' }] }
@@ -984,6 +988,17 @@ describe Kitchen::Driver::Openstack do
984
988
  expect { driver.send(:get_ip, server) }.to raise_error(expected)
985
989
  end
986
990
  end
991
+
992
+ context 'when network information is not found' do
993
+ before do
994
+ allow(server).to receive(:wait_for).and_raise(Fog::Errors::TimeoutError)
995
+ end
996
+
997
+ it 'raises an exception' do
998
+ expected = Kitchen::ActionFailed
999
+ expect { driver.send(:get_ip, server) }.to raise_error(expected)
1000
+ end
1001
+ end
987
1002
  end
988
1003
 
989
1004
  describe '#parse_ips' do
@@ -1078,6 +1093,16 @@ describe Kitchen::Driver::Openstack do
1078
1093
  .and_return(read)
1079
1094
  end
1080
1095
 
1096
+ context 'when executed in a non-bourne shell' do
1097
+ before do
1098
+ allow(driver).to receive(:bourne_shell?).and_return(false)
1099
+ end
1100
+
1101
+ it 'does not execute the ssh setup' do
1102
+ expect(driver).not_to receive(:setup_ssh)
1103
+ end
1104
+ end
1105
+
1081
1106
  it 'opens an SSH session to the server' do
1082
1107
  expect(Fog::SSH).to receive(:new).with(state[:hostname],
1083
1108
  'root',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-openstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Hartman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-30 00:00:00.000000000 Z
12
+ date: 2015-10-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-kitchen
@@ -237,9 +237,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
237
237
  version: 2.0.0
238
238
  required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  requirements:
240
- - - ">="
240
+ - - ">"
241
241
  - !ruby/object:Gem::Version
242
- version: '0'
242
+ version: 1.3.1
243
243
  requirements: []
244
244
  rubyforge_project:
245
245
  rubygems_version: 2.2.2