Class: VagrantPlugins::SoftwareBridge::Action
- Inherits:
-
Object
- Object
- VagrantPlugins::SoftwareBridge::Action
- Defined in:
- lib/vagrant-software-bridge/action.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ Action
constructor
A new instance of Action.
- #normalize_config(config) ⇒ Object
Constructor Details
#initialize(app, env) ⇒ Action
Returns a new instance of Action.
4 5 6 |
# File 'lib/vagrant-software-bridge/action.rb', line 4 def initialize(app, env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/vagrant-software-bridge/action.rb', line 8 def call(env) bridges = env[:machine].config.software_bridge.software_bridges.map.with_index do |bridge, index| # If interface name is not specified, default to br<index>. normalize_config({:interface => "br#{index}"}.merge(bridge || {})) end # Call subsequent middleware steps. We'll do our setup at the # end @app.call(env) if !bridges.empty? env[:ui].output("Configuring software bridges...") env[:machine].guest.capability(:configure_software_bridges, bridges) end end |
#normalize_config(config) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/vagrant-software-bridge/action.rb', line 25 def normalize_config(config) return { :type => "dhcp", :auto_config => true, :bridge_ports => [], :ip => nil, :netmask => "255.255.255.0" }.merge(config || {}) end |