Sha256: bd60f4b319f8a3a92859fed5a595203ef2e06b41d91324bc8cea6a1c2884a34c

Contents?: true

Size: 1.2 KB

Versions: 26

Compression:

Stored size: 1.2 KB

Contents

# == AddressManager::Linux
#
# A Linux-specific driver for the AddressManager provides complete support for
# querying, adding and removing addresses on platforms that feature Linux-like
# tools.
class AutomateIt::AddressManager::Linux < AutomateIt::AddressManager::BaseDriver
  depends_on :programs => "ifconfig",
    :callbacks => lambda{`ifconfig --version 2>&1`.match(/net-tools/)}

  def suitability(method, *args) # :nodoc:
    available? ? 2 : 0
  end

  # See AddressManager#add
  def add(opts)
    _add_helper(opts) do |opts|
      interpreter.sh(_ifconfig_helper(:add, opts))
      if interpreter.which("arping")
        interpreter.sh("arping -q -c #{opts[:announcements]} -w #{opts[:announcements]} -I #{opts[:device]} #{opts[:address]}")
      end
    end
  end

  # See AddressManager#remove
  def remove(opts)
    _remove_helper(opts) do |opts|
      interpreter.sh(_ifconfig_helper(:remove, opts))
    end
  end

  # See AddressManager#interfaces
  def interfaces()
    _raise_unless_available
    return `ifconfig`.scan(/^(\w+?(?::\w+)?)\b\s+Link/).flatten
  end

  # See AddressManager#addresses
  def addresses()
    _raise_unless_available
    return `ifconfig`.scan(/inet6? addr:\s*(.+?)\s+/).flatten
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
automate-it-0.9.2 lib/automateit/address_manager/linux.rb
automate-it-0.9.1 lib/automateit/address_manager/linux.rb
automate-it-0.9.0 lib/automateit/address_manager/linux.rb
automateit-0.71031.1 lib/automateit/address_manager/linux.rb
automateit-0.71031.2 lib/automateit/address_manager/linux.rb
automateit-0.71012 lib/automateit/address_manager/linux.rb
automateit-0.71021 lib/automateit/address_manager/linux.rb
automateit-0.71030 lib/automateit/address_manager/linux.rb
automateit-0.71017 lib/automateit/address_manager/linux.rb
automateit-0.71102 lib/automateit/address_manager/linux.rb
automateit-0.71031 lib/automateit/address_manager/linux.rb
automateit-0.71103 lib/automateit/address_manager/linux.rb
automateit-0.71101.1 lib/automateit/address_manager/linux.rb
automateit-0.71101 lib/automateit/address_manager/linux.rb
automateit-0.71101.2 lib/automateit/address_manager/linux.rb
automateit-0.71112 lib/automateit/address_manager/linux.rb
automateit-0.71221 lib/automateit/address_manager/linux.rb
automateit-0.71220 lib/automateit/address_manager/linux.rb
automateit-0.71111 lib/automateit/address_manager/linux.rb
automateit-0.71219 lib/automateit/address_manager/linux.rb