Class: HashiCorp::VagrantVMwareDesktop::Action::FixOldMachineID

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/vagrant-vmware-desktop/action/fix_old_machine_id.rb

Overview

This fixes old-style machine IDs that were set in early versions of the VMware providers.

Instance Method Summary collapse

Methods included from Common

#to_s

Constructor Details

#initialize(app, env) ⇒ FixOldMachineID

Returns a new instance of FixOldMachineID.



14
15
16
17
# File 'lib/vagrant-vmware-desktop/action/fix_old_machine_id.rb', line 14

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new("hashicorp::provider::vmware::fix_old_machine_id")
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/vagrant-vmware-desktop/action/fix_old_machine_id.rb', line 19

def call(env)
  driver     = env[:machine].provider.driver
  machine_id = env[:machine].id
  if machine_id && driver.vmx_path.to_s != machine_id
    @logger.warn("Old-style ID found. Resetting to VMX path.")
    env[:machine].id = driver.vmx_path.to_s
  end

  @app.call(env)
end