Class: Commutateurs::HP

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of HP.



27
28
29
30
31
# File 'lib/commutateurs/device.rb', line 27

def initialize(host, credentials, verbose = false)
  super
  @transport.default_prompt = /(Press any key to continue|# )/
  @transport.debug = Proc.new { |line| $stderr.print(clean(line)) }
end

Instance Method Details

#clean(arg) ⇒ Object



60
61
62
63
64
# File 'lib/commutateurs/device.rb', line 60

def clean(arg)
  cleaned = ""
  (arg || "").each_byte { |x|  cleaned << x unless x > 127   }
  cleaned
end

#configurationObject



43
44
45
# File 'lib/commutateurs/device.rb', line 43

def configuration
  execute('write term')
end

#connectObject



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

def connect
  @transport.connect
  @transport.command("\n")
  @transport.command("terminal length 1000")
end

#disconnectObject



51
52
53
54
# File 'lib/commutateurs/device.rb', line 51

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

#enableObject



39
40
41
# File 'lib/commutateurs/device.rb', line 39

def enable

end

#execute(arg) ⇒ Object



56
57
58
# File 'lib/commutateurs/device.rb', line 56

def execute(arg)
  clean(super(arg))
end

#saveObject



47
48
49
# File 'lib/commutateurs/device.rb', line 47

def save
  raise "Not implemented yet"
end