forked from ytti/oxidized
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dlink.rb
43 lines (34 loc) · 1.07 KB
/
dlink.rb
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 Dlink < Oxidized::Model
using Refinements
# D-LINK Switches
prompt /[\w.@()\/:-]+[#>]\s?$/
comment '# '
cmd :secret do |cfg|
cfg.gsub! /^(create snmp community) \S+/, '\\1 <removed>'
cfg.gsub! /^(create snmp group) \S+/, '\\1 <removed>'
cfg
end
cmd :all do |cfg|
cfg.each_line.to_a[2..-2].map { |line| line.delete("\r").rstrip }.join("\n") + "\n"
end
cmd 'show switch' do |cfg|
cfg.gsub! /^System Uptime\s.+/, '' # Omit constantly changing uptime info
cfg.gsub! /^System up time\s.+/, '' # Omit constantly changing uptime info
cfg.gsub! /^System Time\s.+/, '' # Omit constantly changing uptime info
cfg.gsub! /^RTC Time\s.+/, '' # Omit constantly changing uptime info
comment cfg
end
cmd 'show vlan' do |cfg|
comment cfg
end
cmd 'show config current'
cfg :telnet do
username /\r*([\w\s.@()\/:-]+)?([Uu]ser[Nn]ame|[Ll]ogin):/
password /\r*[Pp]ass[Ww]ord:/
end
cfg :telnet, :ssh do
post_login 'disable clipaging'
post_login 'enable admin' if vars(:enable) == true
pre_logout 'logout'
end
end