oxidized 0.24.0 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +4 -0
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +26 -2
- data/Dockerfile +8 -32
- data/README.md +17 -5
- data/bin/oxidized +1 -1
- data/docs/Configuration.md +41 -3
- data/docs/Hooks.md +26 -0
- data/docs/Model-Notes/AireOS.md +1 -2
- data/docs/Model-Notes/ArbOS.md +1 -2
- data/docs/Model-Notes/Comware.md +1 -2
- data/docs/Model-Notes/EOS.md +1 -2
- data/docs/Model-Notes/JunOS.md +1 -2
- data/docs/Model-Notes/Netgear.md +5 -6
- data/docs/Model-Notes/Nokia.md +9 -0
- data/docs/Model-Notes/README.md +3 -2
- data/docs/Model-Notes/VRP-Huawei.md +1 -2
- data/docs/Model-Notes/Viptela.md +12 -0
- data/docs/Model-Notes/XGS4600-Zyxel.md +1 -2
- data/docs/Ruby-API.md +54 -2
- data/docs/Supported-OS-Types.md +12 -0
- data/extra/oxidized.service +7 -0
- data/lib/oxidized/cli.rb +7 -0
- data/lib/oxidized/config.rb +3 -0
- data/lib/oxidized/core.rb +1 -0
- data/lib/oxidized/hook/ciscosparkdiff.rb +11 -17
- data/lib/oxidized/hook/slackdiff.rb +5 -11
- data/lib/oxidized/hook/xmppdiff.rb +1 -0
- data/lib/oxidized/input/ssh.rb +43 -27
- data/lib/oxidized/input/telnet.rb +1 -0
- data/lib/oxidized/model/acos.rb +2 -2
- data/lib/oxidized/model/acsw.rb +6 -6
- data/lib/oxidized/model/adtran.rb +22 -0
- data/lib/oxidized/model/aen.rb +2 -2
- data/lib/oxidized/model/aireos.rb +3 -2
- data/lib/oxidized/model/alteonos.rb +2 -2
- data/lib/oxidized/model/aos.rb +1 -1
- data/lib/oxidized/model/aos7.rb +1 -1
- data/lib/oxidized/model/aosw.rb +5 -3
- data/lib/oxidized/model/apc_aos.rb +1 -1
- data/lib/oxidized/model/arbos.rb +2 -2
- data/lib/oxidized/model/asa.rb +8 -2
- data/lib/oxidized/model/awplus.rb +1 -1
- data/lib/oxidized/model/axos.rb +16 -0
- data/lib/oxidized/model/c4cmts.rb +3 -5
- data/lib/oxidized/model/casa.rb +1 -1
- data/lib/oxidized/model/catos.rb +1 -1
- data/lib/oxidized/model/ciscosma.rb +1 -1
- data/lib/oxidized/model/ciscosmb.rb +10 -4
- data/lib/oxidized/model/comtrol.rb +41 -0
- data/lib/oxidized/model/comware.rb +1 -1
- data/lib/oxidized/model/coriantgroove.rb +4 -6
- data/lib/oxidized/model/cumulus.rb +14 -1
- data/lib/oxidized/model/datacom.rb +1 -2
- data/lib/oxidized/model/dcnos.rb +1 -1
- data/lib/oxidized/model/dellx.rb +76 -0
- data/lib/oxidized/model/dlink.rb +2 -2
- data/lib/oxidized/model/dnos.rb +3 -1
- data/lib/oxidized/model/eciapollo.rb +34 -0
- data/lib/oxidized/model/edgecos.rb +1 -0
- data/lib/oxidized/model/edgeos.rb +6 -1
- data/lib/oxidized/model/eos.rb +3 -2
- data/lib/oxidized/model/fiberdriver.rb +1 -1
- data/lib/oxidized/model/firebrick.rb +31 -0
- data/lib/oxidized/model/firewareos.rb +1 -1
- data/lib/oxidized/model/fortios.rb +5 -4
- data/lib/oxidized/model/ftos.rb +4 -1
- data/lib/oxidized/model/fujitsupy.rb +3 -3
- data/lib/oxidized/model/gaiaos.rb +1 -1
- data/lib/oxidized/model/gcombnps.rb +3 -1
- data/lib/oxidized/model/hatteras.rb +1 -1
- data/lib/oxidized/model/hirschmann.rb +2 -2
- data/lib/oxidized/model/hpebladesystem.rb +1 -1
- data/lib/oxidized/model/ios.rb +21 -13
- data/lib/oxidized/model/ipos.rb +3 -3
- data/lib/oxidized/model/ironware.rb +3 -3
- data/lib/oxidized/model/isam.rb +1 -1
- data/lib/oxidized/model/junos.rb +1 -1
- data/lib/oxidized/model/masteros.rb +2 -3
- data/lib/oxidized/model/mlnxos.rb +5 -5
- data/lib/oxidized/model/model.rb +3 -0
- data/lib/oxidized/model/ndms.rb +1 -2
- data/lib/oxidized/model/netgear.rb +7 -9
- data/lib/oxidized/model/netonix.rb +1 -1
- data/lib/oxidized/model/netscaler.rb +6 -1
- data/lib/oxidized/model/nos.rb +2 -2
- data/lib/oxidized/model/oneos.rb +1 -1
- data/lib/oxidized/model/openbsd.rb +8 -22
- data/lib/oxidized/model/openwrt.rb +1 -0
- data/lib/oxidized/model/opnsense.rb +1 -1
- data/lib/oxidized/model/panos.rb +9 -9
- data/lib/oxidized/model/pfsense.rb +2 -1
- data/lib/oxidized/model/planet.rb +1 -1
- data/lib/oxidized/model/powerconnect.rb +7 -4
- data/lib/oxidized/model/procurve.rb +7 -5
- data/lib/oxidized/model/routeros.rb +1 -1
- data/lib/oxidized/model/saos.rb +1 -1
- data/lib/oxidized/model/screenos.rb +3 -3
- data/lib/oxidized/model/sros.rb +2 -2
- data/lib/oxidized/model/stoneos.rb +1 -1
- data/lib/oxidized/model/tmos.rb +2 -0
- data/lib/oxidized/model/tplink.rb +4 -0
- data/lib/oxidized/model/viptela.rb +29 -0
- data/lib/oxidized/model/voltaire.rb +5 -5
- data/lib/oxidized/model/voss.rb +4 -4
- data/lib/oxidized/model/vrp.rb +1 -1
- data/lib/oxidized/model/vyatta.rb +1 -1
- data/lib/oxidized/model/weos.rb +1 -1
- data/lib/oxidized/model/xos.rb +9 -2
- data/lib/oxidized/node.rb +20 -31
- data/lib/oxidized/nodes.rb +3 -0
- data/lib/oxidized/output/git.rb +17 -20
- data/lib/oxidized/output/gitcrypt.rb +2 -1
- data/lib/oxidized/output/http.rb +19 -12
- data/lib/oxidized/source/csv.rb +15 -8
- data/lib/oxidized/source/http.rb +26 -22
- data/lib/oxidized/string.rb +9 -4
- data/lib/oxidized/version.rb +2 -2
- data/lib/oxidized/worker.rb +44 -36
- data/oxidized.gemspec +1 -4
- metadata +26 -16
@@ -0,0 +1,22 @@
|
|
1
|
+
class Adtran < Oxidized::Model
|
2
|
+
# Adtran
|
3
|
+
|
4
|
+
prompt /([\w.@-]+[#>]\s?)$/
|
5
|
+
|
6
|
+
cmd :secret do |cfg|
|
7
|
+
cfg.gsub!(/password (\S+)/, 'password <hidden>')
|
8
|
+
cfg
|
9
|
+
end
|
10
|
+
|
11
|
+
cmd 'show running-config'
|
12
|
+
|
13
|
+
cfg :ssh do
|
14
|
+
post_login do
|
15
|
+
send "enable\n"
|
16
|
+
cmd vars(:enable)
|
17
|
+
end
|
18
|
+
post_login 'terminal length 0'
|
19
|
+
pre_logout 'exit'
|
20
|
+
sleep 1
|
21
|
+
end
|
22
|
+
end
|
data/lib/oxidized/model/aen.rb
CHANGED
@@ -3,14 +3,14 @@ class AEN < Oxidized::Model
|
|
3
3
|
|
4
4
|
comment '# '
|
5
5
|
|
6
|
-
prompt /^([-\w.\/:?\[\]
|
6
|
+
prompt /^([-\w.\/:?\[\]()]+:\s?)$/
|
7
7
|
|
8
8
|
cmd 'configuration generate-script module all' do |cfg|
|
9
9
|
cfg
|
10
10
|
end
|
11
11
|
|
12
12
|
cmd :all do |cfg|
|
13
|
-
cfg.
|
13
|
+
cfg.cut_both
|
14
14
|
end
|
15
15
|
|
16
16
|
cfg :ssh do
|
@@ -3,10 +3,10 @@ class Aireos < Oxidized::Model
|
|
3
3
|
# Used in Cisco WLC 5500
|
4
4
|
|
5
5
|
comment '# ' # this complains too, can't find real comment char
|
6
|
-
prompt /^\([
|
6
|
+
prompt /^\([^)]+\)\s>/
|
7
7
|
|
8
8
|
cmd :all do |cfg|
|
9
|
-
cfg.
|
9
|
+
cfg.cut_both
|
10
10
|
end
|
11
11
|
|
12
12
|
# show sysinfo?
|
@@ -44,6 +44,7 @@ class Aireos < Oxidized::Model
|
|
44
44
|
cfg.each_line do |line|
|
45
45
|
next if line.match /^\s*$/
|
46
46
|
next if line.match /rogue (adhoc|client) (alert|Unknown) [\da-f]{2}:/
|
47
|
+
|
47
48
|
line = line[1..-1] if line[0] == "\r"
|
48
49
|
out << line.strip
|
49
50
|
end
|
@@ -35,13 +35,13 @@ class ALTEONOS < Oxidized::Model
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# Answer for Dispay private keys
|
38
|
-
expect /^Display private keys\?\s?\[y\/n\]
|
38
|
+
expect /^Display private keys\?\s?\[y\/n\]: $/ do |data, re|
|
39
39
|
send "n\r"
|
40
40
|
data.sub re, ''
|
41
41
|
end
|
42
42
|
|
43
43
|
# Answer for sync to peer on exit
|
44
|
-
expect /^Confirm Sync to Peer\s?\[y\/n\]
|
44
|
+
expect /^Confirm Sync to Peer\s?\[y\/n\]: $/ do |data, re|
|
45
45
|
send "n\r"
|
46
46
|
data.sub re, ''
|
47
47
|
end
|
data/lib/oxidized/model/aos.rb
CHANGED
data/lib/oxidized/model/aos7.rb
CHANGED
data/lib/oxidized/model/aosw.rb
CHANGED
@@ -13,7 +13,7 @@ class AOSW < Oxidized::Model
|
|
13
13
|
prompt /^\(?.+\)?\s[#>]/
|
14
14
|
|
15
15
|
cmd :all do |cfg|
|
16
|
-
cfg.
|
16
|
+
cfg.cut_both
|
17
17
|
end
|
18
18
|
|
19
19
|
cmd :secret do |cfg|
|
@@ -25,8 +25,8 @@ class AOSW < Oxidized::Model
|
|
25
25
|
cfg.gsub!(/ sha (\S+)/, ' sha <secret removed>')
|
26
26
|
cfg.gsub!(/ des (\S+)/, ' des <secret removed>')
|
27
27
|
cfg.gsub!(/mobility-manager (\S+) user (\S+) (\S+)/, 'mobility-manager \1 user \2 <secret removed>')
|
28
|
-
cfg.gsub!(/mgmt-user (\S+) (root|guest
|
29
|
-
cfg.gsub!(/mgmt-user (\S+) (\S+)( (read
|
28
|
+
cfg.gsub!(/mgmt-user (\S+) (root|guest-provisioning|network-operations|read-only|location-api-mgmt) (\S+)$/, 'mgmt-user \1 \2 <secret removed>') # MAS & Wireless Controler
|
29
|
+
cfg.gsub!(/mgmt-user (\S+) (\S+)( (read-only|guest-mgmt))?$/, 'mgmt-user \1 <secret removed> \3') # IAP
|
30
30
|
# MAS format: mgmt-user <username> <accesslevel> <password hash>
|
31
31
|
# IAP format (root user): mgmt-user <username> <password hash>
|
32
32
|
# IAP format: mgmt-user <username> <password hash> <access level>
|
@@ -63,6 +63,7 @@ class AOSW < Oxidized::Model
|
|
63
63
|
cfg.each_line do |line|
|
64
64
|
next if line.match /^controller config \d+$/
|
65
65
|
next if line.match /^Building Configuration/
|
66
|
+
|
66
67
|
out << line.strip
|
67
68
|
end
|
68
69
|
out = out.join "\n"
|
@@ -106,6 +107,7 @@ class AOSW < Oxidized::Model
|
|
106
107
|
next if line.match /(Tachometers|Temperatures|Voltages)/
|
107
108
|
next if line.match /((Card|CPU) Temperature|Chassis Fan|VMON1[0-9])/
|
108
109
|
next if line.match /[0-9]+\s+(RPMS?|m?V|C)/i
|
110
|
+
|
109
111
|
out << line.strip
|
110
112
|
end
|
111
113
|
out = comment out.join "\n"
|
data/lib/oxidized/model/arbos.rb
CHANGED
@@ -5,8 +5,8 @@ class ARBOS < Oxidized::Model
|
|
5
5
|
comment '# '
|
6
6
|
|
7
7
|
cmd 'system hardware' do |cfg|
|
8
|
-
cfg.gsub! /^Boot
|
9
|
-
cfg.gsub! /^Load
|
8
|
+
cfg.gsub! /^Boot time:\s.+/, '' # Remove boot timer
|
9
|
+
cfg.gsub! /^Load averages:\s.+/, '' # Remove CPU load info
|
10
10
|
cfg = cfg.each_line.to_a[2..-1].join
|
11
11
|
comment cfg
|
12
12
|
end
|
data/lib/oxidized/model/asa.rb
CHANGED
@@ -6,16 +6,22 @@ class ASA < Oxidized::Model
|
|
6
6
|
comment '! '
|
7
7
|
|
8
8
|
cmd :all do |cfg|
|
9
|
-
cfg.
|
9
|
+
cfg.cut_both
|
10
10
|
end
|
11
11
|
|
12
12
|
cmd :secret do |cfg|
|
13
13
|
cfg.gsub! /enable password (\S+) (.*)/, 'enable password <secret hidden> \2'
|
14
|
+
cfg.gsub! /^passwd (\S+) (.*)/, 'passwd <secret hidden> \2'
|
14
15
|
cfg.gsub! /username (\S+) password (\S+) (.*)/, 'username \1 password <secret hidden> \3'
|
15
16
|
cfg.gsub! /(ikev[12] ((remote|local)-authentication )?pre-shared-key) (\S+)/, '\1 <secret hidden>'
|
16
|
-
cfg.gsub! /^(aaa-server TACACS\+? \(\S+\) host
|
17
|
+
cfg.gsub! /^(aaa-server TACACS\+? \(\S+\) host[^\n]*\n(\s+[^\n]+\n)*\skey) \S+$/mi, '\1 <secret hidden>'
|
18
|
+
cfg.gsub! /^(aaa-server \S+ \(\S+\) host[^\n]*\n(\s+[^\n]+\n)*\s+key) \S+$/mi, '\1 <secret hidden>'
|
17
19
|
cfg.gsub! /ldap-login-password (\S+)/, 'ldap-login-password <secret hidden>'
|
18
20
|
cfg.gsub! /^snmp-server host (.*) community (\S+)/, 'snmp-server host \1 community <secret hidden>'
|
21
|
+
cfg.gsub! /^(failover key) .+/, '\1 <secret hidden>'
|
22
|
+
cfg.gsub! /^(\s+ospf message-digest-key \d+ md5) .+/, '\1 <secret hidden>'
|
23
|
+
cfg.gsub! /^(\s+ospf authentication-key) .+/, '\1 <secret hidden>'
|
24
|
+
cfg.gsub! /^(\s+neighbor \S+ password) .+/, '\1 <secret hidden>'
|
19
25
|
cfg
|
20
26
|
end
|
21
27
|
|
@@ -16,7 +16,7 @@ class AWPlus < Oxidized::Model
|
|
16
16
|
cfg.gsub! /\e\[K/, '' # example how to handle pager - cleareol EL0
|
17
17
|
cfg.gsub! /\e\[7m\e\[m/, '' # example how to handle pager - Reverse SGR7
|
18
18
|
cfg.gsub! /\r/, '' # Filters rogue ^M - see issue #415
|
19
|
-
cfg.
|
19
|
+
cfg.cut_both
|
20
20
|
end
|
21
21
|
|
22
22
|
# Remove passwords from config file.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class AxOS < Oxidized::Model
|
2
|
+
prompt /(\x1b\[\?7h)?([\w.@()-]+[#]\s?)$/
|
3
|
+
comment '! '
|
4
|
+
|
5
|
+
cmd 'show running-config | nomore' do |cfg|
|
6
|
+
cfg.cut_head
|
7
|
+
end
|
8
|
+
|
9
|
+
cmd :all do |cfg|
|
10
|
+
cfg.cut_tail
|
11
|
+
end
|
12
|
+
|
13
|
+
cfg :ssh do
|
14
|
+
pre_logout 'exit'
|
15
|
+
end
|
16
|
+
end
|
@@ -17,9 +17,8 @@ class C4CMTS < Oxidized::Model
|
|
17
17
|
end
|
18
18
|
|
19
19
|
cmd 'show environment' do |cfg|
|
20
|
-
cfg.gsub! /\s+[\-\d]+\s+C\s+[
|
21
|
-
cfg.
|
22
|
-
comment cfg
|
20
|
+
cfg.gsub! /\s+[\-\d]+\s+C\s+[(\s\d]+\s+F\)/, '' # remove temperature readings
|
21
|
+
comment cfg.cut_both
|
23
22
|
end
|
24
23
|
|
25
24
|
cmd 'show version' do |cfg|
|
@@ -29,8 +28,7 @@ class C4CMTS < Oxidized::Model
|
|
29
28
|
end
|
30
29
|
|
31
30
|
cmd 'show running-config' do |cfg|
|
32
|
-
cfg
|
33
|
-
cfg
|
31
|
+
cfg.cut_both
|
34
32
|
end
|
35
33
|
|
36
34
|
cfg :telnet do
|
data/lib/oxidized/model/casa.rb
CHANGED
data/lib/oxidized/model/catos.rb
CHANGED
@@ -15,7 +15,13 @@ class CiscoSMB < Oxidized::Model
|
|
15
15
|
cmd :secret do |cfg|
|
16
16
|
cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
|
17
17
|
cfg.gsub! /username (\S+) privilege (\d+) (\S+).*/, '<secret hidden>'
|
18
|
+
cfg.gsub! /^(username \S+ password encrypted) \S+(.*)/, '\\1 <secret hidden> \\2'
|
19
|
+
cfg.gsub! /^(enable password level \d+ encrypted) \S+/, '\\1 <secret hidden>'
|
18
20
|
cfg.gsub! /^(encrypted radius-server key).*/, '\\1 <configuration removed>'
|
21
|
+
cfg.gsub! /^(encrypted radius-server host .+ key) \S+(.*)/, '\\1 <secret hidden> \\2'
|
22
|
+
cfg.gsub! /^(encrypted tacacs-server key).*/, '\\1 <secret hidden>'
|
23
|
+
cfg.gsub! /^(encrypted tacacs-server host .+ key) \S+(.*)/, '\\1 <secret hidden> \\2'
|
24
|
+
cfg.gsub! /^(encrypted sntp authentication-key \d+ md5) .*/, '\\1 <secret hidden>'
|
19
25
|
cfg
|
20
26
|
end
|
21
27
|
|
@@ -24,7 +30,7 @@ class CiscoSMB < Oxidized::Model
|
|
24
30
|
end
|
25
31
|
|
26
32
|
cmd 'show system' do |cfg|
|
27
|
-
cfg.gsub! /System Up Time
|
33
|
+
cfg.gsub! /System Up Time.*\n/, ''
|
28
34
|
comment cfg
|
29
35
|
end
|
30
36
|
|
@@ -36,9 +42,9 @@ class CiscoSMB < Oxidized::Model
|
|
36
42
|
cfg = cfg.each_line.to_a[0..-1].join
|
37
43
|
cfg.gsub! /^Current configuration : [^\n]*\n/, ''
|
38
44
|
cfg.sub! /^(ntp clock-period).*/, '! \1'
|
39
|
-
cfg.gsub!
|
40
|
-
(
|
41
|
-
tunnel
|
45
|
+
cfg.gsub! /^ tunnel mpls traffic-eng bandwidth[^\n]*\n*(
|
46
|
+
(?: [^\n]*\n*)*
|
47
|
+
tunnel mpls traffic-eng auto-bw)/mx, '\1'
|
42
48
|
cfg
|
43
49
|
end
|
44
50
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class Comtrol < Oxidized::Model
|
2
|
+
# Used in Comtrol Industrial Switches, such as RocketLinx ES8510
|
3
|
+
|
4
|
+
# Typical prompt "<hostname>#"
|
5
|
+
prompt /([#>]\s?)$/
|
6
|
+
comment '! '
|
7
|
+
|
8
|
+
# how to handle pager
|
9
|
+
expect /--More--+\s$/ do |data, re|
|
10
|
+
send ' '
|
11
|
+
data.sub re, ''
|
12
|
+
end
|
13
|
+
|
14
|
+
cmd 'show version' do |cfg|
|
15
|
+
comment cfg
|
16
|
+
end
|
17
|
+
|
18
|
+
cmd 'show running-config' do |cfg|
|
19
|
+
cfg
|
20
|
+
end
|
21
|
+
|
22
|
+
cfg :telnet do
|
23
|
+
username /^User name:/i
|
24
|
+
password /^Password:/i
|
25
|
+
end
|
26
|
+
|
27
|
+
cfg :telnet, :ssh do
|
28
|
+
if vars :enable
|
29
|
+
post_login do
|
30
|
+
send "enable\n"
|
31
|
+
# Interpret enable: true as meaning we won't be prompted for a password
|
32
|
+
unless vars(:enable).is_a? TrueClass
|
33
|
+
expect /[pP]assword:\s?$/
|
34
|
+
send vars(:enable) + "\n"
|
35
|
+
end
|
36
|
+
expect /^.+[#]\s?$/
|
37
|
+
end
|
38
|
+
end
|
39
|
+
pre_logout 'exit'
|
40
|
+
end
|
41
|
+
end
|
@@ -8,21 +8,19 @@ class CoriantGroove < Oxidized::Model
|
|
8
8
|
end
|
9
9
|
|
10
10
|
cmd 'show inventory' do |cfg|
|
11
|
-
|
12
|
-
comment cfg
|
11
|
+
comment cfg.cut_tail
|
13
12
|
end
|
14
13
|
|
15
14
|
cmd 'show softwareload' do |cfg|
|
16
|
-
|
17
|
-
comment cfg
|
15
|
+
comment cfg.cut_tail
|
18
16
|
end
|
19
17
|
|
20
18
|
cmd 'show config | display commands' do |cfg|
|
21
|
-
cfg.
|
19
|
+
cfg.cut_head
|
22
20
|
end
|
23
21
|
|
24
22
|
cfg :ssh do
|
25
|
-
post_login 'set -f cli-config cli-columns
|
23
|
+
post_login 'set -f cli-config cli-columns 4000'
|
26
24
|
pre_logout 'quit -f'
|
27
25
|
end
|
28
26
|
end
|
@@ -8,7 +8,7 @@ class Cumulus < Oxidized::Model
|
|
8
8
|
end
|
9
9
|
|
10
10
|
cmd :all do |cfg|
|
11
|
-
cfg.
|
11
|
+
cfg.cut_both
|
12
12
|
end
|
13
13
|
|
14
14
|
# show the persistent configuration
|
@@ -88,6 +88,19 @@ class Cumulus < Oxidized::Model
|
|
88
88
|
end
|
89
89
|
|
90
90
|
cfg :telnet, :ssh do
|
91
|
+
post_login do
|
92
|
+
if vars(:enable) == true
|
93
|
+
cmd "sudo su -", /^\[sudo\] password/
|
94
|
+
cmd @node.auth[:password]
|
95
|
+
elsif vars(:enable)
|
96
|
+
cmd "su -", /^Password:/
|
97
|
+
cmd vars(:enable)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
pre_logout do
|
102
|
+
cmd "exit" if vars(:enable)
|
103
|
+
end
|
91
104
|
pre_logout 'exit'
|
92
105
|
end
|
93
106
|
end
|
data/lib/oxidized/model/dcnos.rb
CHANGED
@@ -0,0 +1,76 @@
|
|
1
|
+
class DellX < Oxidized::Model
|
2
|
+
# Used in Dell X-Series Switches
|
3
|
+
|
4
|
+
prompt /[#>]$/
|
5
|
+
|
6
|
+
comment '! '
|
7
|
+
|
8
|
+
expect /(^.*)?+[mM]ore\:+.*$/ do |data, re|
|
9
|
+
send ' '
|
10
|
+
data.sub re, ''
|
11
|
+
end
|
12
|
+
|
13
|
+
cmd :all do |cfg|
|
14
|
+
cfg.each_line.to_a[1..-3].join
|
15
|
+
end
|
16
|
+
|
17
|
+
cmd :secret do |cfg|
|
18
|
+
cfg.gsub! /^(username \S+ password (?:encrypted )?)\S+(.*)/, '\1<hidden>\2'
|
19
|
+
cfg
|
20
|
+
end
|
21
|
+
|
22
|
+
cmd 'show version' do |cfg|
|
23
|
+
if @stackable.nil?
|
24
|
+
@stackable = true if cfg.match /(U|u)nit\s/
|
25
|
+
end
|
26
|
+
cfg = cfg.split("\n").reject { |line| line[/Up\sTime/] }
|
27
|
+
comment cfg.join("\n") + "\n"
|
28
|
+
end
|
29
|
+
|
30
|
+
cmd 'show system' do |cfg|
|
31
|
+
clean cfg
|
32
|
+
end
|
33
|
+
|
34
|
+
cmd 'show running-config' do |cfg|
|
35
|
+
cfg.sub(/^(sflow \S+ destination owner \S+ timeout )\d+$/, '! \1<timeout>')
|
36
|
+
end
|
37
|
+
|
38
|
+
cfg :telnet, :ssh do
|
39
|
+
username /[uU]ser\s?[nN]ame:$/
|
40
|
+
password /[pP]assword:$/
|
41
|
+
end
|
42
|
+
|
43
|
+
cfg :telnet, :ssh do
|
44
|
+
if vars :enable
|
45
|
+
post_login do
|
46
|
+
send "enable\n"
|
47
|
+
cmd vars(:enable)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
pre_logout "logout"
|
52
|
+
pre_logout "exit"
|
53
|
+
end
|
54
|
+
|
55
|
+
def clean cfg
|
56
|
+
out = []
|
57
|
+
skip_blocks = 0
|
58
|
+
cfg.each_line do |line|
|
59
|
+
# If this is a stackable switch we should skip this block of information
|
60
|
+
if line.match /Up\sTime|Temperature|Power Suppl(ies|y)|Fans/i and @stackable == true
|
61
|
+
skip_blocks = 1
|
62
|
+
# Some switches have another empty line. This is identified by this line having a colon
|
63
|
+
skip_blocks = 2 if line.match /:/
|
64
|
+
end
|
65
|
+
# If we have lines to skip do this until we reach and empty line
|
66
|
+
if skip_blocks > 0
|
67
|
+
skip_blocks -= 1 if /\S/ !~ line
|
68
|
+
next
|
69
|
+
end
|
70
|
+
out << line.strip
|
71
|
+
end
|
72
|
+
out = out.reject { |line| line[/Up\sTime/] }
|
73
|
+
out = comment out.join "\n"
|
74
|
+
out << "\n"
|
75
|
+
end
|
76
|
+
end
|