Class: HashiCorp::VagrantVMwareDesktop::Action::PackageVagrantfile
- Inherits:
-
Object
- Object
- HashiCorp::VagrantVMwareDesktop::Action::PackageVagrantfile
- Includes:
- Vagrant::Util
- Defined in:
- lib/vagrant-vmware-desktop/action/package_vagrantfile.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#create_metadata ⇒ Object
Creates a metadata.json file which includes provider information.
-
#create_vagrantfile ⇒ Object
This method creates the auto-generated Vagrantfile at the root of the box.
-
#initialize(app, env) ⇒ PackageVagrantfile
constructor
A new instance of PackageVagrantfile.
Constructor Details
#initialize(app, env) ⇒ PackageVagrantfile
Returns a new instance of PackageVagrantfile.
13 14 15 |
# File 'lib/vagrant-vmware-desktop/action/package_vagrantfile.rb', line 13 def initialize(app, env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 |
# File 'lib/vagrant-vmware-desktop/action/package_vagrantfile.rb', line 17 def call(env) @env = env @app.call(env) end |
#create_metadata ⇒ Object
Creates a metadata.json file which includes provider information
41 42 43 44 45 |
# File 'lib/vagrant-vmware-desktop/action/package_vagrantfile.rb', line 41 def File.open(File.join(@env["export.temp_dir"], "metadata.json"), "w") do |f| f.write({provider: "vmware_desktop"}.to_json) end end |
#create_vagrantfile ⇒ Object
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.
30 31 32 33 34 35 36 37 38 |
# File 'lib/vagrant-vmware-desktop/action/package_vagrantfile.rb', line 30 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 |