summaryrefslogtreecommitdiff
path: root/lib/oxidized/model/aireos.rb
blob: 7056e3ff3f2275cd1175bd27471561e9ce2b1ac2 (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
46
47
48
49
50
51
52
53
54
55
class Aireos < Oxidized::Model

  # AireOS (at least I think that is what it's called, hard to find data)
  # Used in Cisco WLC 5500

  comment  '# '     ## this complains too, can't find real comment char
  prompt /^\([^\)]+\)\s>/

  cmd :all do |cfg|
    cfg.each_line.to_a[1..-2].join
  end

  ##show sysinfo?
  ##show switchconfig?

  cmd 'show udi' do |cfg|
    cfg = comment clean cfg
    cfg << "\n"
  end

  cmd 'show boot' do |cfg|
    cfg = comment clean cfg
    cfg << "\n"
  end

  cmd 'show run-config commands' do |cfg|
    clean cfg
  end

  cfg :telnet, :ssh do
    username /^User:\s*/
    password /^Password:\s*/
    post_login 'config paging disable'
  end

  cfg :telnet, :ssh do
    pre_logout do
      send "logout\n"
      send "n"
    end
  end

  def clean cfg
    out = []
    cfg.each_line do |line|
      next if line.match /^\s*$/
      next if line.match /rogue (adhoc|client) alert [\da-f]{2}:/
      line = line[1..-1] if line[0] == "\r"
      out << line.strip
    end
    out = out.join "\n"
    out << "\n"
  end

end