chef-provisioning-vsphere 2.2.2 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,5 +3,5 @@
3
3
  # Provisions machines in vSphere.
4
4
  module ChefProvisioningVsphere
5
5
  # The version of this awesome Gem. BOOM.
6
- VERSION = '2.2.2'.freeze
6
+ VERSION = "2.3.0".freeze
7
7
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'chef/provisioning/driver'
3
+ require "chef/provisioning/driver"
4
4
 
5
5
  # Provisions machines in vSphere.
6
6
  module ChefProvisioningVsphere
@@ -31,16 +31,16 @@ module ChefProvisioningVsphere
31
31
  def find_port?(vm, options)
32
32
  @port = options[:ssh][:port]
33
33
  customization_spec = options[:customization_spec]
34
- if vm.config.guestId.start_with?('win')
34
+ if vm.config.guestId.start_with?("win")
35
35
  if customization_spec.is_a?(Hash)
36
36
  winrm_transport =
37
37
  customization_spec[:winrm_transport].nil? ? :negotiate : customization_spec[:winrm_transport].to_sym
38
38
  end
39
39
  winrm_transport ||= :negotiate
40
- default_win_port = winrm_transport == :ssl ? '5986' : '5985'
40
+ default_win_port = winrm_transport == :ssl ? "5986" : "5985"
41
41
  @port = default_win_port if @port.nil?
42
42
  elsif port.nil?
43
- @port = '22'
43
+ @port = "22"
44
44
  end
45
45
  true
46
46
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rbvmomi'
4
- require 'uri'
5
- require 'net/http'
3
+ require "rbvmomi"
4
+ require "uri"
5
+ require "net/http"
6
6
 
7
7
  # Provisions machines in vSphere.
8
8
  module ChefProvisioningVsphere
@@ -58,7 +58,7 @@ module ChefProvisioningVsphere
58
58
  #
59
59
  # @param [String] uuid the UUID of the machine
60
60
  def find_vm_by_id(uuid)
61
- vm = vim.searchIndex.FindByUuid(
61
+ vm = vim.searchIndex.FindByUuid( # rubocop:disable Naming/VariableName, Lint/UselessAssignment
62
62
  uuid: uuid,
63
63
  vmSearch: true,
64
64
  instanceUuid: true
@@ -71,7 +71,7 @@ module ChefProvisioningVsphere
71
71
  # @param [Object] _wait_on_port Defaults to port 22, to connect and verify it's up.
72
72
  def start_vm(vm, _wait_on_port = 22)
73
73
  state = vm.runtime.powerState
74
- vm.PowerOnVM_Task.wait_for_completion unless state == 'poweredOn'
74
+ vm.PowerOnVM_Task.wait_for_completion unless state == "poweredOn"
75
75
  end
76
76
 
77
77
  # Stops the VM
@@ -80,12 +80,12 @@ module ChefProvisioningVsphere
80
80
  # @param [Object] timeout Defaults to 600 seconds or 10 mins before giving up.
81
81
  def stop_vm(vm, timeout = 600)
82
82
  start = Time.now.utc
83
- return if vm.runtime.powerState == 'poweredOff'
83
+ return if vm.runtime.powerState == "poweredOff"
84
84
  begin
85
85
  vm.ShutdownGuest
86
86
  until (Time.now.utc - start) > timeout ||
87
- vm.runtime.powerState == 'poweredOff'
88
- print '.'
87
+ vm.runtime.powerState == "poweredOff"
88
+ print "."
89
89
  sleep 2
90
90
  end
91
91
  rescue
@@ -100,9 +100,9 @@ module ChefProvisioningVsphere
100
100
  def find_folder(folder_name)
101
101
  base = datacenter.vmFolder
102
102
  unless folder_name.nil?
103
- folder_name.split('/').reject(&:empty?).each do |item|
103
+ folder_name.split("/").reject(&:empty?).each do |item|
104
104
  base = base.find(item, RbVmomi::VIM::Folder) ||
105
- raise("vSphere Folder not found [#{folder_name}]")
105
+ raise("vSphere Folder not found [#{folder_name}]")
106
106
  end
107
107
  end
108
108
  base
@@ -132,8 +132,8 @@ module ChefProvisioningVsphere
132
132
  def datacenter
133
133
  vim # ensure connection is valid
134
134
  @datacenter ||= begin
135
- rootFolder = vim.serviceInstance.content.rootFolder
136
- dc = traverse_folders_for_dc(vim.rootFolder, datacenter_name) || abort("vSphere Datacenter not found [#{datacenter_name}]")
135
+ rootFolder = vim.serviceInstance.content.rootFolder # rubocop:disable Naming/VariableName, Lint/UselessAssignment
136
+ dc = traverse_folders_for_dc(vim.rootFolder, datacenter_name) || abort("vSphere Datacenter not found [#{datacenter_name}]") # rubocop:disable Naming/VariableName, Lint/UselessAssignment
137
137
  end
138
138
  end
139
139
 
@@ -152,7 +152,7 @@ module ChefProvisioningVsphere
152
152
  )
153
153
  device = RbVmomi::VIM::VirtualVmxnet3(
154
154
  backing: backing_info,
155
- deviceInfo: RbVmomi::VIM::Description(label: network_label, summary: network_name.split('/').last),
155
+ deviceInfo: RbVmomi::VIM::Description(label: network_label, summary: network_name.split("/").last),
156
156
  key: device_key,
157
157
  connectable: connectable
158
158
  )
@@ -176,14 +176,14 @@ module ChefProvisioningVsphere
176
176
  # @param [Object] options the options from Chef Provisioning to help configure the VM.
177
177
  # @param [Object] vm the actual VM object to connect the VM to.
178
178
  def add_extra_nic(action_handler, vm_template, options, vm)
179
- deviceAdditions, changes = network_device_changes(action_handler, vm_template, options)
179
+ deviceAdditions, changes = network_device_changes(action_handler, vm_template, options) # rubocop:disable Naming/VariableName, Lint/UselessAssignment
180
180
 
181
- if deviceAdditions.count.positive?
181
+ if deviceAdditions.count > 0
182
182
  current_networks = find_ethernet_cards_for(vm).map { |card| network_id_for(card.backing) }
183
183
  new_devices = deviceAdditions.reject { |device| current_networks.include?(network_id_for(device.device.backing)) }
184
184
 
185
- if new_devices.count.positive?
186
- action_handler.report_progress 'Adding extra NICs'
185
+ if new_devices.count > 0
186
+ action_handler.report_progress "Adding extra NICs"
187
187
  task = vm.ReconfigVM_Task(spec: RbVmomi::VIM.VirtualMachineConfigSpec(deviceChange: new_devices))
188
188
  task.wait_for_completion
189
189
  new_devices
@@ -212,7 +212,7 @@ module ChefProvisioningVsphere
212
212
  deviceChange: [
213
213
  {
214
214
  operation: :remove,
215
- device: disk
215
+ device: disk,
216
216
  },
217
217
  {
218
218
  operation: :add,
@@ -221,9 +221,9 @@ module ChefProvisioningVsphere
221
221
  new_disk.backing = new_disk.backing.dup
222
222
  new_disk.backing.fileName = "[#{disk.backing.datastore.name}]"
223
223
  new_disk.backing.parent = disk.backing
224
- end
225
- }
226
- ]
224
+ end,
225
+ },
226
+ ],
227
227
  }
228
228
  vm_template.ReconfigVM_Task(spec: spec).wait_for_completion
229
229
  end
@@ -243,7 +243,7 @@ module ChefProvisioningVsphere
243
243
  key: idx,
244
244
  backing: RbVmomi::VIM.VirtualDiskFlatVer2BackingInfo(
245
245
  fileName: "[#{datastore}]",
246
- diskMode: 'persistent',
246
+ diskMode: "persistent",
247
247
  thinProvisioned: true
248
248
  ),
249
249
  capacityInKB: size_gb * 1024 * 1024,
@@ -259,7 +259,7 @@ module ChefProvisioningVsphere
259
259
  # @param [Subject] datastore the datastore the disk will be created on.
260
260
  # @param [Subject] size_gb the size of the disk.
261
261
  def set_additional_disks_for(vm, datastore, additional_disk_size_gb)
262
- raise ':datastore must be specified when adding a disk to a cloned vm' if datastore.to_s.empty? && additional_disk_size_gb
262
+ raise ":datastore must be specified when adding a disk to a cloned vm" if datastore.to_s.empty? && additional_disk_size_gb
263
263
 
264
264
  Array(additional_disk_size_gb).each do |size|
265
265
  size = size.to_i
@@ -272,7 +272,7 @@ module ChefProvisioningVsphere
272
272
  vm,
273
273
  datastore,
274
274
  size
275
- )
275
+ ),
276
276
  ]
277
277
  )
278
278
  )
@@ -304,7 +304,7 @@ module ChefProvisioningVsphere
304
304
 
305
305
  allowGuestControl: true
306
306
  )
307
- )
307
+ ),
308
308
  ]
309
309
  )
310
310
  )
@@ -333,8 +333,8 @@ module ChefProvisioningVsphere
333
333
  deviceChange: [
334
334
  {
335
335
  operation: :edit,
336
- device: disk
337
- }
336
+ device: disk,
337
+ },
338
338
  ]
339
339
  )
340
340
  ).wait_for_completion
@@ -357,16 +357,16 @@ module ChefProvisioningVsphere
357
357
  networks.each_index do |i|
358
358
  label = "Ethernet #{i + 1}"
359
359
  backing_info = backing_info_for(action_handler, networks[i])
360
- if card = cards.shift
360
+ if card = cards.shift # rubocop:disable Lint/AssignmentInCondition
361
361
  key = card.key
362
- operation = RbVmomi::VIM::VirtualDeviceConfigSpecOperation('edit')
362
+ operation = RbVmomi::VIM::VirtualDeviceConfigSpecOperation("edit")
363
363
  action_handler.report_progress "changing template nic for #{networks[i]}"
364
364
  changes.push(
365
365
  network_adapter_for(operation, networks[i], label, key, backing_info)
366
366
  )
367
367
  else
368
368
  key += 1
369
- operation = RbVmomi::VIM::VirtualDeviceConfigSpecOperation('add')
369
+ operation = RbVmomi::VIM::VirtualDeviceConfigSpecOperation("add")
370
370
  action_handler.report_progress "will be adding nic for #{networks[i]}"
371
371
  additions.push(
372
372
  network_adapter_for(operation, networks[i], label, key, backing_info)
@@ -381,7 +381,7 @@ module ChefProvisioningVsphere
381
381
  # @param [Object] action_handler TODO
382
382
  # @param [String] network_name The network name to attach to
383
383
  def backing_info_for(action_handler, network_name)
384
- action_handler.report_progress('finding networks...')
384
+ action_handler.report_progress("finding networks...")
385
385
  network = find_network(network_name)
386
386
  action_handler.report_progress(
387
387
  "network: #{network_name} is a #{network.class}"
@@ -396,7 +396,7 @@ module ChefProvisioningVsphere
396
396
  )
397
397
  else
398
398
  RbVmomi::VIM::VirtualEthernetCardNetworkBackingInfo(
399
- deviceName: network_name.split('/').last
399
+ deviceName: network_name.split("/").last
400
400
  )
401
401
  end
402
402
  end
@@ -413,11 +413,11 @@ module ChefProvisioningVsphere
413
413
  # @param [String] name The name of the "thing."
414
414
  # @param [String] parent_folder The name of the folder to start from.
415
415
  def find_entity(name, parent_folder)
416
- parts = name.split('/').reject(&:empty?)
416
+ parts = name.split("/").reject(&:empty?)
417
417
  parts.each do |item|
418
418
  Chef::Log.debug("Identifying entity part: #{item} in folder type: #{parent_folder.class}")
419
419
  if parent_folder.is_a? RbVmomi::VIM::Folder
420
- Chef::Log.debug('Parent folder is a folder')
420
+ Chef::Log.debug("Parent folder is a folder")
421
421
  parent_folder = parent_folder.childEntity.find { |f| f.name == item }
422
422
  else
423
423
  parent_folder = yield(parent_folder, item)
@@ -481,7 +481,7 @@ module ChefProvisioningVsphere
481
481
  # @param [String] name Name of the Network.
482
482
  def find_network(name)
483
483
  base = datacenter.networkFolder
484
- entity_array = name.split('/').reject(&:empty?)
484
+ entity_array = name.split("/").reject(&:empty?)
485
485
  entity_array.each do |item|
486
486
  base = traverse_folders_for_network(base, item)
487
487
  end
@@ -548,8 +548,8 @@ module ChefProvisioningVsphere
548
548
 
549
549
  req = Net::HTTP::Put.new("#{uri.path}?#{uri.query}")
550
550
  req.body_stream = File.open(local)
551
- req['Content-Type'] = 'application/octet-stream'
552
- req['Content-Length'] = size
551
+ req["Content-Type"] = "application/octet-stream"
552
+ req["Content-Length"] = size
553
553
  res = http.request(req)
554
554
  unless res.is_a?(Net::HTTPSuccess)
555
555
  raise "Error: #{res.inspect} :: #{res.body} :: sending #{local} to #{remote} at #{vm.name} via #{endpoint} with a size of #{size}"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
 
3
- require 'uri'
3
+ require "uri"
4
4
 
5
5
  # The main URI Module
6
6
  module URI
@@ -9,20 +9,20 @@ module URI
9
9
  # Default port for connecting to the vSphere cluster Webserver
10
10
  DEFAULT_PORT = 443
11
11
  # Default path for connecting to the vSphere cluster URL
12
- DEFAULT_PATH = '/sdk'.freeze
12
+ DEFAULT_PATH = "/sdk".freeze
13
13
 
14
14
  # Creates the URL from options that are decided
15
15
  #
16
16
  def self.from_config(options)
17
17
  parts = []
18
- parts << 'vsphere://'
18
+ parts << "vsphere://"
19
19
  parts << options[:host]
20
- parts << ':'
20
+ parts << ":"
21
21
  parts << (options[:port] || DEFAULT_PORT)
22
22
  parts << (options[:path] || DEFAULT_PATH)
23
- parts << '?use_ssl='
23
+ parts << "?use_ssl="
24
24
  parts << (options[:use_ssl] == false ? false : true)
25
- parts << '&insecure='
25
+ parts << "&insecure="
26
26
  parts << (options[:insecure] || false)
27
27
  URI parts.join
28
28
  end
@@ -31,10 +31,10 @@ module URI
31
31
  #
32
32
  def use_ssl
33
33
  if query
34
- ssl_query = query.split('&').each.select do |q|
35
- q.start_with?('use_ssl=')
34
+ ssl_query = query.split("&").each.select do |q|
35
+ q.start_with?("use_ssl=")
36
36
  end.first
37
- ssl_query == 'use_ssl=true'
37
+ ssl_query == "use_ssl=true"
38
38
  else
39
39
  true
40
40
  end
@@ -44,14 +44,14 @@ module URI
44
44
  #
45
45
  def insecure
46
46
  if query
47
- insecure_query = query.split('&').each.select do |q|
48
- q.start_with?('insecure=')
47
+ insecure_query = query.split("&").each.select do |q|
48
+ q.start_with?("insecure=")
49
49
  end.first
50
- insecure_query == 'insecure=true'
50
+ insecure_query == "insecure=true"
51
51
  else
52
52
  false
53
53
  end
54
54
  end
55
55
  end
56
- @@schemes['VSPHERE'] = VsphereUrl
56
+ @@schemes["VSPHERE"] = VsphereUrl
57
57
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'json'
4
- require 'kitchen'
5
- require 'chef/provisioning/vsphere_driver'
6
- require 'chef/provisioning/machine_spec'
3
+ require "json"
4
+ require "kitchen"
5
+ require "chef/provisioning/vsphere_driver"
6
+ require "chef/provisioning/machine_spec"
7
7
 
8
8
  # Main Kitchen Module
9
9
  module Kitchen
@@ -21,14 +21,14 @@ module Kitchen
21
21
  bootstrap_options: {
22
22
  use_linked_clone: true,
23
23
  ssh: {
24
- user: 'root',
24
+ user: "root",
25
25
  paranoid: false,
26
- port: 22
26
+ port: 22,
27
27
  },
28
28
  convergence_options: {},
29
29
  customization_spec: {
30
- domain: 'local'
31
- }
30
+ domain: "local",
31
+ },
32
32
  }
33
33
 
34
34
  default_config(:vsphere_name) do |driver|
@@ -53,8 +53,8 @@ module Kitchen
53
53
  ensure
54
54
  if machine_spec
55
55
  if machine_spec.location
56
- state[:server_id] = machine_spec.location['server_id']
57
- state[:hostname] = machine_spec.location['ipaddress']
56
+ state[:server_id] = machine_spec.location["server_id"]
57
+ state[:hostname] = machine_spec.location["ipaddress"]
58
58
  end
59
59
  machine_spec.save(action_handler)
60
60
  end
@@ -69,8 +69,8 @@ module Kitchen
69
69
  return if state[:server_id].nil?
70
70
 
71
71
  with_provisioning_driver(state) do |action_handler, driver, machine_spec|
72
- machine_spec.location = { 'driver_url' => driver.driver_url,
73
- 'server_id' => state[:server_id] }
72
+ machine_spec.location = { "driver_url" => driver.driver_url,
73
+ "server_id" => state[:server_id] }
74
74
  driver.destroy_machine(action_handler, machine_spec, config[:machine_options])
75
75
  end
76
76
 
@@ -103,7 +103,7 @@ module Kitchen
103
103
  unless @@chef_zero_server
104
104
  Chef::Config.local_mode = true
105
105
  Chef::Config.chef_repo_path = Chef::Config.find_chef_repo_path(Dir.pwd)
106
- require 'chef/local_mode'
106
+ require "chef/local_mode"
107
107
  Chef::LocalMode.setup_server_connectivity
108
108
  @@chef_zero_server = true
109
109
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'chef/provisioning/vsphere_driver'
3
- require 'chef/provisioning/machine_spec'
2
+ require "chef/provisioning/vsphere_driver"
3
+ require "chef/provisioning/machine_spec"
4
4
 
5
5
  # A file named config.rb in the same directory as this spec file
6
6
  # must exist containing the driver options to use for the test.
@@ -34,12 +34,12 @@ require 'chef/provisioning/machine_spec'
34
34
  # }
35
35
  # }
36
36
 
37
- describe 'vsphere_driver' do
37
+ describe "vsphere_driver" do
38
38
  before :all do
39
- skip("driver options do not exist") unless File.exist?(File.expand_path('../config.rb', __FILE__))
39
+ skip("driver options do not exist") unless File.exist?(File.expand_path("../config.rb", __FILE__))
40
40
 
41
41
  @vm_name = "cmvd-test-#{SecureRandom.hex}"
42
- @metal_config = eval File.read(File.expand_path('../config.rb', __FILE__))
42
+ @metal_config = eval File.read(File.expand_path("../config.rb", __FILE__)) # rubocop:disable Security/Eval
43
43
  Cheffish.honor_local_mode do
44
44
  Chef::Log.level = :debug
45
45
  chef_server = Cheffish.default_chef_server
@@ -49,8 +49,8 @@ describe 'vsphere_driver' do
49
49
  action_handler = Chef::Provisioning::ActionHandler.new
50
50
  @driver.allocate_machine(action_handler, @machine_spec, @metal_config[:machine_options])
51
51
  @metal_config[:machine_options][:convergence_options] = { chef_server: chef_server }
52
- machine = @driver.ready_machine(action_handler, @machine_spec, @metal_config[:machine_options])
53
- @server_id = @machine_spec.location['server_id']
52
+ machine = @driver.ready_machine(action_handler, @machine_spec, @metal_config[:machine_options]) # rubocop:disable Lint/UselessAssignment
53
+ @server_id = @machine_spec.location["server_id"]
54
54
  @vsphere_helper = ChefProvisioningVsphere::VsphereHelper.new(
55
55
  @metal_config[:driver_options],
56
56
  @metal_config[:machine_options][:bootstrap_options][:datacenter]
@@ -59,88 +59,88 @@ describe 'vsphere_driver' do
59
59
  end
60
60
  end
61
61
 
62
- context 'when allocating a machine' do
63
- it 'adds machine to the correct folder' do
62
+ context "when allocating a machine" do
63
+ it "adds machine to the correct folder" do
64
64
  expect(@vm.parent.name).to eq(@metal_config[:machine_options][:bootstrap_options][:vm_folder])
65
65
  end
66
- it 'has a matching id with the machine_spec' do
67
- expect(@vm.config.instanceUuid).to eq(@machine_spec.location['server_id'])
66
+ it "has a matching id with the machine_spec" do
67
+ expect(@vm.config.instanceUuid).to eq(@machine_spec.location["server_id"])
68
68
  end
69
- it 'has the correct name' do
69
+ it "has the correct name" do
70
70
  custom_name = @metal_config[:machine_options][:bootstrap_options][:customization_spec][:hostname]
71
71
  now = Time.now.utc
72
72
  trimmed_name = if custom_name
73
- @vm.config.guestId.start_with?('win') ? custom_name.to_s.byteslice(0, 15) : custom_name
73
+ @vm.config.guestId.start_with?("win") ? custom_name.to_s.byteslice(0, 15) : custom_name
74
74
  else
75
- @vm.config.guestId.start_with?('win') ? @vm_name.byteslice(0, 15) : @vm_name
75
+ @vm.config.guestId.start_with?("win") ? @vm_name.byteslice(0, 15) : @vm_name
76
76
  end
77
77
  expected_name = "#{trimmed_name}.#{@metal_config[:machine_options][:bootstrap_options][:customization_spec][:domain]}"
78
- if @vm.config.guestId.start_with?('win')
78
+ if @vm.config.guestId.start_with?("win")
79
79
  until (Time.now.utc - now) > 30 || expected_name.to_s.include?(@vm.guest.hostName)
80
- print '.'
80
+ print "."
81
81
  sleep 5
82
82
  end
83
83
  expect(expected_name).to include(@vm.guest.hostName)
84
84
  else
85
85
  until (Time.now.utc - now) > 30 || (@vm.guest.hostName == expected_name)
86
- print '.'
86
+ print "."
87
87
  sleep 5
88
88
  end
89
89
  expect(@vm.guest.hostName).to eq(expected_name) # For linux Systems
90
90
  end
91
91
  end
92
- it 'is on the correct networks' do
93
- expect(@vm.network.map(&:name)).to include(@metal_config[:machine_options][:bootstrap_options][:network_name][0]) unless @vm.config.guestId.start_with?('win')
94
- expect(@vm.network.map(&:name)).to include(@metal_config[:machine_options][:bootstrap_options][:network_name][1]) unless @vm.config.guestId.start_with?('win')
92
+ it "is on the correct networks" do
93
+ expect(@vm.network.map(&:name)).to include(@metal_config[:machine_options][:bootstrap_options][:network_name][0]) unless @vm.config.guestId.start_with?("win")
94
+ expect(@vm.network.map(&:name)).to include(@metal_config[:machine_options][:bootstrap_options][:network_name][1]) unless @vm.config.guestId.start_with?("win")
95
95
  end
96
- it 'is on the correct datastore' do
97
- expect(@vm.datastore[0].name).to eq(@metal_config[:machine_options][:bootstrap_options][:datastore]) unless @vm.config.guestId.start_with?('win')
96
+ it "is on the correct datastore" do
97
+ expect(@vm.datastore[0].name).to eq(@metal_config[:machine_options][:bootstrap_options][:datastore]) unless @vm.config.guestId.start_with?("win")
98
98
  end
99
- it 'is in the correct datacenter' do
100
- expect(@vsphere_helper.vim.serviceInstance.find_datacenter(@metal_config[:machine_options][:bootstrap_options][:datacenter]).find_vm("#{@vm.parent.name}/#{@vm_name}")).not_to eq(nil) unless @vm.config.guestId.start_with?('win')
99
+ it "is in the correct datacenter" do
100
+ expect(@vsphere_helper.vim.serviceInstance.find_datacenter(@metal_config[:machine_options][:bootstrap_options][:datacenter]).find_vm("#{@vm.parent.name}/#{@vm_name}")).not_to eq(nil) unless @vm.config.guestId.start_with?("win")
101
101
  end
102
- it 'has an added disk of the correct size' do
102
+ it "has an added disk of the correct size" do
103
103
  disk_count = @vm.disks.count
104
- expect(@vm.disks[disk_count - 1].capacityInKB).to eq(@metal_config[:machine_options][:bootstrap_options][:additional_disk_size_gb][1] * 1024 * 1024) unless @vm.config.guestId.start_with?('win')
104
+ expect(@vm.disks[disk_count - 1].capacityInKB).to eq(@metal_config[:machine_options][:bootstrap_options][:additional_disk_size_gb][1] * 1024 * 1024) unless @vm.config.guestId.start_with?("win")
105
105
  end
106
- it 'has the correct number of CPUs' do
106
+ it "has the correct number of CPUs" do
107
107
  expect(@vm.config.hardware.numCPU).to eq(@metal_config[:machine_options][:bootstrap_options][:num_cpus])
108
108
  end
109
- it 'has the correct amount of memory' do
109
+ it "has the correct amount of memory" do
110
110
  expect(@vm.config.hardware.memoryMB).to eq(@metal_config[:machine_options][:bootstrap_options][:memory_mb])
111
111
  end
112
- it 'is in the correct resource pool' do
112
+ it "is in the correct resource pool" do
113
113
  if @metal_config[:machine_options][:bootstrap_options].key?(:resource_pool)
114
- expect(@vm.resourcePool.name).to eq(@metal_config[:machine_options][:bootstrap_options][:resource_pool].split('/')[1])
114
+ expect(@vm.resourcePool.name).to eq(@metal_config[:machine_options][:bootstrap_options][:resource_pool].split("/")[1])
115
115
  end
116
116
  end
117
- it 'is in the correct host' do
117
+ it "is in the correct host" do
118
118
  if @metal_config[:machine_options][:bootstrap_options].key?(:host)
119
- expect(@vm.runtime.host.name).to eq(@metal_config[:machine_options][:bootstrap_options][:host].split('/').last)
119
+ expect(@vm.runtime.host.name).to eq(@metal_config[:machine_options][:bootstrap_options][:host].split("/").last)
120
120
  end
121
121
  end
122
- it 'is in the correct cluster' do
122
+ it "is in the correct cluster" do
123
123
  if @metal_config[:machine_options][:bootstrap_options].key?(:resource_pool)
124
- expect(@vm.resourcePool.owner.name).to eq(@metal_config[:machine_options][:bootstrap_options][:resource_pool].split('/')[0])
124
+ expect(@vm.resourcePool.owner.name).to eq(@metal_config[:machine_options][:bootstrap_options][:resource_pool].split("/")[0])
125
125
  end
126
126
  end
127
- it 'has the correct number of disks' do
128
- expect(@vm.disks.count).to eq(3) unless @vm.config.guestId.start_with?('win')
127
+ it "has the correct number of disks" do
128
+ expect(@vm.disks.count).to eq(3) unless @vm.config.guestId.start_with?("win")
129
129
  end
130
- it 'has hot add cpu enabled' do
130
+ it "has hot add cpu enabled" do
131
131
  expect(@vm.config.cpuHotAddEnabled).to eq(true)
132
132
  end
133
- it 'has hot remove cpu enabled' do
133
+ it "has hot remove cpu enabled" do
134
134
  expect(@vm.config.cpuHotRemoveEnabled).to eq(true)
135
135
  end
136
- it 'has hot add memory enabled' do
136
+ it "has hot add memory enabled" do
137
137
  expect(@vm.config.memoryHotAddEnabled).to eq(true)
138
138
  end
139
- it 'has the correct static IP address' do
139
+ it "has the correct static IP address" do
140
140
  if @metal_config[:machine_options][:bootstrap_options][:customization_spec][:ipsettings][:ip]
141
141
  now = Time.now.utc
142
- until (Time.now.utc - now) > 30 || (@vm.guest.toolsRunningStatus == 'guestToolsRunning' && @vm.guest.net.count == 2 && @vm.guest.net[1].ipAddress[1] == @metal_config[:machine_options][:bootstrap_options][:customization_spec][:ipsettings][:ip])
143
- print '.'
142
+ until (Time.now.utc - now) > 30 || (@vm.guest.toolsRunningStatus == "guestToolsRunning" && @vm.guest.net.count == 2 && @vm.guest.net[1].ipAddress[1] == @metal_config[:machine_options][:bootstrap_options][:customization_spec][:ipsettings][:ip])
143
+ print "."
144
144
  sleep 5
145
145
  end
146
146
  expect(@vm.guest.net.map(&:ipAddress).flatten).to include(@metal_config[:machine_options][:bootstrap_options][:customization_spec][:ipsettings][:ip])
@@ -148,8 +148,8 @@ describe 'vsphere_driver' do
148
148
  end
149
149
  end
150
150
 
151
- context 'destroy_machine' do
152
- it 'removes the machine' do
151
+ context "destroy_machine" do
152
+ it "removes the machine" do
153
153
  Cheffish.honor_local_mode do
154
154
  chef_server = Cheffish.default_chef_server
155
155
  url = URI::VsphereUrl.from_config(@metal_config[:driver_options]).to_s
@@ -158,8 +158,8 @@ describe 'vsphere_driver' do
158
158
  machine_spec = Chef::Provisioning.chef_managed_entry_store(chef_server)
159
159
  .new_entry(:machine, @vm_name)
160
160
  machine_spec.location = {
161
- 'driver_url' => driver.driver_url,
162
- 'server_id' => @server_id
161
+ "driver_url" => driver.driver_url,
162
+ "server_id" => @server_id,
163
163
  }
164
164
  driver.destroy_machine(
165
165
  action_handler,