Class: Courgette::Fetchers::CommutateursFetcher

Inherits:
Fetcher
  • Object
show all
Defined in:
lib/courgette/fetchers/commutateurs_fetcher.rb

Constant Summary collapse

VENDORS =
{
  'cisco'     => Commutateurs::Cisco,
  'fortigate' => Commutateurs::Fortigate,
  'h3c'       => Commutateurs::H3c,
  'juniper'   => Commutateurs::Juniper,
  'hp'        => Commutateurs::HP,
  'brocade'   => Commutateurs::Brocade,
  'ironport'  => Commutateurs::Ironport
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ip, details) ⇒ CommutateursFetcher

Returns a new instance of CommutateursFetcher.



14
15
16
17
18
# File 'lib/courgette/fetchers/commutateurs_fetcher.rb', line 14

def initialize(ip, details)
  @ip = ip
  @klass = VENDORS[details['vendor']]
  @credentials = Commutateurs::Credentials.new(details['login'], details['password'], details['enable'])
end

Class Method Details

.responsible_of(vendor) ⇒ Object



20
21
22
# File 'lib/courgette/fetchers/commutateurs_fetcher.rb', line 20

def self.responsible_of(vendor)
  VENDORS.keys.include? vendor
end

Instance Method Details

#fetchObject



24
25
26
27
28
29
30
31
# File 'lib/courgette/fetchers/commutateurs_fetcher.rb', line 24

def fetch
  device = @klass.new(@ip, @credentials, false)

  device.connect
  device.enable

  device.configuration
end