summaryrefslogtreecommitdiff
path: root/lib/oxidized/model/boss.rb
blob: 93f990362ccf78964f61a39f5dfcfa476e0e2374 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
class Boss < Oxidized::Model
  # Avaya Baystack Operating System Software(BOSS)
  # Created by danielcoxman@gmail.com
  # May 15, 2017
  # This was tested on ers3510, ers5530, ers4850, ers5952
  # ssh and telnet were tested with banner and without

  comment  '! '

  prompt /^[^\s#>]+[#>]$/

  # Handle the banner
  # to disable the banner on BOSS the configuration parameter is "banner disabled"
  expect /Enter Ctrl-Y to begin\./ do |data, re|
    send "\cY"
    data.sub re, ''
  end

  # Handle the Failed retries since last login 
  # no known way to disable other than to implement radius authentication
  expect /Press ENTER to continue/ do |data, re|
    send "\n"
    data.sub re, ''
  end

  # Handle the menu on the older BOSS example ers55xx, ers56xx
  # to disable them menu on BOSS the configuration parameter is "cmd-interface cli"
  expect /ommand Line Interface\.\.\./ do |data, re|
    send "c"
    data.sub re, ''
  end
 
  # needed for proper formatting
  cmd('') { |cfg| comment "#{cfg}\n" }

  # Do a sys-info and check and see if it supports stack
  cmd 'show sys-info' do |cfg|
    @stack = true if cfg.match /Stack/
    cfg.gsub! /(^((.*)sysUpTime(.*))$)/, 'removed sysUpTime'
    cfg.gsub! /(^((.*)sysNtpTime(.*))$)/, 'removed sysNtpTime'
    cfg.gsub! /(^((.*)sysRtcTime(.*))$)/, 'removed sysNtpTime'
    cfg.gsub! /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} .*/, ''
    comment "#{cfg}\n"
  end
  
  # if a stack then collect the stacking information
  cmd 'show stack-info' do |cfg|
    if @stack
      cfg.gsub! /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} .*/, ''
      comment "#{cfg}\n"
    end
  end

  cmd 'show running-config' do |cfg|
    cfg.gsub! /^show running-config/, '! show running-config'
    # remove cli timestamp
    cfg.gsub! /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} .*/, ''
    cfg.gsub! /^[^\s#>]+[#>]$/, ''
    cfg.gsub! /^! clock set.*/, '! removed clock set'
    cfg
  end

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

  cfg :telnet, :ssh do
    pre_logout do
      # Backup the running-config via tftp to a tftpserver of your choice
      #send "copy running-config tftp address x.x.x.x filename " + node.name + ".cli\n"
      send "logout\n"
    end
    post_login do
      send "terminal length 0\n"
      send "terminal width 132\n"
    end
  end

end