oxidized 0.21.0 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/no-response.yml +13 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +37 -0
- data/.rubocop_todo.yml +714 -0
- data/.travis.yml +7 -1
- data/CHANGELOG.md +341 -243
- data/Dockerfile +44 -16
- data/LICENSE +201 -0
- data/README.md +114 -82
- data/Rakefile +19 -0
- data/TODO.md +29 -23
- data/bin/oxidized +1 -2
- data/docs/Configuration.md +71 -31
- data/docs/Creating-Models.md +78 -0
- data/docs/Hooks.md +145 -41
- data/docs/Model-Notes/AireOS.md +12 -0
- data/docs/Model-Notes/ArbOS.md +12 -0
- data/docs/Model-Notes/Comware.md +14 -0
- data/docs/Model-Notes/EOS.md +9 -0
- data/docs/Model-Notes/JunOS.md +34 -0
- data/docs/Model-Notes/Netgear.md +68 -0
- data/docs/Model-Notes/README.md +19 -0
- data/docs/{VRP-Huawei.md → Model-Notes/VRP-Huawei.md} +10 -2
- data/docs/Model-Notes/XGS4600-Zyxel.md +39 -0
- data/docs/Outputs.md +27 -28
- data/docs/Ruby-API.md +38 -18
- data/docs/Sources.md +78 -16
- data/docs/Supported-OS-Types.md +171 -148
- data/extra/oxidized.logrotate +7 -0
- data/extra/oxidized.service +1 -1
- data/extra/rest_client.rb +4 -5
- data/extra/syslog.rb +16 -16
- data/lib/oxidized/cli.rb +3 -3
- data/lib/oxidized/config.rb +7 -4
- data/lib/oxidized/core.rb +3 -3
- data/lib/oxidized/hook.rb +64 -65
- data/lib/oxidized/hook/awssns.rb +2 -3
- data/lib/oxidized/hook/ciscosparkdiff.rb +49 -0
- data/lib/oxidized/hook/exec.rb +5 -5
- data/lib/oxidized/hook/githubrepo.rb +20 -14
- data/lib/oxidized/hook/slackdiff.rb +38 -19
- data/lib/oxidized/hook/xmppdiff.rb +58 -0
- data/lib/oxidized/input/cli.rb +5 -6
- data/lib/oxidized/input/ftp.rb +8 -7
- data/lib/oxidized/input/http.rb +39 -0
- data/lib/oxidized/input/ssh.rb +24 -22
- data/lib/oxidized/input/telnet.rb +38 -32
- data/lib/oxidized/jobs.rb +3 -4
- data/lib/oxidized/manager.rb +9 -4
- data/lib/oxidized/model/acos.rb +15 -16
- data/lib/oxidized/model/acsw.rb +3 -8
- data/lib/oxidized/model/aen.rb +1 -2
- data/lib/oxidized/model/aireos.rb +3 -5
- data/lib/oxidized/model/alteonos.rb +16 -18
- data/lib/oxidized/model/alvarion.rb +0 -4
- data/lib/oxidized/model/aos.rb +2 -4
- data/lib/oxidized/model/aos7.rb +2 -3
- data/lib/oxidized/model/aosw.rb +13 -15
- data/lib/oxidized/model/apc_aos.rb +0 -3
- data/lib/oxidized/model/arbos.rb +26 -0
- data/lib/oxidized/model/aricentiss.rb +51 -0
- data/lib/oxidized/model/asa.rb +33 -35
- data/lib/oxidized/model/asyncos.rb +41 -44
- data/lib/oxidized/model/audiocodes.rb +4 -8
- data/lib/oxidized/model/awplus.rb +84 -0
- data/lib/oxidized/model/boss.rb +6 -5
- data/lib/oxidized/model/br6910.rb +43 -45
- data/lib/oxidized/model/c4cmts.rb +3 -5
- data/lib/oxidized/model/cambium.rb +22 -0
- data/lib/oxidized/model/catos.rb +0 -2
- data/lib/oxidized/model/cisconga.rb +1 -3
- data/lib/oxidized/model/ciscosma.rb +37 -40
- data/lib/oxidized/model/ciscosmb.rb +7 -4
- data/lib/oxidized/model/comnetms.rb +43 -0
- data/lib/oxidized/model/comware.rb +9 -9
- data/lib/oxidized/model/coriant8600.rb +3 -5
- data/lib/oxidized/model/coriantgroove.rb +3 -5
- data/lib/oxidized/model/corianttmos.rb +1 -3
- data/lib/oxidized/model/cumulus.rb +26 -32
- data/lib/oxidized/model/datacom.rb +0 -2
- data/lib/oxidized/model/dcnos.rb +46 -0
- data/lib/oxidized/model/dlink.rb +1 -1
- data/lib/oxidized/model/dnos.rb +9 -5
- data/lib/oxidized/model/edgecos.rb +45 -0
- data/lib/oxidized/model/edgeos.rb +5 -3
- data/lib/oxidized/model/edgeswitch.rb +1 -3
- data/lib/oxidized/model/enterasys.rb +1 -3
- data/lib/oxidized/model/eos.rb +6 -8
- data/lib/oxidized/model/fabricos.rb +3 -5
- data/lib/oxidized/model/firewareos.rb +2 -5
- data/lib/oxidized/model/fortios.rb +21 -17
- data/lib/oxidized/model/ftos.rb +2 -4
- data/lib/oxidized/model/fujitsupy.rb +2 -4
- data/lib/oxidized/model/gaiaos.rb +6 -10
- data/lib/oxidized/model/gcombnps.rb +82 -0
- data/lib/oxidized/model/hatteras.rb +8 -5
- data/lib/oxidized/model/hirschmann.rb +8 -10
- data/lib/oxidized/model/hpebladesystem.rb +19 -17
- data/lib/oxidized/model/hpemsa.rb +0 -3
- data/lib/oxidized/model/ios.rb +54 -55
- data/lib/oxidized/model/iosxe.rb +5 -0
- data/lib/oxidized/model/iosxr.rb +1 -3
- data/lib/oxidized/model/ipos.rb +1 -3
- data/lib/oxidized/model/ironware.rb +12 -15
- data/lib/oxidized/model/isam.rb +4 -5
- data/lib/oxidized/model/junos.rb +8 -7
- data/lib/oxidized/model/masteros.rb +1 -3
- data/lib/oxidized/model/mlnxos.rb +3 -4
- data/lib/oxidized/model/model.rb +15 -7
- data/lib/oxidized/model/mtrlrfs.rb +1 -4
- data/lib/oxidized/model/ndms.rb +24 -0
- data/lib/oxidized/model/netgear.rb +3 -4
- data/lib/oxidized/model/netscaler.rb +0 -2
- data/lib/oxidized/model/nos.rb +1 -3
- data/lib/oxidized/model/nxos.rb +13 -3
- data/lib/oxidized/model/oneos.rb +6 -8
- data/lib/oxidized/model/openbsd.rb +76 -0
- data/lib/oxidized/model/opengear.rb +3 -5
- data/lib/oxidized/model/openwrt.rb +77 -0
- data/lib/oxidized/model/opnsense.rb +19 -0
- data/lib/oxidized/model/outputs.rb +1 -3
- data/lib/oxidized/model/panos.rb +1 -2
- data/lib/oxidized/model/pfsense.rb +9 -5
- data/lib/oxidized/model/planet.rb +8 -12
- data/lib/oxidized/model/powerconnect.rb +6 -9
- data/lib/oxidized/model/procurve.rb +18 -4
- data/lib/oxidized/model/quantaos.rb +3 -5
- data/lib/oxidized/model/routeros.rb +3 -2
- data/lib/oxidized/model/saos.rb +0 -1
- data/lib/oxidized/model/screenos.rb +3 -5
- data/lib/oxidized/model/sgos.rb +2 -3
- data/lib/oxidized/model/siklu.rb +0 -2
- data/lib/oxidized/model/slxos.rb +59 -0
- data/lib/oxidized/model/sros.rb +117 -0
- data/lib/oxidized/model/stoneos.rb +32 -0
- data/lib/oxidized/model/supermicro.rb +6 -41
- data/lib/oxidized/model/timos.rb +6 -114
- data/lib/oxidized/model/tmos.rb +1 -3
- data/lib/oxidized/model/tplink.rb +7 -11
- data/lib/oxidized/model/trango.rb +6 -7
- data/lib/oxidized/model/ucs.rb +0 -1
- data/lib/oxidized/model/voltaire.rb +3 -6
- data/lib/oxidized/model/voss.rb +1 -2
- data/lib/oxidized/model/vrp.rb +4 -5
- data/lib/oxidized/model/vyatta.rb +6 -4
- data/lib/oxidized/model/weos.rb +1 -3
- data/lib/oxidized/model/xos.rb +6 -5
- data/lib/oxidized/model/zhoneolt.rb +2 -2
- data/lib/oxidized/model/zynos.rb +1 -3
- data/lib/oxidized/model/zynoscli.rb +36 -0
- data/lib/oxidized/node.rb +11 -11
- data/lib/oxidized/node/stats.rb +15 -2
- data/lib/oxidized/nodes.rb +8 -8
- data/lib/oxidized/output/file.rb +41 -42
- data/lib/oxidized/output/git.rb +113 -115
- data/lib/oxidized/output/gitcrypt.rb +241 -242
- data/lib/oxidized/output/http.rb +23 -27
- data/lib/oxidized/output/output.rb +1 -2
- data/lib/oxidized/source/csv.rb +44 -45
- data/lib/oxidized/source/http.rb +52 -49
- data/lib/oxidized/source/source.rb +6 -7
- data/lib/oxidized/source/sql.rb +55 -51
- data/lib/oxidized/string.rb +3 -4
- data/lib/oxidized/version.rb +17 -1
- data/lib/oxidized/worker.rb +12 -3
- data/oxidized.gemspec +19 -13
- metadata +139 -51
- data/.ruby-version +0 -1
- data/Gemfile.lock +0 -44
@@ -1,8 +1,7 @@
|
|
1
1
|
class OpenGear < Oxidized::Model
|
2
|
+
comment '# '
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
prompt /^(\$\s)?$/
|
4
|
+
prompt /^(\$\s)$/
|
6
5
|
|
7
6
|
cmd :secret do |cfg|
|
8
7
|
cfg.gsub!(/password (\S+)/, 'password <secret removed>')
|
@@ -15,7 +14,6 @@ class OpenGear < Oxidized::Model
|
|
15
14
|
cmd 'config -g config'
|
16
15
|
|
17
16
|
cfg :ssh do
|
18
|
-
exec true
|
17
|
+
exec true # don't run shell, run each command in exec channel
|
19
18
|
end
|
20
|
-
|
21
19
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
class OpenWrt < Oxidized::Model
|
2
|
+
prompt /^[^#]+#/
|
3
|
+
comment '#'
|
4
|
+
|
5
|
+
cmd 'cat /etc/banner' do |cfg|
|
6
|
+
comment "#### Info: /etc/banner #####\n#{cfg}"
|
7
|
+
end
|
8
|
+
|
9
|
+
cmd 'cat /proc/cpuinfo' do |cfg|
|
10
|
+
comment "#### Info: /proc/cpuinfo #####\n#{cfg}"
|
11
|
+
end
|
12
|
+
|
13
|
+
cmd 'cat /etc/openwrt_release' do |cfg|
|
14
|
+
comment "#### Info: /etc/openwrt_release #####\n#{cfg}"
|
15
|
+
end
|
16
|
+
|
17
|
+
cmd 'sysupgrade -l' do |cfg|
|
18
|
+
@sysupgradefiles = cfg
|
19
|
+
comment "#### Info: sysupgrade -l #####\n#{cfg}"
|
20
|
+
end
|
21
|
+
|
22
|
+
cmd 'cat /proc/mtd' do |cfg|
|
23
|
+
@mtdpartitions = cfg
|
24
|
+
comment "#### Info: /proc/mtd #####\n#{cfg}"
|
25
|
+
end
|
26
|
+
|
27
|
+
post do
|
28
|
+
cfg = []
|
29
|
+
binary_files = vars(:openwrt_binary_files) || %w[/etc/dropbear/dropbear_rsa_host_key]
|
30
|
+
non_sensitive_files = vars(:openwrt_non_sensitive_files) || %w[rpcd uhttpd]
|
31
|
+
partitions_to_backup = vars(:openwrt_partitions_to_backup) || %w[art devinfo u_env config caldata]
|
32
|
+
@sysupgradefiles.lines.each do |sysupgradefile|
|
33
|
+
sysupgradefile = sysupgradefile.strip
|
34
|
+
if sysupgradefile.start_with?('/etc/config/')
|
35
|
+
unless sysupgradefile.end_with?('-opkg')
|
36
|
+
filename = sysupgradefile.split('/')[-1]
|
37
|
+
cfg << comment("#### File: #{sysupgradefile} #####")
|
38
|
+
uciexport = cmd("uci export #{filename}")
|
39
|
+
Oxidized.logger.debug "Exporting uci config - #{filename}"
|
40
|
+
if vars(:remove_secret) && !(non_sensitive_files.include? filename)
|
41
|
+
Oxidized.logger.debug "Scrubbing uci config - #{filename}"
|
42
|
+
uciexport.gsub!(/^(\s+option\s+(password|key)\s+')[^']+'/, '\\1<secret hidden>\'')
|
43
|
+
end
|
44
|
+
cfg << uciexport
|
45
|
+
end
|
46
|
+
elsif binary_files.include? sysupgradefile
|
47
|
+
Oxidized.logger.debug "Exporting binary file - #{sysupgradefile}"
|
48
|
+
cfg << comment("#### Binary file: #{sysupgradefile} #####")
|
49
|
+
cfg << comment("Decode using 'echo -en <data> | gzip -dc > #{sysupgradefile}'")
|
50
|
+
cfg << cmd("gzip -c #{sysupgradefile} | hexdump -ve '1/1 \"_x%.2x\"' | tr _ \\")
|
51
|
+
elsif vars(:remove_secret) && sysupgradefile == '/etc/shadow'
|
52
|
+
Oxidized.logger.debug 'Exporting and scrubbing /etc/shadow'
|
53
|
+
cfg << comment("#### File: #{sysupgradefile} #####")
|
54
|
+
shadow = cmd("cat #{sysupgradefile}")
|
55
|
+
shadow.gsub!(/^([^:]+:)[^:]*(:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:)/, '\\1\\2')
|
56
|
+
cfg << shadow
|
57
|
+
else
|
58
|
+
Oxidized.logger.debug "Exporting file - #{sysupgradefile}"
|
59
|
+
cfg << comment("#### File: #{sysupgradefile} #####")
|
60
|
+
cfg << cmd("cat #{sysupgradefile}")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
@mtdpartitions.scan(/(\w+):\s+\w+\s+\w+\s+"(.*)"/).each do |partition, name|
|
64
|
+
next unless vars(:openwrt_backup_partitions) && partitions_to_backup.include?(name)
|
65
|
+
Oxidized.logger.debug "Exporting partition - #{name}(#{partition})"
|
66
|
+
cfg << comment("#### Partition: #{name} /dev/#{partition} #####")
|
67
|
+
cfg << comment("Decode using 'echo -en <data> | gzip -dc > #{name}'")
|
68
|
+
cfg << cmd("dd if=/dev/#{partition} 2>/dev/null | gzip -c | hexdump -ve '1/1 \"%.2x\"'")
|
69
|
+
end
|
70
|
+
cfg.join "\n"
|
71
|
+
end
|
72
|
+
|
73
|
+
cfg :ssh do
|
74
|
+
exec true
|
75
|
+
pre_logout 'exit'
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class OpnSense < Oxidized::Model
|
2
|
+
# minimum required permissions: "System: Shell account access"
|
3
|
+
# must enable SSH and password-based SSH access
|
4
|
+
|
5
|
+
cmd :all do |cfg|
|
6
|
+
cfg.each_line.to_a[1..-1].join
|
7
|
+
end
|
8
|
+
|
9
|
+
cmd 'cat /conf/config.xml' do |cfg|
|
10
|
+
cfg.gsub! /\s<revision>\s*<time>\d*<\/time>\s*.*\s*.*\s*<\/revision>/, ''
|
11
|
+
cfg.gsub! /\s<last_rule_upd_time>\d*<\/last_rule_upd_time>/, ''
|
12
|
+
cfg
|
13
|
+
end
|
14
|
+
|
15
|
+
cfg :ssh do
|
16
|
+
exec true
|
17
|
+
pre_logout 'exit'
|
18
|
+
end
|
19
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Oxidized
|
2
2
|
class Model
|
3
3
|
class Outputs
|
4
|
-
|
5
4
|
def to_cfg
|
6
5
|
type_to_str(nil)
|
7
6
|
end
|
@@ -23,7 +22,7 @@ module Oxidized
|
|
23
22
|
end
|
24
23
|
|
25
24
|
def type type
|
26
|
-
@outputs.select { |out| out.type==type }
|
25
|
+
@outputs.select { |out| out.type == type }
|
27
26
|
end
|
28
27
|
|
29
28
|
def types
|
@@ -35,7 +34,6 @@ module Oxidized
|
|
35
34
|
def initialize
|
36
35
|
@outputs = []
|
37
36
|
end
|
38
|
-
|
39
37
|
end
|
40
38
|
end
|
41
39
|
end
|
data/lib/oxidized/model/panos.rb
CHANGED
@@ -1,20 +1,24 @@
|
|
1
1
|
class PfSense < Oxidized::Model
|
2
|
-
|
3
2
|
# use other use than 'admin' user, 'admin' user cannot get ssh/exec. See issue #535
|
4
|
-
|
3
|
+
|
5
4
|
cmd :all do |cfg|
|
6
5
|
cfg.each_line.to_a[1..-1].join
|
7
6
|
end
|
8
|
-
|
7
|
+
|
8
|
+
cmd :secret do |cfg|
|
9
|
+
cfg.gsub! /(\s+<bcrypt-hash>)[^<]+(<\/bcrypt-hash>)/, '\\1<secret hidden>\\2'
|
10
|
+
cfg.gsub! /(\s+<password>)[^<]+(<\/password>)/, '\\1<secret hidden>\\2'
|
11
|
+
cfg
|
12
|
+
end
|
13
|
+
|
9
14
|
cmd 'cat /cf/conf/config.xml' do |cfg|
|
10
15
|
cfg.gsub! /\s<revision>\s*<time>\d*<\/time>\s*.*\s*.*\s*<\/revision>/, ''
|
11
16
|
cfg.gsub! /\s<last_rule_upd_time>\d*<\/last_rule_upd_time>/, ''
|
12
17
|
cfg
|
13
18
|
end
|
14
|
-
|
19
|
+
|
15
20
|
cfg :ssh do
|
16
21
|
exec true
|
17
22
|
pre_logout 'exit'
|
18
23
|
end
|
19
|
-
|
20
24
|
end
|
@@ -1,24 +1,23 @@
|
|
1
1
|
class Planet < Oxidized::Model
|
2
|
-
|
3
2
|
prompt /^\r?([\w.@()-]+[#>]\s?)$/
|
4
3
|
comment '! '
|
5
4
|
|
6
5
|
# example how to handle pager
|
7
|
-
#expect /^\s--More--\s+.*$/ do |data, re|
|
6
|
+
# expect /^\s--More--\s+.*$/ do |data, re|
|
8
7
|
# send ' '
|
9
8
|
# data.sub re, ''
|
10
|
-
#end
|
9
|
+
# end
|
11
10
|
|
12
11
|
# non-preferred way to handle additional PW prompt
|
13
|
-
#expect /^[\w.]+>$/ do |data|
|
12
|
+
# expect /^[\w.]+>$/ do |data|
|
14
13
|
# send "enable\n"
|
15
14
|
# send vars(:enable) + "\n"
|
16
15
|
# data
|
17
|
-
#end
|
16
|
+
# end
|
18
17
|
|
19
18
|
cmd :all do |cfg|
|
20
|
-
#cfg.gsub! /\cH+\s{8}/, '' # example how to handle pager
|
21
|
-
#cfg.gsub! /\cH+/, '' # example how to handle pager
|
19
|
+
# cfg.gsub! /\cH+\s{8}/, '' # example how to handle pager
|
20
|
+
# cfg.gsub! /\cH+/, '' # example how to handle pager
|
22
21
|
cfg.each_line.to_a[1..-2].join
|
23
22
|
end
|
24
23
|
|
@@ -39,7 +38,7 @@ class Planet < Oxidized::Model
|
|
39
38
|
|
40
39
|
cfg = cfg.each_line.to_a[0...-2]
|
41
40
|
|
42
|
-
|
41
|
+
# Strip system (up)time and temperature
|
43
42
|
cfg = cfg.reject { |line| line.match /System Time\s*:.*/ }
|
44
43
|
cfg = cfg.reject { |line| line.match /System Uptime\s*:.*/ }
|
45
44
|
cfg = cfg.reject { |line| line.match /Temperature\s*:.*/ }
|
@@ -47,13 +46,12 @@ class Planet < Oxidized::Model
|
|
47
46
|
comment cfg.join
|
48
47
|
end
|
49
48
|
|
50
|
-
|
51
49
|
cmd 'show running-config' do |cfg|
|
52
50
|
cfg.gsub! "\n\r", "\n"
|
53
51
|
cfg = cfg.each_line.to_a
|
54
52
|
|
55
53
|
cfg = cfg.reject { |line| line.match "Building configuration..." }
|
56
|
-
|
54
|
+
|
57
55
|
if @planetsgs
|
58
56
|
cfg << cmd('show transceiver detail | include transceiver detail information|found|Type|length|Nominal|wavelength|Base information') do |cfg|
|
59
57
|
comment cfg
|
@@ -62,7 +60,6 @@ class Planet < Oxidized::Model
|
|
62
60
|
|
63
61
|
cfg.join
|
64
62
|
end
|
65
|
-
|
66
63
|
|
67
64
|
cfg :telnet do
|
68
65
|
username /^Username:/
|
@@ -80,5 +77,4 @@ class Planet < Oxidized::Model
|
|
80
77
|
end
|
81
78
|
pre_logout 'exit'
|
82
79
|
end
|
83
|
-
|
84
80
|
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
class PowerConnect < Oxidized::Model
|
2
|
-
|
3
2
|
prompt /^([\w\s.@-]+[#>]\s?)$/ # allow spaces in hostname..dell does not limit it.. #
|
4
3
|
|
5
|
-
comment
|
4
|
+
comment '! '
|
6
5
|
|
7
6
|
expect /^\s*--More--\s+.*$/ do |data, re|
|
8
|
-
|
9
|
-
|
7
|
+
send ' '
|
8
|
+
data.sub re, ''
|
10
9
|
end
|
11
10
|
|
12
11
|
cmd :all do |cfg|
|
@@ -14,7 +13,7 @@ class PowerConnect < Oxidized::Model
|
|
14
13
|
end
|
15
14
|
|
16
15
|
cmd :secret do |cfg|
|
17
|
-
cfg.gsub! /^username
|
16
|
+
cfg.gsub! /^(username \S+ password (?:encrypted )?)\S+(.*)/, '\1<hidden>\2'
|
18
17
|
cfg
|
19
18
|
end
|
20
19
|
|
@@ -22,7 +21,7 @@ class PowerConnect < Oxidized::Model
|
|
22
21
|
if (@stackable.nil?)
|
23
22
|
@stackable = true if cfg.match /(U|u)nit\s/
|
24
23
|
end
|
25
|
-
cfg = cfg.split("\n").
|
24
|
+
cfg = cfg.split("\n").reject { |line| line[/Up\sTime/] }
|
26
25
|
comment cfg.join("\n") + "\n"
|
27
26
|
end
|
28
27
|
|
@@ -52,7 +51,6 @@ class PowerConnect < Oxidized::Model
|
|
52
51
|
post_login "terminal length 0"
|
53
52
|
pre_logout "logout"
|
54
53
|
pre_logout "exit"
|
55
|
-
|
56
54
|
end
|
57
55
|
|
58
56
|
def clean cfg
|
@@ -72,9 +70,8 @@ class PowerConnect < Oxidized::Model
|
|
72
70
|
end
|
73
71
|
out << line.strip
|
74
72
|
end
|
75
|
-
out = out.
|
73
|
+
out = out.reject { |line| line[/Up\sTime/] }
|
76
74
|
out = comment out.join "\n"
|
77
75
|
out << "\n"
|
78
76
|
end
|
79
|
-
|
80
77
|
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
class Procurve < Oxidized::Model
|
2
|
-
|
3
2
|
# some models start lines with \r
|
4
3
|
# previous command is repeated followed by "\eE", which sometimes ends up on last line
|
5
4
|
prompt /^\r?([\w.-]+# )$/
|
6
5
|
|
7
|
-
comment
|
6
|
+
comment '! '
|
8
7
|
|
9
8
|
# replace next line control sequence with a new line
|
10
9
|
expect /(\e\[1M\e\[\??\d+(;\d+)*[A-Za-z]\e\[1L)|(\eE)/ do |data, re|
|
@@ -21,6 +20,11 @@ class Procurve < Oxidized::Model
|
|
21
20
|
""
|
22
21
|
end
|
23
22
|
|
23
|
+
expect /Enter switch number/ do
|
24
|
+
send "\n"
|
25
|
+
""
|
26
|
+
end
|
27
|
+
|
24
28
|
cmd :all do |cfg|
|
25
29
|
cfg = cfg.each_line.to_a[1..-2].join
|
26
30
|
cfg = cfg.gsub /^\r/, ''
|
@@ -42,6 +46,10 @@ class Procurve < Oxidized::Model
|
|
42
46
|
comment cfg
|
43
47
|
end
|
44
48
|
|
49
|
+
cmd 'show system power-supply' do |cfg|
|
50
|
+
comment cfg
|
51
|
+
end
|
52
|
+
|
45
53
|
cmd 'show interfaces transceiver' do |cfg|
|
46
54
|
comment cfg
|
47
55
|
end
|
@@ -58,7 +66,7 @@ class Procurve < Oxidized::Model
|
|
58
66
|
|
59
67
|
# not supported on all models
|
60
68
|
cmd 'show system information' do |cfg|
|
61
|
-
cfg = cfg.each_line.
|
69
|
+
cfg = cfg.each_line.reject { |line| line.match /(.*CPU.*)|(.*Up Time.*)|(.*Total.*)|(.*Free.*)|(.*Lowest.*)|(.*Missed.*)/ }
|
62
70
|
cfg = cfg.join
|
63
71
|
comment cfg
|
64
72
|
end
|
@@ -71,6 +79,13 @@ class Procurve < Oxidized::Model
|
|
71
79
|
end
|
72
80
|
|
73
81
|
cfg :telnet, :ssh do
|
82
|
+
# preferred way to handle additional passwords
|
83
|
+
if vars :enable
|
84
|
+
post_login do
|
85
|
+
send "enable\n"
|
86
|
+
cmd vars(:enable)
|
87
|
+
end
|
88
|
+
end
|
74
89
|
post_login 'no page'
|
75
90
|
pre_logout "logout\ny\nn"
|
76
91
|
end
|
@@ -78,5 +93,4 @@ class Procurve < Oxidized::Model
|
|
78
93
|
cfg :ssh do
|
79
94
|
pty_options({ chars_wide: 1000 })
|
80
95
|
end
|
81
|
-
|
82
96
|
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
class QuantaOS < Oxidized::Model
|
2
|
-
|
3
2
|
prompt /^\((\w|\S)+\) (>|#)$/
|
4
3
|
comment '! '
|
5
|
-
|
4
|
+
|
6
5
|
cmd 'show run' do |cfg|
|
7
6
|
cfg.each_line.select do |line|
|
8
7
|
not line.match /^!.*$/ and
|
9
|
-
|
10
|
-
|
8
|
+
not line.match /^\((\w|\S)+\) (>|#)$/ and
|
9
|
+
not line.match /^show run$/
|
11
10
|
end.join
|
12
11
|
end
|
13
12
|
|
@@ -31,5 +30,4 @@ class QuantaOS < Oxidized::Model
|
|
31
30
|
send "n\n"
|
32
31
|
end
|
33
32
|
end
|
34
|
-
|
35
33
|
end
|
@@ -18,8 +18,9 @@ class RouterOS < Oxidized::Model
|
|
18
18
|
run_cmd = vars(:remove_secret) ? '/export hide-sensitive' : '/export'
|
19
19
|
cmd run_cmd do |cfg|
|
20
20
|
cfg.gsub! /\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]/, '' # strip ANSI colours
|
21
|
-
cfg.gsub! /\\\r\n\s+/, ''
|
22
|
-
cfg
|
21
|
+
cfg.gsub! /\\\r\n\s+/, '' # strip new line
|
22
|
+
cfg.gsub! /# inactive time\r\n/, '' # Remove time based system comment
|
23
|
+
cfg = cfg.split("\n").reject { |line| line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] }
|
23
24
|
cfg.join("\n") + "\n"
|
24
25
|
end
|
25
26
|
end
|
data/lib/oxidized/model/saos.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
class ScreenOS
|
2
|
-
|
1
|
+
class ScreenOS < Oxidized::Model
|
3
2
|
# Netscreen ScreenOS model #
|
4
3
|
|
5
|
-
comment
|
4
|
+
comment '! '
|
6
5
|
|
7
6
|
prompt /^[\w.:\(\)-]+->\s?$/
|
8
7
|
|
@@ -10,7 +9,7 @@ class ScreenOS < Oxidized::Model
|
|
10
9
|
cfg.each_line.to_a[2..-2].join
|
11
10
|
end
|
12
11
|
|
13
|
-
cmd :secret do |cfg|
|
12
|
+
cmd :secret do |cfg|
|
14
13
|
cfg.gsub! /^(set admin name) .*|^(set admin password) .*/, '\\1 <removed>'
|
15
14
|
cfg.gsub! /^(set admin user .* password) .* (.*)/, '\\1 <removed> \\2'
|
16
15
|
cfg.gsub! /(secret|password|preshare) .*/, '\\1 <secret hidden>'
|
@@ -41,5 +40,4 @@ class ScreenOS < Oxidized::Model
|
|
41
40
|
send "n"
|
42
41
|
end
|
43
42
|
end
|
44
|
-
|
45
43
|
end
|
data/lib/oxidized/model/sgos.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
class SGOS < Oxidized::Model
|
2
|
-
|
3
2
|
comment '!- '
|
4
3
|
prompt /\w+>|#/
|
5
4
|
|
@@ -20,14 +19,14 @@ class SGOS < Oxidized::Model
|
|
20
19
|
comment cfg
|
21
20
|
end
|
22
21
|
|
23
|
-
|
22
|
+
cmd :secret do |cfg|
|
24
23
|
cfg.gsub! /^(security hashed-enable-password).*/, '\\1 <secret hidden>'
|
25
24
|
cfg.gsub! /^(security hashed-password).*/, '\\1 <secret hidden>'
|
26
25
|
cfg
|
27
26
|
end
|
28
27
|
|
29
28
|
cmd 'show configuration expanded noprompts with-keyrings unencrypted' do |cfg|
|
30
|
-
cfg.gsub! /^(!- Local time).*/,""
|
29
|
+
cfg.gsub! /^(!- Local time).*/, ""
|
31
30
|
cfg.gsub! /^(archive-configuration encrypted-password).*/, ""
|
32
31
|
cfg.gsub! /^(download encrypted-password).*/, ""
|
33
32
|
cfg
|