knife-vsphere 3.0.1 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chef/knife/base_vsphere_command.rb +35 -32
  3. data/lib/chef/knife/search_helper.rb +3 -3
  4. data/lib/chef/knife/vsphere_customization_list.rb +1 -1
  5. data/lib/chef/knife/vsphere_datastore_file.rb +12 -12
  6. data/lib/chef/knife/vsphere_datastore_list.rb +6 -6
  7. data/lib/chef/knife/vsphere_datastore_maxfree.rb +8 -8
  8. data/lib/chef/knife/vsphere_datastorecluster_list.rb +2 -1
  9. data/lib/chef/knife/vsphere_datastorecluster_maxfree.rb +4 -4
  10. data/lib/chef/knife/vsphere_folder_list.rb +1 -1
  11. data/lib/chef/knife/vsphere_hosts_list.rb +3 -3
  12. data/lib/chef/knife/vsphere_pool_list.rb +1 -1
  13. data/lib/chef/knife/vsphere_vlan_create.rb +2 -2
  14. data/lib/chef/knife/vsphere_vlan_list.rb +1 -1
  15. data/lib/chef/knife/vsphere_vm_cdrom.rb +18 -18
  16. data/lib/chef/knife/vsphere_vm_clone.rb +168 -333
  17. data/lib/chef/knife/vsphere_vm_delete.rb +7 -7
  18. data/lib/chef/knife/vsphere_vm_disk_extend.rb +4 -3
  19. data/lib/chef/knife/vsphere_vm_execute.rb +8 -8
  20. data/lib/chef/knife/vsphere_vm_find.rb +50 -49
  21. data/lib/chef/knife/vsphere_vm_list.rb +13 -12
  22. data/lib/chef/knife/vsphere_vm_migrate.rb +8 -8
  23. data/lib/chef/knife/vsphere_vm_move.rb +13 -13
  24. data/lib/chef/knife/vsphere_vm_net.rb +1 -1
  25. data/lib/chef/knife/vsphere_vm_network_add.rb +7 -8
  26. data/lib/chef/knife/vsphere_vm_network_delete.rb +1 -1
  27. data/lib/chef/knife/vsphere_vm_property_set.rb +3 -3
  28. data/lib/chef/knife/vsphere_vm_snapshot.rb +32 -30
  29. data/lib/chef/knife/vsphere_vm_state.rb +12 -12
  30. data/lib/chef/knife/vsphere_vm_toolsconfig.rb +3 -3
  31. data/lib/chef/knife/vsphere_vm_vmdk_add.rb +15 -13
  32. data/lib/chef/knife/vsphere_vm_vnc_set.rb +7 -7
  33. data/lib/chef/knife/vsphere_vm_wait_sysprep.rb +6 -6
  34. data/lib/knife-vsphere/version.rb +1 -1
  35. metadata +31 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26a03ccec0064effa45cd806abb8b6138780488f1898a777bebe061ddf6f5efb
4
- data.tar.gz: 7c0f1c51012bc52c2ed655b6f294f8518b75e677de5ea155a5dd6ee89cbe7f3b
3
+ metadata.gz: a8f368d4573e232a6f85d7b21aa08ebfe1402874def28c7ef02dbd424d2b925e
4
+ data.tar.gz: 6431989292639804374815f7b3b3f232e708901f8e51b02ac24c18d88edef8e4
5
5
  SHA512:
6
- metadata.gz: 3ded62ab8c4166844142a2c4a93c255d35114796d09ba63ef12dd90e42756299f872fc371b52fd0a327b54cf59d3c8dd8a39d206b0e703aa8c1c9fb6de41be54
7
- data.tar.gz: 7609876a7dbcad5cd4edadd28b7a8e6d2477098cc42363e2f9e2b92a482ddc83ad3cbc545746b25d614d15251502adb58dabbbc0008a0c1f7aeb22b47900c3b0
6
+ metadata.gz: 2bbd470a6557c299d64459d8d9d557280851bff0093d37c9dad63c30625b412ec3edc863c695860b84fafffebd9312711b343afa07d3dfdf735f3cbf4a36ef96
7
+ data.tar.gz: 51e6cdedd5efd0bdf9dcf74ffc8570e81beb69b3d3d7967ca31daa239626b1bf5b35681c423e53a2b96ade0e1ea0ba266340ca0f133f9a01520781168bacfae3
@@ -8,6 +8,7 @@ require "chef/knife"
8
8
  require "rbvmomi"
9
9
  require "base64"
10
10
  require "filesize"
11
+ require "chef/knife/bootstrap"
11
12
 
12
13
  # Power state on
13
14
  PS_ON ||= "poweredOn".freeze
@@ -21,9 +22,8 @@ class Chef
21
22
  # Base class for knife
22
23
  class Knife
23
24
  # Main knife vsphere that more or less everything in this gem is built off of
24
- class BaseVsphereCommand < Knife
25
+ class BaseVsphereCommand < Chef::Knife::Bootstrap
25
26
  deps do
26
- require "chef/knife/bootstrap"
27
27
  Chef::Knife::Bootstrap.load_deps
28
28
  require "socket"
29
29
  require "net/ssh/multi"
@@ -33,55 +33,55 @@ class Chef
33
33
 
34
34
  def self.common_options
35
35
  option :vsphere_user,
36
- short: "-u USERNAME",
37
- long: "--vsuser USERNAME",
38
- description: "The username for vsphere"
36
+ short: "-u USERNAME",
37
+ long: "--vsuser USERNAME",
38
+ description: "The username for vsphere"
39
39
 
40
40
  option :vsphere_pass,
41
- short: "-p PASSWORD",
42
- long: "--vspass PASSWORD",
43
- description: "The password for vsphere"
41
+ short: "-p PASSWORD",
42
+ long: "--vspass PASSWORD",
43
+ description: "The password for vsphere"
44
44
 
45
45
  option :vsphere_host,
46
- long: "--vshost HOST",
47
- description: "The vsphere host"
46
+ long: "--vshost HOST",
47
+ description: "The vsphere host"
48
48
 
49
49
  option :vsphere_dc,
50
- short: "-D DATACENTER",
51
- long: "--vsdc DATACENTER",
52
- description: "The Datacenter for vsphere"
50
+ short: "-D DATACENTER",
51
+ long: "--vsdc DATACENTER",
52
+ description: "The Datacenter for vsphere"
53
53
 
54
54
  option :vsphere_path,
55
- long: "--vspath SOAP_PATH",
56
- description: "The vsphere SOAP endpoint path",
57
- default: "/sdk"
55
+ long: "--vspath SOAP_PATH",
56
+ description: "The vsphere SOAP endpoint path",
57
+ default: "/sdk"
58
58
 
59
59
  option :vsphere_port,
60
- long: "--vsport PORT",
61
- description: "The VI SDK port number to use",
62
- default: "443"
60
+ long: "--vsport PORT",
61
+ description: "The VI SDK port number to use",
62
+ default: "443"
63
63
 
64
64
  option :vsphere_nossl,
65
- long: "--vsnossl",
66
- description: "Disable SSL connectivity"
65
+ long: "--vsnossl",
66
+ description: "Disable SSL connectivity"
67
67
 
68
68
  option :vsphere_insecure,
69
- long: "--vsinsecure",
70
- description: "Disable SSL certificate verification"
69
+ long: "--vsinsecure",
70
+ description: "Disable SSL certificate verification"
71
71
 
72
72
  option :folder,
73
- short: "-f FOLDER",
74
- long: "--folder FOLDER",
75
- description: "The folder to get VMs from",
76
- default: ""
73
+ short: "-f FOLDER",
74
+ long: "--folder FOLDER",
75
+ description: "The folder to get VMs from",
76
+ default: ""
77
77
 
78
78
  option :proxy_host,
79
- long: "--proxyhost PROXY_HOSTNAME",
80
- description: "Proxy hostname"
79
+ long: "--proxyhost PROXY_HOSTNAME",
80
+ description: "Proxy hostname"
81
81
 
82
82
  option :proxy_port,
83
- long: "--proxyport PROXY_PORT",
84
- description: "Proxy port"
83
+ long: "--proxyport PROXY_PORT",
84
+ description: "Proxy port"
85
85
  end
86
86
 
87
87
  def get_config(key)
@@ -199,6 +199,7 @@ class Chef
199
199
  if dvswitch && dvswitch != "auto"
200
200
  return networks.find do |f|
201
201
  next unless f.respond_to?(:config)
202
+
202
203
  sw = f.config.distributedVirtualSwitch
203
204
  sw.uuid == dvswitch || sw.name == dvswitch
204
205
  end
@@ -226,6 +227,7 @@ class Chef
226
227
  entity_array = poolName.split("/")
227
228
  entity_array.each do |entityArrItem|
228
229
  next if entityArrItem == ""
230
+
229
231
  if base_entity.is_a? RbVmomi::VIM::Folder
230
232
  base_entity = base_entity.childEntity.find { |f| f.name == entityArrItem } ||
231
233
  abort("no such pool #{poolName} while looking for #{entityArrItem}")
@@ -251,13 +253,14 @@ class Chef
251
253
  dstores.each do |store|
252
254
  avail = number_to_human_size(store.summary[:freeSpace])
253
255
  cap = number_to_human_size(store.summary[:capacity])
254
- puts "#{ui.color('Datastore', :cyan)}: #{store.name} (#{avail}(#{store.summary[:freeSpace]}) / #{cap})"
256
+ puts "#{ui.color("Datastore", :cyan)}: #{store.name} (#{avail}(#{store.summary[:freeSpace]}) / #{cap})"
255
257
 
256
258
  # vm's can span multiple datastores, so instead of grabbing the first one
257
259
  # let's find the first datastore with the available space on a LUN the vm
258
260
  # is already using, or use a specified LUN (if given)
259
261
 
260
262
  next unless (store.summary[:freeSpace] - vmdk_size_b) > 0
263
+
261
264
  # also let's not use more than 90% of total space to save room for snapshots.
262
265
  cap_remains = 100 * ((store.summary[:freeSpace].to_f - vmdk_size_b.to_f) / store.summary[:capacity].to_f)
263
266
  candidates.push(store) if cap_remains.to_i > 10
@@ -34,11 +34,11 @@ module SearchHelper
34
34
  type: "ContainerView",
35
35
  path: "view",
36
36
  skip: false
37
- )
38
- ]
37
+ ),
38
+ ],
39
39
  ],
40
40
  propSet: [
41
- { type: opts[:type], pathSet: opts[:properties] }
41
+ { type: opts[:type], pathSet: opts[:properties] },
42
42
  ]
43
43
  )
44
44
  pc.RetrieveProperties(specSet: [filter_spec])
@@ -21,7 +21,7 @@ class Chef::Knife::VsphereCustomizationList < Chef::Knife::BaseVsphereCommand
21
21
 
22
22
  csm = vim.serviceContent.customizationSpecManager
23
23
  csm.info.each do |c|
24
- puts "#{ui.color('Customization Name', :cyan)}: #{c.name}"
24
+ puts "#{ui.color("Customization Name", :cyan)}: #{c.name}"
25
25
  end
26
26
  end
27
27
  end
@@ -10,24 +10,24 @@ class Chef::Knife::VsphereDatastoreFile < Chef::Knife::BaseVsphereCommand
10
10
  common_options
11
11
 
12
12
  option :local_file,
13
- long: "--local-file FILE",
14
- short: "-f",
15
- description: "Local file and path"
13
+ long: "--local-file FILE",
14
+ short: "-f",
15
+ description: "Local file and path"
16
16
 
17
17
  option :remote_file,
18
- long: "--remote-file FILE",
19
- short: "-r",
20
- description: "Remote file and path"
18
+ long: "--remote-file FILE",
19
+ short: "-r",
20
+ description: "Remote file and path"
21
21
 
22
22
  option :upload,
23
- long: "--upload-file",
24
- short: "-u",
25
- description: "Upload local file to remote"
23
+ long: "--upload-file",
24
+ short: "-u",
25
+ description: "Upload local file to remote"
26
26
 
27
27
  option :download,
28
- long: "--download-file",
29
- short: "-D",
30
- description: "Download remote file to local"
28
+ long: "--download-file",
29
+ short: "-D",
30
+ description: "Download remote file to local"
31
31
 
32
32
  # Main run method for datastore_file
33
33
  #
@@ -26,13 +26,13 @@ class Chef::Knife::VsphereDatastoreList < Chef::Knife::BaseVsphereCommand
26
26
  common_options
27
27
 
28
28
  option :list,
29
- long: "--list",
30
- short: "-L",
31
- description: "Indicates whether to list VM's in datastore",
32
- boolean: true
29
+ long: "--list",
30
+ short: "-L",
31
+ description: "Indicates whether to list VM's in datastore",
32
+ boolean: true
33
33
  option :pool,
34
- long: "--pool pool",
35
- description: "Target pool"
34
+ long: "--pool pool",
35
+ description: "Target pool"
36
36
 
37
37
  # The main run method for datastore_list
38
38
  #
@@ -24,18 +24,18 @@ class Chef::Knife::VsphereDatastoreMaxfree < Chef::Knife::BaseVsphereCommand
24
24
  banner "knife vsphere datastore maxfree"
25
25
 
26
26
  option :regex,
27
- short: "-r REGEX",
28
- long: "--regex REGEX",
29
- description: "Regex to match the datastore name",
30
- default: ""
27
+ short: "-r REGEX",
28
+ long: "--regex REGEX",
29
+ description: "Regex to match the datastore name",
30
+ default: ""
31
31
 
32
32
  option :vlan,
33
- long: "--vlan VLAN",
34
- description: "Require listed vlan available to datastore's parent"
33
+ long: "--vlan VLAN",
34
+ description: "Require listed vlan available to datastore's parent"
35
35
 
36
36
  option :pool,
37
- long: "--pool pool",
38
- description: "Pool or Cluster to search for datastores in"
37
+ long: "--pool pool",
38
+ description: "Pool or Cluster to search for datastores in"
39
39
 
40
40
  common_options
41
41
 
@@ -45,9 +45,10 @@ end
45
45
  def print_dsclusters_in_folder(folder)
46
46
  folder.childEntity.each do |child|
47
47
  next unless child.class.to_s == "StoragePod"
48
+
48
49
  avail = number_to_human_size(child.summary[:freeSpace])
49
50
  cap = number_to_human_size(child.summary[:capacity])
50
- puts "#{ui.color('DatastoreCluster', :cyan)}: #{child.name} (#{avail} / #{cap})"
51
+ puts "#{ui.color("DatastoreCluster", :cyan)}: #{child.name} (#{avail} / #{cap})"
51
52
  end
52
53
  end
53
54
 
@@ -48,10 +48,10 @@ class Chef::Knife::VsphereDatastoreclusterMaxfree < Chef::Knife::BaseVsphereComm
48
48
  banner "knife vsphere datastorecluster maxfree"
49
49
 
50
50
  option :regex,
51
- short: "-r REGEX",
52
- long: "--regex REGEX",
53
- description: "Regex to match the datastore cluster name",
54
- default: ""
51
+ short: "-r REGEX",
52
+ long: "--regex REGEX",
53
+ description: "Regex to match the datastore cluster name",
54
+ default: ""
55
55
  common_options
56
56
 
57
57
  def run
@@ -17,7 +17,7 @@ class Chef::Knife::VsphereFolderList < Chef::Knife::BaseVsphereCommand
17
17
  # param [String] folder that you should go through
18
18
  # param [String] indent_level for the output to indent
19
19
  def traverse_folders(folder, indent_level)
20
- puts "#{' ' * indent_level} #{ui.color('Folder', :cyan)}: " + folder.name
20
+ puts "#{" " * indent_level} #{ui.color("Folder", :cyan)}: " + folder.name
21
21
 
22
22
  folders = find_all_in_folder(folder, RbVmomi::VIM::Folder)
23
23
  folders.each do |child|
@@ -10,9 +10,9 @@ class Chef::Knife::VsphereHostsList < Chef::Knife::BaseVsphereCommand
10
10
 
11
11
  common_options
12
12
  option :pool,
13
- long: "--pool pool",
14
- short: "-h",
15
- description: "Target pool"
13
+ long: "--pool pool",
14
+ short: "-h",
15
+ description: "Target pool"
16
16
 
17
17
  # The main run method for hosts_list
18
18
  #
@@ -16,7 +16,7 @@ class Chef::Knife::VspherePoolList < Chef::Knife::BaseVsphereCommand
16
16
 
17
17
  if folder.is_a? RbVmomi::VIM::ResourcePool
18
18
  pools = folder.path[3..-1].reject { |p| p.last == "Resources" }
19
- puts "#{ui.color('Pool', :cyan)}: " + pools.map(&:last).join("/")
19
+ puts "#{ui.color("Pool", :cyan)}: " + pools.map(&:last).join("/")
20
20
  end
21
21
 
22
22
  folders = find_all_in_folder(folder, RbVmomi::VIM::ManagedObject) || []
@@ -9,8 +9,8 @@ class Chef::Knife::VsphereVlanCreate < Chef::Knife::BaseVsphereCommand
9
9
  common_options
10
10
 
11
11
  option :switch,
12
- long: "--switch DVSNAME",
13
- description: "The DVSwitch that will hold this VLAN"
12
+ long: "--switch DVSNAME",
13
+ description: "The DVSwitch that will hold this VLAN"
14
14
 
15
15
  # The main run method for vlan_create
16
16
  #
@@ -32,7 +32,7 @@ class Chef::Knife::VsphereVlanList < Chef::Knife::BaseVsphereCommand
32
32
  vim_connection
33
33
  dc = datacenter
34
34
  dc.network.each do |network|
35
- puts "#{ui.color('VLAN', :cyan)}: #{network.name}"
35
+ puts "#{ui.color("VLAN", :cyan)}: #{network.name}"
36
36
  end
37
37
  end
38
38
  end
@@ -15,36 +15,36 @@ class Chef::Knife::VsphereVmCdrom < Chef::Knife::BaseVsphereCommand
15
15
  common_options
16
16
 
17
17
  option :datastore,
18
- long: "--datastore STORE",
19
- description: "The datastore for an iso source"
18
+ long: "--datastore STORE",
19
+ description: "The datastore for an iso source"
20
20
 
21
21
  option :iso,
22
- long: "--iso ISO",
23
- description: "The name and path of the ISO to attach"
22
+ long: "--iso ISO",
23
+ description: "The name and path of the ISO to attach"
24
24
 
25
25
  option :attach,
26
- short: "-a",
27
- long: "--attach",
28
- description: "Attach the virtual cdrom to the VM",
29
- boolean: true
26
+ short: "-a",
27
+ long: "--attach",
28
+ description: "Attach the virtual cdrom to the VM",
29
+ boolean: true
30
30
 
31
31
  option :disconnect,
32
- long: "--disconnect",
33
- description: "Disconnect the virtual cdrom from the VM",
34
- boolean: true
32
+ long: "--disconnect",
33
+ description: "Disconnect the virtual cdrom from the VM",
34
+ boolean: true
35
35
 
36
36
  option :on_boot,
37
- long: "--on_boot ONBOOT",
38
- description: "False for Detached on boot or True for Attached on boot"
37
+ long: "--on_boot ONBOOT",
38
+ description: "False for Detached on boot or True for Attached on boot"
39
39
 
40
40
  option :client_device,
41
- long: "--client_device",
42
- description: "Set the backing store to client-device"
41
+ long: "--client_device",
42
+ description: "Set the backing store to client-device"
43
43
 
44
44
  option :recursive,
45
- short: "-r",
46
- long: "--recursive",
47
- description: "Search all folders"
45
+ short: "-r",
46
+ long: "--recursive",
47
+ description: "Search all folders"
48
48
 
49
49
  # The main run method for vm_cdrom
50
50
  #
@@ -10,7 +10,6 @@ require "chef/knife"
10
10
  require "chef/knife/base_vsphere_command"
11
11
  require "chef/knife/customization_helper"
12
12
  require "chef/knife/search_helper"
13
- require "chef/knife/winrm_base"
14
13
  require "ipaddr"
15
14
  require "netaddr"
16
15
  require "securerandom"
@@ -26,327 +25,226 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
26
25
  # a linklayer origin is an actual nic
27
26
  ORIGIN_IS_REAL_NIC ||= "linklayer".freeze
28
27
 
29
- include Chef::Knife::WinrmBase
28
+ # include Chef::Knife::WinrmBase
30
29
  include CustomizationHelper
31
30
  include SearchHelper
32
31
  deps do
33
32
  require "chef/json_compat"
34
- require "chef/knife/bootstrap"
35
33
  Chef::Knife::Bootstrap.load_deps
36
34
  end
37
35
 
38
36
  common_options
39
37
 
40
38
  option :dest_folder,
41
- long: "--dest-folder FOLDER",
42
- description: "The folder into which to put the cloned VM"
39
+ long: "--dest-folder FOLDER",
40
+ description: "The folder into which to put the cloned VM"
43
41
 
44
42
  option :datastore,
45
- long: "--datastore STORE",
46
- description: "The datastore into which to put the cloned VM"
43
+ long: "--datastore STORE",
44
+ description: "The datastore into which to put the cloned VM"
47
45
 
48
46
  option :datastorecluster,
49
- long: "--datastorecluster STORE",
50
- description: "The datastorecluster into which to put the cloned VM"
47
+ long: "--datastorecluster STORE",
48
+ description: "The datastorecluster into which to put the cloned VM"
51
49
 
52
50
  option :host,
53
- long: "--host HOST",
54
- description: "The host into which to put the cloned VM"
51
+ long: "--host HOST",
52
+ description: "The host into which to put the cloned VM"
55
53
 
56
54
  option :resource_pool,
57
- long: "--resource-pool POOL",
58
- description: "The resource pool or cluster into which to put the cloned VM"
55
+ long: "--resource-pool POOL",
56
+ description: "The resource pool or cluster into which to put the cloned VM"
59
57
 
60
58
  option :source_vm,
61
- long: "--template TEMPLATE",
62
- description: "The source VM / Template to clone from"
59
+ long: "--template TEMPLATE",
60
+ description: "The source VM / Template to clone from"
63
61
 
64
62
  option :linked_clone,
65
- long: "--linked-clone",
66
- description: "Indicates whether to use linked clones.",
67
- boolean: false
63
+ long: "--linked-clone",
64
+ description: "Indicates whether to use linked clones.",
65
+ boolean: false
68
66
 
69
67
  option :thin_provision,
70
- long: "--thin-provision",
71
- description: "Indicates whether disk should be thin provisioned.",
72
- boolean: true
68
+ long: "--thin-provision",
69
+ description: "Indicates whether disk should be thin provisioned.",
70
+ boolean: true
73
71
 
74
72
  option :annotation,
75
- long: "--annotation TEXT",
76
- description: "Add TEXT in Notes field from annotation"
73
+ long: "--annotation TEXT",
74
+ description: "Add TEXT in Notes field from annotation"
77
75
 
78
76
  option :customization_spec,
79
- long: "--cspec CUST_SPEC",
80
- description: "The name of any customization specification to apply"
77
+ long: "--cspec CUST_SPEC",
78
+ description: "The name of any customization specification to apply"
81
79
 
82
80
  option :customization_plugin,
83
- long: "--cplugin CUST_PLUGIN_PATH",
84
- description: "Path to plugin that implements KnifeVspherePlugin.customize_clone_spec and/or KnifeVspherePlugin.reconfig_vm"
81
+ long: "--cplugin CUST_PLUGIN_PATH",
82
+ description: "Path to plugin that implements KnifeVspherePlugin.customize_clone_spec and/or KnifeVspherePlugin.reconfig_vm"
85
83
 
86
84
  option :customization_plugin_data,
87
- long: "--cplugin-data CUST_PLUGIN_DATA",
88
- description: "String of data to pass to the plugin. Use any format you wish."
85
+ long: "--cplugin-data CUST_PLUGIN_DATA",
86
+ description: "String of data to pass to the plugin. Use any format you wish."
89
87
 
90
88
  option :customization_vlan,
91
- long: "--cvlan CUST_VLANS",
92
- description: "Comma-delimited list of VLAN names for network adapters to join"
89
+ long: "--cvlan CUST_VLANS",
90
+ description: "Comma-delimited list of VLAN names for network adapters to join"
93
91
 
94
92
  option :customization_sw_uuid,
95
- long: "--sw-uuid SWITCH_UUIDS",
96
- description: "Comma-delimited list of distributed virtual switch UUIDs for network adapter to connect, use 'auto' to automatically assign"
93
+ long: "--sw-uuid SWITCH_UUIDS",
94
+ description: "Comma-delimited list of distributed virtual switch UUIDs for network adapter to connect, use 'auto' to automatically assign"
97
95
 
98
96
  option :customization_macs,
99
- long: "--cmacs CUST_MACS",
100
- description: "Comma-delimited list of MAC addresses for network adapters",
101
- default: AUTO_MAC
97
+ long: "--cmacs CUST_MACS",
98
+ description: "Comma-delimited list of MAC addresses for network adapters",
99
+ default: AUTO_MAC
102
100
 
103
101
  option :customization_ips,
104
- long: "--cips CUST_IPS",
105
- description: "Comma-delimited list of CIDR IPs for customization",
106
- default: NO_IPS
102
+ long: "--cips CUST_IPS",
103
+ description: "Comma-delimited list of CIDR IPs for customization",
104
+ default: NO_IPS
107
105
 
108
106
  option :customization_dns_ips,
109
- long: "--cdnsips CUST_DNS_IPS",
110
- description: "Comma-delimited list of DNS IP addresses"
107
+ long: "--cdnsips CUST_DNS_IPS",
108
+ description: "Comma-delimited list of DNS IP addresses"
111
109
 
112
110
  option :customization_dns_suffixes,
113
- long: "--cdnssuffix CUST_DNS_SUFFIXES",
114
- description: "Comma-delimited list of DNS search suffixes"
111
+ long: "--cdnssuffix CUST_DNS_SUFFIXES",
112
+ description: "Comma-delimited list of DNS search suffixes"
115
113
 
116
114
  option :customization_gw,
117
- long: "--cgw CUST_GW",
118
- description: "CIDR IP of gateway for customization"
115
+ long: "--cgw CUST_GW",
116
+ description: "CIDR IP of gateway for customization"
119
117
 
120
118
  option :customization_hostname,
121
- long: "--chostname CUST_HOSTNAME",
122
- description: "Unqualified hostname for customization"
119
+ long: "--chostname CUST_HOSTNAME",
120
+ description: "Unqualified hostname for customization"
123
121
 
124
122
  option :customization_domain,
125
- long: "--cdomain CUST_DOMAIN",
126
- description: "Domain name for customization"
123
+ long: "--cdomain CUST_DOMAIN",
124
+ description: "Domain name for customization"
127
125
 
128
126
  option :customization_tz,
129
- long: "--ctz CUST_TIMEZONE",
130
- description: "Timezone invalid 'Area/Location' format"
127
+ long: "--ctz CUST_TIMEZONE",
128
+ description: "Timezone invalid 'Area/Location' format"
131
129
 
132
130
  option :customization_cpucount,
133
- long: "--ccpu CUST_CPU_COUNT",
134
- description: "Number of CPUs"
131
+ long: "--ccpu CUST_CPU_COUNT",
132
+ description: "Number of CPUs"
135
133
 
136
134
  option :customization_corespersocket,
137
- long: "--ccorespersocket CUST_CPU_CORES_PER_SOCKET",
138
- description: "Number of CPU Cores per Socket"
135
+ long: "--ccorespersocket CUST_CPU_CORES_PER_SOCKET",
136
+ description: "Number of CPU Cores per Socket"
139
137
 
140
138
  option :customization_memory,
141
- long: "--cram CUST_MEMORY_GB",
142
- description: "Gigabytes of RAM"
139
+ long: "--cram CUST_MEMORY_GB",
140
+ description: "Gigabytes of RAM"
143
141
 
144
142
  option :customization_memory_reservation,
145
- long: "--cram_reservation CUST_MEMORY_RESERVATION_GB",
146
- description: "Gigabytes of RAM"
143
+ long: "--cram_reservation CUST_MEMORY_RESERVATION_GB",
144
+ description: "Gigabytes of RAM"
147
145
 
148
146
  option :power,
149
- long: "--start",
150
- description: "Indicates whether to start the VM after a successful clone",
151
- boolean: false
147
+ long: "--start",
148
+ description: "Indicates whether to start the VM after a successful clone",
149
+ boolean: false
152
150
 
153
151
  option :bootstrap,
154
- long: "--bootstrap",
155
- description: "Indicates whether to bootstrap the VM",
156
- boolean: false
152
+ long: "--bootstrap",
153
+ description: "Indicates whether to bootstrap the VM",
154
+ boolean: false
157
155
 
158
156
  option :environment,
159
- long: "--environment ENVIRONMENT",
160
- description: "Environment to add the node to for bootstrapping"
157
+ long: "--environment ENVIRONMENT",
158
+ description: "Environment to add the node to for bootstrapping"
161
159
 
162
160
  option :fqdn,
163
- long: "--fqdn SERVER_FQDN",
164
- description: "Fully qualified hostname for bootstrapping"
161
+ long: "--fqdn SERVER_FQDN",
162
+ description: "Fully qualified hostname for bootstrapping"
165
163
 
166
164
  option :bootstrap_msi_url,
167
- long: "--bootstrap-msi-url URL",
168
- description: "Location of the Chef Client MSI. The default templates will prefer to download from this location."
165
+ long: "--bootstrap-msi-url URL",
166
+ description: "Location of the Chef Client MSI. The default templates will prefer to download from this location."
169
167
 
170
168
  option :bootstrap_protocol,
171
- long: "--bootstrap-protocol protocol",
172
- description: "Protocol to bootstrap windows servers. options: winrm/ssh",
173
- proc: proc { |key| Chef::Config[:knife][:bootstrap_protocol] = key },
174
- default: nil
175
-
176
- option :ssh_user,
177
- short: "-x USERNAME",
178
- long: "--ssh-user USERNAME",
179
- description: "The ssh username",
180
- default: "root"
181
-
182
- option :ssh_password,
183
- short: "-P PASSWORD",
184
- long: "--ssh-password PASSWORD",
185
- description: "The ssh password"
186
-
187
- option :ssh_port,
188
- short: "-p PORT",
189
- long: "--ssh-port PORT",
190
- description: "The ssh port",
191
- default: "22"
192
-
193
- option :identity_file,
194
- short: "-i IDENTITY_FILE",
195
- long: "--identity-file IDENTITY_FILE",
196
- description: "The SSH identity file used for authentication"
197
-
198
- option :chef_node_name,
199
- short: "-N NAME",
200
- long: "--node-name NAME",
201
- description: "The Chef node name for your new node"
202
-
203
- option :prerelease,
204
- long: "--prerelease",
205
- description: "Install the pre-release chef gems",
206
- boolean: false
207
-
208
- option :bootstrap_version,
209
- long: "--bootstrap-version VERSION",
210
- description: "The version of Chef to install",
211
- proc: proc { |v| Chef::Config[:knife][:bootstrap_version] = v }
212
-
213
- option :bootstrap_proxy,
214
- long: "--bootstrap-proxy PROXY_URL",
215
- description: "The proxy server for the node being bootstrapped",
216
- proc: proc { |p| Chef::Config[:knife][:bootstrap_proxy] = p }
217
-
218
- option :bootstrap_vault_file,
219
- long: "--bootstrap-vault-file VAULT_FILE",
220
- description: "A JSON file with a list of vault(s) and item(s) to be updated"
221
-
222
- option :bootstrap_vault_json,
223
- long: "--bootstrap-vault-json VAULT_JSON",
224
- description: "A JSON string with the vault(s) and item(s) to be updated"
225
-
226
- option :bootstrap_vault_item,
227
- long: "--bootstrap-vault-item VAULT_ITEM",
228
- description: 'A single vault and item to update as "vault:item"',
229
- proc: proc { |i|
230
- (vault, item) = i.split(/:/)
231
- Chef::Config[:knife][:bootstrap_vault_item] ||= {}
232
- Chef::Config[:knife][:bootstrap_vault_item][vault] ||= []
233
- Chef::Config[:knife][:bootstrap_vault_item][vault].push(item)
234
- Chef::Config[:knife][:bootstrap_vault_item]
235
- }
236
-
237
- option :distro,
238
- short: "-d DISTRO",
239
- long: "--distro DISTRO",
240
- description: "Bootstrap a distro using a template. [DEPRECATED] Use -t / --bootstrap-template option instead.",
241
- proc: Proc.new { |v|
242
- Chef::Log.fatal("[DEPRECATED] -d / --distro option is deprecated. Use --bootstrap-template option instead.")
243
- v
244
- }
245
-
246
- option :tags,
247
- long: "--tags TAGS",
248
- description: "Comma separated list of tags to apply to the node",
249
- proc: ->(tags) { tags.split(/[\s,]+/) },
250
- default: []
251
-
252
- option :bootstrap_template,
253
- short: "-t TEMPLATE",
254
- long: "--bootstrap-template TEMPLATE",
255
- description: "Bootstrap Chef using a built-in or custom template. Set to the full path of an erb template or use one of the built-in templates."
256
-
257
- option :template_file,
258
- long: "--template-file TEMPLATE",
259
- description: "Full path to location of template to use. [DEPRECATED] Use -t / --bootstrap-template option",
260
- proc: Proc.new { |v|
261
- Chef::Log.fatal("[DEPRECATED] --template-file option is deprecated. Use --bootstrap-template option instead.")
262
- v
263
- }
264
-
265
- option :run_list,
266
- short: "-r RUN_LIST",
267
- long: "--run-list RUN_LIST",
268
- description: "Comma separated list of roles/recipes to apply",
269
- proc: ->(o) { o.split(/[\s,]+/) },
270
- default: []
271
-
272
- option :secret_file,
273
- long: "--secret-file SECRET_FILE",
274
- description: "A file containing the secret key to use to encrypt data bag item values",
275
- proc: ->(secret_file) { Chef::Config[:knife][:secret_file] = secret_file }
276
-
277
- # rubocop:disable Style/Blocks
278
- option :hint,
279
- long: "--hint HINT_NAME[=HINT_FILE]",
280
- description: "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.",
281
- proc: proc { |h|
282
- Chef::Config[:knife][:hints] ||= {}
283
- name, path = h.split("=")
284
- Chef::Config[:knife][:hints][name] = path ? JSON.parse(::File.read(path)) : {}
285
- },
286
- default: ""
287
- # rubocop:enable Style/Blocks
288
-
289
- option :no_host_key_verify,
290
- long: "--no-host-key-verify",
291
- description: "Disable host key verification",
292
- boolean: true
293
-
294
- option :node_ssl_verify_mode,
295
- long: "--node-ssl-verify-mode [peer|none]",
296
- description: "Whether or not to verify the SSL cert for all HTTPS requests when bootstrapping"
297
-
298
- option :first_boot_attributes,
299
- short: "-j JSON_ATTRIBS",
300
- long: "--json-attributes",
301
- description: "A JSON string to be added to the first run of chef-client",
302
- proc: ->(o) { JSON.parse(o) },
303
- default: {}
169
+ long: "--bootstrap-protocol protocol",
170
+ description: "Protocol to bootstrap windows servers. options: winrm/ssh",
171
+ proc: proc { |key| Chef::Config[:knife][:bootstrap_protocol] = key },
172
+ default: nil
304
173
 
305
174
  option :disable_customization,
306
- long: "--disable-customization",
307
- description: "Disable default customization",
308
- boolean: true,
309
- default: false
175
+ long: "--disable-customization",
176
+ description: "Disable default customization",
177
+ boolean: true,
178
+ default: false
310
179
 
311
180
  option :log_level,
312
- short: "-l LEVEL",
313
- long: "--log_level",
314
- description: "Set the log level (debug, info, warn, error, fatal) for chef-client",
315
- proc: ->(l) { l.to_sym }
181
+ short: "-l LEVEL",
182
+ long: "--log_level",
183
+ description: "Set the log level (debug, info, warn, error, fatal) for chef-client",
184
+ proc: ->(l) { l.to_sym }
316
185
 
317
186
  option :mark_as_template,
318
- long: "--mark_as_template",
319
- description: "Indicates whether to mark the new vm as a template",
320
- boolean: false
187
+ long: "--mark_as_template",
188
+ description: "Indicates whether to mark the new vm as a template",
189
+ boolean: false
321
190
 
322
191
  option :random_vmname,
323
- long: "--random-vmname",
324
- description: "Creates a random VMNAME starts with vm-XXXXXXXX",
325
- boolean: false
192
+ long: "--random-vmname",
193
+ description: "Creates a random VMNAME starts with vm-XXXXXXXX",
194
+ boolean: false
326
195
 
327
196
  option :random_vmname_prefix,
328
- long: "--random-vmname-prefix PREFIX",
329
- description: "Change the VMNAME prefix",
330
- default: "vm-"
197
+ long: "--random-vmname-prefix PREFIX",
198
+ description: "Change the VMNAME prefix",
199
+ default: "vm-"
331
200
 
332
201
  option :sysprep_timeout,
333
- long: "--sysprep_timeout TIMEOUT",
334
- description: "Wait TIMEOUT seconds for sysprep event before continuing with bootstrap",
335
- default: 600
202
+ long: "--sysprep_timeout TIMEOUT",
203
+ description: "Wait TIMEOUT seconds for sysprep event before continuing with bootstrap",
204
+ default: 600
336
205
 
337
206
  option :bootstrap_nic,
338
- long: "--bootstrap-nic INTEGER",
339
- description: "Network interface to use when multiple NICs are defined on a template.",
340
- default: 0
207
+ long: "--bootstrap-nic INTEGER",
208
+ description: "Network interface to use when multiple NICs are defined on a template.",
209
+ default: 0
341
210
 
342
211
  option :bootstrap_ipv4,
343
- long: "--bootstrap-ipv4",
344
- description: "Force using an IPv4 address when a NIC has both IPv4 and IPv6 addresses.",
345
- default: false
212
+ long: "--bootstrap-ipv4",
213
+ description: "Force using an IPv4 address when a NIC has both IPv4 and IPv6 addresses.",
214
+ default: false
346
215
 
347
216
  def run
217
+ check_license
218
+
219
+ plugin_setup!
220
+ validate_name_args!
221
+ validate_protocol!
222
+ validate_first_boot_attributes!
223
+ validate_winrm_transport_opts!
224
+ validate_policy_options!
225
+ plugin_validate_options!
226
+
227
+ winrm_warn_no_ssl_verification
228
+ warn_on_short_session_timeout
229
+
230
+ plugin_create_instance!
231
+
232
+ return unless get_config(:bootstrap)
233
+
348
234
  $stdout.sync = true
235
+ connect!
236
+ register_client
349
237
 
238
+ content = render_template
239
+ bootstrap_path = upload_bootstrap(content)
240
+ perform_bootstrap(bootstrap_path)
241
+ plugin_finalize
242
+ ensure
243
+ connection.del_file!(bootstrap_path) if connection && bootstrap_path
244
+ end
245
+
246
+ # @return [TrueClass] If options are valid or exits
247
+ def plugin_validate_options!
350
248
  unless using_supplied_hostname? ^ using_random_hostname?
351
249
  show_usage
352
250
  fatal_exit("You must specify a virtual machine name OR use --random-vmname")
@@ -361,7 +259,18 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
361
259
  if get_config(:customization_macs) != AUTO_MAC && get_config(:customization_ips) == NO_IPS
362
260
  abort('Must specify IP numbers with --cips when specifying MAC addresses with --cmacs, can use "dhcp" as placeholder')
363
261
  end
262
+ end
364
263
 
264
+ attr_accessor :server_name
265
+
266
+ alias host_descriptor server_name
267
+
268
+ # Create the server that we will bootstrap, if necessary
269
+ #
270
+ # Plugins that subclass bootstrap, e.g. knife-ec2, can use this method to call out to an API to build an instance of the server we wish to bootstrap
271
+ #
272
+ # @return [TrueClass] If instance successfully created, or exits
273
+ def plugin_create_instance!
365
274
  config[:chef_node_name] = vmname unless get_config(:chef_node_name)
366
275
 
367
276
  vim = vim_connection
@@ -405,6 +314,7 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
405
314
  end
406
315
 
407
316
  return if get_config(:mark_as_template)
317
+
408
318
  if get_config(:power) || get_config(:bootstrap)
409
319
  vm = get_vm_by_name(vmname, cust_folder) || fatal_exit("VM #{vmname} not found")
410
320
  begin
@@ -414,13 +324,12 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
414
324
  end
415
325
  puts "Powered on virtual machine #{vmname}"
416
326
  end
417
-
418
327
  return unless get_config(:bootstrap)
419
328
 
420
- connect_port = get_config(:ssh_port)
421
329
  protocol = get_config(:bootstrap_protocol)
422
330
  if windows?(src_vm.config)
423
331
  protocol ||= "winrm"
332
+ connect_port ||= 5985
424
333
  unless config[:disable_customization]
425
334
  # Wait for customization to complete
426
335
  puts "Waiting for customization to complete..."
@@ -428,20 +337,35 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
428
337
  puts "Customization Complete"
429
338
  end
430
339
  connect_host = guest_address(vm)
340
+ self.server_name = connect_host
431
341
  Chef::Log.debug("Connect Host for winrm Bootstrap: #{connect_host}")
432
342
  wait_for_access(connect_host, connect_port, protocol)
433
- ssh_override_winrm
434
- bootstrap_for_windows_node.run
435
343
  else
436
344
  connect_host = guest_address(vm)
345
+ self.server_name = connect_host
346
+ connect_port ||= 22
437
347
  Chef::Log.debug("Connect Host for SSH Bootstrap: #{connect_host}")
438
348
  protocol ||= "ssh"
439
349
  wait_for_access(connect_host, connect_port, protocol)
440
- ssh_override_winrm
441
- bootstrap_for_node.run
442
350
  end
443
351
  end
444
352
 
353
+ # Perform any setup necessary by the plugin
354
+ #
355
+ # Plugins that subclass bootstrap, e.g. knife-ec2, can use this method to create connection objects
356
+ #
357
+ # @return [TrueClass] If instance successfully created, or exits
358
+ def plugin_setup!; end
359
+
360
+ # Perform any teardown or cleanup necessary by the plugin
361
+ #
362
+ # Plugins that subclass bootstrap, e.g. knife-ec2, can use this method to display a message or perform any cleanup
363
+ #
364
+ # @return [void]
365
+ def plugin_finalize; end
366
+
367
+ def validate_name_args!; end
368
+
445
369
  def ipv4_address(vm)
446
370
  puts "Waiting for a valid IPv4 address..."
447
371
  # Multiple reboots occur during guest customization in which a link-local
@@ -475,12 +399,11 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
475
399
  end
476
400
 
477
401
  def wait_for_access(connect_host, connect_port, protocol)
478
- if protocol == "winrm"
479
- load_winrm_deps
480
- if get_config(:winrm_transport) == "ssl" && get_config(:winrm_port) == "5985"
481
- config[:winrm_port] = "5986"
402
+ if winrm?
403
+ if get_config(:winrm_ssl) && get_config(:connection_port) == "5985"
404
+ config[:connection_port] = "5986"
482
405
  end
483
- connect_port = get_config(:winrm_port)
406
+ connect_port = get_config(:connection_port)
484
407
  print "\n#{ui.color("Waiting for winrm access to become available on #{connect_host}:#{connect_port}", :magenta)}"
485
408
  print(".") until tcp_test_winrm(connect_host, connect_port) do
486
409
  sleep 10
@@ -513,7 +436,7 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
513
436
  new_disk.backing.fileName = "[#{disk.backing.datastore.name}]"
514
437
  new_disk.backing.parent = disk.backing
515
438
  end,
516
- }
439
+ },
517
440
  ],
518
441
  }
519
442
  src_vm.ReconfigVM_Task(spec: spec).wait_for_completion
@@ -565,6 +488,7 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
565
488
  def find_host(host_name)
566
489
  host = all_the_hosts.find { |host| host.name == host_name }
567
490
  raise "Can't find #{host_name}. I found #{all_the_hosts.map(&:name)}" unless host
491
+
568
492
  host
569
493
  end
570
494
 
@@ -843,89 +767,8 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
843
767
  adapter_map
844
768
  end
845
769
 
846
- def bootstrap_common_params(bootstrap)
847
- bootstrap.config[:run_list] = config[:run_list]
848
- bootstrap.config[:bootstrap_version] = get_config(:bootstrap_version)
849
- bootstrap.config[:environment] = get_config(:environment)
850
- bootstrap.config[:prerelease] = get_config(:prerelease)
851
- bootstrap.config[:first_boot_attributes] = get_config(:first_boot_attributes)
852
- bootstrap.config[:hint] = get_config(:hint)
853
- bootstrap.config[:chef_node_name] = get_config(:chef_node_name)
854
- bootstrap.config[:bootstrap_vault_file] = get_config(:bootstrap_vault_file)
855
- bootstrap.config[:bootstrap_vault_json] = get_config(:bootstrap_vault_json)
856
- bootstrap.config[:bootstrap_vault_item] = get_config(:bootstrap_vault_item)
857
- # may be needed for vpc mode
858
- bootstrap.config[:no_host_key_verify] = get_config(:no_host_key_verify)
859
- bootstrap.config[:node_ssl_verify_mode] = get_config(:node_ssl_verify_mode)
860
- bootstrap.config[:tags] = get_config(:tags)
861
- bootstrap
862
- end
863
-
864
- def bootstrap_for_windows_node
865
- Chef::Knife::Bootstrap.load_deps
866
- if get_config(:bootstrap_protocol) == "winrm" || get_config(:bootstrap_protocol).nil?
867
- bootstrap = Chef::Knife::BootstrapWindowsWinrm.new
868
- bootstrap.name_args = [config[:fqdn]]
869
- bootstrap.config[:winrm_user] = get_config(:winrm_user)
870
- bootstrap.config[:winrm_password] = get_config(:winrm_password)
871
- bootstrap.config[:winrm_transport] = get_config(:winrm_transport)
872
- bootstrap.config[:winrm_port] = get_config(:winrm_port)
873
- elsif get_config(:bootstrap_protocol) == "ssh"
874
- bootstrap = Chef::Knife::BootstrapWindowsSsh.new
875
- bootstrap.config[:ssh_user] = get_config(:ssh_user)
876
- bootstrap.config[:ssh_password] = get_config(:ssh_password)
877
- bootstrap.config[:ssh_port] = get_config(:ssh_port)
878
- else
879
- ui.error("Unsupported Bootstrapping Protocol. Supports : winrm, ssh")
880
- exit 1
881
- end
882
- bootstrap.config[:msi_url] = get_config(:bootstrap_msi_url)
883
- bootstrap_common_params(bootstrap)
884
- end
885
-
886
- def bootstrap_for_node
887
- Chef::Knife::Bootstrap.load_deps
888
- bootstrap = Chef::Knife::Bootstrap.new
889
- bootstrap.name_args = [config[:fqdn]]
890
- bootstrap.config[:bootstrap_template] = get_config(:bootstrap_template)
891
- bootstrap.config[:secret_file] = get_config(:secret_file)
892
- bootstrap.config[:ssh_user] = get_config(:ssh_user)
893
- bootstrap.config[:ssh_password] = get_config(:ssh_password)
894
- bootstrap.config[:ssh_port] = get_config(:ssh_port)
895
- bootstrap.config[:identity_file] = get_config(:identity_file)
896
- bootstrap.config[:use_sudo] = true unless get_config(:ssh_user) == "root"
897
- bootstrap.config[:use_sudo_password] = true unless get_config(:ssh_user) == "root"
898
- bootstrap.config[:log_level] = get_config(:log_level)
899
- bootstrap_common_params(bootstrap)
900
- end
901
-
902
- def ssh_override_winrm
903
- # unchanged ssh_user and changed winrm_user, override ssh_user
904
- if get_config(:ssh_user).eql?(options[:ssh_user][:default]) &&
905
- !get_config(:winrm_user).eql?(options[:winrm_user][:default])
906
- config[:ssh_user] = get_config(:winrm_user)
907
- end
908
-
909
- # unchanged ssh_port and changed winrm_port, override ssh_port
910
- if get_config(:ssh_port).eql?(options[:ssh_port][:default]) &&
911
- !get_config(:winrm_port).eql?(options[:winrm_port][:default])
912
- config[:ssh_port] = get_config(:winrm_port)
913
- end
914
-
915
- # unset ssh_password and set winrm_password, override ssh_password
916
- if get_config(:ssh_password).nil? &&
917
- !get_config(:winrm_password).nil?
918
- config[:ssh_password] = get_config(:winrm_password)
919
- end
920
-
921
- # unset identity_file and set kerberos_keytab_file, override identity_file
922
- return unless get_config(:identity_file).nil? && !get_config(:kerberos_keytab_file).nil?
923
-
924
- config[:identity_file] = get_config(:kerberos_keytab_file)
925
- end
926
-
927
- def tcp_test_ssh(hostname, ssh_port)
928
- tcp_socket = TCPSocket.new(hostname, ssh_port)
770
+ def tcp_test_ssh(hostname, connection_port)
771
+ tcp_socket = TCPSocket.new(hostname, connection_port)
929
772
  readable = IO.select([tcp_socket], nil, nil, 5)
930
773
  if readable
931
774
  ssh_banner = tcp_socket.gets
@@ -978,14 +821,6 @@ class Chef::Knife::VsphereVmClone < Chef::Knife::BaseVsphereCommand
978
821
  tcp_socket && tcp_socket.close
979
822
  end
980
823
 
981
- def load_winrm_deps
982
- require "winrm"
983
- require "chef/knife/winrm"
984
- require "chef/knife/bootstrap_windows_winrm"
985
- require "chef/knife/bootstrap_windows_ssh"
986
- require "chef/knife/core/windows_bootstrap_context"
987
- end
988
-
989
824
  private
990
825
 
991
826
  def vmname