chef-provisioning-vsphere 1.1.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 585d88ba43c9f510245efabf7d21140cddc4ca6d
4
- data.tar.gz: 9e1b630c7295efd1de81d78f59145076d29e936f
3
+ metadata.gz: 21e02f6746bff52619d863fa3c127884d5ffa0ea
4
+ data.tar.gz: a3b5e5c8640d74ab193b784a5c5ab263dbf19daa
5
5
  SHA512:
6
- metadata.gz: 0613dfed2829b0ec5fc77e2651e155dba8ce95ef9fd03068f78e89b6595d931d5f63d97bc549f080dbf68da303b9374681a8010f48689843cec74613d72c10bc
7
- data.tar.gz: 8f7d54fe4bda54588697336bcd6f02cf8e34f3d70e189936db3c7d1269c189762d97ba7ca2a7f274fd1339fff55f31cf00d6babc61c4d375422dee290aa013ec
6
+ metadata.gz: 8b2a9949cc6fd0d1d4f9e9b8868f063e6fd5e126f3338a425e0bd26a672cbf0d6d8bf21fdf5dc1a73344ded8413f6f92936e422c06ebc2fd9fcc27c7be75293a
7
+ data.tar.gz: a7377e8a83760434aa64b7211da8c8fac87c0f070ec60085c9a868a0b639d16796d9435dcd78ff9cb6cfaf01680385dd4f5c590cd277e67b9b5c71c2d336857f
data/.rubocop_todo.yml CHANGED
@@ -53,7 +53,7 @@ Metrics/BlockNesting:
53
53
  # Offense count: 3
54
54
  # Configuration parameters: CountComments.
55
55
  Metrics/ClassLength:
56
- Max: 599
56
+ Max: 650
57
57
 
58
58
  # Offense count: 7
59
59
  Metrics/CyclomaticComplexity:
data/CHANGELOG.md CHANGED
@@ -1,10 +1,20 @@
1
1
  # Change Log
2
2
 
3
- ## [1.1.2](https://github.com/chef-partners/chef-provisioning-vsphere/tree/1.1.2) (2017-05-08)
4
- [Full Changelog](https://github.com/chef-partners/chef-provisioning-vsphere/compare/v1.1.1...1.1.2)
3
+ ## [2.0.0](https://github.com/chef-partners/chef-provisioning-vsphere/tree/2.0.0) (2017-05-12)
4
+ [Full Changelog](https://github.com/chef-partners/chef-provisioning-vsphere/compare/v1.1.2...2.0.0)
5
5
 
6
6
  **Merged pull requests:**
7
7
 
8
+ - Traverse folders for dc \(issue \#23\) [\#24](https://github.com/chef-partners/chef-provisioning-vsphere/pull/24) ([danhiris](https://github.com/danhiris))
9
+ - allow chef13, since it works now [\#22](https://github.com/chef-partners/chef-provisioning-vsphere/pull/22) ([jjlimepoint](https://github.com/jjlimepoint))
10
+ - Wait for ipv4 enhancement v2 [\#21](https://github.com/chef-partners/chef-provisioning-vsphere/pull/21) ([jcalonsoh](https://github.com/jcalonsoh))
11
+
12
+ ## [v1.1.2](https://github.com/chef-partners/chef-provisioning-vsphere/tree/v1.1.2) (2017-05-08)
13
+ [Full Changelog](https://github.com/chef-partners/chef-provisioning-vsphere/compare/v1.1.1...v1.1.2)
14
+
15
+ **Merged pull requests:**
16
+
17
+ - 1.1.2 release [\#20](https://github.com/chef-partners/chef-provisioning-vsphere/pull/20) ([jjasghar](https://github.com/jjasghar))
8
18
  - corrected winrm port assignment so it does not always equal 5986 [\#19](https://github.com/chef-partners/chef-provisioning-vsphere/pull/19) ([tuccimon](https://github.com/tuccimon))
9
19
  - Update README to cover multi-nodes in kitchen.yml [\#18](https://github.com/chef-partners/chef-provisioning-vsphere/pull/18) ([michaeltlombardi](https://github.com/michaeltlombardi))
10
20
  - Revert "Wait for ipv4 enhancement" [\#16](https://github.com/chef-partners/chef-provisioning-vsphere/pull/16) ([jjasghar](https://github.com/jjasghar))
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ end
17
17
 
18
18
  RSpec::Core::RakeTask.new(:integration) do |task|
19
19
  task.pattern = 'spec/integration_tests/*_spec.rb'
20
- task.rspec_opts = ['--color', '-f documentation']
20
+ task.rspec_opts = ['--color', '-f documentation', '--out rspec.txt']
21
21
  end
22
22
 
23
23
  begin
@@ -24,8 +24,8 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency 'rbvmomi', '~> 1.10'
25
25
  s.add_dependency 'chef-provisioning', '~> 2.0'
26
26
  s.add_dependency 'github_changelog_generator'
27
- s.add_dependency 'chef', '~> 12'
28
- s.add_dependency 'cheffish', '~> 4'
27
+ s.add_dependency 'cheffish', '>= 4.0', '< 14.0'
28
+ s.add_dependency 'chef', '>= 12.0', '< 14.0'
29
29
 
30
30
  s.add_development_dependency 'rspec'
31
31
  s.add_development_dependency 'rake'
@@ -157,7 +157,7 @@ module ChefProvisioningVsphere
157
157
  def hostname_from(options, vm_name)
158
158
  hostname = options[:hostname] || vm_name
159
159
  test = /^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])$/
160
- unless hostname =~ test
160
+ unless hostname.match?(test)
161
161
  raise 'Only letters, numbers or hyphens in hostnames allowed'
162
162
  end
163
163
  RbVmomi::VIM::CustomizationFixedName.new(name: hostname)
@@ -8,6 +8,7 @@ require 'chef/provisioning/vsphere_driver/clone_spec_builder'
8
8
  require 'chef/provisioning/vsphere_driver/version'
9
9
  require 'chef/provisioning/vsphere_driver/vsphere_helpers'
10
10
  require 'chef/provisioning/vsphere_driver/vsphere_url'
11
+ require 'chef/provisioning/vsphere_driver/vm_helper'
11
12
 
12
13
  module ChefProvisioningVsphere
13
14
  # Provisions machines in vSphere.
@@ -19,7 +20,6 @@ module ChefProvisioningVsphere
19
20
  end
20
21
 
21
22
  # Create a new Vsphere provisioner.
22
- #
23
23
  # ## Parameters
24
24
  # connect_options - hash of options to be passed to RbVmomi::VIM.connect
25
25
  # :host - required - hostname of the vSphere API server
@@ -72,7 +72,11 @@ module ChefProvisioningVsphere
72
72
  end
73
73
  end
74
74
 
75
- attr_reader :connect_options
75
+ attr_reader :connect_options, :vm_helper
76
+
77
+ def vm_helper
78
+ @vm_helper ||= ChefProvisioningVsphere::VmHelper.new
79
+ end
76
80
 
77
81
  # Acquire a machine, generally by provisioning it. Returns a Machine
78
82
  # object pointing at the machine, allowing useful actions like setup,
@@ -92,7 +96,6 @@ module ChefProvisioningVsphere
92
96
  # fail if different?
93
97
  # node will have node['normal']['provisioner_options'] in it with any options.
94
98
  # It is a hash with this format:
95
- #
96
99
  # -- provisioner_url: vsphere://host:port?ssl=[true|false]&insecure=[true|false]
97
100
  # -- bootstrap_options: hash of options to pass to RbVmomi::VIM::VirtualMachine::CloneTask()
98
101
  # :datacenter
@@ -116,7 +119,6 @@ module ChefProvisioningVsphere
116
119
  # node['normal']['provisioner_output'] will be populated with information
117
120
  # about the created machine. For vSphere, it is a hash with this
118
121
  # format:
119
- #
120
122
  # -- provisioner_url: vsphere:host:port?ssl=[true|false]&insecure=[true|false]
121
123
  # -- vm_folder: name of the vSphere folder containing the VM
122
124
  #
@@ -243,6 +245,8 @@ module ChefProvisioningVsphere
243
245
  setup_ubuntu_dns(machine, bootstrap_options, machine_spec)
244
246
  end
245
247
 
248
+ ## Check if true available after added nic
249
+ @vm_helper.open_port?(@vm_helper.ip, @vm_helper.port) unless @vm_helper.ip.nil?
246
250
  machine
247
251
  end
248
252
 
@@ -257,7 +261,7 @@ module ChefProvisioningVsphere
257
261
  bootstrap_options,
258
262
  vm
259
263
  )
260
- if is_windows?(vm) && !new_nics.nil?
264
+ if is_windows?(vm) && !new_nics.nil? && @vm_helper.open_port?(@vm_helper.ip, @vm_helper.port)
261
265
  new_nics.each do |nic|
262
266
  nic_label = nic.device.deviceInfo.label
263
267
  machine.execute_always(
@@ -305,8 +309,7 @@ module ChefProvisioningVsphere
305
309
  begin
306
310
  wait_for_transport(action_handler, machine_spec, machine_options, vm)
307
311
  rescue Timeout::Error
308
- # Only ever reboot once, and only if it's been less than 10 minutes
309
- # since we stopped waiting
312
+ # Only ever reboot once, and only if it's been less than 10 minutes since we stopped waiting
310
313
  if machine_spec.location['started_at'] ||
311
314
  remaining_wait_time(machine_spec, machine_options) < -(10 * 60)
312
315
  raise
@@ -377,21 +380,25 @@ module ChefProvisioningVsphere
377
380
 
378
381
  def wait_for_ip(vm, machine_options, machine_spec, action_handler)
379
382
  bootstrap_options = machine_options[:bootstrap_options]
380
- vm_ip = ip_to_bootstrap(bootstrap_options, vm)
383
+ ip_to_bootstrap(bootstrap_options, vm)
381
384
  ready_timeout = machine_options[:ready_timeout] || 300
382
- msg = "waiting up to #{ready_timeout} seconds for customization"
383
- msg << " and find #{vm_ip}" unless vm_ip == vm.guest.ipAddress
385
+ msg1 = "waiting up to #{ready_timeout} seconds for customization"
386
+ msg2 = " and find #{@vm_helper.ip}" if @vm_helper.ip? # unless vm_ip == vm.guest.ipAddress # RuntimeError: can't modify frozen String
387
+ msg = [msg1, msg2].join
384
388
  action_handler.report_progress msg
385
389
 
386
- start = Time.now.utc
387
- connectable = false
388
- until (Time.now.utc - start) > ready_timeout || connectable
390
+ vm_ip ||= ip_to_bootstrap(bootstrap_options, vm)
391
+ until transport_for(
392
+ machine_spec,
393
+ machine_options[:bootstrap_options][:ssh],
394
+ vm_ip
395
+ ).available? || remaining_wait_time(machine_spec, machine_options) < 0
389
396
  action_handler.report_progress(
390
397
  "IP addresses found: #{all_ips_for(vm)}"
391
398
  )
392
399
  vm_ip ||= ip_to_bootstrap(bootstrap_options, vm)
393
400
  if has_ip?(vm_ip, vm)
394
- connectable = transport_for(
401
+ transport_for(
395
402
  machine_spec,
396
403
  machine_options[:bootstrap_options][:ssh],
397
404
  vm_ip
@@ -652,6 +659,7 @@ module ChefProvisioningVsphere
652
659
  end
653
660
 
654
661
  def wait_for_transport(action_handler, machine_spec, machine_options, vm)
662
+ @vm_helper.find_port?(vm, machine_options[:bootstrap_options]) if vm_helper.port.nil?
655
663
  transport = transport_for(
656
664
  machine_spec,
657
665
  machine_options[:bootstrap_options][:ssh]
@@ -684,9 +692,12 @@ module ChefProvisioningVsphere
684
692
 
685
693
  def create_winrm_transport(host, options)
686
694
  require 'chef/provisioning/transport/winrm'
687
- winrm_transport =
688
- options[:winrm_transport].nil? ? :negotiate : options[:winrm_transport].to_sym
689
- port = options[:port] || (winrm_transport == :ssl ? '5986' : '5985')
695
+ winrm_transport = if options[:port] == 5986
696
+ :ssl
697
+ else
698
+ options[:winrm_transport].nil? ? :negotiate : options[:winrm_transport].to_sym
699
+ end
700
+ port = options[:port] || @vm_helper.port # winrm_transport == :ssl ? '5986' : '5985'
690
701
  winrm_options = {
691
702
  user: (options[:user]).to_s,
692
703
  pass: options[:password]
@@ -722,18 +733,25 @@ module ChefProvisioningVsphere
722
733
  end
723
734
 
724
735
  def ip_to_bootstrap(bootstrap_options, vm)
736
+ @vm_helper.find_port?(vm, bootstrap_options) unless vm_helper.port?
725
737
  if has_static_ip(bootstrap_options)
726
738
  if bootstrap_options[:customization_spec].is_a?(String)
727
739
  spec = vsphere_helper.find_customization_spec(bootstrap_options[:customization_spec])
728
740
  spec.nicSettingMap[0].adapter.ip.ipAddress
729
741
  else
730
- bootstrap_options[:customization_spec][:ipsettings][:ip]
742
+ ## Check if true available
743
+ @vm_helper.ip = bootstrap_options[:customization_spec][:ipsettings][:ip] unless vm_helper.ip?
744
+ print '.' until @vm_helper.open_port?(@vm_helper.ip, @vm_helper.port, 1)
745
+ @vm_helper.ip.to_s
731
746
  end
732
747
  else
733
748
  if use_ipv4_during_bootstrap?(bootstrap_options)
734
- wait_for_ipv4(bootstrap_ip_timeout(bootstrap_options), vm)
749
+ until @vm_helper.open_port?(@vm_helper.ip, @vm_helper.port, 1)
750
+ wait_for_ipv4(bootstrap_ip_timeout(bootstrap_options), vm)
751
+ end
735
752
  end
736
- vm.guest.ipAddress
753
+ @vm_helper.ip = vm.guest.ipAddress until vm_guest_ip?(vm) && @vm_helper.open_port?(@vm_helper.ip, @vm_helper.port, 1) # Don't set empty ip
754
+ @vm_helper.ip
737
755
  end
738
756
  end
739
757
 
@@ -755,14 +773,21 @@ module ChefProvisioningVsphere
755
773
  sleep_time = 5
756
774
  print 'Waiting for ipv4 address.'
757
775
  tries = 0
776
+ start_search_ip = true
758
777
  max_tries = timeout > sleep_time ? timeout / sleep_time : 1
759
- while (vm.guest.ipAddress.nil? || !IPAddr.new(vm.guest.ipAddress).ipv4?) && (tries += 1) <= max_tries
778
+ while start_search_ip && (tries += 1) <= max_tries
760
779
  print '.'
761
780
  sleep sleep_time
781
+ @vm_helper.ip = vm.guest.ipAddress if vm_guest_ip?(vm)
782
+ start_search_ip = false if @vm_helper.open_port?(@vm_helper.ip, @vm_helper.port, 1)
762
783
  end
763
784
  raise 'Timed out waiting for ipv4 address!' if tries > max_tries && !IPAddr.new(vm.guest.ipAddress).ipv4?
764
785
  puts 'Found ipv4 address!'
765
786
  true
766
787
  end
788
+
789
+ def vm_guest_ip?(vm)
790
+ vm.guest.guestState == 'running' && vm.guest.toolsRunningStatus == 'guestToolsRunning' && !vm.guest.ipAddress.nil? && IPAddr.new(vm.guest.ipAddress).ipv4?
791
+ end
767
792
  end
768
793
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ChefProvisioningVsphere
3
- VERSION = '1.1.2'.freeze
3
+ VERSION = '2.0.0'
4
4
  end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+ require 'chef/provisioning/driver'
3
+
4
+ module ChefProvisioningVsphere
5
+ # Helps save data in provisioning a machine
6
+ class VmHelper
7
+ attr_accessor :ip, :port
8
+
9
+ RESCUE_EXCEPTIONS_ON_ESTABLISH = [
10
+ Errno::EACCES, Errno::EADDRINUSE, Errno::ECONNREFUSED, Errno::ETIMEDOUT,
11
+ Errno::ECONNRESET, Errno::ENETUNREACH, Errno::EHOSTUNREACH, Errno::EPIPE,
12
+ Errno::EPERM, Errno::EFAULT, Errno::EIO, Errno::EHOSTDOWN,
13
+ Net::SSH::Disconnect, Net::SSH::AuthenticationFailed, Net::SSH::ConnectionTimeout,
14
+ Timeout::Error, IPAddr::AddressFamilyError
15
+ ].freeze
16
+
17
+ def ip?
18
+ @ip
19
+ end
20
+
21
+ def port?
22
+ @port
23
+ end
24
+
25
+ def find_port?(vm, options)
26
+ @port = options[:ssh][:port]
27
+ customization_spec = options[:customization_spec]
28
+ if vm.config.guestId.start_with?('win')
29
+ unless customization_spec.nil? && customization_spec.is_a?(Hash)
30
+ winrm_transport =
31
+ customization_spec[:winrm_transport].nil? ? :negotiate : customization_spec[:winrm_transport].to_sym
32
+ end
33
+ winrm_transport ||= :negotiate
34
+ default_win_port = winrm_transport == :ssl ? '5986' : '5985'
35
+ @port = default_win_port if @port.nil?
36
+ elsif port.nil?
37
+ @port = '22'
38
+ end
39
+ true
40
+ end
41
+
42
+ def open_port?(host, port, timeout = 5)
43
+ true if ::Socket.tcp(host, port, connect_timeout: timeout)
44
+ rescue *RESCUE_EXCEPTIONS_ON_ESTABLISH
45
+ false
46
+ end
47
+ end
48
+ end
@@ -84,15 +84,24 @@ module ChefProvisioningVsphere
84
84
  base
85
85
  end
86
86
 
87
+ def traverse_folders_for_dc(folder, dcname)
88
+ children = folder.children.find_all
89
+ children.each do |child|
90
+ if child.class == RbVmomi::VIM::Datacenter && child.name == dcname
91
+ return child
92
+ elsif child.class == RbVmomi::VIM::Folder
93
+ dc = traverse_folders_for_dc(child, dcname)
94
+ return dc if dc
95
+ end
96
+ end
97
+ false
98
+ end
99
+
87
100
  def datacenter
88
101
  vim # ensure connection is valid
89
102
  @datacenter ||= begin
90
103
  rootFolder = vim.serviceInstance.content.rootFolder
91
- dc = rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter).find do |x|
92
- x.name == datacenter_name
93
- end
94
- raise("vSphere Datacenter not found [#{datacenter_name}]") if dc.nil?
95
- dc
104
+ dc = traverse_folders_for_dc(vim.rootFolder, datacenter_name) || abort('vSphere Datacenter not found [#{datacenter_name}]')
96
105
  end
97
106
  end
98
107
 
@@ -4,7 +4,7 @@ require 'uri'
4
4
  module URI
5
5
  class VsphereUrl < Generic
6
6
  DEFAULT_PORT = 443
7
- DEFAULT_PATH = '/sdk'.freeze
7
+ DEFAULT_PATH = '/sdk'
8
8
 
9
9
  def self.from_config(options)
10
10
  parts = []
@@ -65,14 +65,41 @@ describe 'vsphere_driver' do
65
65
  expect(@vm.config.instanceUuid).to eq(@machine_spec.location['server_id'])
66
66
  end
67
67
  it 'has the correct name' do
68
+ custom_name = @metal_config[:machine_options][:bootstrap_options][:customization_spec][:hostname]
68
69
  now = Time.now.utc
69
- trimmed_name = @vm.config.guestId.start_with?('win') ? @vm_name.byteslice(0, 15) : @vm_name
70
+ trimmed_name = if custom_name
71
+ @vm.config.guestId.start_with?('win') ? custom_name.to_s.byteslice(0, 15) : custom_name
72
+ else
73
+ @vm.config.guestId.start_with?('win') ? @vm_name.byteslice(0, 15) : @vm_name
74
+ end
70
75
  expected_name = "#{trimmed_name}.#{@metal_config[:machine_options][:bootstrap_options][:customization_spec][:domain]}"
71
- until (Time.now.utc - now) > 30 || (@vm.guest.hostName == expected_name)
72
- print '.'
73
- sleep 5
76
+ if @vm.config.guestId.start_with?('win')
77
+ until (Time.now.utc - now) > 30 || expected_name.to_s.include?(@vm.guest.hostName)
78
+ print '.'
79
+ sleep 5
80
+ end
81
+ expect(expected_name).to include(@vm.guest.hostName)
82
+ else
83
+ until (Time.now.utc - now) > 30 || (@vm.guest.hostName == expected_name)
84
+ print '.'
85
+ sleep 5
86
+ end
87
+ expect(@vm.guest.hostName).to eq(expected_name) # For linux Systems
74
88
  end
75
- expect(@vm.guest.hostName).to eq(expected_name)
89
+ end
90
+ it 'is on the correct networks' do
91
+ expect(@vm.network.map(&:name)).to include(@metal_config[:machine_options][:bootstrap_options][:network_name][0]) unless @vm.config.guestId.start_with?('win')
92
+ expect(@vm.network.map(&:name)).to include(@metal_config[:machine_options][:bootstrap_options][:network_name][1]) unless @vm.config.guestId.start_with?('win')
93
+ end
94
+ it 'is on the correct datastore' do
95
+ expect(@vm.datastore[0].name).to eq(@metal_config[:machine_options][:bootstrap_options][:datastore]) unless @vm.config.guestId.start_with?('win')
96
+ end
97
+ it 'is in the correct datacenter' do
98
+ 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
+ end
100
+ it 'has an added disk of the correct size' do
101
+ disk_count = @vm.disks.count
102
+ 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')
76
103
  end
77
104
  it 'has the correct number of CPUs' do
78
105
  expect(@vm.config.hardware.numCPU).to eq(@metal_config[:machine_options][:bootstrap_options][:num_cpus])
@@ -80,13 +107,6 @@ describe 'vsphere_driver' do
80
107
  it 'has the correct amount of memory' do
81
108
  expect(@vm.config.hardware.memoryMB).to eq(@metal_config[:machine_options][:bootstrap_options][:memory_mb])
82
109
  end
83
- it 'is on the correct networks' do
84
- expect(@vm.network.map(&:name)).to include(@metal_config[:machine_options][:bootstrap_options][:network_name][0])
85
- expect(@vm.network.map(&:name)).to include(@metal_config[:machine_options][:bootstrap_options][:network_name][1])
86
- end
87
- it 'is on the correct datastore' do
88
- expect(@vm.datastore[0].name).to eq(@metal_config[:machine_options][:bootstrap_options][:datastore])
89
- end
90
110
  it 'is in the correct resource pool' do
91
111
  if @metal_config[:machine_options][:bootstrap_options].key?(:resource_pool)
92
112
  expect(@vm.resourcePool.name).to eq(@metal_config[:machine_options][:bootstrap_options][:resource_pool].split('/')[1])
@@ -102,15 +122,8 @@ describe 'vsphere_driver' do
102
122
  expect(@vm.resourcePool.owner.name).to eq(@metal_config[:machine_options][:bootstrap_options][:resource_pool].split('/')[0])
103
123
  end
104
124
  end
105
- it 'is in the correct datacenter' do
106
- 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)
107
- end
108
- it 'has an added disk of the correct size' do
109
- disk_count = @vm.disks.count
110
- expect(@vm.disks[disk_count - 1].capacityInKB).to eq(@metal_config[:machine_options][:bootstrap_options][:additional_disk_size_gb][1] * 1024 * 1024)
111
- end
112
125
  it 'has the correct number of disks' do
113
- expect(@vm.disks.count).to eq(3)
126
+ expect(@vm.disks.count).to eq(3) unless @vm.config.guestId.start_with?('win')
114
127
  end
115
128
  it 'has hot add cpu enabled' do
116
129
  expect(@vm.config.cpuHotAddEnabled).to eq(true)
@@ -121,13 +134,15 @@ describe 'vsphere_driver' do
121
134
  it 'has hot add memory enabled' do
122
135
  expect(@vm.config.memoryHotAddEnabled).to eq(true)
123
136
  end
124
- it 'has the correct IP address' do
125
- now = Time.now.utc
126
- 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])
127
- print '.'
128
- sleep 5
137
+ it 'has the correct static IP address' do
138
+ if @metal_config[:machine_options][:bootstrap_options][:customization_spec][:ipsettings][:ip]
139
+ now = Time.now.utc
140
+ 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])
141
+ print '.'
142
+ sleep 5
143
+ end
144
+ expect(@vm.guest.net.map(&:ipAddress).flatten).to include(@metal_config[:machine_options][:bootstrap_options][:customization_spec][:ipsettings][:ip])
129
145
  end
130
- expect(@vm.guest.net.map(&:ipAddress).flatten).to include(@metal_config[:machine_options][:bootstrap_options][:customization_spec][:ipsettings][:ip])
131
146
  end
132
147
  end
133
148
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-provisioning-vsphere
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CenturyLink Cloud
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-08 00:00:00.000000000 Z
12
+ date: 2017-05-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rbvmomi
@@ -54,33 +54,45 @@ dependencies:
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
- name: chef
57
+ name: cheffish
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: '12'
62
+ version: '4.0'
63
+ - - "<"
64
+ - !ruby/object:Gem::Version
65
+ version: '14.0'
63
66
  type: :runtime
64
67
  prerelease: false
65
68
  version_requirements: !ruby/object:Gem::Requirement
66
69
  requirements:
67
- - - "~>"
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '4.0'
73
+ - - "<"
68
74
  - !ruby/object:Gem::Version
69
- version: '12'
75
+ version: '14.0'
70
76
  - !ruby/object:Gem::Dependency
71
- name: cheffish
77
+ name: chef
72
78
  requirement: !ruby/object:Gem::Requirement
73
79
  requirements:
74
- - - "~>"
80
+ - - ">="
75
81
  - !ruby/object:Gem::Version
76
- version: '4'
82
+ version: '12.0'
83
+ - - "<"
84
+ - !ruby/object:Gem::Version
85
+ version: '14.0'
77
86
  type: :runtime
78
87
  prerelease: false
79
88
  version_requirements: !ruby/object:Gem::Requirement
80
89
  requirements:
81
- - - "~>"
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '12.0'
93
+ - - "<"
82
94
  - !ruby/object:Gem::Version
83
- version: '4'
95
+ version: '14.0'
84
96
  - !ruby/object:Gem::Dependency
85
97
  name: rspec
86
98
  requirement: !ruby/object:Gem::Requirement
@@ -203,6 +215,7 @@ files:
203
215
  - lib/chef/provisioning/vsphere_driver/clone_spec_builder.rb
204
216
  - lib/chef/provisioning/vsphere_driver/driver.rb
205
217
  - lib/chef/provisioning/vsphere_driver/version.rb
218
+ - lib/chef/provisioning/vsphere_driver/vm_helper.rb
206
219
  - lib/chef/provisioning/vsphere_driver/vsphere_helpers.rb
207
220
  - lib/chef/provisioning/vsphere_driver/vsphere_url.rb
208
221
  - lib/kitchen/driver/vsphere.rb
@@ -233,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
246
  version: '0'
234
247
  requirements: []
235
248
  rubyforge_project:
236
- rubygems_version: 2.5.1
249
+ rubygems_version: 2.6.11
237
250
  signing_key:
238
251
  specification_version: 4
239
252
  summary: Provisioner for creating vSphere VM instances in Chef Provisioning.