summaryrefslogtreecommitdiff
path: root/lib/oxidized/model/aos7.rb
blob: 8d1106685b59af739e55b3824744b3b83fcd83cf (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
56
57
58
class AOS7 < Oxidized::Model

  # Alcatel-Lucent Operating System Version 7 (Linux based)
  # used in OmniSwitch 6900/10k
 
  comment  '! '

  cmd :all do |cfg, cmdstring|
    new_cfg = comment "COMMAND: #{cmdstring}\n"
    new_cfg << cfg.each_line.to_a[1..-2].join
  end

  cmd 'show system' do |cfg|
    cfg = cfg.each_line.find{|line|line.match 'Description'}
    comment cfg.to_s.strip + "\n"
  end

  cmd 'show chassis' do |cfg|
    # check for virtual chassis existence
    @slave_vcids = cfg.scan(/Chassis ID (\d+) \(Slave\)/).flatten
    @master_vcid = $1 if cfg.match /Chassis ID (\d+) \(Master\)/
    comment cfg
  end

  cmd 'show hardware-info' do |cfg|
    comment cfg
  end

  cmd 'show running-directory' do |cfg|
    comment cfg
  end

  cmd 'show configuration snapshot' do |cfg|
    cfg
  end

  pre do
    cfg = []
    if @master_vcid
      # add slave VC boot config as comment
      @slave_vcids.each do |id|
        cfg << comment("vc_boot.cfg for slave chassis #{id}")
        cfg << comment(cmd("show configuration vcm-snapshot chassis-id #{id}"))
      end
      cfg << cmd("show configuration vcm-snapshot chassis-id #{@master_vcid}")
    end
    cfg.join "\n"
  end

  cfg :telnet do
    username /^login : /
    password /^Password : /
  end

  cfg :telnet, :ssh do
    pre_logout 'exit'
  end
end