knife-vsphere 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/knife/base_vsphere_command.rb +13 -0
- data/lib/chef/knife/vsphere_pool_list.rb +0 -13
- data/lib/chef/knife/vsphere_vm_clone.rb +27 -4
- data/lib/chef/knife/vsphere_vm_disk_list.rb +2 -1
- data/lib/chef/knife/vsphere_vm_migrate.rb +8 -19
- data/lib/knife-vsphere/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc8369abb89134912a7e683ce60b1bbd0e8d484f
|
4
|
+
data.tar.gz: 813c2580d02825cd3d14376b5a4e18d982cb6cf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46f01a944324a64476df295187ba4859ade28677c4a47c62c3e1603e1804150fa60d0db72fa2ac829e0f14e49cb8a4e05ff9646abd4f30674bbf727fbb088d61
|
7
|
+
data.tar.gz: ccaa4f2c5d8a44349ad90e36a56c041f10ecb9479062daa44fd63953c9f8b41440b3cc259571db7e76f5c55bba16d062f293a056c1cbc32441fce9e5a526d3f3
|
@@ -246,6 +246,19 @@ class Chef
|
|
246
246
|
networks.first
|
247
247
|
end
|
248
248
|
|
249
|
+
def find_pool_folder(folderName)
|
250
|
+
dc = datacenter
|
251
|
+
base_entity = dc.hostFolder
|
252
|
+
entity_array = folderName.split('/')
|
253
|
+
entity_array.each do |entityArrItem|
|
254
|
+
if entityArrItem != ''
|
255
|
+
base_entity = base_entity.childEntity.grep(RbVmomi::VIM::ManagedObject).find { |f| f.name == entityArrItem } ||
|
256
|
+
abort("no such folder #{folderName} while looking for #{entityArrItem}")
|
257
|
+
end
|
258
|
+
end
|
259
|
+
base_entity
|
260
|
+
end
|
261
|
+
|
249
262
|
def find_pool(poolName)
|
250
263
|
dc = datacenter
|
251
264
|
base_entity = dc.hostFolder
|
@@ -25,19 +25,6 @@ class Chef::Knife::VspherePoolList < Chef::Knife::BaseVsphereCommand
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def find_pool_folder(folderName)
|
29
|
-
dc = datacenter
|
30
|
-
base_entity = dc.hostFolder
|
31
|
-
entity_array = folderName.split('/')
|
32
|
-
entity_array.each do |entityArrItem|
|
33
|
-
if entityArrItem != ''
|
34
|
-
base_entity = base_entity.childEntity.grep(RbVmomi::VIM::ManagedObject).find { |f| f.name == entityArrItem } ||
|
35
|
-
abort("no such folder #{folderName} while looking for #{entityArrItem}")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
base_entity
|
39
|
-
end
|
40
|
-
|
41
28
|
def run
|
42
29
|
vim_connection
|
43
30
|
base_folder = find_pool_folder(get_config(:folder))
|
@@ -23,6 +23,8 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
|
|
23
23
|
AUTO_MAC = 'auto'
|
24
24
|
# A NO IP for you to use!
|
25
25
|
NO_IPS = ''
|
26
|
+
# a linklayer origin is an actual nic
|
27
|
+
ORIGIN_IS_REAL_NIC = 'linklayer'.freeze
|
26
28
|
|
27
29
|
include Chef::Knife::WinrmBase
|
28
30
|
include CustomizationHelper
|
@@ -424,10 +426,15 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
|
|
424
426
|
# Multiple reboots occur during guest customization in which a link-local
|
425
427
|
# address is assigned. As such, we need to wait until a routable IP address
|
426
428
|
# becomes available. This is most commonly an issue with Windows instances.
|
427
|
-
sleep 2 while vm
|
429
|
+
sleep 2 while vm_is_waiting_for_ip?(vm)
|
428
430
|
vm.guest.net[bootstrap_nic_index].ipAddress.detect { |addr| IPAddr.new(addr).ipv4? }
|
429
431
|
end
|
430
432
|
|
433
|
+
def vm_is_waiting_for_ip?(vm)
|
434
|
+
first_ip_address = vm.guest.net[bootstrap_nic_index].ipConfig.ipAddress.detect { |addr| IPAddr.new(addr.ipAddress).ipv4? }
|
435
|
+
first_ip_address.nil? || first_ip_address.origin == ORIGIN_IS_REAL_NIC
|
436
|
+
end
|
437
|
+
|
431
438
|
def guest_address(vm)
|
432
439
|
puts 'Waiting for network interfaces to become available...'
|
433
440
|
sleep 2 while vm.guest.net.empty? || !vm.guest.ipAddress
|
@@ -687,9 +694,8 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
|
|
687
694
|
# We should get here with the customizations set, either by a plugin or a --cspec
|
688
695
|
fatal_exit 'Windows clones need a customization identity. Try passing a --cspec or making a --cplugin' if cust_spec.identity.props.empty?
|
689
696
|
|
690
|
-
identification =
|
691
|
-
|
692
|
-
)
|
697
|
+
identification = identification_for_spec(cust_spec)
|
698
|
+
|
693
699
|
license_file_print_data = RbVmomi::VIM.CustomizationLicenseFilePrintData(
|
694
700
|
autoMode: cust_spec.identity.licenseFilePrintData.autoMode
|
695
701
|
) if cust_spec.identity.licenseFilePrintData # optional param
|
@@ -983,4 +989,21 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
|
|
983
989
|
def bootstrap_nic_index
|
984
990
|
Integer(get_config(:bootstrap_nic))
|
985
991
|
end
|
992
|
+
|
993
|
+
def identification_for_spec(cust_spec)
|
994
|
+
# If --cdomain matches what is in --cspec then use identification from the --cspec, else use --cdomain
|
995
|
+
case domain = get_config(:customization_domain)
|
996
|
+
when nil?
|
997
|
+
# Fall back to original behavior of using joinWorkgroup from the --cspec
|
998
|
+
RbVmomi::VIM.CustomizationIdentification(
|
999
|
+
joinWorkgroup: cust_spec.identity.identification.joinWorkgroup
|
1000
|
+
)
|
1001
|
+
when cust_spec.identity.identification.joinDomain
|
1002
|
+
cust_spec.identity.identification
|
1003
|
+
else
|
1004
|
+
RbVmomi::VIM.CustomizationIdentification(
|
1005
|
+
joinDomain: domain
|
1006
|
+
)
|
1007
|
+
end
|
1008
|
+
end
|
986
1009
|
end
|
@@ -27,8 +27,9 @@ class Chef::Knife::VsphereVmDiskList < Chef::Knife::BaseVsphereCommand
|
|
27
27
|
end
|
28
28
|
|
29
29
|
disks.each do |disk|
|
30
|
-
puts '%3d %20s %s' % [disk.unitNumber,
|
30
|
+
puts '%3d %20s %20s %s' % [disk.unitNumber,
|
31
31
|
disk.deviceInfo.label,
|
32
|
+
disk.backing.datastore.name,
|
32
33
|
Filesize.from("#{disk.capacityInKB} KiB").pretty]
|
33
34
|
end
|
34
35
|
end
|
@@ -28,21 +28,13 @@ class Chef::Knife::VsphereVmMigrate < Chef::Knife::BaseVsphereCommand
|
|
28
28
|
long: '--resource-pool POOL',
|
29
29
|
description: 'The resource pool into which to put the VM'
|
30
30
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
return child if child.name == poolname
|
36
|
-
elsif child.class == RbVmomi::VIM::Folder
|
37
|
-
pool = traverse_folders_for_pool(child, poolname)
|
38
|
-
return pool if pool
|
31
|
+
def find_host_folder(folder, name)
|
32
|
+
folder.childEntity.each do |cluster|
|
33
|
+
cluster.host.each do |host|
|
34
|
+
return host if host.name == name
|
39
35
|
end
|
40
36
|
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
def find_host_folder(folder, _type, name)
|
45
|
-
folder.host.find { |o| o.name == name }
|
37
|
+
nil
|
46
38
|
end
|
47
39
|
|
48
40
|
def run
|
@@ -62,12 +54,9 @@ class Chef::Knife::VsphereVmMigrate < Chef::Knife::BaseVsphereCommand
|
|
62
54
|
priority = config[:priority]
|
63
55
|
dest_host = config[:dest_host]
|
64
56
|
ndc = find_datastore(config[:dest_datastore]) || abort('dest-datastore not found')
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
h = find_host_folder(pool, RbVmomi::VIM::HostSystem, dest_host)
|
69
|
-
migrate_spec = RbVmomi::VIM.VirtualMachineRelocateSpec(datastore: ndc, pool: npool, host: h)
|
70
|
-
# puts migrate_spec.host.name
|
57
|
+
pool = find_pool(config[:resource_pool]) if config[:resource_pool]
|
58
|
+
dest_host = find_host_folder(dc.hostFolder, dest_host)
|
59
|
+
migrate_spec = RbVmomi::VIM.VirtualMachineRelocateSpec(datastore: ndc, pool: pool, host: dest_host)
|
71
60
|
vm.RelocateVM_Task(spec: migrate_spec, priority: priority).wait_for_completion
|
72
61
|
end
|
73
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-vsphere
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ezra Pagel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: knife-windows
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '11.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: '11.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
222
|
version: '0'
|
223
223
|
requirements: []
|
224
224
|
rubyforge_project:
|
225
|
-
rubygems_version: 2.
|
225
|
+
rubygems_version: 2.6.11
|
226
226
|
signing_key:
|
227
227
|
specification_version: 4
|
228
228
|
summary: vSphere Support for Knife
|