Class: HashiCorp::VagrantVMwareDesktop::Action::PackageVagrantfile

Inherits:
Object
  • Object
show all
Includes:
Vagrant::Util
Defined in:
lib/vagrant-vmware-desktop/action/package_vagrantfile.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ PackageVagrantfile

Returns a new instance of PackageVagrantfile.



10
11
12
# File 'lib/vagrant-vmware-desktop/action/package_vagrantfile.rb', line 10

def initialize(app, env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  @env = env
  
  @app.call(env)
end

#create_metadataObject

Creates a metadata.json file which includes provider information



38
39
40
41
42
# File 'lib/vagrant-vmware-desktop/action/package_vagrantfile.rb', line 38

def 
  File.open(File.join(@env["export.temp_dir"], "metadata.json"), "w") do |f|
    f.write({provider: "vmware_desktop"}.to_json)
  end
end

#create_vagrantfileObject

Note:

This is deprecated as the base mac is no longer required to be set. The method (and template) are preserved to easily allow enabling this functionality in the future for a different purpose if requried.

This method creates the auto-generated Vagrantfile at the root of the box. This Vagrantfile contains the MAC address so that the user doesn’t have to worry about it.



27
28
29
30
31
32
33
34
35
# File 'lib/vagrant-vmware-desktop/action/package_vagrantfile.rb', line 27

def create_vagrantfile
  mac_addresses = @env[:machine].provider.driver.read_mac_addresses
  base_mac = mac_addresses[mac_addresses.keys.min]
  File.open(File.join(@env["export.temp_dir"], "Vagrantfile"), "w") do |f|
    f.write(TemplateRenderer.render("package_Vagrantfile", {
      base_mac: base_mac
    }))
  end
end