chef-provisioning-vsphere 0.5.7.dev2 → 0.5.7.dev3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f778a9ae4af6203b2d0eb7f5663c1b1b8abada3
|
4
|
+
data.tar.gz: c8faca15f12bd087a48a16fd8748c089e7bc71b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08b07fcb55fadc5d25b1f747c40a6aa342147f797b81095760e545bc8af7e87844260e6fad8c36280409eb70a13aa694cb01a09fdc08aac7dc9563cf4262f621
|
7
|
+
data.tar.gz: df5967c9c2654ca2a40705248c9cd88c450f1a338a8635df26838177ebd7996190e7d4e92f66ab38deb7f4309dcbe40586e7f7726fb4ed6c5a09b679bca0a52e
|
@@ -47,14 +47,6 @@ module ChefProvisioningVsphere
|
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
50
|
-
def vm_started?(vm, wait_on_port = 22)
|
51
|
-
return false if vm.nil?
|
52
|
-
state = vm.runtime.powerState
|
53
|
-
return false unless state == 'poweredOn'
|
54
|
-
return false unless port_ready?(vm, wait_on_port)
|
55
|
-
return true
|
56
|
-
end
|
57
|
-
|
58
50
|
def vm_stopped?(vm)
|
59
51
|
return true if vm.nil?
|
60
52
|
state = vm.runtime.powerState
|
@@ -78,31 +70,6 @@ module ChefProvisioningVsphere
|
|
78
70
|
end
|
79
71
|
end
|
80
72
|
|
81
|
-
def port_ready?(vm, port)
|
82
|
-
vm_ip = vm.guest.ipAddress
|
83
|
-
return false if vm_ip.nil?
|
84
|
-
|
85
|
-
begin
|
86
|
-
tcp_socket = TCPSocket.new(vm_ip, port)
|
87
|
-
readable = IO.select([tcp_socket], nil, nil, 5)
|
88
|
-
if readable
|
89
|
-
true
|
90
|
-
else
|
91
|
-
false
|
92
|
-
end
|
93
|
-
rescue Errno::ETIMEDOUT
|
94
|
-
false
|
95
|
-
rescue Errno::EPERM
|
96
|
-
false
|
97
|
-
rescue Errno::ECONNREFUSED
|
98
|
-
false
|
99
|
-
rescue Errno::EHOSTUNREACH, Errno::ENETUNREACH
|
100
|
-
false
|
101
|
-
ensure
|
102
|
-
tcp_socket && tcp_socket.close
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
73
|
#folder could be like: /Level1/Level2/folder_name
|
107
74
|
def find_folder(folder_name)
|
108
75
|
base = datacenter.vmFolder
|
@@ -139,56 +106,6 @@ module ChefProvisioningVsphere
|
|
139
106
|
vm.config.hardware.device.select {|d| d.is_a?(RbVmomi::VIM::VirtualEthernetCard)}
|
140
107
|
end
|
141
108
|
|
142
|
-
def do_vm_clone(action_handler, vm_template, vm_name, options)
|
143
|
-
deviceAdditions = []
|
144
|
-
|
145
|
-
clone_spec = RbVmomi::VIM.VirtualMachineCloneSpec(
|
146
|
-
location: relocate_spec_for(vm_template, options),
|
147
|
-
powerOn: false,
|
148
|
-
template: false,
|
149
|
-
config: RbVmomi::VIM.VirtualMachineConfigSpec(
|
150
|
-
:cpuHotAddEnabled => true,
|
151
|
-
:memoryHotAddEnabled => true,
|
152
|
-
:cpuHotRemoveEnabled => true,
|
153
|
-
:deviceChange => Array.new)
|
154
|
-
)
|
155
|
-
|
156
|
-
clone_spec.customization = customization_options_from(action_handler, vm_template, vm_name, options)
|
157
|
-
|
158
|
-
unless options[:annotation].to_s.nil?
|
159
|
-
clone_spec.config.annotation = options[:annotation]
|
160
|
-
end
|
161
|
-
|
162
|
-
unless options[:num_cpus].to_s.nil?
|
163
|
-
clone_spec.config.numCPUs = options[:num_cpus]
|
164
|
-
end
|
165
|
-
|
166
|
-
unless options[:memory_mb].to_s.nil?
|
167
|
-
clone_spec.config.memoryMB = options[:memory_mb]
|
168
|
-
end
|
169
|
-
|
170
|
-
unless options[:network_name].nil?
|
171
|
-
deviceAdditions, changes = network_device_changes(action_handler, vm_template, options)
|
172
|
-
clone_spec.config.deviceChange = changes
|
173
|
-
end
|
174
|
-
|
175
|
-
vm_folder = find_folder(options[:vm_folder])
|
176
|
-
vm_template.CloneVM_Task(
|
177
|
-
name: vm_name,
|
178
|
-
folder: vm_folder,
|
179
|
-
spec: clone_spec
|
180
|
-
).wait_for_completion
|
181
|
-
|
182
|
-
vm = find_vm(vm_folder, vm_name)
|
183
|
-
|
184
|
-
if options[:additional_disk_size_gb].to_i > 0
|
185
|
-
task = vm.ReconfigVM_Task(:spec => RbVmomi::VIM.VirtualMachineConfigSpec(:deviceChange => [virtual_disk_for(vm, options)]))
|
186
|
-
task.wait_for_completion
|
187
|
-
end
|
188
|
-
|
189
|
-
vm
|
190
|
-
end
|
191
|
-
|
192
109
|
def add_extra_nic(action_handler, vm_template, options, vm)
|
193
110
|
deviceAdditions, changes = network_device_changes(action_handler, vm_template, options)
|
194
111
|
|
@@ -314,7 +231,9 @@ module ChefProvisioningVsphere
|
|
314
231
|
def find_entity(name, parent_folder, &block)
|
315
232
|
parts = name.split('/').reject(&:empty?)
|
316
233
|
parts.each do |item|
|
234
|
+
Chef::Log.debug("Identifying entity part: #{item} in folder type: #{parent_folder.class}")
|
317
235
|
if parent_folder.is_a? RbVmomi::VIM::Folder
|
236
|
+
Chef::Log.debug('Parent folder is a folder')
|
318
237
|
parent_folder = parent_folder.childEntity.find { |f| f.name == item }
|
319
238
|
else
|
320
239
|
parent_folder = block.call(parent_folder, item)
|
@@ -344,13 +263,21 @@ module ChefProvisioningVsphere
|
|
344
263
|
end
|
345
264
|
|
346
265
|
def find_pool(pool_name)
|
266
|
+
Chef::Log.debug("Finding pool: #{pool_name}")
|
347
267
|
pool = find_entity(pool_name, datacenter.hostFolder) do |parent, part|
|
348
268
|
case parent
|
349
269
|
when RbVmomi::VIM::ClusterComputeResource || RbVmomi::VIM::ComputeResource
|
270
|
+
Chef::Log.debug("finding #{part} in a #{parent.class}: #{parent.name}")
|
271
|
+
Chef::Log.debug("Parent root pool has #{parent.resourcePool.resourcePool.count} pools")
|
272
|
+
parent.resourcePool.resourcePool.each { |p| Chef::Log.debug(p.name ) }
|
350
273
|
parent.resourcePool.resourcePool.find { |f| f.name == part }
|
351
274
|
when RbVmomi::VIM::ResourcePool
|
275
|
+
Chef::Log.debug("finding #{part} in a Resource Pool: #{parent.name}")
|
276
|
+
Chef::Log.debug("Pool has #{parent.resourcePool.count} pools")
|
277
|
+
parent.resourcePool.each { |p| Chef::Log.debug(p.name ) }
|
352
278
|
parent.resourcePool.find { |f| f.name == part }
|
353
279
|
else
|
280
|
+
Chef::Log.debug("parent of #{part} is unexpected type: #{patrent.class}")
|
354
281
|
nil
|
355
282
|
end
|
356
283
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-provisioning-vsphere
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.7.
|
4
|
+
version: 0.5.7.dev3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CenturyLink Cloud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbvmomi
|