Class: Courgette::Fetchers::HpFetcher

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ip, details) ⇒ HpFetcher

Returns a new instance of HpFetcher.



4
5
6
7
8
# File 'lib/courgette/fetchers/hp_fetcher.rb', line 4

def initialize(ip, details)
  @ip = ip
  @user = details['login']
  @password = details['password']
end

Class Method Details

.responsible_of(vendor) ⇒ Object



10
11
12
# File 'lib/courgette/fetchers/hp_fetcher.rb', line 10

def self.responsible_of(vendor)
  "hp" == vendor
end

Instance Method Details

#fetchObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/courgette/fetchers/hp_fetcher.rb', line 14

def fetch     
  begin
  data = ""
  Net::SFTP.start(@ip, @user, :password => @password) do |sftp|
    data = sftp.download!("/cfg/running-config")
  end
  data
  rescue IOError => e
  data
  end
end