Class: VagrantPlugins::ProviderBhyve::Action::CreateTap

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-bhyve/action/create_tap.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ CreateTap

Returns a new instance of CreateTap.



8
9
10
11
# File 'lib/vagrant-bhyve/action/create_tap.rb', line 8

def initialize(app, env)
  @logger = Log4r::Logger.new("vagrant_bhyve::action::create_tap")
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vagrant-bhyve/action/create_tap.rb', line 13

def call(env)
  @machine	= env[:machine]
  @driver	= @machine.provider.driver

  env[:ui].detail I18n.t('vagrant_bhyve.action.vm.boot.create_tap')
  vm_name	= @driver.get_attr('vm_name')
  tap_name	= "vagrant_bhyve_#{vm_name}"
  tap_list 	= [tap_name]
  # The switch name is used as created bridge device's description
  tap_list.each do |tap|
    @driver.create_network_device(tap, "tap")
  end
  @app.call(env)
end