Module: HashiCorp::VagrantVMwareDesktop

Defined in:
lib/vagrant-vmware-desktop.rb,
lib/vagrant-vmware-desktop/action.rb,
lib/vagrant-vmware-desktop/config.rb,
lib/vagrant-vmware-desktop/driver.rb,
lib/vagrant-vmware-desktop/errors.rb,
lib/vagrant-vmware-desktop/plugin.rb,
lib/vagrant-vmware-desktop/cap/disk.rb,
lib/vagrant-vmware-desktop/provider.rb,
lib/vagrant-vmware-desktop/constants.rb,
lib/vagrant-vmware-desktop/action/boot.rb,
lib/vagrant-vmware-desktop/action/halt.rb,
lib/vagrant-vmware-desktop/driver/base.rb,
lib/vagrant-vmware-desktop/helper/lock.rb,
lib/vagrant-vmware-desktop/cap/provider.rb,
lib/vagrant-vmware-desktop/cap/snapshot.rb,
lib/vagrant-vmware-desktop/setup_plugin.rb,
lib/vagrant-vmware-desktop/action/common.rb,
lib/vagrant-vmware-desktop/action/export.rb,
lib/vagrant-vmware-desktop/action/import.rb,
lib/vagrant-vmware-desktop/synced_folder.rb,
lib/vagrant-vmware-desktop/action/created.rb,
lib/vagrant-vmware-desktop/action/destroy.rb,
lib/vagrant-vmware-desktop/action/network.rb,
lib/vagrant-vmware-desktop/action/running.rb,
lib/vagrant-vmware-desktop/action/suspend.rb,
lib/vagrant-vmware-desktop/action/suspended.rb,
lib/vagrant-vmware-desktop/action/checkpoint.rb,
lib/vagrant-vmware-desktop/action/vmx_modify.rb,
lib/vagrant-vmware-desktop/checkpoint_client.rb,
lib/vagrant-vmware-desktop/action/check_vmware.rb,
lib/vagrant-vmware-desktop/action/machine_lock.rb,
lib/vagrant-vmware-desktop/action/compatibility.rb,
lib/vagrant-vmware-desktop/action/forward_ports.rb,
lib/vagrant-vmware-desktop/action/share_folders.rb,
lib/vagrant-vmware-desktop/action/snapshot_save.rb,
lib/vagrant-vmware-desktop/helper/routing_table.rb,
lib/vagrant-vmware-desktop/action/base_mac_to_ip.rb,
lib/vagrant-vmware-desktop/action/snapshot_delete.rb,
lib/vagrant-vmware-desktop/helper/vagrant_utility.rb,
lib/vagrant-vmware-desktop/action/set_display_name.rb,
lib/vagrant-vmware-desktop/action/snapshot_restore.rb,
lib/vagrant-vmware-desktop/action/wait_for_address.rb,
lib/vagrant-vmware-desktop/action/prune_nfs_exports.rb,
lib/vagrant-vmware-desktop/action/wait_for_vmx_halt.rb,
lib/vagrant-vmware-desktop/action/fix_old_machine_id.rb,
lib/vagrant-vmware-desktop/action/message_not_created.rb,
lib/vagrant-vmware-desktop/action/message_not_running.rb,
lib/vagrant-vmware-desktop/action/package_vagrantfile.rb,
lib/vagrant-vmware-desktop/action/clear_shared_folders.rb,
lib/vagrant-vmware-desktop/action/prepare_nfs_settings.rb,
lib/vagrant-vmware-desktop/action/prune_forwarded_ports.rb,
lib/vagrant-vmware-desktop/action/check_existing_network.rb,
lib/vagrant-vmware-desktop/action/discard_suspended_state.rb,
lib/vagrant-vmware-desktop/action/message_already_running.rb,
lib/vagrant-vmware-desktop/guest_cap/linux/verify_vmware_hgfs.rb,
lib/vagrant-vmware-desktop/action/wait_for_communicator_compat.rb,
lib/vagrant-vmware-desktop/action/prepare_synced_folder_cleanup.rb,
lib/vagrant-vmware-desktop/guest_cap/linux/mount_vmware_shared_folder.rb,
lib/vagrant-vmware-desktop/action/prepare_forwarded_port_collision_params.rb

Defined Under Namespace

Modules: Action, Cap, Driver, Errors, GuestCap, Helper Classes: CheckpointClient, Config, Plugin, Provider, SetupPlugin, SyncedFolder

Constant Summary collapse

CONFLICTING_GEMS =

List of plugins that are incompatible with this plugin. These are the deprecated versions of the VMware plugin that this plugin replaces.

[
  "vagrant-vmware-fusion",
  "vagrant-vmware-workstation"
].map(&:freeze).freeze
VERSION =
"STUB"
PRODUCT_NAME =

This is the name of the gem.

Returns:

  • (String)
RbConfig::CONFIG["host_os"].include?("darwin") ? "fusion" : "workstation"
PLUGIN_NAME =
"vagrant-vmware-desktop"

Class Method Summary collapse

Class Method Details

.case_insensitive_fs?(path) ⇒ Boolean

Check if path is case insensitive

Parameters:

  • path (String, Pathname)

    to check (must exist)

Returns:

  • (Boolean)


146
147
148
149
150
151
152
# File 'lib/vagrant-vmware-desktop.rb', line 146

def self.case_insensitive_fs?(path)
  begin
    FileUtils.compare_file(path.to_s, path.to_s.downcase)
  rescue Errno::ENOENT
    false
  end
end

.case_sensitive_fs?(path) ⇒ Boolean

Check if path is case sensitive

Parameters:

  • path (String, Pathname)

    to check (must exist)

Returns:

  • (Boolean)


138
139
140
# File 'lib/vagrant-vmware-desktop.rb', line 138

def self.case_sensitive_fs?(path)
  !case_sensitive_fs(path)
end

.init_i18nObject

This initializes the i18n load path so that the plugin-specific translations work.



30
31
32
33
# File 'lib/vagrant-vmware-desktop.rb', line 30

def self.init_i18n
  I18n.load_path << File.expand_path("locales/en.yml", source_root)
  I18n.reload!
end

.init_loggingObject

This initializes the logging so that our logs are outputted at the same level as Vagrant core logs.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/vagrant-vmware-desktop.rb', line 37

def self.init_logging
  # Initialize logging
  level = nil
  begin
    level = Log4r.const_get(ENV["VAGRANT_LOG"].upcase)
  rescue NameError
    # This means that the logging constant wasn't found,
    # which is fine. We just keep `level` as `nil`. But
    # we tell the user.
    level = nil
  end

  # Some constants, such as "true" resolve to booleans, so the
  # above error checking doesn't catch it. This will check to make
  # sure that the log level is an integer, as Log4r requires.
  level = nil if !level.is_a?(Integer)

  # Set the logging level on all "vagrant" namespaced
  # logs as long as we have a valid level.
  if level
    logger = Log4r::Logger.new("hashicorp")
    logger.outputters = Log4r::Outputter.stderr
    logger.level = level
    logger = nil
  end
end

.orphan_artifact_cleanup!Object

Check for any deprecated suid binaries from previous vmware plugin installations and remove them



177
178
179
180
181
182
183
184
# File 'lib/vagrant-vmware-desktop.rb', line 177

def self.orphan_artifact_cleanup!
  if !Vagrant::Util::Platform.windows?
    glob_path = Vagrant.user_data_path.join("gems", "**", "**", "vagrant-vmware-{workstation,fusion}*").to_s
    Dir.glob(glob_path).each do |del_path|
      FileUtils.rm_rf(del_path) if File.directory?(del_path)
    end
  end
end

.source_rootPathname

This returns the path to the source of this plugin.

Returns:

  • (Pathname)


67
68
69
# File 'lib/vagrant-vmware-desktop.rb', line 67

def self.source_root
  @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
end

.validate_install!NilClass

Checks for a valid installation state. Raises exception if invalid state detected.

Returns:

  • (NilClass)


159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/vagrant-vmware-desktop.rb', line 159

def self.validate_install!
  CONFLICTING_GEMS.each do |libname|
    if !Gem::Specification.find_all_by_name(libname).empty?
      $stderr.puts <<-EOF
ERROR: Vagrant has detected an incompatible plugin installed. Please uninstall
the `#{libname}` plugin and run the command again. To uninstall the plugin,
run the command shown below:

  vagrant plugin uninstall #{libname}

EOF
      raise "Plugin conflict"
    end
  end
end

.windows_to_wsl_path(path) ⇒ String

Convert Windows path to WSL path

Parameters:

  • path (String, Pathname)

Returns:

  • (String)


108
109
110
111
112
113
114
115
116
117
# File 'lib/vagrant-vmware-desktop.rb', line 108

def self.windows_to_wsl_path(path)
  if wsl?
    if Vagrant::Util::Platform.respond_to?(:windows_to_wsl_path)
      return Vagrant::Util::Platform.windows_to_wsl_path(path.to_s)
    elsif path.match(/^[A-Za-z]:/)
      return "/mnt/#{path[0, 1].downcase}#{path[2..-1].tr(92.chr, '/')}"
    end
  end
  path.to_s
end

.wsl?Boolean

Detect if inside WSL

Returns:

  • (Boolean)


80
81
82
83
# File 'lib/vagrant-vmware-desktop.rb', line 80

def self.wsl?
  Vagrant::Util::Platform.respond_to?(:wsl?) &&
    Vagrant::Util::Platform.wsl?
end

.wsl_drvfs_path?(path) ⇒ Boolean

Check if path is located on DrvFs file system

Parameters:

  • (String, Pathname)

Returns:

  • (Boolean)


123
124
125
126
127
128
129
130
131
132
# File 'lib/vagrant-vmware-desktop.rb', line 123

def self.wsl_drvfs_path?(path)
  path = path.to_s
  if Vagrant::Util::Platform.respond_to?(:wsl_drvfs_path?)
    return Vagrant::Util::Platform.wsl_drvfs_path?(path)
  end
  if wsl?
    return Vagrant::Util::Platform.wsl_windows_access_bypass?(path)
  end
  false
end

.wsl_to_windows_path(path) ⇒ String

Convert WSL path to a Windows path

Parameters:

  • path (String, Pathname)

Returns:

  • (String)


89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/vagrant-vmware-desktop.rb', line 89

def self.wsl_to_windows_path(path)
  if wsl?
    oval = ENV["VAGRANT_WSL_ENABLE_WINDOWS_ACCESS"]
    ENV["VAGRANT_WSL_ENABLE_WINDOWS_ACCESS"] = "1"
    path = Vagrant::Util::Platform.wsl_to_windows_path(path.to_s)
    ENV["VAGRANT_WSL_ENABLE_WINDOWS_ACCESS"] = oval
    return "//?/#{path}".tr("/", 92.chr)
  end
  if Vagrant::Util::Platform.windows?
    path.to_s.tr("/", 92.chr)
  else
    path.to_s
  end
end