chef-provisioning-vsphere 2.0.8 → 2.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ac457d36ea3bae1eefdf3dcaba502d925840270
4
- data.tar.gz: 76a60e37d9861883bc4932074c9f6d80034c2245
3
+ metadata.gz: 3e151627320d531a6712a2336485d7cf03f61519
4
+ data.tar.gz: b565bf4a774b636ccb3448ff3ba3f07d3fab1b33
5
5
  SHA512:
6
- metadata.gz: 7996f02f1e180e2375fb790c06a961b8abcd32850085b31adc56e3b7feb12fbc5f6805199112443d143e2404c19c625f133a29922f48afc36d00245aa27bba31
7
- data.tar.gz: 4e805e07531c27d64143917c094d3037b2e25aa2047ace08b2c2bf2eab8e78529cfc656bce0db161de72ac06d35e8510a14f67015b6ec2817806112be79754ad
6
+ metadata.gz: 355bc3e74e5719ff8731eaee695939add96bd675433ba79a11e19841d2a02d5c858ddba678f5f2769fb20b448af190bc0c4129894776d2c03bf4069ccd5fb56e
7
+ data.tar.gz: 443b85c9e3f5994a586b97a5c3a6c8875bec4f563cc25dc4eb4446c09ed977b647cd8c611efb744524e43534f7617291a2f4c782d1890011db20661d31805840
data/CHANGELOG.md CHANGED
@@ -1,7 +1,18 @@
1
1
  # Change Log
2
2
 
3
- ## [2.0.8](https://github.com/chef-partners/chef-provisioning-vsphere/tree/2.0.8) (2017-10-23)
4
- [Full Changelog](https://github.com/chef-partners/chef-provisioning-vsphere/compare/v2.0.7...2.0.8)
3
+ ## [2.0.9](https://github.com/chef-partners/chef-provisioning-vsphere/tree/2.0.9) (2017-10-30)
4
+ [Full Changelog](https://github.com/chef-partners/chef-provisioning-vsphere/compare/v2.0.8...2.0.9)
5
+
6
+ **Closed issues:**
7
+
8
+ - Networks under a distributed switch not at the rootFolder cannot be found [\#56](https://github.com/chef-partners/chef-provisioning-vsphere/issues/56)
9
+
10
+ **Merged pull requests:**
11
+
12
+ - Several small fixes [\#63](https://github.com/chef-partners/chef-provisioning-vsphere/pull/63) ([algaut](https://github.com/algaut))
13
+
14
+ ## [v2.0.8](https://github.com/chef-partners/chef-provisioning-vsphere/tree/v2.0.8) (2017-10-23)
15
+ [Full Changelog](https://github.com/chef-partners/chef-provisioning-vsphere/compare/v2.0.7...v2.0.8)
5
16
 
6
17
  **Closed issues:**
7
18
 
data/Rakefile CHANGED
@@ -38,4 +38,4 @@ YARD::Rake::YardocTask.new do |t|
38
38
  t.stats_options = ['--list-undoc'] # optional
39
39
  end
40
40
 
41
- task default: %i[style unit]
41
+ task default: %i(style unit)
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.homepage = 'https://github.com/chef-partners/chef-provisioning-vsphere'
17
17
  s.license = 'MIT'
18
18
  s.bindir = 'bin'
19
- s.executables = %w[]
19
+ s.executables = %w()
20
20
  s.require_path = 'lib'
21
21
  s.files = `git ls-files -z`.split("\x0")
22
22
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
@@ -178,7 +178,7 @@ module ChefProvisioningVsphere
178
178
  def hostname_from(options, vm_name)
179
179
  hostname = options[:hostname] || vm_name
180
180
  test = /^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])$/
181
- unless hostname =~ test
181
+ unless hostname.match?(test)
182
182
  raise 'Only letters, numbers or hyphens in hostnames allowed'
183
183
  end
184
184
  RbVmomi::VIM::CustomizationFixedName.new(name: hostname)
@@ -14,7 +14,7 @@ require 'chef/provisioning/vsphere_driver/vm_helper'
14
14
  # Provisions machines in vSphere.
15
15
  module ChefProvisioningVsphere
16
16
  # Inherits the Chef::Provisioning::Driver attirbutes
17
- class VsphereDriver < Chef::Provisioning::Driver
17
+ class VsphereDriver < Chef::Provisioning::Driver # rubocop:disable Metrics/ClassLength
18
18
  include Chef::Mixin::ShellOut
19
19
 
20
20
  # Creates the new object via the URL
@@ -670,11 +670,18 @@ module ChefProvisioningVsphere
670
670
  Chef::Log.debug("Clone spec: #{clone_spec.pretty_inspect}")
671
671
 
672
672
  vm_folder = vsphere_helper.find_folder(bootstrap_options[:vm_folder])
673
+ last_progress = 0
673
674
  vm_template.CloneVM_Task(
674
675
  name: machine_name,
675
676
  folder: vm_folder,
676
677
  spec: clone_spec
677
- ).wait_for_completion
678
+ ).wait_for_progress do |progress|
679
+ if (progress.is_a? Numeric) && (progress / 10).floor != (last_progress / 10).floor
680
+ print "\n#{machine_name} progress: #{progress}%"
681
+ last_progress = progress
682
+ end
683
+ end
684
+ print "\n#{machine_name} done!"
678
685
 
679
686
  vm = vsphere_helper.find_vm(vm_folder, machine_name)
680
687
 
@@ -882,7 +889,11 @@ module ChefProvisioningVsphere
882
889
  else
883
890
  ## Check if true available
884
891
  vm_ip = bootstrap_options[:customization_spec][:ipsettings][:ip] unless vm_helper.ip?
885
- print '.' until @vm_helper.open_port?(vm_ip, @vm_helper.port, 1)
892
+ nb_attempts = 0
893
+ until @vm_helper.open_port?(vm_ip, @vm_helper.port, 1) || nb_attempts > bootstrap_options[:ready_timeout]
894
+ print '.'
895
+ nb_attempts += 1
896
+ end
886
897
  end
887
898
  else
888
899
  if use_ipv4_during_bootstrap?(bootstrap_options)
@@ -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.0.8'.freeze
6
+ VERSION = '2.0.9'.freeze
7
7
  end
@@ -178,11 +178,11 @@ module ChefProvisioningVsphere
178
178
  def add_extra_nic(action_handler, vm_template, options, vm)
179
179
  deviceAdditions, changes = network_device_changes(action_handler, vm_template, options)
180
180
 
181
- if deviceAdditions.count > 0
181
+ if deviceAdditions.count.positive?
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 > 0
185
+ if new_devices.count.positive?
186
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
@@ -396,13 +396,7 @@ module ChefProvisioningVsphere
396
396
  base = datacenter.networkFolder
397
397
  entity_array = name.split('/').reject(&:empty?)
398
398
  entity_array.each do |item|
399
- case base
400
- when RbVmomi::VIM::Folder
401
- base = base.find(item)
402
- when RbVmomi::VIM::VmwareDistributedVirtualSwitch
403
- idx = base.summary.portgroupName.find_index(item)
404
- base = idx.nil? ? nil : base.portgroup[idx]
405
- end
399
+ base = traverse_folders_for_network(base, item)
406
400
  end
407
401
 
408
402
  raise "vSphere Network not found [#{name}]" if base.nil?
@@ -410,6 +404,25 @@ module ChefProvisioningVsphere
410
404
  base
411
405
  end
412
406
 
407
+ # Search the item through the base's children
408
+ # @param base vSphere object where to search
409
+ # @param [String] item the name of the network to look for
410
+ def traverse_folders_for_network(base, item)
411
+ Chef::Log.debug("Searching #{item} in #{base.name}")
412
+ case base
413
+ when RbVmomi::VIM::Folder
414
+ res = base.find(item)
415
+ return res unless res.nil?
416
+ base.childEntity.each do |child|
417
+ res = traverse_folders_for_network(child, item)
418
+ return res unless res.nil?
419
+ end
420
+ when RbVmomi::VIM::VmwareDistributedVirtualSwitch
421
+ idx = base.summary.portgroupName.find_index(item)
422
+ idx.nil? ? nil : base.portgroup[idx]
423
+ end
424
+ end
425
+
413
426
  # Locate the Customization Spec in vSphere.
414
427
  #
415
428
  # @param [String] customization_spec The name of the Customization Spec.
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: 2.0.8
4
+ version: 2.0.9
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-10-23 00:00:00.000000000 Z
12
+ date: 2017-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef