kitchen-vcenter 1.3.1 → 1.3.4

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
  SHA256:
3
- metadata.gz: 708b1e6365ef0e46165bcc9e769fed085b00443bcdc7bec5be10408fcf71bf1c
4
- data.tar.gz: c946b45441efa5b7fa06b6f98275923e1222fcdf506091bbce72c917d5003fd1
3
+ metadata.gz: 9e72f7421bcae71612b39ca42859c0ba3ad8ad8809f29e0e9720e5c8f4ebd668
4
+ data.tar.gz: '062093f1b32dfff9571cfd4aad8e3072de37fc3485f93ff0908f5d34e60ffa23'
5
5
  SHA512:
6
- metadata.gz: 8740db6063447e8c72d0fba7df35ce022143136938bb26de5de1f7ed1e6c7521cd94615ea44970358e7345b502a76a029c499521426c0917b228f119fc06c49b
7
- data.tar.gz: 3919686c7c95821aa077fbf519a0ab31c36920a2e4392c9f2689b115e553c008bbb03295ca0593a173fe5438da481a043fc2d0fbd8184858c77ff12294680549
6
+ metadata.gz: 7dd6a013bb356d39b9c59d2eaea3c93f3bc6a9629958fbde48807ab40ea249ef518f05c98580f27d080c73f24da503b5952439fc03368bcae7536eb1772278ee
7
+ data.tar.gz: 15f635777a44a3e1d6e70af030589300ebb5a8d86e7b74d27d6141c2fdef433d6d32b8b5cf8c467e9ace37e5abde8620034d461ab725ca59378bf0e8e453c6fc
@@ -1,21 +1,29 @@
1
1
  # Change Log
2
2
 
3
- <!-- latest_release 1.3.1 -->
4
- ## [v1.3.1](https://github.com/chef/kitchen-vcenter/tree/v1.3.1) (2018-11-19)
3
+ <!-- latest_release 1.3.4 -->
4
+ ## [v1.3.4](https://github.com/chef/kitchen-vcenter/tree/v1.3.4) (2019-01-04)
5
5
 
6
6
  #### Merged Pull Requests
7
- - Chefstyle fixes [#37](https://github.com/chef/kitchen-vcenter/pull/37) ([tas50](https://github.com/tas50))
7
+ - Fix for Issues #26 and #30 [#44](https://github.com/chef/kitchen-vcenter/pull/44) ([tecracer-theinen](https://github.com/tecracer-theinen))
8
8
  <!-- latest_release -->
9
- <!-- release_rollup since=1.2.1 -->
10
- ### Changes since 1.2.1 release
9
+ <!-- release_rollup since=1.3.1 -->
10
+ ### Changes not yet released to rubygems.org
11
11
 
12
12
  #### Merged Pull Requests
13
- - Chefstyle fixes [#37](https://github.com/chef/kitchen-vcenter/pull/37) ([tas50](https://github.com/tas50)) <!-- 1.3.1 -->
14
- - Implement support for linked clones (feature #18) [#32](https://github.com/chef/kitchen-vcenter/pull/32) ([tecracer-theinen](https://github.com/tecracer-theinen)) <!-- 1.3.0 -->
15
- - Fixed behaviour when not having any resource pools (Issue #28) [#31](https://github.com/chef/kitchen-vcenter/pull/31) ([tecracer-theinen](https://github.com/tecracer-theinen)) <!-- 1.2.2 -->
13
+ - Fix for Issues #26 and #30 [#44](https://github.com/chef/kitchen-vcenter/pull/44) ([tecracer-theinen](https://github.com/tecracer-theinen)) <!-- 1.3.4 -->
14
+ - Feature/check parameters [#40](https://github.com/chef/kitchen-vcenter/pull/40) ([tecracer-theinen](https://github.com/tecracer-theinen)) <!-- 1.3.3 -->
15
+ - README edits [#38](https://github.com/chef/kitchen-vcenter/pull/38) ([mjingle](https://github.com/mjingle)) <!-- 1.3.2 -->
16
16
  <!-- release_rollup -->
17
17
  <!-- latest_stable_release -->
18
- ## [1.2.0](https://github.com/chef/kitchen-vcenter/tree/1.2.1) (2017-09-14)
18
+ ## [v1.3.1](https://github.com/chef/kitchen-vcenter/tree/v1.3.1) (2018-11-19)
19
+
20
+ #### Merged Pull Requests
21
+ - Fixed behaviour when not having any resource pools (Issue #28) [#31](https://github.com/chef/kitchen-vcenter/pull/31) ([tecracer-theinen](https://github.com/tecracer-theinen))
22
+ - Implement support for linked clones (feature #18) [#32](https://github.com/chef/kitchen-vcenter/pull/32) ([tecracer-theinen](https://github.com/tecracer-theinen))
23
+ - Chefstyle fixes [#37](https://github.com/chef/kitchen-vcenter/pull/37) ([tas50](https://github.com/tas50))
24
+ <!-- latest_stable_release -->
25
+
26
+ ## [1.2.1](https://github.com/chef/kitchen-vcenter/tree/1.2.1) (2017-09-14)
19
27
  [Full Changelog](https://github.com/chef/kitchen-vcenter/compare/v1.2.0...1.2.1)
20
28
 
21
29
  **Closed issues:**
@@ -25,7 +33,6 @@
25
33
  **Merged pull requests:**
26
34
 
27
35
  - Update dependency reqs. Update README for dep install. [\#12](https://github.com/chef/kitchen-vcenter/pull/12) ([akulbe](https://github.com/akulbe))
28
- <!-- latest_stable_release -->
29
36
 
30
37
  ## [v1.2.0](https://github.com/chef/kitchen-vcenter/tree/v1.2.0) (2017-09-12)
31
38
  [Full Changelog](https://github.com/chef/kitchen-vcenter/compare/v1.1.0...v1.2.0)
data/README.md CHANGED
@@ -23,7 +23,7 @@ Please refer to the [CHANGELOG](CHANGELOG.md) for version history and known issu
23
23
 
24
24
  ## Installation
25
25
 
26
- This driver has a dependency. It requires the [vSphere Automation SDK](https://github.com/vmware/vsphere-automation-sdk-ruby) be installed. The steps to do that are as follows, for the time being it's not published to Rubygems, if you are interested please comment [here](https://github.com/vmware/vsphere-automation-sdk-ruby/issues/10).
26
+ This driver has a dependency. It requires the [vSphere Automation SDK](https://github.com/vmware/vsphere-automation-sdk-ruby) be installed. The steps to do that are as follows, for the time being it's not published to Rubygems. If you are interested, please comment [here](https://github.com/vmware/vsphere-automation-sdk-ruby/issues/10).
27
27
 
28
28
  - `$ git clone` [https://github.com/vmware/vsphere-automation-sdk-ruby.git](https://github.com/vmware/vsphere-automation-sdk-ruby.git)
29
29
  - `cd vsphere-automation-sdk-ruby`
@@ -104,26 +104,31 @@ suites:
104
104
 
105
105
  ### Required parameters:
106
106
 
107
- The following parameters should be set in the main `driver_config` section as they are common to all platforms.
107
+ The following parameters should be set in the main `driver_config` section as they are common to all platforms:
108
108
 
109
109
  - `vcenter_username` - Name to use when connecting to the vSphere environment
110
110
  - `vcenter_password` - Password associated with the specified user
111
111
  - `vcenter_host` - Host against which logins should be attempted
112
- - `vcenter_disable_ssl_verify` - Whether or not to disable SSL verification checks. Good when using self signed certificates. Default: false
113
112
 
114
- The following parameters should be set in the `driver_config` for the individual platform.
113
+ The following parameters should be set in the `driver_config` for the individual platform:
115
114
 
116
- - `template` - Template or virtual machine to use when cloning the new machine (needs to be a VM for linked clones)
117
115
  - `datacenter` - Name of the datacenter to use to deploy into
116
+ - `template` - Template or virtual machine to use when cloning the new machine (needs to be a VM for linked clones)
118
117
 
119
118
  ### Optional Parameters
120
119
 
120
+ The following parameters should be set in the main `driver_config` section as they are common to all platforms:
121
+ - `vcenter_disable_ssl_verify` - Whether or not to disable SSL verification checks. Good when using self signed certificates. Default: false
122
+
121
123
  The following optional parameters should be used in the `driver_config` for the platform.
122
124
 
123
125
  - `targethost` - Host on which the new virtual machine should be created. If not specified then the first host in the cluster is used.
124
126
  - `folder` - Folder into which the new machine should be stored. If specified the folder _must_ already exist.
125
- - `resource_pool` - Name of the resource pool to use when creating the machine. Will search first pool by default, can use value 'Resources' for none
126
- - `clone_type` - Type of clone, will default to "full" to create complete copies of template. Needs a VM as template parameter, if "linked" clone desired
127
+ - `poweron` - Power on the new virtual machine. Default: true
128
+ - `vm_name` - Specify name of virtual machine. Default: `<suite>-<platform>-<random-hexid>`
129
+ - `resource_pool` - Name of the resource pool to use when creating the machine. Will search first pool by default, can use value 'Resources' for none.
130
+ - `clone_type` - Type of clone, will default to "full" to create complete copies of template. Needs a VM as template parameter, if "linked" clone desired.
131
+ - `lookup_service_host` - Specify hostname of Lookup Service for setups with external PSC. Default: autodetect
127
132
 
128
133
  ## Contributing
129
134
 
@@ -133,9 +138,7 @@ For information on contributing to this project see <https://github.com/chef/che
133
138
 
134
139
  * Report issues/questions/feature requests on [GitHub Issues][issues]
135
140
 
136
- Pull requests are very welcome! Make sure your patches are well tested.
137
- Ideally create a topic branch for every separate change you make. For
138
- example:
141
+ Pull requests are very welcome! Make sure your patches are well tested. Ideally create a topic branch for every separate change you make. For example:
139
142
 
140
143
  1. Fork the repo
141
144
  2. Create your feature branch (`git checkout -b my-new-feature`)
@@ -20,5 +20,5 @@
20
20
  # The main kitchen-vcenter module
21
21
  module KitchenVcenter
22
22
  # The version of this version of test-kitchen we assume enterprises want.
23
- VERSION = "1.3.1"
23
+ VERSION = "1.3.4"
24
24
  end
@@ -28,6 +28,7 @@ require "com/vmware/vcenter"
28
28
  require "com/vmware/vcenter/vm"
29
29
  require "support/clone_vm"
30
30
  require "securerandom"
31
+ require "uri"
31
32
 
32
33
  # The main kitchen module
33
34
  module Kitchen
@@ -37,23 +38,33 @@ module Kitchen
37
38
  class Vcenter < Kitchen::Driver::Base
38
39
  attr_accessor :connection_options, :ipaddress, :vapi_config, :session_svc, :session_id
39
40
 
40
- default_config :targethost
41
- default_config :folder
42
- default_config :template
43
- default_config :datacenter
44
- default_config :vcenter_username
45
- default_config :vcenter_password
46
- default_config :vcenter_host
41
+ required_config :vcenter_username
42
+ required_config :vcenter_password
43
+ required_config :vcenter_host
44
+ required_config :datacenter
45
+ required_config :template
46
+
47
47
  default_config :vcenter_disable_ssl_verify, false
48
+ default_config :targethost, nil
49
+ default_config :folder, nil
48
50
  default_config :poweron, true
49
51
  default_config :vm_name, nil
50
52
  default_config :resource_pool, nil
51
53
  default_config :clone_type, :full
54
+ default_config :lookup_service_host, nil
52
55
 
53
56
  # The main create method
54
57
  #
55
58
  # @param [Object] state is the state of the vm
56
59
  def create(state)
60
+ # Configure the hash for use when connecting for cloning a machine
61
+ @connection_options = {
62
+ user: config[:vcenter_username],
63
+ password: config[:vcenter_password],
64
+ insecure: config[:vcenter_disable_ssl_verify] ? true : false,
65
+ host: config[:vcenter_host],
66
+ }
67
+
57
68
  # If the vm_name has not been set then set it now based on the suite, platform and a random number
58
69
  if config[:vm_name].nil?
59
70
  config[:vm_name] = format("%s-%s-%s", instance.suite.name, instance.platform.name, SecureRandom.hex(4))
@@ -215,13 +226,48 @@ module Kitchen
215
226
  resource_pool[0].resource_pool
216
227
  end
217
228
 
229
+ # Get location of lookup service
230
+ def lookup_service_host
231
+ # Allow manual overrides
232
+ return config[:lookup_service_host] unless config[:lookup_service_host].nil?
233
+
234
+ # Retrieve SSO service via RbVmomi, which is always co-located with the Lookup Service.
235
+ vim = RbVmomi::VIM.connect @connection_options
236
+ vim_settings = vim.serviceContent.setting.setting
237
+ sso_url = vim_settings.select { |o| o.key == "config.vpxd.sso.sts.uri" }&.first&.value
238
+
239
+ # Configuration fallback, if no SSO URL found for some reason
240
+ ls_host = sso_url.nil? ? config[:vcenter_host] : URI.parse(sso_url).host
241
+ debug("Using Lookup Service at: " + ls_host)
242
+
243
+ ls_host
244
+ end
245
+
246
+ # Get vCenter FQDN
247
+ def vcenter_host
248
+ # Retrieve SSO service via RbVmomi, which is always co-located with the Lookup Service.
249
+ vim = RbVmomi::VIM.connect @connection_options
250
+ vim_settings = vim.serviceContent.setting.setting
251
+
252
+ vim_settings.select { |o| o.key == "VirtualCenter.FQDN" }.first.value
253
+ end
254
+
218
255
  # The main connect method
219
256
  #
220
257
  def connect
221
258
  # Configure the connection to vCenter
222
- lookup_service_helper = LookupServiceHelper.new(config[:vcenter_host])
259
+ lookup_service_helper = LookupServiceHelper.new(lookup_service_host)
223
260
  vapi_urls = lookup_service_helper.find_vapi_urls
224
- vapi_url = vapi_urls.values[0]
261
+ debug("Found vAPI endpoints: [" + vapi_urls.to_s + "]")
262
+
263
+ vim_urls = lookup_service_helper.find_vim_urls
264
+ debug("Found VIM endpoints: [" + vim_urls.to_s + "]")
265
+
266
+ node_id = vim_urls.select { |id, url| url.include? vcenter_host }.keys.first
267
+ debug("NodeID of vCenter " + config[:vcenter_host] + " is " + node_id.to_s)
268
+
269
+ vapi_url = lookup_service_helper.find_vapi_url(node_id)
270
+ debug("vAPI Endpoint for vCenter is " + vapi_url)
225
271
 
226
272
  # Create the VAPI config object
227
273
  ssl_options = {}
@@ -242,14 +288,6 @@ module Kitchen
242
288
  vapi_config.set_security_context(
243
289
  VAPI::Security.create_session_security_context(session_id)
244
290
  )
245
-
246
- # Configure the hash for use when connecting for cloning a machine
247
- @connection_options = {
248
- user: config[:vcenter_username],
249
- password: config[:vcenter_password],
250
- insecure: config[:vcenter_disable_ssl_verify] ? true : false,
251
- host: config[:vcenter_host],
252
- }
253
291
  end
254
292
  end
255
293
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-vcenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Russell Seymour
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-19 00:00:00.000000000 Z
11
+ date: 2019-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbvmomi