Sha256: 76250bcb3470b89bfbd742c1fafe93f412c5e6e2f40ed24578be433cf39c0758
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
require 'auto_network/action_helpers' require 'log4r' class AutoNetwork::Action::FilterNetworks include AutoNetwork::ActionHelpers def initialize(app, env) @app, @env = app, env @logger = Log4r::Logger.new('vagrant::auto_network::filter_networks') end # Convert auto_network interfaces to static private_network interfaces. # # @param env [Hash] # # @option env [AutoNetwork::Pool] auto_network_pool The global auto network pool # @option env [Vagrant::Environment] env The Vagrant environment containing # the active machines that need to be filtered. # # @return [void] def call(env) @env = env @pool = @env[:auto_network_pool] @global_env = @env[:env] filter if has_working_env? @app.call(@env) end private def has_working_env? !!(@global_env.local_data_path) end def filter machines_for_env.each do |machine| assign_address(machine) if machine_has_address?(machine) end end def machines_for_env @global_env.active_machines.map { |vm_id| @global_env.machine(*vm_id) } end def assign_address(machine) machine_auto_networks(machine).each do |net| addr = @pool.address_for(machine) @logger.info "Reassigning #{addr.inspect} to existing machine #{machine.id}" filter_private_network(net, addr) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vagrant-auto_network-0.2.2 | lib/auto_network/action/filter_networks.rb |
vagrant-auto_network-0.2.1 | lib/auto_network/action/filter_networks.rb |