From cd26555bdc8109ee10ff0b874f1a99a011bff9e5 Mon Sep 17 00:00:00 2001 From: Mike Laxer Date: Mon, 31 Jan 2022 14:51:23 -0700 Subject: [PATCH 01/12] ruby 2 to 3 --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index 57cf282e..4efbd8f7 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.6.5 +ruby-3.0.2 From ec15278c87322893e9136266529a2f64cd4b1bb3 Mon Sep 17 00:00:00 2001 From: Mike Laxer Date: Mon, 31 Jan 2022 14:56:25 -0700 Subject: [PATCH 02/12] update deps for vagrant 2.2.19, ruby 3 --- Gemfile | 2 +- vSphere.gemspec | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 9b41f7d2..d4312117 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ group :development do # We depend on Vagrant for development, but we don't add it as a # gem dependency because we expect to be installed within the # Vagrant environment itself using `vagrant plugin`. - gem 'vagrant', github: 'mitchellh/vagrant', ref: 'v2.2.6' + gem 'vagrant', github: 'mitchellh/vagrant', ref: 'v2.2.19' end group :plugins do diff --git a/vSphere.gemspec b/vSphere.gemspec index 355d6f39..386a5dd0 100644 --- a/vSphere.gemspec +++ b/vSphere.gemspec @@ -12,17 +12,17 @@ Gem::Specification.new do |s| s.description = 'Enables Vagrant to manage machines with VMWare vSphere.' # pin nokogiri to 1.10.10 to get around 1.11.0 requiring ruby >=2.5 - s.add_dependency 'nokogiri', '1.10.10' + s.add_dependency 'nokogiri', '1.31.1' - s.add_dependency 'rbvmomi', '>=1.11.5', '<2.0.0' + s.add_dependency 'rbvmomi', '3.0.0' s.add_dependency 'i18n', '>=0.6.4' - s.add_development_dependency 'rake', '11.1.2' # pinned to accommodate rubocop 0.32.1 + s.add_development_dependency 'rake', '13.0.6' # pinned to accommodate rubocop 0.32.1 s.add_development_dependency 'rspec-core' s.add_development_dependency 'rspec-expectations' s.add_development_dependency 'rspec-mocks' - s.add_development_dependency 'rubocop', '~> 0.32.1' + s.add_development_dependency 'rubocop', '1.25.0' s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) s.executables = s.files.grep(/^bin\//) { |f| File.basename(f) } From 773a5d8f0ddd0d6bd5363d7dcc35f68e9628211e Mon Sep 17 00:00:00 2001 From: Mike Laxer Date: Mon, 31 Jan 2022 14:57:51 -0700 Subject: [PATCH 03/12] typo: nokogiri version --- vSphere.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vSphere.gemspec b/vSphere.gemspec index 386a5dd0..c1d25ff9 100644 --- a/vSphere.gemspec +++ b/vSphere.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |s| s.description = 'Enables Vagrant to manage machines with VMWare vSphere.' # pin nokogiri to 1.10.10 to get around 1.11.0 requiring ruby >=2.5 - s.add_dependency 'nokogiri', '1.31.1' + s.add_dependency 'nokogiri', '1.13.1' s.add_dependency 'rbvmomi', '3.0.0' From f55babb78ce276ad2c1bac828ad98cdb159af985 Mon Sep 17 00:00:00 2001 From: Mike Laxer Date: Tue, 12 Apr 2022 13:25:14 -0600 Subject: [PATCH 04/12] Bump to next minor version with pre1 instead --- .bumpversion.cfg | 3 ++- README.md | 4 ++-- lib/vSphere/version.rb | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 2bb95e89..baf5648d 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.13.5 +current_version = 1.14.0.pre1 tag = true commit = true @@ -8,3 +8,4 @@ commit = true [bumpversion:file:README.md] parse = version: (?P\d+)\.(?P\d+)\.(?P\d+) serialize = version: {major}.{minor}.{patch} + diff --git a/README.md b/README.md index 8276015d..0fd8d433 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ This provider is built on top of the * libxml2, libxml2-dev, libxslt, libxslt-dev ## Current Version -**version: 1.13.5** +**version: 1.14.0.pre1** -vagrant-vsphere (**version: 1.13.5**) is available from +vagrant-vsphere (**version: 1.14.0.pre1**) is available from [RubyGems.org](https://rubygems.org/gems/vagrant-vsphere) ## Installation diff --git a/lib/vSphere/version.rb b/lib/vSphere/version.rb index 295c58a3..e4d8ac2d 100644 --- a/lib/vSphere/version.rb +++ b/lib/vSphere/version.rb @@ -1,5 +1,5 @@ module VagrantPlugins module VSphere - VERSION = '1.13.5' + VERSION = '1.14.0.pre1' end end From e1257bc79569b1f029933afdaf20e1ebafb3b01c Mon Sep 17 00:00:00 2001 From: Mike Laxer Date: Tue, 12 Apr 2022 13:27:39 -0600 Subject: [PATCH 05/12] Update nokogiri to address dependabot security alerts --- vSphere.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vSphere.gemspec b/vSphere.gemspec index c1d25ff9..a266185c 100644 --- a/vSphere.gemspec +++ b/vSphere.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |s| s.description = 'Enables Vagrant to manage machines with VMWare vSphere.' # pin nokogiri to 1.10.10 to get around 1.11.0 requiring ruby >=2.5 - s.add_dependency 'nokogiri', '1.13.1' + s.add_dependency 'nokogiri', '1.13.4' s.add_dependency 'rbvmomi', '3.0.0' From de237ed891e693bf7b09c3542dc75661b2dd9b30 Mon Sep 17 00:00:00 2001 From: Mike Laxer Date: Tue, 12 Apr 2022 13:35:57 -0600 Subject: [PATCH 06/12] Update with changes --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aecbecac..ab875cdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.14.0 (2022-04-12)](https://github.com/nsidc/vagrant-vsphere/releases/tag/v1.14.0.pre1) + + - Update gem to ruby 3.0.2 + - Support for vagrant >=2.2.17 + - Update nokogiri dependency (1.13.4) to take care of dependabot alerts + - Update rbvmomi, rake, rubocop dependencies + ## [1.13.5 (2021-01-05)](https://github.com/nsidc/vagrant-vsphere/releases/tag/v1.13.5) - Pin nokogiri to 1.10.10. This fixes an issue where vagrant-vsphere failed to install due to nokogiri requiring Ruby >=2.5. This is a workaround until the vagrant-nsidc plugin is updated From e7ec2f6c5077352150bcab28762e3467dd58ad6d Mon Sep 17 00:00:00 2001 From: Mike Laxer Date: Tue, 12 Apr 2022 15:11:11 -0600 Subject: [PATCH 07/12] rubocop; delete old comments --- vSphere.gemspec | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vSphere.gemspec b/vSphere.gemspec index a266185c..911969bc 100644 --- a/vSphere.gemspec +++ b/vSphere.gemspec @@ -1,4 +1,6 @@ -$LOAD_PATH.unshift File.expand_path('../lib', __FILE__) +# frozen_string_literal: true + +$LOAD_PATH.unshift File.expand_path('lib', __dir__) require 'vSphere/version' Gem::Specification.new do |s| @@ -11,14 +13,13 @@ Gem::Specification.new do |s| s.summary = 'VMWare vSphere provider' s.description = 'Enables Vagrant to manage machines with VMWare vSphere.' - # pin nokogiri to 1.10.10 to get around 1.11.0 requiring ruby >=2.5 s.add_dependency 'nokogiri', '1.13.4' s.add_dependency 'rbvmomi', '3.0.0' s.add_dependency 'i18n', '>=0.6.4' - s.add_development_dependency 'rake', '13.0.6' # pinned to accommodate rubocop 0.32.1 + s.add_development_dependency 'rake', '13.0.6' s.add_development_dependency 'rspec-core' s.add_development_dependency 'rspec-expectations' s.add_development_dependency 'rspec-mocks' From d6deadaf9712ed9b5186dd138c4f4c0d0afb991f Mon Sep 17 00:00:00 2001 From: Mike Laxer Date: Tue, 12 Apr 2022 15:16:15 -0600 Subject: [PATCH 08/12] Temporarily disable some cops --- .rubocop.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 7b89d350..bff011bf 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -32,3 +32,18 @@ Metrics/ModuleLength: Metrics/PerceivedComplexity: Enabled: false + +# Disabled these cops upgrading rubocop to 1.25.0 +# TODO:Correct the issues found by these cops someday +Lint/MissingSuper: + Enabled: false + +Metrics/BlockLength: + Enabled: false + +Naming: + Enabled: false + +# TODO: Add required ruby version to gemspec +Gemspec/RequiredRubyVersion: + Enabled: false From 53dd3d624f5ccbbfbb6a96a415f16146945e857c Mon Sep 17 00:00:00 2001 From: Mike Laxer Date: Tue, 12 Apr 2022 15:16:45 -0600 Subject: [PATCH 09/12] rubocop autocorrect --- Gemfile | 2 + Rakefile | 6 +- lib/vSphere/action.rb | 14 ++-- lib/vSphere/action/clone.rb | 39 +++++------ lib/vSphere/action/close_vsphere.rb | 2 + lib/vSphere/action/connect_vsphere.rb | 2 + lib/vSphere/action/destroy.rb | 3 + lib/vSphere/action/get_ssh_info.rb | 9 ++- lib/vSphere/action/get_state.rb | 4 +- lib/vSphere/action/is_created.rb | 2 + lib/vSphere/action/is_running.rb | 2 + lib/vSphere/action/is_suspended.rb | 2 + lib/vSphere/action/message_already_created.rb | 2 + lib/vSphere/action/message_not_created.rb | 2 + lib/vSphere/action/message_not_running.rb | 2 + lib/vSphere/action/message_not_suspended.rb | 2 + lib/vSphere/action/power_off.rb | 2 + lib/vSphere/action/power_on.rb | 2 + lib/vSphere/action/resume.rb | 2 + lib/vSphere/action/snapshot_delete.rb | 12 ++-- lib/vSphere/action/snapshot_list.rb | 2 + lib/vSphere/action/snapshot_restore.rb | 7 +- lib/vSphere/action/snapshot_save.rb | 12 ++-- lib/vSphere/action/suspend.rb | 2 + lib/vSphere/action/wait_for_ip_address.rb | 2 + lib/vSphere/cap/public_address.rb | 3 + lib/vSphere/cap/snapshot_list.rb | 2 + lib/vSphere/config.rb | 35 ++-------- lib/vSphere/errors.rb | 2 + lib/vSphere/plugin.rb | 10 +-- lib/vSphere/provider.rb | 3 + lib/vSphere/util/vim_helpers.rb | 45 +++++++------ lib/vSphere/util/vm_helpers.rb | 15 +++-- lib/vSphere/version.rb | 2 + lib/vagrant-vsphere.rb | 6 +- spec/action_spec.rb | 2 + spec/clone_spec.rb | 14 ++-- spec/connect_vsphere_spec.rb | 2 + spec/destroy_spec.rb | 2 + spec/get_ssh_info_spec.rb | 20 ++---- spec/get_state_spec.rb | 2 + spec/is_created_spec.rb | 2 + spec/power_off_spec.rb | 2 + spec/spec_helper.rb | 65 ++++++++++--------- 44 files changed, 218 insertions(+), 154 deletions(-) diff --git a/Gemfile b/Gemfile index d4312117..cf9eebaf 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'http://rubygems.org' group :development do diff --git a/Rakefile b/Rakefile index 9c72c8fb..cd03be09 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rubygems' require 'bundler/setup' require 'rspec/core/rake_task' @@ -9,7 +11,7 @@ $stdout.sync = true $stderr.sync = true # Change to the directory of this file. -Dir.chdir(File.expand_path('../', __FILE__)) +Dir.chdir(File.expand_path(__dir__)) Bundler::GemHelper.install_tasks @@ -17,4 +19,4 @@ RSpec::Core::RakeTask.new RuboCop::RakeTask.new -task default: %w(rubocop spec) +task default: %w[rubocop spec] diff --git a/lib/vSphere/action.rb b/lib/vSphere/action.rb index 7a340070..2e41c5a6 100644 --- a/lib/vSphere/action.rb +++ b/lib/vSphere/action.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'vagrant' require 'vagrant/action/builder' @@ -224,7 +226,7 @@ def self.action_get_ssh_info end # TODO: Remove the if guard when Vagrant 1.8.0 is the minimum version. - # rubocop:disable IndentationWidth + # rubocop:disable Layout/IndentationWidth if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('1.8.0') def self.action_snapshot_delete Vagrant::Action::Builder.new.tap do |b| @@ -292,11 +294,11 @@ def self.action_snapshot_save b.use CloseVSphere end end - end # Vagrant > 1.8.0 guard - # rubocop:enable IndentationWidth + end + # rubocop:enable Layout/IndentationWidth # autoload - action_root = Pathname.new(File.expand_path('../action', __FILE__)) + action_root = Pathname.new(File.expand_path('action', __dir__)) autoload :Clone, action_root.join('clone') autoload :CloseVSphere, action_root.join('close_vsphere') autoload :ConnectVSphere, action_root.join('connect_vsphere') @@ -317,14 +319,14 @@ def self.action_snapshot_save autoload :WaitForIPAddress, action_root.join('wait_for_ip_address') # TODO: Remove the if guard when Vagrant 1.8.0 is the minimum version. - # rubocop:disable IndentationWidth + # rubocop:disable Layout/IndentationWidth if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('1.8.0') autoload :SnapshotDelete, action_root.join('snapshot_delete') autoload :SnapshotList, action_root.join('snapshot_list') autoload :SnapshotRestore, action_root.join('snapshot_restore') autoload :SnapshotSave, action_root.join('snapshot_save') end - # rubocop:enable IndentationWidth + # rubocop:enable Layout/IndentationWidth end end end diff --git a/lib/vSphere/action/clone.rb b/lib/vSphere/action/clone.rb index 00116cf6..51ef8f94 100644 --- a/lib/vSphere/action/clone.rb +++ b/lib/vSphere/action/clone.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rbvmomi' require 'i18n' require 'vSphere/util/vim_helpers' @@ -19,14 +21,15 @@ def call(env) name = get_name machine, config, env[:root_path] dc = get_datacenter connection, machine template = dc.find_vm config.template_name - fail Errors::VSphereError, :'missing_template' if template.nil? + raise Errors::VSphereError, :'missing_template' if template.nil? + vm_base_folder = get_vm_base_folder dc, template, config - fail Errors::VSphereError, :'invalid_base_path' if vm_base_folder.nil? + raise Errors::VSphereError, :'invalid_base_path' if vm_base_folder.nil? begin # Storage DRS does not support vSphere linked clones. http://www.vmware.com/files/pdf/techpaper/vsphere-storage-drs-interoperability.pdf ds = get_datastore dc, machine - fail Errors::VSphereError, :'invalid_configuration_linked_clone_with_sdrs' if config.linked_clone && ds.is_a?(RbVmomi::VIM::StoragePod) + raise Errors::VSphereError, :'invalid_configuration_linked_clone_with_sdrs' if config.linked_clone && ds.is_a?(RbVmomi::VIM::StoragePod) location = get_location ds, dc, machine, template spec = RbVmomi::VIM.VirtualMachineCloneSpec location: location, powerOn: true, template: false @@ -74,9 +77,7 @@ def call(env) recommendation = result.recommendations[0] key = recommendation.key ||= '' - if key == '' - fail Errors::VSphereError, :missing_datastore_recommendation - end + raise Errors::VSphereError, :missing_datastore_recommendation if key == '' env[:ui].info I18n.t('vsphere.creating_cloned_vm_sdrs') env[:ui].info " -- Storage DRS recommendation: #{recommendation.target.name} #{recommendation.reasonText}" @@ -125,13 +126,13 @@ def wait_for_sysprep(env, vm, vim_connection, timeout, sleep_time) while wait events = query_customization_succeeded(vm, vem) - if events.size > 0 + if events.size.positive? events.each do |e| env[:ui].info e.fullFormattedMessage end wait = false elsif waited_seconds >= timeout - fail Errors::VSphereError, :'sysprep_timeout' + raise Errors::VSphereError, :'sysprep_timeout' else sleep(sleep_time) waited_seconds += sleep_time @@ -154,7 +155,7 @@ def get_customization_spec(machine, spec_info) return customization_spec if private_networks.nil? # make sure we have enough NIC settings to override with the private network settings - fail Errors::VSphereError, :'too_many_private_networks' if private_networks.length > customization_spec.nicSettingMap.length + raise Errors::VSphereError, :'too_many_private_networks' if private_networks.length > customization_spec.nicSettingMap.length # assign the private network IP to the NIC private_networks.each_index do |idx| @@ -212,7 +213,7 @@ def get_name(machine, config, root_path) return config.name unless config.name.nil? prefix = "#{root_path.basename}_#{machine.name}" - prefix.gsub!(/[^-a-z0-9_\.]/i, '') + prefix.gsub!(/[^-a-z0-9_.]/i, '') # milliseconds + random number suffix to allow for simultaneous `vagrant up` of the same box in different dirs prefix + "_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100_000)}" end @@ -229,7 +230,7 @@ def modify_network_card(template, spec) spec[:config][:deviceChange] ||= [] @card ||= template.config.hardware.device.grep(RbVmomi::VIM::VirtualEthernetCard).first - fail Errors::VSphereError, :missing_network_card if @card.nil? + raise Errors::VSphereError, :missing_network_card if @card.nil? yield(@card) @@ -241,7 +242,7 @@ def modify_network_card(template, spec) def add_custom_address_type(template, spec, addressType) spec[:config][:deviceChange] = [] config = template.config - card = config.hardware.device.grep(RbVmomi::VIM::VirtualEthernetCard).first || fail(Errors::VSphereError, :missing_network_card) + card = config.hardware.device.grep(RbVmomi::VIM::VirtualEthernetCard).first || raise(Errors::VSphereError, :missing_network_card) card.addressType = addressType card_spec = { :deviceChange => [{ :operation => :edit, :device => card }] } template.ReconfigVM_Task(:spec => card_spec).wait_for_completion @@ -257,13 +258,13 @@ def add_custom_vlan(template, dc, spec, vlan) network = get_network_by_name(dc, vlan) modify_network_card(template, spec) do |card| - begin - switch_port = RbVmomi::VIM.DistributedVirtualSwitchPortConnection(switchUuid: network.config.distributedVirtualSwitch.uuid, portgroupKey: network.key) - card.backing = RbVmomi::VIM::VirtualEthernetCardDistributedVirtualPortBackingInfo(port: switch_port) - rescue - # not connected to a distibuted switch? - card.backing = RbVmomi::VIM::VirtualEthernetCardNetworkBackingInfo(network: network, deviceName: network.name) - end + + switch_port = RbVmomi::VIM.DistributedVirtualSwitchPortConnection(switchUuid: network.config.distributedVirtualSwitch.uuid, portgroupKey: network.key) + card.backing = RbVmomi::VIM::VirtualEthernetCardDistributedVirtualPortBackingInfo(port: switch_port) + rescue StandardError + # not connected to a distibuted switch? + card.backing = RbVmomi::VIM::VirtualEthernetCardNetworkBackingInfo(network: network, deviceName: network.name) + end end diff --git a/lib/vSphere/action/close_vsphere.rb b/lib/vSphere/action/close_vsphere.rb index 4f8f93ff..a954f29a 100644 --- a/lib/vSphere/action/close_vsphere.rb +++ b/lib/vSphere/action/close_vsphere.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rbvmomi' module VagrantPlugins diff --git a/lib/vSphere/action/connect_vsphere.rb b/lib/vSphere/action/connect_vsphere.rb index aa8580bb..ccd32a21 100644 --- a/lib/vSphere/action/connect_vsphere.rb +++ b/lib/vSphere/action/connect_vsphere.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rbvmomi' module VagrantPlugins diff --git a/lib/vSphere/action/destroy.rb b/lib/vSphere/action/destroy.rb index d394e616..8c7ef868 100644 --- a/lib/vSphere/action/destroy.rb +++ b/lib/vSphere/action/destroy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rbvmomi' require 'i18n' require 'vSphere/util/vim_helpers' @@ -23,6 +25,7 @@ def call(env) def destroy_vm(env) return if env[:machine].state.id == :not_created + vm = get_vm_by_uuid env[:vSphere_connection], env[:machine] return if vm.nil? diff --git a/lib/vSphere/action/get_ssh_info.rb b/lib/vSphere/action/get_ssh_info.rb index dc0a1c2d..26b2943c 100644 --- a/lib/vSphere/action/get_ssh_info.rb +++ b/lib/vSphere/action/get_ssh_info.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rbvmomi' require 'vSphere/util/vim_helpers' @@ -21,12 +23,13 @@ def call(env) def filter_guest_nic(vm, machine) return vm.guest.ipAddress unless machine.provider_config.real_nic_ip - interfaces = vm.guest.net.select { |g| g.deviceConfigId > 0 } + interfaces = vm.guest.net.select { |g| g.deviceConfigId.positive? } ip_addresses = interfaces.map { |i| i.ipConfig.ipAddress.select { |a| a.state == 'preferred' } }.flatten return (vm.guest.ipAddress || nil) if ip_addresses.empty? - fail Errors::VSphereError.new, :'multiple_interface_with_real_nic_ip_set' if ip_addresses.size > 1 + raise Errors::VSphereError.new, :'multiple_interface_with_real_nic_ip_set' if ip_addresses.size > 1 + ip_addresses.first.ipAddress end @@ -35,8 +38,10 @@ def get_ssh_info(connection, machine) vm = get_vm_by_uuid connection, machine return nil if vm.nil? + ip_address = filter_guest_nic(vm, machine) return nil if ip_address.nil? || ip_address.empty? + { host: ip_address, port: 22 diff --git a/lib/vSphere/action/get_state.rb b/lib/vSphere/action/get_state.rb index bfd72a02..e6076975 100644 --- a/lib/vSphere/action/get_state.rb +++ b/lib/vSphere/action/get_state.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rbvmomi' require 'vSphere/util/vim_helpers' require 'vSphere/util/vm_helpers' @@ -22,7 +24,7 @@ def call(env) private def get_state(connection, machine) - return :not_created if machine.id.nil? + return :not_created if machine.id.nil? vm = get_vm_by_uuid connection, machine diff --git a/lib/vSphere/action/is_created.rb b/lib/vSphere/action/is_created.rb index 1a669592..2a416c1a 100644 --- a/lib/vSphere/action/is_created.rb +++ b/lib/vSphere/action/is_created.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module VagrantPlugins module VSphere module Action diff --git a/lib/vSphere/action/is_running.rb b/lib/vSphere/action/is_running.rb index a2524ae5..adfab3be 100644 --- a/lib/vSphere/action/is_running.rb +++ b/lib/vSphere/action/is_running.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module VagrantPlugins module VSphere module Action diff --git a/lib/vSphere/action/is_suspended.rb b/lib/vSphere/action/is_suspended.rb index 3a5970c4..f9d34996 100644 --- a/lib/vSphere/action/is_suspended.rb +++ b/lib/vSphere/action/is_suspended.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module VagrantPlugins module VSphere module Action diff --git a/lib/vSphere/action/message_already_created.rb b/lib/vSphere/action/message_already_created.rb index 93e28062..044b8a29 100644 --- a/lib/vSphere/action/message_already_created.rb +++ b/lib/vSphere/action/message_already_created.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'i18n' module VagrantPlugins diff --git a/lib/vSphere/action/message_not_created.rb b/lib/vSphere/action/message_not_created.rb index a20a6692..6a35b8a8 100644 --- a/lib/vSphere/action/message_not_created.rb +++ b/lib/vSphere/action/message_not_created.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'i18n' module VagrantPlugins diff --git a/lib/vSphere/action/message_not_running.rb b/lib/vSphere/action/message_not_running.rb index c8781b26..71ad5831 100644 --- a/lib/vSphere/action/message_not_running.rb +++ b/lib/vSphere/action/message_not_running.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'i18n' module VagrantPlugins diff --git a/lib/vSphere/action/message_not_suspended.rb b/lib/vSphere/action/message_not_suspended.rb index 72a90138..90c7c781 100644 --- a/lib/vSphere/action/message_not_suspended.rb +++ b/lib/vSphere/action/message_not_suspended.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'i18n' module VagrantPlugins diff --git a/lib/vSphere/action/power_off.rb b/lib/vSphere/action/power_off.rb index 9720f019..6177dcbd 100644 --- a/lib/vSphere/action/power_off.rb +++ b/lib/vSphere/action/power_off.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rbvmomi' require 'i18n' require 'vSphere/util/vim_helpers' diff --git a/lib/vSphere/action/power_on.rb b/lib/vSphere/action/power_on.rb index 6d7c546a..42efde32 100644 --- a/lib/vSphere/action/power_on.rb +++ b/lib/vSphere/action/power_on.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rbvmomi' require 'i18n' require 'vSphere/util/vim_helpers' diff --git a/lib/vSphere/action/resume.rb b/lib/vSphere/action/resume.rb index ac5e85e3..88965210 100644 --- a/lib/vSphere/action/resume.rb +++ b/lib/vSphere/action/resume.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rbvmomi' require 'i18n' require 'vSphere/util/vim_helpers' diff --git a/lib/vSphere/action/snapshot_delete.rb b/lib/vSphere/action/snapshot_delete.rb index 445a4928..4a489c94 100644 --- a/lib/vSphere/action/snapshot_delete.rb +++ b/lib/vSphere/action/snapshot_delete.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'vSphere/util/vim_helpers' require 'vSphere/util/vm_helpers' @@ -16,8 +18,9 @@ def call(env) vm = get_vm_by_uuid(env[:vSphere_connection], env[:machine]) env[:ui].info(I18n.t( - "vagrant.actions.vm.snapshot.deleting", - name: env[:snapshot_name])) + "vagrant.actions.vm.snapshot.deleting", + name: env[:snapshot_name] + )) delete_snapshot(vm, env[:snapshot_name]) do |progress| env[:ui].clear_line @@ -27,8 +30,9 @@ def call(env) env[:ui].clear_line env[:ui].info(I18n.t( - "vagrant.actions.vm.snapshot.deleted", - name: env[:snapshot_name])) + "vagrant.actions.vm.snapshot.deleted", + name: env[:snapshot_name] + )) @app.call env end diff --git a/lib/vSphere/action/snapshot_list.rb b/lib/vSphere/action/snapshot_list.rb index 0c3f74cb..9a0eaadd 100644 --- a/lib/vSphere/action/snapshot_list.rb +++ b/lib/vSphere/action/snapshot_list.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'vSphere/util/vim_helpers' require 'vSphere/util/vm_helpers' diff --git a/lib/vSphere/action/snapshot_restore.rb b/lib/vSphere/action/snapshot_restore.rb index 2783257b..7e78e84e 100644 --- a/lib/vSphere/action/snapshot_restore.rb +++ b/lib/vSphere/action/snapshot_restore.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'vSphere/util/vim_helpers' require 'vSphere/util/vm_helpers' @@ -16,8 +18,9 @@ def call(env) vm = get_vm_by_uuid(env[:vSphere_connection], env[:machine]) env[:ui].info(I18n.t( - "vagrant.actions.vm.snapshot.restoring", - name: env[:snapshot_name])) + "vagrant.actions.vm.snapshot.restoring", + name: env[:snapshot_name] + )) restore_snapshot(vm, env[:snapshot_name]) do |progress| env[:ui].clear_line diff --git a/lib/vSphere/action/snapshot_save.rb b/lib/vSphere/action/snapshot_save.rb index ec054d69..6be9a3f6 100644 --- a/lib/vSphere/action/snapshot_save.rb +++ b/lib/vSphere/action/snapshot_save.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'vSphere/util/vim_helpers' require 'vSphere/util/vm_helpers' @@ -16,8 +18,9 @@ def call(env) vm = get_vm_by_uuid(env[:vSphere_connection], env[:machine]) env[:ui].info(I18n.t( - "vagrant.actions.vm.snapshot.saving", - name: env[:snapshot_name])) + "vagrant.actions.vm.snapshot.saving", + name: env[:snapshot_name] + )) create_snapshot(vm, env[:snapshot_name]) do |progress| env[:ui].clear_line @@ -27,8 +30,9 @@ def call(env) env[:ui].clear_line env[:ui].success(I18n.t( - "vagrant.actions.vm.snapshot.saved", - name: env[:snapshot_name])) + "vagrant.actions.vm.snapshot.saved", + name: env[:snapshot_name] + )) @app.call env end end diff --git a/lib/vSphere/action/suspend.rb b/lib/vSphere/action/suspend.rb index 5af27e7c..94d219c8 100644 --- a/lib/vSphere/action/suspend.rb +++ b/lib/vSphere/action/suspend.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rbvmomi' require 'i18n' require 'vSphere/util/vim_helpers' diff --git a/lib/vSphere/action/wait_for_ip_address.rb b/lib/vSphere/action/wait_for_ip_address.rb index 2d9b2b63..276f9ade 100644 --- a/lib/vSphere/action/wait_for_ip_address.rb +++ b/lib/vSphere/action/wait_for_ip_address.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'ipaddr' require 'timeout' diff --git a/lib/vSphere/cap/public_address.rb b/lib/vSphere/cap/public_address.rb index ec143ad8..54a16768 100644 --- a/lib/vSphere/cap/public_address.rb +++ b/lib/vSphere/cap/public_address.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module VagrantPlugins module VSphere module Cap @@ -7,6 +9,7 @@ def self.public_address(machine) ssh_info = machine.ssh_info return nil unless ssh_info + ssh_info[:host] end end diff --git a/lib/vSphere/cap/snapshot_list.rb b/lib/vSphere/cap/snapshot_list.rb index cb44ceee..70fab408 100644 --- a/lib/vSphere/cap/snapshot_list.rb +++ b/lib/vSphere/cap/snapshot_list.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module VagrantPlugins module VSphere module Cap diff --git a/lib/vSphere/config.rb b/lib/vSphere/config.rb index 19d3efb5..de247907 100644 --- a/lib/vSphere/config.rb +++ b/lib/vSphere/config.rb @@ -1,36 +1,11 @@ +# frozen_string_literal: true + require 'vagrant' module VagrantPlugins module VSphere class Config < Vagrant.plugin('2', :config) - attr_accessor :ip_address_timeout # Time to wait for an IP address when booting, in seconds @return [Integer] - attr_accessor :host - attr_accessor :insecure - attr_accessor :user - attr_accessor :password - attr_accessor :data_center_name - attr_accessor :compute_resource_name - attr_accessor :resource_pool_name - attr_accessor :clone_from_vm - attr_accessor :template_name - attr_accessor :name - attr_accessor :vm_base_path - attr_accessor :customization_spec_name - attr_accessor :data_store_name - attr_accessor :linked_clone - attr_accessor :proxy_host - attr_accessor :proxy_port - attr_accessor :vlan - attr_accessor :addressType - attr_accessor :mac - attr_accessor :memory_mb - attr_accessor :cpu_count - attr_accessor :cpu_reservation - attr_accessor :mem_reservation - attr_accessor :extra_config - attr_accessor :real_nic_ip - attr_accessor :notes - attr_accessor :wait_for_sysprep + attr_accessor :ip_address_timeout, :host, :insecure, :user, :password, :data_center_name, :compute_resource_name, :resource_pool_name, :clone_from_vm, :template_name, :name, :vm_base_path, :customization_spec_name, :data_store_name, :linked_clone, :proxy_host, :proxy_port, :vlan, :addressType, :mac, :memory_mb, :cpu_count, :cpu_reservation, :mem_reservation, :extra_config, :real_nic_ip, :notes, :wait_for_sysprep # Time to wait for an IP address when booting, in seconds @return [Integer] attr_reader :custom_attributes @@ -53,9 +28,7 @@ def custom_attribute(key, value) def validate(machine) errors = _detected_errors - if password == :ask || password.nil? - self.password = machine.ui.ask('vSphere Password (will be hidden): ', echo: false) - end + self.password = machine.ui.ask('vSphere Password (will be hidden): ', echo: false) if password == :ask || password.nil? # TODO: add blank? errors << I18n.t('vsphere.config.host') if host.nil? diff --git a/lib/vSphere/errors.rb b/lib/vSphere/errors.rb index 0e7f9279..828fd42d 100644 --- a/lib/vSphere/errors.rb +++ b/lib/vSphere/errors.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'vagrant' module VagrantPlugins diff --git a/lib/vSphere/plugin.rb b/lib/vSphere/plugin.rb index d21ff127..54ae9026 100644 --- a/lib/vSphere/plugin.rb +++ b/lib/vSphere/plugin.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + begin require 'vagrant' rescue LoadError @@ -6,9 +8,7 @@ # This is a sanity check to make sure no one is attempting to install # this into an early Vagrant version. -if Vagrant::VERSION < '1.5' - fail 'The Vagrant vSphere plugin is only compatible with Vagrant 1.5+' -end +raise 'The Vagrant vSphere plugin is only compatible with Vagrant 1.5+' if Vagrant::VERSION < '1.5' module VagrantPlugins module VSphere @@ -36,14 +36,14 @@ class Plugin < Vagrant.plugin('2') end # TODO: Remove the if guard when Vagrant 1.8.0 is the minimum version. - # rubocop:disable IndentationWidth + # rubocop:disable Layout/IndentationWidth if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('1.8.0') provider_capability('vsphere', 'snapshot_list') do require_relative 'cap/snapshot_list' Cap::SnapshotList end end - # rubocop:enable IndentationWidth + # rubocop:enable Layout/IndentationWidth def self.setup_i18n I18n.load_path << File.expand_path('locales/en.yml', VSphere.source_root) diff --git a/lib/vSphere/provider.rb b/lib/vSphere/provider.rb index f30c48a4..f174dd3d 100644 --- a/lib/vSphere/provider.rb +++ b/lib/vSphere/provider.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'vagrant' module VagrantPlugins @@ -10,6 +12,7 @@ def initialize(machine) def action(name) action_method = "action_#{name}" return Action.send(action_method) if Action.respond_to?(action_method) + nil end diff --git a/lib/vSphere/util/vim_helpers.rb b/lib/vSphere/util/vim_helpers.rb index d23e3bb4..3d09fc4a 100644 --- a/lib/vSphere/util/vim_helpers.rb +++ b/lib/vSphere/util/vim_helpers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rbvmomi' module VagrantPlugins @@ -5,7 +7,7 @@ module VSphere module Util module VimHelpers def get_datacenter(connection, machine) - connection.serviceInstance.find_datacenter(machine.provider_config.data_center_name) || fail(Errors::VSphereError, :missing_datacenter) + connection.serviceInstance.find_datacenter(machine.provider_config.data_center_name) || raise(Errors::VSphereError, :missing_datacenter) end def get_vm_by_uuid(connection, machine) @@ -20,16 +22,18 @@ def get_resource_pool(datacenter, machine) entity_array = resource_pool_name.split('/') entity_array.each do |entity_array_item| next if entity_array_item.empty? - if rp.is_a? RbVmomi::VIM::Folder - rp = rp.childEntity.find { |f| f.name == entity_array_item } || fail(Errors::VSphereError, :missing_resource_pool) - elsif rp.is_a? RbVmomi::VIM::ClusterComputeResource - rp = rp.resourcePool.resourcePool.find { |f| f.name == entity_array_item } || fail(Errors::VSphereError, :missing_resource_pool) - elsif rp.is_a? RbVmomi::VIM::ResourcePool - rp = rp.resourcePool.find { |f| f.name == entity_array_item } || fail(Errors::VSphereError, :missing_resource_pool) - elsif rp.is_a? RbVmomi::VIM::ComputeResource - rp = rp.resourcePool.find(resource_pool_name) || fail(Errors::VSphereError, :missing_resource_pool) + + case rp + when RbVmomi::VIM::Folder + rp = rp.childEntity.find { |f| f.name == entity_array_item } || raise(Errors::VSphereError, :missing_resource_pool) + when RbVmomi::VIM::ClusterComputeResource + rp = rp.resourcePool.resourcePool.find { |f| f.name == entity_array_item } || raise(Errors::VSphereError, :missing_resource_pool) + when RbVmomi::VIM::ResourcePool + rp = rp.resourcePool.find { |f| f.name == entity_array_item } || raise(Errors::VSphereError, :missing_resource_pool) + when RbVmomi::VIM::ComputeResource + rp = rp.resourcePool.find(resource_pool_name) || raise(Errors::VSphereError, :missing_resource_pool) else - fail Errors::VSphereError, :missing_resource_pool + raise Errors::VSphereError, :missing_resource_pool end end rp = rp.resourcePool if !rp.is_a?(RbVmomi::VIM::ResourcePool) && rp.respond_to?(:resourcePool) @@ -38,19 +42,22 @@ def get_resource_pool(datacenter, machine) def get_compute_resource(datacenter, machine) cr = find_clustercompute_or_compute_resource(datacenter, machine.provider_config.compute_resource_name) - fail Errors::VSphereError, :missing_compute_resource if cr.nil? + raise Errors::VSphereError, :missing_compute_resource if cr.nil? + cr end def find_clustercompute_or_compute_resource(datacenter, path) - if path.is_a? String + case path + when String es = path.split('/').reject(&:empty?) - elsif path.is_a? Enumerable + when Enumerable es = path else - fail "unexpected path class #{path.class}" + raise "unexpected path class #{path.class}" end return datacenter.hostFolder if es.empty? + final = es.pop p = es.inject(datacenter.hostFolder) do |f, e| @@ -69,7 +76,7 @@ def find_clustercompute_or_compute_resource(datacenter, path) if x.is_a?(RbVmomi::VIM::ClusterComputeResource) || x.is_a?(RbVmomi::VIM::ComputeResource) x else - puts 'ex unknown type ' + x.to_json + puts "ex unknown type #{x.to_json}" nil end end @@ -80,10 +87,10 @@ def get_customization_spec_info_by_name(connection, machine) return if name.nil? || name.empty? manager = connection.serviceContent.customizationSpecManager - fail Errors::VSphereError, :null_configuration_spec_manager if manager.nil? + raise Errors::VSphereError, :null_configuration_spec_manager if manager.nil? spec = manager.GetCustomizationSpec(name: name) - fail Errors::VSphereError, :missing_configuration_spec if spec.nil? + raise Errors::VSphereError, :missing_configuration_spec if spec.nil? spec end @@ -93,11 +100,11 @@ def get_datastore(datacenter, machine) return if name.nil? || name.empty? # find_datastore uses folder datastore that only lists Datastore and not StoragePod, if not found also try datastoreFolder which contains StoragePod(s) - datacenter.find_datastore(name) || datacenter.datastoreFolder.traverse(name) || fail(Errors::VSphereError, :missing_datastore) + datacenter.find_datastore(name) || datacenter.datastoreFolder.traverse(name) || raise(Errors::VSphereError, :missing_datastore) end def get_network_by_name(dc, name) - dc.network.find { |f| f.name == name } || fail(Errors::VSphereError, :missing_vlan) + dc.network.find { |f| f.name == name } || raise(Errors::VSphereError, :missing_vlan) end end end diff --git a/lib/vSphere/util/vm_helpers.rb b/lib/vSphere/util/vm_helpers.rb index 7416f482..29dda7c3 100644 --- a/lib/vSphere/util/vm_helpers.rb +++ b/lib/vSphere/util/vm_helpers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rbvmomi' module VagrantPlugins @@ -55,11 +57,11 @@ def suspended?(vm) def enumerate_snapshots(vm) snapshot_info = vm.snapshot - if snapshot_info.nil? - snapshot_root = [] - else - snapshot_root = snapshot_info.rootSnapshotList - end + snapshot_root = if snapshot_info.nil? + [] + else + snapshot_info.rootSnapshotList + end recursor = lambda do |snapshot_list| Enumerator.new do |yielder| @@ -95,7 +97,8 @@ def create_snapshot(vm, name) task = vm.CreateSnapshot_Task( name: name, memory: false, - quiesce: false) + quiesce: false + ) if block_given? task.wait_for_progress do |progress| diff --git a/lib/vSphere/version.rb b/lib/vSphere/version.rb index e4d8ac2d..6ec84697 100644 --- a/lib/vSphere/version.rb +++ b/lib/vSphere/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module VagrantPlugins module VSphere VERSION = '1.14.0.pre1' diff --git a/lib/vagrant-vsphere.rb b/lib/vagrant-vsphere.rb index f880da1d..84f70677 100644 --- a/lib/vagrant-vsphere.rb +++ b/lib/vagrant-vsphere.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + require 'pathname' require 'vSphere/plugin' module VagrantPlugins module VSphere - lib_path = Pathname.new(File.expand_path('../vSphere', __FILE__)) + lib_path = Pathname.new(File.expand_path('vSphere', __dir__)) autoload :Action, lib_path.join('action') autoload :Errors, lib_path.join('errors') @@ -12,7 +14,7 @@ module VSphere # # @return [Pathname] def self.source_root - @source_root ||= Pathname.new(File.expand_path('../../', __FILE__)) + @source_root ||= Pathname.new(File.expand_path('..', __dir__)) end end end diff --git a/spec/action_spec.rb b/spec/action_spec.rb index 411de697..25d79774 100644 --- a/spec/action_spec.rb +++ b/spec/action_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'vagrant' diff --git a/spec/clone_spec.rb b/spec/clone_spec.rb index 7035f0c0..4e8ee53f 100644 --- a/spec/clone_spec.rb +++ b/spec/clone_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' CUSTOM_VM_FOLDER = 'custom_vm_folder' @@ -55,9 +57,8 @@ expect(@template).to have_received(:CloneVM_Task).with( folder: @data_center, name: NAME, - spec: { location: { pool: @child_resource_pool }, - config: expected_config - } + spec: { location: { pool: @child_resource_pool }, + config: expected_config } ) end @@ -102,10 +103,11 @@ it 'should set extraConfig if specified' do @machine.provider_config.stub(:extra_config).and_return( - 'guestinfo.hostname' => 'somehost.testvm') + 'guestinfo.hostname' => 'somehost.testvm' + ) expected_config = RbVmomi::VIM.VirtualMachineConfigSpec(extraConfig: [ - { 'key' => 'guestinfo.hostname', 'value' => 'somehost.testvm' } - ]) + { 'key' => 'guestinfo.hostname', 'value' => 'somehost.testvm' } + ]) call expect(@template).to have_received(:CloneVM_Task).with( diff --git a/spec/connect_vsphere_spec.rb b/spec/connect_vsphere_spec.rb index 1eea83da..dd644d2b 100644 --- a/spec/connect_vsphere_spec.rb +++ b/spec/connect_vsphere_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe VagrantPlugins::VSphere::Action::ConnectVSphere do diff --git a/spec/destroy_spec.rb b/spec/destroy_spec.rb index eec68375..aa3c74d9 100644 --- a/spec/destroy_spec.rb +++ b/spec/destroy_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe VagrantPlugins::VSphere::Action::Destroy do diff --git a/spec/get_ssh_info_spec.rb b/spec/get_ssh_info_spec.rb index f522c939..4a908b60 100644 --- a/spec/get_ssh_info_spec.rb +++ b/spec/get_ssh_info_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe VagrantPlugins::VSphere::Action::GetSshInfo do @@ -51,9 +53,7 @@ ipAddress: [double('NetIpConfigInfoIpAddress', ipAddress: 'bad address', state: 'unknown'), double('NetIpConfigInfoIpAddress', - ipAddress: '127.0.0.1', state: 'preferred')] - ) - ), + ipAddress: '127.0.0.1', state: 'preferred')])), double('GuestNicInfo', ipAddress: ['bad address', '255.255.255.255'], deviceConfigId: -1, @@ -61,10 +61,7 @@ ipAddress: [double('NetIpConfigInfoIpAddress', ipAddress: 'bad address', state: 'unknown'), double('NetIpConfigInfoIpAddress', - ipAddress: '255.255.255.255', state: 'preferred')] - ) - ) - ] + ipAddress: '255.255.255.255', state: 'preferred')]))] } end @@ -89,9 +86,7 @@ ipAddress: [double('NetIpConfigInfoIpAddress', ipAddress: 'bad address', state: 'unknown'), double('NetIpConfigInfoIpAddress', - ipAddress: '127.0.0.2', state: 'preferred')] - ) - ), + ipAddress: '127.0.0.2', state: 'preferred')])), double('GuestNicInfo', ipAddress: ['bad address', '255.255.255.255'], deviceConfigId: 2000, @@ -99,10 +94,7 @@ ipAddress: [double('NetIpConfigInfoIpAddress', ipAddress: 'bad address', state: 'unknown'), double('NetIpConfigInfoIpAddress', - ipAddress: '255.255.255.255', state: 'preferred')] - ) - ) - ] + ipAddress: '255.255.255.255', state: 'preferred')]))] } end diff --git a/spec/get_state_spec.rb b/spec/get_state_spec.rb index 8817ed9a..701a084c 100644 --- a/spec/get_state_spec.rb +++ b/spec/get_state_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'vSphere/util/vim_helpers' diff --git a/spec/is_created_spec.rb b/spec/is_created_spec.rb index eac1302d..e3c52214 100644 --- a/spec/is_created_spec.rb +++ b/spec/is_created_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'vSphere/action/is_created' diff --git a/spec/power_off_spec.rb b/spec/power_off_spec.rb index e661bf38..cd9652bc 100644 --- a/spec/power_off_spec.rb +++ b/spec/power_off_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe VagrantPlugins::VSphere::Action::PowerOff do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b0d9d188..cf2f7683 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rbvmomi' require 'pathname' require 'vSphere/errors' @@ -29,7 +31,7 @@ # removes deprecation warnings. # http://stackoverflow.com/questions/20275510/how-to-avoid-deprecation-warning-for-stub-chain-in-rspec-3-0/20296359#20296359 config.mock_with :rspec do |c| - c.syntax = [:should, :expect] + c.syntax = %i[should expect] end config.before(:each) do @@ -38,36 +40,37 @@ def call end provider_config = double( - host: 'testhost.com', - user: 'testuser', - password: 'testpassword', - data_center_name: nil, - compute_resource_name: 'testcomputeresource', - resource_pool_name: 'testresourcepool', - vm_base_path: nil, - template_name: TEMPLATE, - name: NAME, - insecure: true, - validate: [], - customization_spec_name: nil, - data_store_name: nil, - clone_from_vm: nil, - linked_clone: nil, - proxy_host: nil, - proxy_port: nil, - vlan: nil, - memory_mb: nil, - cpu_count: nil, - mac: nil, - addressType: nil, - cpu_reservation: nil, - mem_reservation: nil, - custom_attributes: {}, - notes: nil, - extra_config: {}, - ip_address_timeout: 1, - real_nic_ip: false, - wait_for_sysprep: false) + host: 'testhost.com', + user: 'testuser', + password: 'testpassword', + data_center_name: nil, + compute_resource_name: 'testcomputeresource', + resource_pool_name: 'testresourcepool', + vm_base_path: nil, + template_name: TEMPLATE, + name: NAME, + insecure: true, + validate: [], + customization_spec_name: nil, + data_store_name: nil, + clone_from_vm: nil, + linked_clone: nil, + proxy_host: nil, + proxy_port: nil, + vlan: nil, + memory_mb: nil, + cpu_count: nil, + mac: nil, + addressType: nil, + cpu_reservation: nil, + mem_reservation: nil, + custom_attributes: {}, + notes: nil, + extra_config: {}, + ip_address_timeout: 1, + real_nic_ip: false, + wait_for_sysprep: false + ) vm_config = double( vm: double('config_vm', box: nil, From 67774cb7b4e3bef4d7764e03e49a84138a9357cd Mon Sep 17 00:00:00 2001 From: Mike Laxer Date: Mon, 1 Aug 2022 14:20:03 -0600 Subject: [PATCH 10/12] Drop pre1 suffix from version --- CHANGELOG.md | 2 +- lib/vSphere/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab875cdb..b31f63b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [1.14.0 (2022-04-12)](https://github.com/nsidc/vagrant-vsphere/releases/tag/v1.14.0.pre1) +## [1.14.0 (2022-08-01)](https://github.com/nsidc/vagrant-vsphere/releases/tag/v1.14.0.pre1) - Update gem to ruby 3.0.2 - Support for vagrant >=2.2.17 diff --git a/lib/vSphere/version.rb b/lib/vSphere/version.rb index 6ec84697..14722df8 100644 --- a/lib/vSphere/version.rb +++ b/lib/vSphere/version.rb @@ -2,6 +2,6 @@ module VagrantPlugins module VSphere - VERSION = '1.14.0.pre1' + VERSION = '1.14.0' end end From d6b2445c0b386c36b4e6f852d6e31e9ac0bfad22 Mon Sep 17 00:00:00 2001 From: Mike Laxer Date: Mon, 1 Aug 2022 14:27:11 -0600 Subject: [PATCH 11/12] Drop pre1 suffix from version --- .bumpversion.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index baf5648d..8a19eafc 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.14.0.pre1 +current_version = 1.14.0 tag = true commit = true From bdbcdfe99da2adf39d2eb3f0cec591f7c457da37 Mon Sep 17 00:00:00 2001 From: Mike Laxer Date: Mon, 1 Aug 2022 19:15:31 -0600 Subject: [PATCH 12/12] Bump to 1.14.0 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0fd8d433..26a47527 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ This provider is built on top of the ## Current Version **version: 1.14.0.pre1** -vagrant-vsphere (**version: 1.14.0.pre1**) is available from +vagrant-vsphere (**version: 1.14.0**) is available from [RubyGems.org](https://rubygems.org/gems/vagrant-vsphere) ## Installation