Class: VagrantPlugins::ProviderKvm::Action::PackageVagrantfile

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

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ PackageVagrantfile

Returns a new instance of PackageVagrantfile.



8
9
10
# File 'lib/vagrant-kvm/action/package_vagrantfile.rb', line 8

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

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
# File 'lib/vagrant-kvm/action/package_vagrantfile.rb', line 12

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.



21
22
23
24
25
26
27
# File 'lib/vagrant-kvm/action/package_vagrantfile.rb', line 21

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