Class | AutomateIt::AddressManager |
In: |
lib/automateit/address_manager.rb
|
Parent: | AutomateIt::Plugin::Manager |
The AddressManager provides a way to query, add and remove network addresses on a host.
DEFAULT_ANNOUNCEMENTS | = | 3 | Number of ARP announcements to make by default during add. |
Add address to host if it doesn‘t have it. Requires root-level access. Returns true if action was taken and succeeded.
Arguments hash must include either a :device (e.g., "eth0") or :address (e.g., "10.0.0.10"), and an optional :label (e.g., "foo") and :mask (e.g. "24").
An optional number of ARP :announcements may be specified, defaulting to AutomateIt::AddressManager::DEFAULT_ANNOUNCEMENTS. Drivers that handle announcements will block an extra second while making each announcement.
Example:
add(:address => "10.0.0.10", :mask => 24, :device => "eth0", :label => "foo", :announcements => 3)
# File lib/automateit/address_manager.rb, line 38 def add(opts) dispatch(opts) end
Does host have an address or interface? Arguments hash must include either a :device (e.g., "eth0") or :address (e.g., "10.0.0.10"), and an optional :label (e.g., "foo"). Note that an interface is the combination of a :device and :label, so "eth0" isn‘t the same as "eth0:foo".
Examples on a host with address "10.0.0.10" on interface "eth0:foo":
has?(:address => "10.0.0.10") => true has?(:address => "10.0.0.10", :device => "eth0") => false has?(:address => "10.0.0.10", :device => "eth0", :label => "foo") => true has?(:device => "eth0") => false has?(:device => "eth0", :label => "foo") => true
# File lib/automateit/address_manager.rb, line 22 def has?(opts) dispatch(opts) end
Array of hostname variants for this hostname. This method performs no name resolution and simply infers a less qualified name from a more qualified hostname argument. Example:
hostnames_for("kagami.lucky-channel") => ["kagami", "kagami.lucky-channel"] hostnames_for("kagami") => ["kagami"]
# File lib/automateit/address_manager.rb, line 78 def hostnames_for(hostname) dispatch(hostname) end
Array of interfaces for this host. Example:
interfaces => ["eth0", "lo"]
# File lib/automateit/address_manager.rb, line 63 def interfaces() dispatch() end
Remove address from host if it has it. Requires root-level access. Returns true if action was taken and succeeded.
Arguments hash must include either a :device (e.g., "eth0") or :address (e.g., "10.0.0.10"), and an optional :label (e.g., "foo") and :mask (e.g. "24").
Example:
remove(:address => "10.0.0.10", :mask => 24, :device => "eth0", :label => "foo")
# File lib/automateit/address_manager.rb, line 53 def remove(opts) dispatch(opts) end