forked from ytti/oxidized
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzynosgs.rb
38 lines (36 loc) · 874 Bytes
/
zynosgs.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
class ZyNOSGS < Oxidized::Model
# Used in Zyxel GS1900 switches, tested with GS1900-8
prompt /^.*# $/
comment '! '
expect /^--More--$/ do |data, re|
send ' '
data.sub re, ''
end
# replace all used vt100 control sequences
expect /\e\[\??\d+(;\d+)*[A-Za-z]/ do |data, re|
data.gsub re, ''
end
cmd 'show running-config' do |cfg|
cfg.gsub! /(System Up Time:) \S+(.*)/, '\\1 <time>'
# Remove garbage vt100 control sequences
# Backspace 0x07 char or escape char + control chars
cfg.gsub! /[\b]|\e\[A|\e\[2K/, ''
cfg
end
cfg :telnet, :ssh do
username /^(User name|.*Username):/
password /^\r?Password:/
end
cfg :telnet do
pre_logout do
send "exit\r"
end
end
cfg :ssh do
pre_logout do
# Yes, that GS1900 switch needs two exit !
send "exit\n"
send "exit\n"
end
end
end