vagrant-vmware-desktop 3.0.3 → 3.0.4

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
  SHA256:
3
- metadata.gz: a3275e668f048933faaa0b580297af432a0d64c88c0f810ba268cf010b5cf5fe
4
- data.tar.gz: 72947322a3dbd3acd97879175f958b820c93df2bcbc683006888346c75c4262f
3
+ metadata.gz: faa4d46aabdc2dfaf78c6c69cf57c3fd2b447192b78495333a1f73e1190d3ddc
4
+ data.tar.gz: 9113eb7729d89bfaf3bb288f6fed490297d117ab20e196f0ea55b86c36f84211
5
5
  SHA512:
6
- metadata.gz: c4a440f8e4e435ae93631aec1f91991079ac0247ed8506f009c915df69cf6c99fc9d11cfcb3d7d51fe0cd4de27f3e2c86c6a3957442cf7234e2b569a3523fcdc
7
- data.tar.gz: ede75391f769645cc913e409042bd80c92718ec54f402af530974561f6bae90e9277152b9a8426df30d89d395e8171d3f93afe0278291c0b1299080f7d0b544a
6
+ metadata.gz: 061b173c5a4d767ec3e8c27144487e85f79b538fa6828443c3068564c1886d2ec750a5cfad57e8e397c41c08cc86a894092462f0e6b0443ff8d3dd5ec5d00b4b
7
+ data.tar.gz: 6e749f952549f49419af194a2e889d2c22861d254ea9cdefb0544c5450bb57f111e6f447a54427802815420875d923a4c5bebf6eb0c331dc42002eec8bac9f91
@@ -361,10 +361,8 @@ module HashiCorp
361
361
  b3.use SetHostname
362
362
  end
363
363
 
364
- Vagrant::Util::Experimental.guard_with(:disks) do
365
- b3.use CleanupDisks
366
- b3.use Disk
367
- end
364
+ b3.use CleanupDisks
365
+ b3.use Disk
368
366
  b3.use VMXModify
369
367
  b3.use PrepareForwardedPortCollisionParams
370
368
  b3.use HandleForwardedPortCollisions
@@ -12,7 +12,7 @@ module HashiCorp
12
12
  @@logger = Log4r::Logger.new("hashicorp::provider::vmware::cap::disk")
13
13
 
14
14
  DEFAULT_DISK_EXT = "vmdk".freeze
15
- BUS_TYPES = ["sata", "ide", "scsi"].map(&:freeze).freeze
15
+ BUS_TYPES = ["nvme", "sata", "ide", "scsi"].map(&:freeze).freeze
16
16
  DEFAULT_BUS = "scsi".freeze
17
17
  DEFAULT_DVD_BUS = "ide".freeze
18
18
  DEFAULT_DVD_DEVICE_TYPE = "cdrom-image"
@@ -28,7 +28,7 @@ module HashiCorp
28
28
  # 5 : compressed disk optimized for streaming
29
29
  # 6 : thin provisioned virtual disk - ESX 3.x and above
30
30
  DEFAULT_DISK_TYPE = 0.freeze
31
- PRIMARY_DISK_SLOT = "scsi0:0".freeze
31
+ PRIMARY_DISK_SLOTS = ["scsi0:0", "sata0:0", "ide0:0"].map(&:freeze).freeze
32
32
 
33
33
  def self.set_default_disk_ext(machine)
34
34
  DEFAULT_DISK_EXT
@@ -112,7 +112,11 @@ module HashiCorp
112
112
  # @return [Hash, nil] - A hash of the current disk, nil if not found
113
113
  def self.get_disk(disk, all_disks)
114
114
  if disk.primary
115
- return all_disks[PRIMARY_DISK_SLOT]
115
+ PRIMARY_DISK_SLOTS.each do |primary_slot|
116
+ disk_info = all_disks[primary_slot]
117
+ @@logger.debug("disk info for primary slot #{primary_slot} - #{disk_info}")
118
+ return disk_info if disk_info["present"].to_s.upcase == "TRUE"
119
+ end
116
120
  else
117
121
  if disk.type == :dvd
118
122
  all_disks.values.detect { |v| v["filename"] == disk.file }
@@ -153,7 +157,12 @@ module HashiCorp
153
157
 
154
158
  # disk.size is in bytes
155
159
  if disk.size > machine.provider.driver.get_disk_size(disk_path)
156
- grow_disk(machine, disk_path, disk)
160
+ if disk.primary && machine.provider.driver.is_linked_clone?
161
+ machine.env.ui.warn(I18n.t("hashicorp.vagrant_vmware_desktop.disk_not_growing_linked_primary"))
162
+ @@logger.warn("Not growing primary disk - guest is linked clone")
163
+ else
164
+ grow_disk(machine, disk_path, disk)
165
+ end
157
166
  elsif disk.size < machine.provider.driver.get_disk_size(disk_path)
158
167
  machine.env.ui.warn(I18n.t("hashicorp.vagrant_vmware_desktop.disk_not_shrinking", path: disk.name))
159
168
  @@logger.warn("Not shrinking disk #{disk.name}")
@@ -586,6 +586,43 @@ module HashiCorp
586
586
  def read_ip(enable_vmrun_ip_lookup=true)
587
587
  @logger.info("Reading an accessible IP for machine...")
588
588
 
589
+ if enable_vmrun_ip_lookup
590
+ # Try to read the IP using vmrun getGuestIPAddress. This
591
+ # won't work if the guest doesn't have guest tools installed or
592
+ # is using an old version of VMware.
593
+ begin
594
+ @logger.info("Trying vmrun getGuestIPAddress...")
595
+ result = vmrun("getGuestIPAddress", host_vmx_path, "-wait", {timeout: 10, retryable: true})
596
+ result = result.stdout.chomp
597
+
598
+ # If returned address ends with a ".1" do not accept address
599
+ # and allow lookup via VMX.
600
+ # see: https://github.com/vmware/open-vm-tools/issues/93
601
+ if result.end_with?(".1")
602
+ @logger.warn("vmrun getGuestIPAddress returned: #{result}. Result resembles address retrieval from wrong " \
603
+ "interface. Discarding value and proceeding with VMX based lookup.")
604
+ result = nil
605
+ else
606
+ # Try to parse the IP Address. This will raise an exception
607
+ # if it fails, which will halt our attempt to use it.
608
+ IPAddr.new(result)
609
+ @logger.info("vmrun getGuestIPAddress success: #{result}")
610
+ return result
611
+ end
612
+ rescue Errors::VMRunError
613
+ @logger.info("vmrun getGuestIPAddress failed: VMRunError")
614
+ # Ignore, try the MAC address way.
615
+ rescue Vagrant::Util::Subprocess::TimeoutExceeded
616
+ @logger.info("vmrun getGuestIPAddress failed: TimeoutExceeded")
617
+ # Ignore, try the MAC address way.
618
+ rescue IPAddr::InvalidAddressError
619
+ @logger.info("vmrun getGuestIPAddress failed: InvalidAddressError for #{result.inspect}")
620
+ # Ignore, try the MAC address way.
621
+ end
622
+ else
623
+ @logger.info("Skipping vmrun getGuestIPAddress as requested by config.")
624
+ end
625
+
589
626
  # NOTE: Read from DHCP leases first so we can attempt to fetch the address
590
627
  # for the vmnet8 device first. If multiple networks are defined on the guest
591
628
  # it will return the address of the last device, which will fail when doing
@@ -628,39 +665,6 @@ module HashiCorp
628
665
  return dhcp_ip if dhcp_ip
629
666
  end
630
667
 
631
- if enable_vmrun_ip_lookup
632
- # Try to read the IP using vmrun getGuestIPAddress. This
633
- # won't work if the guest doesn't have guest tools installed or
634
- # is using an old version of VMware.
635
- begin
636
- @logger.info("Trying vmrun getGuestIPAddress...")
637
- result = vmrun("getGuestIPAddress", host_vmx_path)
638
- result = result.stdout.chomp
639
-
640
- # If returned address ends with a ".1" do not accept address
641
- # and allow lookup via VMX.
642
- # see: https://github.com/vmware/open-vm-tools/issues/93
643
- if result.end_with?(".1")
644
- @logger.warn("vmrun getGuestIPAddress returned: #{result}. Result resembles address retrieval from wrong " \
645
- "interface. Discarding value and proceeding with VMX based lookup.")
646
- result = nil
647
- else
648
- # Try to parse the IP Address. This will raise an exception
649
- # if it fails, which will halt our attempt to use it.
650
- IPAddr.new(result)
651
- @logger.info("vmrun getGuestIPAddress success: #{result}")
652
- return result
653
- end
654
- rescue Errors::VMRunError
655
- @logger.info("vmrun getGuestIPAddress failed: VMRunError")
656
- # Ignore, try the MAC address way.
657
- rescue IPAddr::InvalidAddressError
658
- @logger.info("vmrun getGuestIPAddress failed: InvalidAddressError for #{result.inspect}")
659
- # Ignore, try the MAC address way.
660
- end
661
- else
662
- @logger.info("Skipping vmrun getGuestIPAddress as requested by config.")
663
- end
664
668
  nil
665
669
  end
666
670
 
@@ -1189,6 +1193,32 @@ module HashiCorp
1189
1193
  disk_size
1190
1194
  end
1191
1195
 
1196
+ # @return [Boolean] Instance is a linked clone
1197
+ def is_linked_clone?
1198
+ if @vmsd_path.nil?
1199
+ @vm_dir.children(true).each do |child|
1200
+ if child.basename.to_s.match(/\.vmsd$/)
1201
+ @vmsd_path = child
1202
+ end
1203
+ end
1204
+ end
1205
+
1206
+ return false if @vmsd_path.nil?
1207
+
1208
+ if @is_clone.nil?
1209
+ @is_clone = false
1210
+
1211
+ File.readlines(@vmsd_path).each do |line|
1212
+ if line.start_with?("cloneOf")
1213
+ @is_clone = true
1214
+ break
1215
+ end
1216
+ end
1217
+ end
1218
+
1219
+ @is_clone
1220
+ end
1221
+
1192
1222
  protected
1193
1223
 
1194
1224
  # This reads the latest DHCP lease for a MAC address on the
@@ -1271,6 +1301,10 @@ module HashiCorp
1271
1301
  end
1272
1302
  result = Vagrant::Util::Subprocess.execute(r_path, *command)
1273
1303
  if result.exit_code != 0
1304
+ if result.stdout.include?("operation was canceled") || result.stderr.include?("operation was canceled")
1305
+ raise_canceled_error!
1306
+ end
1307
+
1274
1308
  raise Errors::VMExecError,
1275
1309
  :executable => executable.to_s,
1276
1310
  :command => command.inspect,
@@ -1352,7 +1386,6 @@ module HashiCorp
1352
1386
  end
1353
1387
  end
1354
1388
 
1355
-
1356
1389
  # This performs common cleanup tasks on a cloned machine.
1357
1390
  def clone_cleanup(destination_vmx)
1358
1391
  destination = destination_vmx.parent
@@ -1380,6 +1413,45 @@ module HashiCorp
1380
1413
  destination_vmx
1381
1414
  end
1382
1415
 
1416
+ # Attempts to extract cause of a vmware canceled operation
1417
+ # by inspecting the vmware.log file for failure information.
1418
+ # If found, an exception will be raised. Otherwise, nothing
1419
+ # will be raised.
1420
+ def raise_canceled_error!
1421
+ vmware_log = @vm_dir.join("vmware.log")
1422
+ return if !vmware_log.exist?
1423
+ error_lines = []
1424
+ found = false
1425
+ File.open(vmware_log.to_s) do |file|
1426
+ until file.eof?
1427
+ line = file.readline.chomp
1428
+ if found
1429
+ break if line.include?("-----------------")
1430
+ error_lines << line
1431
+ next
1432
+ end
1433
+
1434
+ if line.include?("Msg_Post: Error")
1435
+ found = true
1436
+ end
1437
+ end
1438
+ end
1439
+
1440
+ # If error content wasn't found, just return
1441
+ return if !found
1442
+
1443
+ # If the size of the content is unreasonably large, just return
1444
+ return if error_lines.size > 10
1445
+
1446
+ error_lines.map! do |line|
1447
+ line.sub(/^.*? vmx \[.*?\] /, "")
1448
+ end
1449
+
1450
+ raise Errors::VMCancelError,
1451
+ error: error_lines.join("\n"),
1452
+ vmware_log_path: vmware_log.to_s
1453
+ end
1454
+
1383
1455
  # Display warning message about allowlisted VMX ethernet settings
1384
1456
  def display_ethernet_allowlist_warning(vmx_key, vmx_val)
1385
1457
  if VMX_ETHERNET_ALLOWLIST_ENFORCE != :quiet
@@ -263,6 +263,10 @@ module HashiCorp
263
263
  error_key(:vmnet_no_ipv6)
264
264
  end
265
265
 
266
+ class VMCancelError < Base
267
+ error_key(:vmcancel_error)
268
+ end
269
+
266
270
  class VMExecError < Base
267
271
  error_key(:vmexec_error)
268
272
  end
@@ -119,7 +119,7 @@ module HashiCorp
119
119
  current_mount_point = "#{VAGRANT_ROOT_MOUNT_POINT}/#{uid}-#{gid}"
120
120
  hgfs_mount_options = "allow_other,default_permissions,uid=#{uid},gid=#{gid}"
121
121
  hgfs_mount_options << ",#{options[:extra]}" if options[:extra]
122
- hgfs_mount_options << ",#{options[:mount_options].join(',')}" if options[:mount_options]
122
+ hgfs_mount_options << ",#{Array(options[:mount_options]).join(',')}" if !Array(options[:mount_options]).empty?
123
123
  hgfs_mount = "vmhgfs-fuse -o #{hgfs_mount_options} .host:/ '#{current_mount_point}'"
124
124
 
125
125
  # Allow user to disable unmounting of default vmhgfs-fuse mount point at /mnt/hgfs
@@ -99,26 +99,24 @@ module HashiCorp
99
99
  Cap::Provider
100
100
  end
101
101
 
102
- Vagrant::Util::Experimental.guard_with(:disks) do
103
- provider_capability(p_name, :set_default_disk_ext) do
104
- require File.expand_path("../cap/disk", __FILE__)
105
- Cap::Disk
106
- end
107
-
108
- provider_capability(p_name, :default_disk_exts) do
109
- require File.expand_path("../cap/disk", __FILE__)
110
- Cap::Disk
111
- end
112
-
113
- provider_capability(p_name, :configure_disks) do
114
- require File.expand_path("../cap/disk", __FILE__)
115
- Cap::Disk
116
- end
117
-
118
- provider_capability(p_name, :cleanup_disks) do
119
- require File.expand_path("../cap/disk", __FILE__)
120
- Cap::Disk
121
- end
102
+ provider_capability(p_name, :set_default_disk_ext) do
103
+ require File.expand_path("../cap/disk", __FILE__)
104
+ Cap::Disk
105
+ end
106
+
107
+ provider_capability(p_name, :default_disk_exts) do
108
+ require File.expand_path("../cap/disk", __FILE__)
109
+ Cap::Disk
110
+ end
111
+
112
+ provider_capability(p_name, :configure_disks) do
113
+ require File.expand_path("../cap/disk", __FILE__)
114
+ Cap::Disk
115
+ end
116
+
117
+ provider_capability(p_name, :cleanup_disks) do
118
+ require File.expand_path("../cap/disk", __FILE__)
119
+ Cap::Disk
122
120
  end
123
121
  end
124
122
 
data/locales/en.yml CHANGED
@@ -16,6 +16,9 @@ en:
16
16
  Configuring network adapters within the VM...
17
17
  destroying: |-
18
18
  Deleting the VM...
19
+ disk_not_growing_linked_primary: |-
20
+ Increasing the size of the primary disk is not allowed for linked
21
+ clones. Primary disk of the guest remains unchanged.
19
22
  disk_not_shrinking: |-
20
23
  Shrinking disks is not supported. Not shrinking disk %{path}
21
24
  discarding_suspended_state: |-
@@ -485,6 +488,15 @@ en:
485
488
  The VMware product does not support IPv6 in a robust way like other
486
489
  Vagrant providers. This is not a bug in Vagrant - the upstream
487
490
  provider does not provide robust support for IPv6.
491
+ vmcancel_error: |-
492
+ An error occurred causing VMware to cancel the current operation. Details
493
+ of the error causing the cancelation:
494
+
495
+ %{error}
496
+
497
+ The full log can be located at:
498
+
499
+ %{vmware_log_path}
488
500
  vmexec_error: |-
489
501
  An error occurred while executing `%{executable}`, a utility for controlling
490
502
  VMware machines. The command and output are below:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-vmware-desktop
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vagrant Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-16 00:00:00.000000000 Z
11
+ date: 2024-08-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Enables Vagrant to power VMware Workstation/Fusion machines.
14
14
  email: vagrant@hashicorp.com
@@ -95,8 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.3.6
97
97
  requirements: []
98
- rubyforge_project:
99
- rubygems_version: 2.7.6
98
+ rubygems_version: 3.5.11
100
99
  signing_key:
101
100
  specification_version: 4
102
101
  summary: Enables Vagrant to power VMware Workstation/Fusion machines.