kitchen-vcenter 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kitchen-vcenter/version.rb +1 -1
- data/lib/kitchen/driver/vcenter.rb +34 -6
- data/lib/support/clone_vm.rb +20 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42c7852178bc1dcfc969a8bf7e425bd47dd69cc6bcf912c2e2448b8a98fac78d
|
4
|
+
data.tar.gz: 14f6e34a3f3ad7e9c8fe137b1266124a12af27a13d2527a4f4bebfc8b419bb2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd7aa018d79d571d67cb222df22146f12ab1e2c45e259afad4ada7569439adee363ba5972abe991139f3638850a4822bed5ce684d26dc0d22faee1fde426c277
|
7
|
+
data.tar.gz: 4d90cb4b2e62da501b0e047365086921f88001e2b48914f535c0cadff15412c77ab488bcd49bdd596283732c1227bcf44701581da783c3e043851bf711030f3c
|
@@ -51,6 +51,7 @@ module Kitchen
|
|
51
51
|
default_config :vm_wait_timeout, 90
|
52
52
|
default_config :vm_wait_interval, 2.0
|
53
53
|
default_config :vm_rollback, false
|
54
|
+
default_config :customize, nil
|
54
55
|
|
55
56
|
# The main create method
|
56
57
|
#
|
@@ -64,13 +65,28 @@ module Kitchen
|
|
64
65
|
config[:targethost] = get_host(config[:targethost])
|
65
66
|
|
66
67
|
# Use the root resource pool of a specified cluster, if any
|
67
|
-
|
68
|
-
unless config[:cluster].nil?
|
69
|
-
cluster = get_cluster(config[:cluster])
|
70
|
-
config[:resource_pool] = cluster.resource_pool
|
71
|
-
else
|
68
|
+
if config[:cluster].nil?
|
72
69
|
# Find the first resource pool on any cluster
|
73
70
|
config[:resource_pool] = get_resource_pool(config[:resource_pool])
|
71
|
+
else
|
72
|
+
cluster = get_cluster(config[:cluster])
|
73
|
+
root_pool = cluster.resource_pool
|
74
|
+
|
75
|
+
if config[:resource_pool].nil?
|
76
|
+
config[:resource_pool] = root_pool
|
77
|
+
else
|
78
|
+
rp_api = VSphereAutomation::VCenter::ResourcePoolApi.new(api_client)
|
79
|
+
|
80
|
+
found_pool = nil
|
81
|
+
pools = rp_api.get(root_pool).value.resource_pools
|
82
|
+
pools.each do |pool|
|
83
|
+
name = rp_api.get(pool).value.name
|
84
|
+
found_pool = pool if name == config[:resource_pool]
|
85
|
+
end
|
86
|
+
|
87
|
+
raise format("Pool %s not found on cluster %s", config[:resource_pool], config[:cluster]) if found_pool.nil?
|
88
|
+
config[:resource_pool] = found_pool
|
89
|
+
end
|
74
90
|
end
|
75
91
|
|
76
92
|
# Check that the datacenter exists
|
@@ -104,6 +120,7 @@ module Kitchen
|
|
104
120
|
network_name: config[:network_name],
|
105
121
|
wait_timeout: config[:vm_wait_timeout],
|
106
122
|
wait_interval: config[:vm_wait_interval],
|
123
|
+
customize: config[:customize],
|
107
124
|
}
|
108
125
|
|
109
126
|
begin
|
@@ -203,7 +220,10 @@ module Kitchen
|
|
203
220
|
config[:vm_name] = format("%s-%s-%s", instance.suite.name, instance.platform.name, SecureRandom.hex(4))
|
204
221
|
end
|
205
222
|
|
206
|
-
|
223
|
+
# See details in function get_resource_pool for more details
|
224
|
+
# if config[:cluster].nil? && config[:resource_pool].nil?
|
225
|
+
# warn("It is recommended to specify cluster and/or resource_pool to avoid unpredictable machine placement on large deployments")
|
226
|
+
# end
|
207
227
|
end
|
208
228
|
|
209
229
|
# A helper method to validate the state
|
@@ -305,6 +325,14 @@ module Kitchen
|
|
305
325
|
# If no name has been set, use the first resource pool that can be found,
|
306
326
|
# otherwise try to find by given name
|
307
327
|
if name.nil?
|
328
|
+
# Unpredictable results can occur, if neither cluster nor resource_pool are specified,
|
329
|
+
# as this relies on the order in which VMware saves the objects. This does not have large
|
330
|
+
# impact on small environments, but on large deployments with lots of clusters and pools,
|
331
|
+
# provisioned machines are likely to "jump around" available hosts.
|
332
|
+
#
|
333
|
+
# This behaviour is carried on from versions 1.2.1 and lower, but likely to be removed in
|
334
|
+
# a new major version due to these insufficiencies and the confusing code for it
|
335
|
+
|
308
336
|
# Remove default pool for first pass (<= 1.2.1 behaviour to pick first user-defined pool found)
|
309
337
|
resource_pools = rp_api.list.value.delete_if { |pool| pool.name == "Resources" }
|
310
338
|
debug("Search of all resource pools found: " + resource_pools.map { |pool| pool.name }.to_s)
|
data/lib/support/clone_vm.rb
CHANGED
@@ -143,7 +143,7 @@ class Support
|
|
143
143
|
task = src_vm.InstantClone_Task(spec: clone_spec)
|
144
144
|
else
|
145
145
|
clone_spec = RbVmomi::VIM.VirtualMachineCloneSpec(location: relocate_spec,
|
146
|
-
powerOn: options[:poweron]
|
146
|
+
powerOn: options[:poweron] && options[:customize].nil?,
|
147
147
|
template: false)
|
148
148
|
|
149
149
|
task = src_vm.CloneVM_Task(spec: clone_spec, folder: dest_folder, name: name)
|
@@ -155,14 +155,27 @@ class Support
|
|
155
155
|
@path = options[:folder].nil? ? name : format("%s/%s", options[:folder][:name], name)
|
156
156
|
@vm = dc.find_vm(path)
|
157
157
|
|
158
|
-
if vm.nil?
|
159
|
-
|
160
|
-
|
161
|
-
|
158
|
+
raise format("Unable to find machine: %s", path) if vm.nil?
|
159
|
+
|
160
|
+
# Pass contents of the customization option/Hash through to allow full customization
|
161
|
+
# https://pubs.vmware.com/vsphere-6-5/index.jsp?topic=%2Fcom.vmware.wssdk.smssdk.doc%2Fvim.vm.ConfigSpec.html
|
162
|
+
unless options[:customize].nil?
|
163
|
+
Kitchen.logger.info "Waiting for reconfiguration to finish"
|
164
|
+
|
165
|
+
config_spec = RbVmomi::VIM.VirtualMachineConfigSpec(options[:customize])
|
166
|
+
task = vm.ReconfigVM_Task(spec: config_spec)
|
167
|
+
task.wait_for_completion
|
168
|
+
end
|
162
169
|
|
163
|
-
|
164
|
-
|
170
|
+
if options[:poweron] && !options[:customize].nil?
|
171
|
+
task = vm.PowerOnVM_Task
|
172
|
+
task.wait_for_completion
|
165
173
|
end
|
174
|
+
|
175
|
+
Kitchen.logger.info format("Waiting for VMware tools/network interfaces to become available (timeout: %d seconds)...", options[:wait_timeout])
|
176
|
+
|
177
|
+
wait_for_ip(vm, options[:wait_timeout], options[:wait_interval])
|
178
|
+
Kitchen.logger.info format("Created machine %s with IP %s", name, ip)
|
166
179
|
end
|
167
180
|
end
|
168
181
|
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: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chef Software
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbvmomi
|