Class: Commutateurs::HP

Inherits:
Base
  • Object
show all
Defined in:
lib/commutateurs/hp.rb

Overview

Work in progress

Instance Method Summary collapse

Methods inherited from Base

#execute

Constructor Details

#initialize(host, credentials, verbose = false) ⇒ HP

Returns a new instance of HP.



4
5
6
7
8
9
10
11
12
13
# File 'lib/commutateurs/hp.rb', line 4

def initialize(host, credentials, verbose = false)
  super
  @transport.default_prompt = /(Press any key to continue|# )/

  # hpuifilter.c used by rancid - https://github.com/dotwaffle/rancid-git/blob/master/bin/hpuifilter.c#L534
  @transport.filter = Proc.new do |line| 
    line.gsub(/\e\[2K|\e\[2J|\e\[\?7l|\e\[\?6l|\e\[[0-9]+;[0-9]+r|\e\[[0-9]+;[0-9]+H|\e\[\?25l|\e\[\?25h/, "")
        .gsub(/\eE|\n\r|\r\n/, "\n") 
  end
end

Instance Method Details

#configurationObject



25
26
27
# File 'lib/commutateurs/hp.rb', line 25

def configuration
  execute('write term')
end

#connectObject



15
16
17
18
19
# File 'lib/commutateurs/hp.rb', line 15

def connect
  @transport.connect
  execute("")
  execute("terminal length 1000")
end

#disconnectObject



33
34
35
36
# File 'lib/commutateurs/hp.rb', line 33

def disconnect
  @transport.send 'exit'
  @transport.close
end

#enableObject



21
22
23
# File 'lib/commutateurs/hp.rb', line 21

def enable

end

#saveObject



29
30
31
# File 'lib/commutateurs/hp.rb', line 29

def save
  execute('write memory')
end