Module: AutoNetwork::Settings
- Included in:
- AutoNetwork
- Defined in:
- lib/auto_network/settings.rb
Overview
This module is used by AutoNetwork to store global state when running under Vagrant. This module is mixed into the top-level AutoNetwork namespace.
Defined Under Namespace
Classes: InvalidSettingErrror
Constant Summary collapse
- DEFAULT_POOL =
Unless overriden, this will be the IP range assigned to the very first Pool created by PoolManager instances.
'10.20.1.0/24'
Instance Attribute Summary collapse
-
#pool_manager ⇒ AutoNetwork::PoolManager?
Access the global PoolManager instance.
Instance Method Summary collapse
-
#active_pool_manager ⇒ AutoNetwork::PoolManager
Assertively retrieve the global PoolManager instance.
-
#default_pool ⇒ String
Retrieve the default pool that PoolManager instances will assign to the first Pool they create.
-
#default_pool=(pool) ⇒ void
Set the default pool to a new IP range.
Instance Attribute Details
#pool_manager ⇒ AutoNetwork::PoolManager?
Access the global PoolManager instance.
21 22 23 |
# File 'lib/auto_network/settings.rb', line 21 def pool_manager @pool_manager end |
Instance Method Details
#active_pool_manager ⇒ AutoNetwork::PoolManager
Assertively retrieve the global PoolManager instance.
Raises an error if #pool_manager has been set to nil
or an invalid
value.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/auto_network/settings.rb', line 31 def active_pool_manager manager = pool_manager unless manager.is_a?(AutoNetwork::PoolManager) raise InvalidSettingErrror, :setting_name => 'pool_manager', :value => manager.inspect end manager end |
#default_pool ⇒ String
Retrieve the default pool that PoolManager instances will assign to the first Pool they create.
50 51 52 |
# File 'lib/auto_network/settings.rb', line 50 def default_pool @default_pool ||= DEFAULT_POOL end |
#default_pool=(pool) ⇒ void
This method returns an undefined value.
Set the default pool to a new IP range.
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/auto_network/settings.rb', line 60 def default_pool=(pool) # Ensure the pool is valid. begin IPAddr.new pool rescue ArgumentError raise InvalidSettingErrror, :setting_name => 'default_pool', :value => pool.inspect end @default_pool = pool end |