summaryrefslogtreecommitdiff
path: root/lib/oxidized/model/mlnxos.rb
blob: 9542c8881fdccbd4bc99e1694f4c087d76594ae8 (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
class MLNXOS < Oxidized::Model

  prompt /([\w.@()-\[:\s\]]+[#>]\s)$/
  comment  '## '
  
  # Pager Handling
  expect /.+lines\s\d+\-\d+([\s]|\/\d+\s\(END\)\s).+$/ do |data, re|
    send ' '
    data.sub re, ''
  end

  cmd :all do |cfg|
    cfg.gsub! /\[\?1h=\r/, '' # Pager Handling
    cfg.gsub! /\r\[K/,'' # Pager Handling
    cfg.gsub! /\s/, '' # Linebreak Handling
    cfg = cfg.lines.to_a[2..-3].join
  end

  cmd :secret do |cfg|
    cfg.gsub! /(snmp-server community).*/, '   <snmp-server community configuration removed>'
    cfg.gsub! /username (\S+) password (\d+) (\S+).*/, '<secret hidden>'
    cfg
  end

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

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

  cmd 'enable'

  cmd 'show running-config' do |cfg|
    cfg
  end

  cfg :ssh do
    password /^Password:\s*/
    pre_logout 'exit'
  end
end