Class: AutomateIt::AddressManager::OpenBSD

Inherits:
BaseDriver show all
Defined in:
lib/automateit/address_manager/openbsd.rb

Overview

AddressManager::OpenBSD

A OpenBSD-specific driver for the AddressManager provides complete support for querying, adding and removing addresses.

Constant Summary

Constants inherited from Plugin::Driver

Plugin::Driver::BASE_DRIVER_NAME

Constants included from Constants

Constants::HELPERS_DIR, Constants::INSTALL_DIR, Constants::PERROR, Constants::PEXEC, Constants::PNOTE, Constants::WARNING_BOILERPLATE

Instance Attribute Summary

Attributes inherited from Plugin::Driver

#manager

Attributes inherited from Common

#interpreter

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseDriver

#hostnames, #hostnames_for

Methods inherited from Plugin::Driver

abstract_driver, #available?, base_driver, base_driver?, depends_on, inherited, manager_token, #setup

Methods inherited from Plugin::Base

#setup, #token

Methods inherited from Common

#initialize, #log, #nitpick, #noop, #noop=, #noop?, #preview, #preview=, #preview?, #preview_for, #setup, #superuser?, #writing, #writing=, #writing?

Constructor Details

This class inherits a constructor from AutomateIt::Common

Class Method Details

.tokenObject



6
7
8
# File 'lib/automateit/address_manager/openbsd.rb', line 6

def self.token
  :openbsd
end

Instance Method Details

#add(opts) ⇒ Object

See AddressManager#add



19
20
21
22
23
# File 'lib/automateit/address_manager/openbsd.rb', line 19

def add(opts)
  _add_helper(opts) do |opts|
    interpreter.sh(_openbsd_ifconfig_helper(:add, opts))
  end
end

#addressesObject

See AddressManager#addresses



34
35
36
37
38
# File 'lib/automateit/address_manager/openbsd.rb', line 34

def addresses()
  _raise_unless_available
  # OpenBSD requires an "-A" to display aliases, not the usual "-a"
  return `ifconfig -A`.scan(/\s+inet\s+([^\s]+)\s+/).flatten
end

#has?(opts) ⇒ Boolean

See AddressManager#has?

Returns:

  • (Boolean)


41
42
43
44
45
# File 'lib/automateit/address_manager/openbsd.rb', line 41

def has?(opts)
  opts2 = opts.clone
  is_alias = opts2.delete(:label)
  return super(opts2)
end

#remove(opts) ⇒ Object

See AddressManager#remove



26
27
28
29
30
31
# File 'lib/automateit/address_manager/openbsd.rb', line 26

def remove(opts)
  _remove_helper(opts) do |opts|
    interpreter.sh(_openbsd_ifconfig_helper(:remove, opts))
    true
  end
end

#suitability(method, *args) ⇒ Object

:nodoc:



13
14
15
16
# File 'lib/automateit/address_manager/openbsd.rb', line 13

def suitability(method, *args) # :nodoc:
  # Must be higher than AddressManager::BSD
  available? ? 3 : 0
end