Class: VagrantPlugins::StartCloud::Action::ConfigureNetworks
- Inherits:
-
Object
- Object
- VagrantPlugins::StartCloud::Action::ConfigureNetworks
- Defined in:
- lib/vagrant-startcloud/action/configure_networks.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ConfigureNetworks
constructor
A new instance of ConfigureNetworks.
Constructor Details
#initialize(app, env) ⇒ ConfigureNetworks
Returns a new instance of ConfigureNetworks.
7 8 9 10 |
# File 'lib/vagrant-startcloud/action/configure_networks.rb', line 7 def initialize(app, env) @app = app @provider = env[:provider] || :virtualbox end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vagrant-startcloud/action/configure_networks.rb', line 12 def call(env) machine = env[:machine] config = machine.config.startcloud if config.networks&.any? machine.ui.info I18n.t('vagrant_startcloud.provisioner.configuring_networks') config.networks.each do |network| = { ip: network['address'], netmask: network['netmask'], gateway: network['gateway'], dhcp: network['dhcp4'], dhcp4: network['dhcp4'], dhcp6: network['dhcp6'], auto_config: network['autoconf'], mac: format_mac_address(network['mac'], @provider), nic_type: network['nic_type'], vlan: network['vlan'], dns: network['dns'], bridge: network['bridge'] }.compact case network['type'] when 'host' configure_network(machine, 'private_network', ) else configure_network(machine, network['type'], ) end rescue StandardError => e raise Errors::NetworkConfigurationError, error: e. end end @app.call(env) end |