Class: AutoNetwork::Action::Request

Inherits:
Base
  • Object
show all
Defined in:
lib/auto_network/action/request.rb

Instance Method Summary collapse

Methods inherited from Base

#filter_private_network, #initialize, #machine_auto_networks, #machine_has_address?

Constructor Details

This class inherits a constructor from AutoNetwork::Action::Base

Instance Method Details

#call(env) ⇒ void

This method returns an undefined value.

Request an auto_network IP address on VM creation

Parameters:

  • env (Hash)

Options Hash (env):

  • auto_network_pool (AutoNetwork::Pool)

    The global auto network pool

  • machine (Vagrant::Machine)

    The Vagrant machine being created



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/auto_network/action/request.rb', line 15

def call(env)
  @env = env

  machine = @env[:machine]

  # Move along if this machine has no AutoNetwork interfaces.
  @app.call(@env) if machine_auto_networks(machine).empty?

  addr = AutoNetwork.active_pool_manager.address_for(machine)
  if addr.nil?
    addr = AutoNetwork.active_pool_manager.request(machine)
    @env[:ui].info "AutoNetwork assigning #{addr.inspect} to '#{machine.name}'",
      :prefix => true
  end

  filter_networks(machine, addr)

  @app.call(@env)
end