Class AutomateIt::AddressManager::BaseDriver
In: lib/automateit/address_manager/base.rb
Parent: AutomateIt::Plugin::Driver

AddressManager::BaseDriver

Base class for all AddressManager drivers.

Methods

Public Instance methods

See AddressManager#has?

See AddressManager#hostnames

See AddressManager#hostname_for

Protected Instance methods

Helper for add method.

Returns a string used to construct an ifconfig command, e.g.

  ifconfig hme0 192.9.2.106 netmask 255.255.255.0 up
  ifconfig hme0:1 172.40.30.4 netmask 255.255.0.0 up

Options:

  • :device — Interface, e.g., "eth0". String.
  • :label — Alias label, e.g., "1". String.
  • :address — IP address, e.g., "127.0.0.1". String.
  • :mask — Netmask, e.g., "255.255.255.0" or 24. String or Fixnum.

Helper options:

  • :append — Array of strings to append to end of command, e.g., ["-alias"].
  • :prepend — Array of strings to prepend to string, adding them after after "ifconfig", e.g., ["inet"].
  • :state — Whether to list "up" and "down" in command. Defaults to true.

Return the interface and label specified in opts hash, e.g., "eth0:1".

Alter opts hash to add alternative names for various options.

Helper for remove method.

Convert a binary number to decimal.

Example:

 bin2dec("11111111") # => 255

Convert CIDR to mask.

Example:

 cidr_to_mask(24) # => "255.255.255.0"

Convert a decimal number to binary notation.

Example:

 dec2bin(255) # => "11111111"

Convert a mask to a CIDR.

Example:

 mask_to_cidr("255.255.255.0") # => 24

[Validate]