Class: AutoNetwork::Action::Base Abstract
- Inherits:
-
Object
- Object
- AutoNetwork::Action::Base
- Defined in:
- lib/auto_network/action/base.rb
Overview
Subclass and override #call to implement a new AutoNetwork action.
This is an abstract base class for AutoNetwork actions that provides helper methods for interfacing with a PoolManager object and the Pool instances it manages.
Direct Known Subclasses
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#filter_private_network(iface, addr) ⇒ void
protected
Convert an auto network to a private network with a static IP address.
-
#initialize(app, env) ⇒ Base
constructor
Create a new action instance that is suitable for execution as part of Vagrant middleware.
-
#machine_auto_networks(machine) ⇒ Array(Symbol, Hash)
protected
Fetch all private networks that are tagged for auto networking.
-
#machine_has_address?(machine) ⇒ true, false
protected
Determine if the given machine exists and has an auto_network address.
Constructor Details
#initialize(app, env) ⇒ Base
Create a new action instance that is suitable for execution as part of Vagrant middleware.
21 22 23 |
# File 'lib/auto_network/action/base.rb', line 21 def initialize(app, env) @app, @env = app, env end |
Instance Method Details
#call(env) ⇒ Object
25 26 27 |
# File 'lib/auto_network/action/base.rb', line 25 def call(env) raise NotImplementedError end |
#filter_private_network(iface, addr) ⇒ void (protected)
This method returns an undefined value.
Convert an auto network to a private network with a static IP address.
This does an in-place modification of the private_network options hash to strip out the auto_network configuration and make this behave like a normal private network interface with a static IP address.
61 62 63 64 65 |
# File 'lib/auto_network/action/base.rb', line 61 def filter_private_network(iface, addr) opts = iface[1] opts.delete(:auto_network) opts[:ip] = addr end |
#machine_auto_networks(machine) ⇒ Array(Symbol, Hash) (protected)
Fetch all private networks that are tagged for auto networking
45 46 47 48 49 |
# File 'lib/auto_network/action/base.rb', line 45 def machine_auto_networks(machine) machine.config.vm.networks.select do |(net_type, )| net_type == :private_network and [:auto_network] end end |
#machine_has_address?(machine) ⇒ true, false (protected)
Determine if the given machine exists and has an auto_network address
36 37 38 |
# File 'lib/auto_network/action/base.rb', line 36 def machine_has_address?(machine) !!(machine and AutoNetwork.active_pool_manager.address_for(machine)) end |