vagrant-vsphere 1.13.3 → 1.14.0.pre1

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.
Files changed (54) hide show
  1. checksums.yaml +5 -5
  2. data/.bumpversion.cfg +2 -1
  3. data/.rubocop.yml +15 -0
  4. data/.ruby-version +1 -1
  5. data/.travis.yml +0 -7
  6. data/CHANGELOG.md +20 -0
  7. data/DEVELOPMENT.md +22 -0
  8. data/Gemfile +3 -1
  9. data/README.md +2 -2
  10. data/Rakefile +4 -2
  11. data/lib/vSphere/action/clone.rb +20 -19
  12. data/lib/vSphere/action/close_vsphere.rb +2 -0
  13. data/lib/vSphere/action/connect_vsphere.rb +2 -0
  14. data/lib/vSphere/action/destroy.rb +3 -0
  15. data/lib/vSphere/action/get_ssh_info.rb +7 -2
  16. data/lib/vSphere/action/get_state.rb +3 -1
  17. data/lib/vSphere/action/is_created.rb +2 -0
  18. data/lib/vSphere/action/is_running.rb +2 -0
  19. data/lib/vSphere/action/is_suspended.rb +2 -0
  20. data/lib/vSphere/action/message_already_created.rb +2 -0
  21. data/lib/vSphere/action/message_not_created.rb +2 -0
  22. data/lib/vSphere/action/message_not_running.rb +2 -0
  23. data/lib/vSphere/action/message_not_suspended.rb +2 -0
  24. data/lib/vSphere/action/power_off.rb +2 -0
  25. data/lib/vSphere/action/power_on.rb +2 -0
  26. data/lib/vSphere/action/resume.rb +2 -0
  27. data/lib/vSphere/action/snapshot_delete.rb +8 -4
  28. data/lib/vSphere/action/snapshot_list.rb +2 -0
  29. data/lib/vSphere/action/snapshot_restore.rb +5 -2
  30. data/lib/vSphere/action/snapshot_save.rb +8 -4
  31. data/lib/vSphere/action/suspend.rb +2 -0
  32. data/lib/vSphere/action/wait_for_ip_address.rb +2 -0
  33. data/lib/vSphere/action.rb +8 -6
  34. data/lib/vSphere/cap/public_address.rb +3 -0
  35. data/lib/vSphere/cap/snapshot_list.rb +2 -0
  36. data/lib/vSphere/config.rb +4 -31
  37. data/lib/vSphere/errors.rb +2 -0
  38. data/lib/vSphere/plugin.rb +5 -5
  39. data/lib/vSphere/provider.rb +3 -0
  40. data/lib/vSphere/util/vim_helpers.rb +26 -19
  41. data/lib/vSphere/util/vm_helpers.rb +9 -6
  42. data/lib/vSphere/version.rb +3 -1
  43. data/lib/vagrant-vsphere.rb +4 -2
  44. data/spec/action_spec.rb +2 -0
  45. data/spec/clone_spec.rb +8 -6
  46. data/spec/connect_vsphere_spec.rb +2 -0
  47. data/spec/destroy_spec.rb +2 -0
  48. data/spec/get_ssh_info_spec.rb +6 -14
  49. data/spec/get_state_spec.rb +2 -0
  50. data/spec/is_created_spec.rb +2 -0
  51. data/spec/power_off_spec.rb +2 -0
  52. data/spec/spec_helper.rb +35 -31
  53. data/vSphere.gemspec +8 -7
  54. metadata +22 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b3633d48c4a883aebd8a67cacf4716c8a58535f6
4
- data.tar.gz: 454d8aa650d41f7a746b5149a6c97cfdf2e07db3
2
+ SHA256:
3
+ metadata.gz: a2c2f3104d84ad0220c48752678d997a9a856527790961de1bf874c174f2ca91
4
+ data.tar.gz: d341a5d0d4c15da2376e33946fbcaca800e561e384d21677ce059522fe2255ca
5
5
  SHA512:
6
- metadata.gz: 6868a6f7ffcf83241298e5e21f3874d86eaf4794a488fee1a76fb52848e9d78c70c804a0c7bc9dba11a016d231262f485fd17984c2f27a660ac64819b05be8d2
7
- data.tar.gz: 7cce82f0a3b19656f7905d51d363e86685ab23da67f1844e7a374a7973cb4eca43908942a145bd5b9d79dc49e69596d47b1422e039f7a6a6fd49d0447b879323
6
+ metadata.gz: dcbcfa728e970b142bae1c3353ba6c87be4a4988586df400dc7a80c742bb53970de31650c2e62a287dde3c1aa295c43817f7436d326d26283e7b51711cbaa46e
7
+ data.tar.gz: 6567b087ba97251076ec7f282b48c1214d8c5e8d67aa3f0107316c33461a5cfd62937ad434ea5c43054e325123feb90a9f739892e313851174e4fe116a9f79b1
data/.bumpversion.cfg CHANGED
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 1.13.3
2
+ current_version = 1.14.0.pre1
3
3
  tag = true
4
4
  commit = true
5
5
 
@@ -8,3 +8,4 @@ commit = true
8
8
  [bumpversion:file:README.md]
9
9
  parse = version: (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
10
10
  serialize = version: {major}.{minor}.{patch}
11
+
data/.rubocop.yml CHANGED
@@ -32,3 +32,18 @@ Metrics/ModuleLength:
32
32
 
33
33
  Metrics/PerceivedComplexity:
34
34
  Enabled: false
35
+
36
+ # Disabled these cops upgrading rubocop to 1.25.0
37
+ # TODO:Correct the issues found by these cops someday
38
+ Lint/MissingSuper:
39
+ Enabled: false
40
+
41
+ Metrics/BlockLength:
42
+ Enabled: false
43
+
44
+ Naming:
45
+ Enabled: false
46
+
47
+ # TODO: Add required ruby version to gemspec
48
+ Gemspec/RequiredRubyVersion:
49
+ Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.5
1
+ ruby-3.0.2
data/.travis.yml CHANGED
@@ -1,11 +1,4 @@
1
1
  language: ruby
2
2
  cache: bundler
3
- rvm:
4
- - 2.3.5
5
-
6
- before_install:
7
- - rvm @global do gem uninstall bundler --all --executables
8
- - gem uninstall bundler --all --executables
9
- - gem install bundler --version '1.15.4'
10
3
 
11
4
  sudo: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## [1.14.0 (2022-04-12)](https://github.com/nsidc/vagrant-vsphere/releases/tag/v1.14.0.pre1)
2
+
3
+ - Update gem to ruby 3.0.2
4
+ - Support for vagrant >=2.2.17
5
+ - Update nokogiri dependency (1.13.4) to take care of dependabot alerts
6
+ - Update rbvmomi, rake, rubocop dependencies
7
+
8
+ ## [1.13.5 (2021-01-05)](https://github.com/nsidc/vagrant-vsphere/releases/tag/v1.13.5)
9
+ - Pin nokogiri to 1.10.10. This fixes an issue where vagrant-vsphere failed to install due to
10
+ nokogiri requiring Ruby >=2.5. This is a workaround until the vagrant-nsidc plugin is updated
11
+ to work with newer versions of vagrant that are bundled with newer versions of Ruby
12
+
13
+ ## [1.13.4 (2020-03-31)](https://github.com/nsidc/vagrant-vsphere/releases/tag/v1.13.4)
14
+
15
+ - Allow newer versions of i18n.
16
+ ([jmartin-r7:release-i18n](https://github.com/nsidc/vagrant-vsphere/pull/286))
17
+ - Updated .ruby-version to 2.6.5
18
+ - Fix broken tests.
19
+ ([wwestenbrink:master](https://github.com/nsidc/vagrant-vsphere/pull/283))
20
+
1
21
  ## [1.13.3 (2018-12-06)](https://github.com/nsidc/vagrant-vsphere/releases/tag/v1.13.3)
2
22
 
3
23
  - Update i18n dependency to allow v1.1.1. This fixes an issue with
data/DEVELOPMENT.md CHANGED
@@ -65,3 +65,25 @@ prefers to be run from the official installer rather than through the gem.
65
65
  Despite those warning messages, this is the
66
66
  [officially recommended](https://docs.vagrantup.com/v2/plugins/development-basics.html)
67
67
  method for Vagrant plugin development.
68
+
69
+ ### Releasing
70
+
71
+ 1) Ensure [travis-ci](https://travis-ci.org/github/nsidc/vagrant-vsphere/) build is passing
72
+ 2) Ensure `CHANGELOG.md` is up-to-date with the changes to release
73
+ 3) Update version in the code, according to [semver](https://semver.org/)
74
+ * [bumpversion](https://github.com/peritus/bumpversion) can be used; if not,
75
+ the version needs to be manually updated in `.bumpversion.cfg`,
76
+ `README.md`, and `lib/vSphere/version.rb` (e.g., as in
77
+ [`11eced2`](https://github.com/nsidc/vagrant-vsphere/commit/11eced2))
78
+ 4) `bundle exec rake build`
79
+ * builds the plugin to `pkg/vagrant-vsphere-$VERSION.gem`
80
+ * install to your system vagrant for further testing with `vagrant plugin
81
+ install ./pkg/vagrant-vsphere-$VERSION.gem`
82
+ 5) `bundle exec rake release`
83
+ * creates the version tag and pushes it to GitHub
84
+ * pushes the built gem to
85
+ [RubyGems.org](https://rubygems.org/gems/vagrant-vsphere/)
86
+ 6) Update the [Releases page](https://github.com/nsidc/vagrant-vsphere/releases)
87
+ * the release name should match the version tag (e.g., `v1.2.3`)
88
+ * the release description can be the same as the `CHANGELOG.md` entry
89
+ * upload the `.gem` from RubyGems.org as an attached binary for the release
data/Gemfile CHANGED
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'http://rubygems.org'
2
4
 
3
5
  group :development do
4
6
  # We depend on Vagrant for development, but we don't add it as a
5
7
  # gem dependency because we expect to be installed within the
6
8
  # Vagrant environment itself using `vagrant plugin`.
7
- gem 'vagrant', github: 'mitchellh/vagrant'
9
+ gem 'vagrant', github: 'mitchellh/vagrant', ref: 'v2.2.19'
8
10
  end
9
11
 
10
12
  group :plugins do
data/README.md CHANGED
@@ -19,9 +19,9 @@ This provider is built on top of the
19
19
  * libxml2, libxml2-dev, libxslt, libxslt-dev
20
20
 
21
21
  ## Current Version
22
- **version: 1.13.3**
22
+ **version: 1.14.0.pre1**
23
23
 
24
- vagrant-vsphere (**version: 1.13.3**) is available from
24
+ vagrant-vsphere (**version: 1.14.0.pre1**) is available from
25
25
  [RubyGems.org](https://rubygems.org/gems/vagrant-vsphere)
26
26
 
27
27
  ## Installation
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rubygems'
2
4
  require 'bundler/setup'
3
5
  require 'rspec/core/rake_task'
@@ -9,7 +11,7 @@ $stdout.sync = true
9
11
  $stderr.sync = true
10
12
 
11
13
  # Change to the directory of this file.
12
- Dir.chdir(File.expand_path('../', __FILE__))
14
+ Dir.chdir(File.expand_path(__dir__))
13
15
 
14
16
  Bundler::GemHelper.install_tasks
15
17
 
@@ -17,4 +19,4 @@ RSpec::Core::RakeTask.new
17
19
 
18
20
  RuboCop::RakeTask.new
19
21
 
20
- task default: %w(rubocop spec)
22
+ task default: %w[rubocop spec]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rbvmomi'
2
4
  require 'i18n'
3
5
  require 'vSphere/util/vim_helpers'
@@ -19,14 +21,15 @@ module VagrantPlugins
19
21
  name = get_name machine, config, env[:root_path]
20
22
  dc = get_datacenter connection, machine
21
23
  template = dc.find_vm config.template_name
22
- fail Errors::VSphereError, :'missing_template' if template.nil?
24
+ raise Errors::VSphereError, :'missing_template' if template.nil?
25
+
23
26
  vm_base_folder = get_vm_base_folder dc, template, config
24
- fail Errors::VSphereError, :'invalid_base_path' if vm_base_folder.nil?
27
+ raise Errors::VSphereError, :'invalid_base_path' if vm_base_folder.nil?
25
28
 
26
29
  begin
27
30
  # Storage DRS does not support vSphere linked clones. http://www.vmware.com/files/pdf/techpaper/vsphere-storage-drs-interoperability.pdf
28
31
  ds = get_datastore dc, machine
29
- fail Errors::VSphereError, :'invalid_configuration_linked_clone_with_sdrs' if config.linked_clone && ds.is_a?(RbVmomi::VIM::StoragePod)
32
+ raise Errors::VSphereError, :'invalid_configuration_linked_clone_with_sdrs' if config.linked_clone && ds.is_a?(RbVmomi::VIM::StoragePod)
30
33
 
31
34
  location = get_location ds, dc, machine, template
32
35
  spec = RbVmomi::VIM.VirtualMachineCloneSpec location: location, powerOn: true, template: false
@@ -74,9 +77,7 @@ module VagrantPlugins
74
77
 
75
78
  recommendation = result.recommendations[0]
76
79
  key = recommendation.key ||= ''
77
- if key == ''
78
- fail Errors::VSphereError, :missing_datastore_recommendation
79
- end
80
+ raise Errors::VSphereError, :missing_datastore_recommendation if key == ''
80
81
 
81
82
  env[:ui].info I18n.t('vsphere.creating_cloned_vm_sdrs')
82
83
  env[:ui].info " -- Storage DRS recommendation: #{recommendation.target.name} #{recommendation.reasonText}"
@@ -125,13 +126,13 @@ module VagrantPlugins
125
126
  while wait
126
127
  events = query_customization_succeeded(vm, vem)
127
128
 
128
- if events.size > 0
129
+ if events.size.positive?
129
130
  events.each do |e|
130
131
  env[:ui].info e.fullFormattedMessage
131
132
  end
132
133
  wait = false
133
134
  elsif waited_seconds >= timeout
134
- fail Errors::VSphereError, :'sysprep_timeout'
135
+ raise Errors::VSphereError, :'sysprep_timeout'
135
136
  else
136
137
  sleep(sleep_time)
137
138
  waited_seconds += sleep_time
@@ -154,7 +155,7 @@ module VagrantPlugins
154
155
  return customization_spec if private_networks.nil?
155
156
 
156
157
  # make sure we have enough NIC settings to override with the private network settings
157
- fail Errors::VSphereError, :'too_many_private_networks' if private_networks.length > customization_spec.nicSettingMap.length
158
+ raise Errors::VSphereError, :'too_many_private_networks' if private_networks.length > customization_spec.nicSettingMap.length
158
159
 
159
160
  # assign the private network IP to the NIC
160
161
  private_networks.each_index do |idx|
@@ -212,7 +213,7 @@ module VagrantPlugins
212
213
  return config.name unless config.name.nil?
213
214
 
214
215
  prefix = "#{root_path.basename}_#{machine.name}"
215
- prefix.gsub!(/[^-a-z0-9_\.]/i, '')
216
+ prefix.gsub!(/[^-a-z0-9_.]/i, '')
216
217
  # milliseconds + random number suffix to allow for simultaneous `vagrant up` of the same box in different dirs
217
218
  prefix + "_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100_000)}"
218
219
  end
@@ -229,7 +230,7 @@ module VagrantPlugins
229
230
  spec[:config][:deviceChange] ||= []
230
231
  @card ||= template.config.hardware.device.grep(RbVmomi::VIM::VirtualEthernetCard).first
231
232
 
232
- fail Errors::VSphereError, :missing_network_card if @card.nil?
233
+ raise Errors::VSphereError, :missing_network_card if @card.nil?
233
234
 
234
235
  yield(@card)
235
236
 
@@ -241,7 +242,7 @@ module VagrantPlugins
241
242
  def add_custom_address_type(template, spec, addressType)
242
243
  spec[:config][:deviceChange] = []
243
244
  config = template.config
244
- card = config.hardware.device.grep(RbVmomi::VIM::VirtualEthernetCard).first || fail(Errors::VSphereError, :missing_network_card)
245
+ card = config.hardware.device.grep(RbVmomi::VIM::VirtualEthernetCard).first || raise(Errors::VSphereError, :missing_network_card)
245
246
  card.addressType = addressType
246
247
  card_spec = { :deviceChange => [{ :operation => :edit, :device => card }] }
247
248
  template.ReconfigVM_Task(:spec => card_spec).wait_for_completion
@@ -257,13 +258,13 @@ module VagrantPlugins
257
258
  network = get_network_by_name(dc, vlan)
258
259
 
259
260
  modify_network_card(template, spec) do |card|
260
- begin
261
- switch_port = RbVmomi::VIM.DistributedVirtualSwitchPortConnection(switchUuid: network.config.distributedVirtualSwitch.uuid, portgroupKey: network.key)
262
- card.backing = RbVmomi::VIM::VirtualEthernetCardDistributedVirtualPortBackingInfo(port: switch_port)
263
- rescue
264
- # not connected to a distibuted switch?
265
- card.backing = RbVmomi::VIM::VirtualEthernetCardNetworkBackingInfo(network: network, deviceName: network.name)
266
- end
261
+
262
+ switch_port = RbVmomi::VIM.DistributedVirtualSwitchPortConnection(switchUuid: network.config.distributedVirtualSwitch.uuid, portgroupKey: network.key)
263
+ card.backing = RbVmomi::VIM::VirtualEthernetCardDistributedVirtualPortBackingInfo(port: switch_port)
264
+ rescue StandardError
265
+ # not connected to a distibuted switch?
266
+ card.backing = RbVmomi::VIM::VirtualEthernetCardNetworkBackingInfo(network: network, deviceName: network.name)
267
+
267
268
  end
268
269
  end
269
270
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rbvmomi'
2
4
 
3
5
  module VagrantPlugins
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rbvmomi'
2
4
 
3
5
  module VagrantPlugins
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rbvmomi'
2
4
  require 'i18n'
3
5
  require 'vSphere/util/vim_helpers'
@@ -23,6 +25,7 @@ module VagrantPlugins
23
25
 
24
26
  def destroy_vm(env)
25
27
  return if env[:machine].state.id == :not_created
28
+
26
29
  vm = get_vm_by_uuid env[:vSphere_connection], env[:machine]
27
30
  return if vm.nil?
28
31
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rbvmomi'
2
4
  require 'vSphere/util/vim_helpers'
3
5
 
@@ -21,12 +23,13 @@ module VagrantPlugins
21
23
  def filter_guest_nic(vm, machine)
22
24
  return vm.guest.ipAddress unless machine.provider_config.real_nic_ip
23
25
 
24
- interfaces = vm.guest.net.select { |g| g.deviceConfigId > 0 }
26
+ interfaces = vm.guest.net.select { |g| g.deviceConfigId.positive? }
25
27
  ip_addresses = interfaces.map { |i| i.ipConfig.ipAddress.select { |a| a.state == 'preferred' } }.flatten
26
28
 
27
29
  return (vm.guest.ipAddress || nil) if ip_addresses.empty?
28
30
 
29
- fail Errors::VSphereError.new, :'multiple_interface_with_real_nic_ip_set' if ip_addresses.size > 1
31
+ raise Errors::VSphereError.new, :'multiple_interface_with_real_nic_ip_set' if ip_addresses.size > 1
32
+
30
33
  ip_addresses.first.ipAddress
31
34
  end
32
35
 
@@ -35,8 +38,10 @@ module VagrantPlugins
35
38
 
36
39
  vm = get_vm_by_uuid connection, machine
37
40
  return nil if vm.nil?
41
+
38
42
  ip_address = filter_guest_nic(vm, machine)
39
43
  return nil if ip_address.nil? || ip_address.empty?
44
+
40
45
  {
41
46
  host: ip_address,
42
47
  port: 22
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rbvmomi'
2
4
  require 'vSphere/util/vim_helpers'
3
5
  require 'vSphere/util/vm_helpers'
@@ -22,7 +24,7 @@ module VagrantPlugins
22
24
  private
23
25
 
24
26
  def get_state(connection, machine)
25
- return :not_created if machine.id.nil?
27
+ return :not_created if machine.id.nil?
26
28
 
27
29
  vm = get_vm_by_uuid connection, machine
28
30
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module VagrantPlugins
2
4
  module VSphere
3
5
  module Action
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module VagrantPlugins
2
4
  module VSphere
3
5
  module Action
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module VagrantPlugins
2
4
  module VSphere
3
5
  module Action
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'i18n'
2
4
 
3
5
  module VagrantPlugins
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'i18n'
2
4
 
3
5
  module VagrantPlugins
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'i18n'
2
4
 
3
5
  module VagrantPlugins
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'i18n'
2
4
 
3
5
  module VagrantPlugins
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rbvmomi'
2
4
  require 'i18n'
3
5
  require 'vSphere/util/vim_helpers'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rbvmomi'
2
4
  require 'i18n'
3
5
  require 'vSphere/util/vim_helpers'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rbvmomi'
2
4
  require 'i18n'
3
5
  require 'vSphere/util/vim_helpers'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'vSphere/util/vim_helpers'
2
4
  require 'vSphere/util/vm_helpers'
3
5
 
@@ -16,8 +18,9 @@ module VagrantPlugins
16
18
  vm = get_vm_by_uuid(env[:vSphere_connection], env[:machine])
17
19
 
18
20
  env[:ui].info(I18n.t(
19
- "vagrant.actions.vm.snapshot.deleting",
20
- name: env[:snapshot_name]))
21
+ "vagrant.actions.vm.snapshot.deleting",
22
+ name: env[:snapshot_name]
23
+ ))
21
24
 
22
25
  delete_snapshot(vm, env[:snapshot_name]) do |progress|
23
26
  env[:ui].clear_line
@@ -27,8 +30,9 @@ module VagrantPlugins
27
30
  env[:ui].clear_line
28
31
 
29
32
  env[:ui].info(I18n.t(
30
- "vagrant.actions.vm.snapshot.deleted",
31
- name: env[:snapshot_name]))
33
+ "vagrant.actions.vm.snapshot.deleted",
34
+ name: env[:snapshot_name]
35
+ ))
32
36
 
33
37
  @app.call env
34
38
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'vSphere/util/vim_helpers'
2
4
  require 'vSphere/util/vm_helpers'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'vSphere/util/vim_helpers'
2
4
  require 'vSphere/util/vm_helpers'
3
5
 
@@ -16,8 +18,9 @@ module VagrantPlugins
16
18
  vm = get_vm_by_uuid(env[:vSphere_connection], env[:machine])
17
19
 
18
20
  env[:ui].info(I18n.t(
19
- "vagrant.actions.vm.snapshot.restoring",
20
- name: env[:snapshot_name]))
21
+ "vagrant.actions.vm.snapshot.restoring",
22
+ name: env[:snapshot_name]
23
+ ))
21
24
 
22
25
  restore_snapshot(vm, env[:snapshot_name]) do |progress|
23
26
  env[:ui].clear_line
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'vSphere/util/vim_helpers'
2
4
  require 'vSphere/util/vm_helpers'
3
5
 
@@ -16,8 +18,9 @@ module VagrantPlugins
16
18
  vm = get_vm_by_uuid(env[:vSphere_connection], env[:machine])
17
19
 
18
20
  env[:ui].info(I18n.t(
19
- "vagrant.actions.vm.snapshot.saving",
20
- name: env[:snapshot_name]))
21
+ "vagrant.actions.vm.snapshot.saving",
22
+ name: env[:snapshot_name]
23
+ ))
21
24
 
22
25
  create_snapshot(vm, env[:snapshot_name]) do |progress|
23
26
  env[:ui].clear_line
@@ -27,8 +30,9 @@ module VagrantPlugins
27
30
  env[:ui].clear_line
28
31
 
29
32
  env[:ui].success(I18n.t(
30
- "vagrant.actions.vm.snapshot.saved",
31
- name: env[:snapshot_name]))
33
+ "vagrant.actions.vm.snapshot.saved",
34
+ name: env[:snapshot_name]
35
+ ))
32
36
  @app.call env
33
37
  end
34
38
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rbvmomi'
2
4
  require 'i18n'
3
5
  require 'vSphere/util/vim_helpers'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ipaddr'
2
4
  require 'timeout'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'vagrant'
2
4
  require 'vagrant/action/builder'
3
5
 
@@ -224,7 +226,7 @@ module VagrantPlugins
224
226
  end
225
227
 
226
228
  # TODO: Remove the if guard when Vagrant 1.8.0 is the minimum version.
227
- # rubocop:disable IndentationWidth
229
+ # rubocop:disable Layout/IndentationWidth
228
230
  if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('1.8.0')
229
231
  def self.action_snapshot_delete
230
232
  Vagrant::Action::Builder.new.tap do |b|
@@ -292,11 +294,11 @@ module VagrantPlugins
292
294
  b.use CloseVSphere
293
295
  end
294
296
  end
295
- end # Vagrant > 1.8.0 guard
296
- # rubocop:enable IndentationWidth
297
+ end
298
+ # rubocop:enable Layout/IndentationWidth
297
299
 
298
300
  # autoload
299
- action_root = Pathname.new(File.expand_path('../action', __FILE__))
301
+ action_root = Pathname.new(File.expand_path('action', __dir__))
300
302
  autoload :Clone, action_root.join('clone')
301
303
  autoload :CloseVSphere, action_root.join('close_vsphere')
302
304
  autoload :ConnectVSphere, action_root.join('connect_vsphere')
@@ -317,14 +319,14 @@ module VagrantPlugins
317
319
  autoload :WaitForIPAddress, action_root.join('wait_for_ip_address')
318
320
 
319
321
  # TODO: Remove the if guard when Vagrant 1.8.0 is the minimum version.
320
- # rubocop:disable IndentationWidth
322
+ # rubocop:disable Layout/IndentationWidth
321
323
  if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('1.8.0')
322
324
  autoload :SnapshotDelete, action_root.join('snapshot_delete')
323
325
  autoload :SnapshotList, action_root.join('snapshot_list')
324
326
  autoload :SnapshotRestore, action_root.join('snapshot_restore')
325
327
  autoload :SnapshotSave, action_root.join('snapshot_save')
326
328
  end
327
- # rubocop:enable IndentationWidth
329
+ # rubocop:enable Layout/IndentationWidth
328
330
  end
329
331
  end
330
332
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module VagrantPlugins
2
4
  module VSphere
3
5
  module Cap
@@ -7,6 +9,7 @@ module VagrantPlugins
7
9
 
8
10
  ssh_info = machine.ssh_info
9
11
  return nil unless ssh_info
12
+
10
13
  ssh_info[:host]
11
14
  end
12
15
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module VagrantPlugins
2
4
  module VSphere
3
5
  module Cap
@@ -1,36 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'vagrant'
2
4
 
3
5
  module VagrantPlugins
4
6
  module VSphere
5
7
  class Config < Vagrant.plugin('2', :config)
6
- attr_accessor :ip_address_timeout # Time to wait for an IP address when booting, in seconds @return [Integer]
7
- attr_accessor :host
8
- attr_accessor :insecure
9
- attr_accessor :user
10
- attr_accessor :password
11
- attr_accessor :data_center_name
12
- attr_accessor :compute_resource_name
13
- attr_accessor :resource_pool_name
14
- attr_accessor :clone_from_vm
15
- attr_accessor :template_name
16
- attr_accessor :name
17
- attr_accessor :vm_base_path
18
- attr_accessor :customization_spec_name
19
- attr_accessor :data_store_name
20
- attr_accessor :linked_clone
21
- attr_accessor :proxy_host
22
- attr_accessor :proxy_port
23
- attr_accessor :vlan
24
- attr_accessor :addressType
25
- attr_accessor :mac
26
- attr_accessor :memory_mb
27
- attr_accessor :cpu_count
28
- attr_accessor :cpu_reservation
29
- attr_accessor :mem_reservation
30
- attr_accessor :extra_config
31
- attr_accessor :real_nic_ip
32
- attr_accessor :notes
33
- attr_accessor :wait_for_sysprep
8
+ 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]
34
9
 
35
10
  attr_reader :custom_attributes
36
11
 
@@ -53,9 +28,7 @@ module VagrantPlugins
53
28
  def validate(machine)
54
29
  errors = _detected_errors
55
30
 
56
- if password == :ask || password.nil?
57
- self.password = machine.ui.ask('vSphere Password (will be hidden): ', echo: false)
58
- end
31
+ self.password = machine.ui.ask('vSphere Password (will be hidden): ', echo: false) if password == :ask || password.nil?
59
32
 
60
33
  # TODO: add blank?
61
34
  errors << I18n.t('vsphere.config.host') if host.nil?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'vagrant'
2
4
 
3
5
  module VagrantPlugins