Class: VagrantPlugins::ProviderVeertu::Action::PackageVagrantfile

Inherits:
Object
  • Object
show all
Includes:
Vagrant::Util
Defined in:
lib/vagrant-veertu/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-veertu/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-veertu/action/package_vagrantfile.rb', line 14

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

#create_vagrantfileObject

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.



23
24
25
26
27
28
29
# File 'lib/vagrant-veertu/action/package_vagrantfile.rb', line 23

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