summaryrefslogtreecommitdiff
path: root/lib/oxidized/model/procurve.rb
blob: e8a6bf6dc561086d59c6ca760d1907fd34ef8e1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class Procurve < Oxidized::Model

  # FIXME: this is way too unsafe
  prompt /.*?(\w+# ).*/m

  comment  '! '

  expect /Press any key to continue/ do
     send ' '
     ""
  end

  cmd :all do |cfg|
    cfg = cfg.each_line.to_a[1..-3].join
    cfg = cfg.gsub /\r/, ''
    new_cfg = ''
    cfg.each_line do |line|
      line.sub! /^\e.*(\e.*)/, '\1'  #leave last escape
      line.sub! /\e\[24;1H/, ''      #remove last escape, is it always this?
      new_cfg << line
    end
    new_cfg
  end

  cmd 'show version' do |cfg|
    comment cfg
  end

  cmd 'show system-information' do |cfg|
    comment cfg
  end

  cmd 'show running-config'

  cfg :telnet do
    username /Username:/
    password /Password:/
  end

  cfg :telnet, :ssh do
    post_login 'no page'
    pre_logout "logout\ny\nn"
  end

end