Sha256: 4751109abac184f8ffb090adef314ffe48dd9f65a352882081eba6ce009fe7f0

Contents?: true

Size: 1.57 KB

Versions: 7

Compression:

Stored size: 1.57 KB

Contents

require "log4r"

require 'vagrant/util/scoped_hash_override'

module VagrantPlugins
  module OpenStack
    module Action
      class CreateNetworkInterfaces
        include Vagrant::Util::ScopedHashOverride

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

        def call(env)
          networks_to_configure = []
          env[:machine].config.vm.networks.each_with_index do |network, slot_number|
            type = network[0]
            original_options = network[1]
            next if type != :private_network
            next if original_options[:auto_config] === false
            next if slot_number == 0

            options = scoped_hash_override(original_options, :openstack)

            @logger.info "Configuring interface slot_number #{slot_number} options #{options}"

            network_to_configure = {
              :interface => slot_number,
            }

            if options[:ip]
              network_to_configure = {
                :type    => :static,
                :ip      => options[:ip],
                :netmask => "255.255.255.0",
              }.merge(network_to_configure)
            else
              network_to_configure[:type] = :dhcp
            end

            networks_to_configure.push(network_to_configure)
          end
          env[:ui].info I18n.t('vagrant.actions.vm.network.configuring')
          env[:machine].guest.capability(:configure_networks, networks_to_configure)
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
vagrant-openstack-plugin-tom-0.12.0 lib/vagrant-openstack-plugin/action/create_network_interfaces.rb
vagrant-openstack-plugin-0.12.0 lib/vagrant-openstack-plugin/action/create_network_interfaces.rb
vagrant-openstack-plugin-0.11.1 lib/vagrant-openstack-plugin/action/create_network_interfaces.rb
vagrant-openstack-plugin-0.11.0 lib/vagrant-openstack-plugin/action/create_network_interfaces.rb
vagrant-openstack-plugin-0.10.0 lib/vagrant-openstack-plugin/action/create_network_interfaces.rb
vagrant-openstack-plugin-0.9.1 lib/vagrant-openstack-plugin/action/create_network_interfaces.rb
vagrant-openstack-plugin-0.9.0 lib/vagrant-openstack-plugin/action/create_network_interfaces.rb