oxidized 0.28.0 → 0.29.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/publishdocker.yml +8 -1
- data/.github/workflows/ruby.yml +42 -0
- data/.rubocop.yml +30 -10
- data/.rubocop_todo.yml +95 -41
- data/CHANGELOG.md +139 -2
- data/Dockerfile +13 -9
- data/README.md +66 -32
- data/Rakefile +2 -0
- data/docs/Configuration.md +49 -7
- data/docs/Creating-Models.md +10 -4
- data/docs/Hooks.md +35 -6
- data/docs/Model-Notes/ADVA.md +12 -0
- data/docs/Model-Notes/Cumulus.md +7 -1
- data/docs/Model-Notes/IOS.md +36 -0
- data/docs/Model-Notes/JunOS.md +3 -3
- data/docs/Model-Notes/LenovoNOS.md +29 -0
- data/docs/Model-Notes/LinksysSRW.md +15 -0
- data/docs/Model-Notes/Nokia.md +3 -0
- data/docs/Model-Notes/OS10.md +33 -0
- data/docs/Model-Notes/PanOS_API.md +28 -0
- data/docs/Model-Notes/README.md +2 -0
- data/docs/Sources.md +18 -0
- data/docs/Supported-OS-Types.md +51 -6
- data/docs/Troubleshooting.md +1 -1
- data/extra/gitdiff-msteams.sh +91 -0
- data/extra/nagios_check_failing_nodes.rb +6 -9
- data/extra/oxidized-report-git-commits +71 -14
- data/extra/oxidized.init +2 -5
- data/extra/oxidized.logrotate +1 -0
- data/extra/oxidized.runit +4 -1
- data/extra/oxidized.service +5 -8
- data/extra/rest_client.rb +1 -1
- data/extra/syslog.rb +2 -2
- data/lib/oxidized/cli.rb +1 -1
- data/lib/oxidized/config/vars.rb +5 -2
- data/lib/oxidized/config.rb +6 -3
- data/lib/oxidized/core.rb +1 -1
- data/lib/oxidized/hook/exec.rb +6 -6
- data/lib/oxidized/hook/githubrepo.rb +42 -11
- data/lib/oxidized/hook/slackdiff.rb +2 -2
- data/lib/oxidized/hook/xmppdiff.rb +45 -25
- data/lib/oxidized/hook.rb +4 -8
- data/lib/oxidized/input/exec.rb +1 -1
- data/lib/oxidized/input/input.rb +1 -0
- data/lib/oxidized/input/ssh.rb +23 -20
- data/lib/oxidized/input/telnet.rb +52 -44
- data/lib/oxidized/job.rb +1 -0
- data/lib/oxidized/jobs.rb +11 -6
- data/lib/oxidized/manager.rb +1 -0
- data/lib/oxidized/model/acmepacket.rb +38 -0
- data/lib/oxidized/model/adtran.rb +5 -3
- data/lib/oxidized/model/adva.rb +66 -0
- data/lib/oxidized/model/airfiber.rb +1 -1
- data/lib/oxidized/model/aoscx.rb +96 -0
- data/lib/oxidized/model/aosw.rb +1 -1
- data/lib/oxidized/model/asa.rb +2 -0
- data/lib/oxidized/model/awplus.rb +1 -1
- data/lib/oxidized/model/bdcom.rb +49 -0
- data/lib/oxidized/model/cambiumepmp.rb +17 -0
- data/lib/oxidized/model/casa.rb +4 -1
- data/lib/oxidized/model/ciscoce.rb +12 -0
- data/lib/oxidized/model/ciscosmb.rb +2 -0
- data/lib/oxidized/model/comware.rb +16 -1
- data/lib/oxidized/model/cumulus.rb +58 -44
- data/lib/oxidized/model/dellx.rb +1 -3
- data/lib/oxidized/model/dlink.rb +2 -1
- data/lib/oxidized/model/edgecos.rb +22 -2
- data/lib/oxidized/model/edgeswitch.rb +4 -4
- data/lib/oxidized/model/eltex.rb +48 -0
- data/lib/oxidized/model/enterasys.rb +18 -3
- data/lib/oxidized/model/enterasys800.rb +29 -0
- data/lib/oxidized/model/eos.rb +2 -1
- data/lib/oxidized/model/fabricos.rb +1 -1
- data/lib/oxidized/model/fastiron.rb +3 -2
- data/lib/oxidized/model/fortios.rb +24 -11
- data/lib/oxidized/model/fortiwlc.rb +24 -0
- data/lib/oxidized/model/gaiaos.rb +40 -3
- data/lib/oxidized/model/h3c.rb +40 -0
- data/lib/oxidized/model/hatteras.rb +2 -2
- data/lib/oxidized/model/hios.rb +38 -0
- data/lib/oxidized/model/hpebladesystem.rb +1 -1
- data/lib/oxidized/model/ios.rb +13 -10
- data/lib/oxidized/model/iosxe.rb +1 -1
- data/lib/oxidized/model/ironware.rb +8 -4
- data/lib/oxidized/model/junos.rb +5 -1
- data/lib/oxidized/model/lancom.rb +23 -0
- data/lib/oxidized/model/lenovonos.rb +82 -0
- data/lib/oxidized/model/linksyssrw.rb +71 -0
- data/lib/oxidized/model/mlnxos.rb +2 -0
- data/lib/oxidized/model/model.rb +29 -3
- data/lib/oxidized/model/necix.rb +30 -0
- data/lib/oxidized/model/netgear.rb +5 -2
- data/lib/oxidized/model/netscaler.rb +38 -1
- data/lib/oxidized/model/nodegrid.rb +23 -0
- data/lib/oxidized/model/nxos.rb +3 -2
- data/lib/oxidized/model/openbsd.rb +9 -0
- data/lib/oxidized/model/opengear.rb +1 -1
- data/lib/oxidized/model/opnsense.rb +12 -4
- data/lib/oxidized/model/panos_api.rb +71 -0
- data/lib/oxidized/model/pfsense.rb +12 -7
- data/lib/oxidized/model/powerconnect.rb +1 -3
- data/lib/oxidized/model/procurve.rb +2 -2
- data/lib/oxidized/model/purityos.rb +8 -1
- data/lib/oxidized/model/quantaos.rb +1 -5
- data/lib/oxidized/model/routeros.rb +15 -2
- data/lib/oxidized/model/slxos.rb +1 -0
- data/lib/oxidized/model/smartcs.rb +40 -0
- data/lib/oxidized/model/sonicos.rb +9 -1
- data/lib/oxidized/model/srosmd.rb +97 -0
- data/lib/oxidized/model/stoneos.rb +6 -2
- data/lib/oxidized/model/supermicro.rb +1 -1
- data/lib/oxidized/model/swos.rb +9 -0
- data/lib/oxidized/model/timos.rb +1 -1
- data/lib/oxidized/model/tmos.rb +2 -1
- data/lib/oxidized/model/tplink.rb +2 -0
- data/lib/oxidized/model/trango.rb +11 -11
- data/lib/oxidized/model/truenas.rb +20 -0
- data/lib/oxidized/model/vrp.rb +1 -1
- data/lib/oxidized/model/xos.rb +4 -3
- data/lib/oxidized/model/yamaha.rb +57 -0
- data/lib/oxidized/model/zteolt.rb +52 -0
- data/lib/oxidized/model/zy1308.rb +11 -0
- data/lib/oxidized/node/stats.rb +1 -0
- data/lib/oxidized/node.rb +16 -11
- data/lib/oxidized/nodes.rb +7 -6
- data/lib/oxidized/output/file.rb +2 -1
- data/lib/oxidized/output/git.rb +4 -3
- data/lib/oxidized/output/gitcrypt.rb +5 -8
- data/lib/oxidized/output/http.rb +2 -0
- data/lib/oxidized/source/csv.rb +1 -0
- data/lib/oxidized/source/http.rb +4 -0
- data/lib/oxidized/source/source.rb +7 -2
- data/lib/oxidized/source/sql.rb +15 -5
- data/lib/oxidized/string.rb +9 -3
- data/lib/oxidized/version.rb +2 -2
- data/lib/oxidized/worker.rb +5 -5
- data/oxidized.gemspec +22 -16
- metadata +116 -29
- data/.travis.yml +0 -10
@@ -14,12 +14,49 @@ class NetScaler < Oxidized::Model
|
|
14
14
|
comment cfg
|
15
15
|
end
|
16
16
|
|
17
|
+
cmd 'show partition' do |cfg|
|
18
|
+
comment cfg
|
19
|
+
end
|
20
|
+
|
17
21
|
cmd :secret do |cfg|
|
18
22
|
cfg.gsub! /\w+\s(-encrypted)/, '<secret hidden> \\1'
|
19
23
|
cfg
|
20
24
|
end
|
21
25
|
|
22
|
-
|
26
|
+
# check for multiple partitions
|
27
|
+
cmd 'show partition' do |cfg|
|
28
|
+
@is_multiple_partition = cfg.include? 'Name:'
|
29
|
+
end
|
30
|
+
|
31
|
+
post do
|
32
|
+
if @is_multiple_partition
|
33
|
+
multiple_partition
|
34
|
+
else
|
35
|
+
single_partition
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def single_partition
|
40
|
+
# Single partition mode
|
41
|
+
cmd 'show ns ns.conf' do |cfg|
|
42
|
+
cfg
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def multiple_partition
|
47
|
+
# Multiple partition mode
|
48
|
+
cmd 'show partition' do |cfg|
|
49
|
+
allcfg = ""
|
50
|
+
partitions = [["default"]] + cfg.scan(/Name: (\S+)$/)
|
51
|
+
partitions.each do |part|
|
52
|
+
allcfg = allcfg + "\n\n####################### [ partition " + part.join(" ") + " ] #######################\n\n"
|
53
|
+
cmd "switch ns partition " + part.join(" ") + "; show ns ns.conf; switch ns partition default" do |cfgpartition|
|
54
|
+
allcfg += cfgpartition
|
55
|
+
end
|
56
|
+
end
|
57
|
+
allcfg
|
58
|
+
end
|
59
|
+
end
|
23
60
|
|
24
61
|
cfg :ssh do
|
25
62
|
pre_logout 'exit'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Nodegrid < Oxidized::Model
|
2
|
+
# ZPE Nodegrid (Tested with Nodegrid Gate/Bold/NSR)
|
3
|
+
# https://www.zpesystems.com/products/
|
4
|
+
|
5
|
+
prompt(%r{(?<!@)\[(.*?\s/)\]#})
|
6
|
+
comment '# '
|
7
|
+
|
8
|
+
cmd 'show system/about/' do |cfg|
|
9
|
+
comment cfg # Show System, Model, Software Version
|
10
|
+
end
|
11
|
+
|
12
|
+
cmd 'show settings/license/' do |cfg|
|
13
|
+
comment cfg # Show License information
|
14
|
+
end
|
15
|
+
|
16
|
+
cmd 'export_settings settings/ --plain-password' do |cfg|
|
17
|
+
cfg # Print all system config including keys to be importable via import_settings function
|
18
|
+
end
|
19
|
+
|
20
|
+
cfg :ssh do
|
21
|
+
pre_logout 'exit'
|
22
|
+
end
|
23
|
+
end
|
data/lib/oxidized/model/nxos.rb
CHANGED
@@ -10,15 +10,16 @@ class NXOS < Oxidized::Model
|
|
10
10
|
cmd :secret do |cfg|
|
11
11
|
cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
|
12
12
|
cfg.gsub! /^(snmp-server user (\S+) (\S+) auth (\S+)) (\S+) (priv) (\S+)/, '\\1 <configuration removed> '
|
13
|
-
cfg.gsub!
|
13
|
+
cfg.gsub! /(password \d+) (\S+)/, '\\1 <secret hidden>'
|
14
14
|
cfg.gsub! /^(radius-server key).*/, '\\1 <secret hidden>'
|
15
|
+
cfg.gsub! /^(tacacs-server host .+ key(?: \d+)?) \S+/, '\\1 <secret hidden>'
|
15
16
|
cfg
|
16
17
|
end
|
17
18
|
|
18
19
|
cmd 'show version' do |cfg|
|
19
20
|
cfg = filter cfg
|
20
21
|
cfg = cfg.each_line.take_while { |line| not line.match(/uptime/i) }
|
21
|
-
comment cfg.join
|
22
|
+
comment cfg.join
|
22
23
|
end
|
23
24
|
|
24
25
|
cmd 'show inventory' do |cfg|
|
@@ -48,6 +48,15 @@ class Openbsd < Oxidized::Model
|
|
48
48
|
cfg += add_comment('PASSWD FILE')
|
49
49
|
cfg += cmd('cat /etc/passwd')
|
50
50
|
|
51
|
+
cfg += add_comment('BGPD FILE')
|
52
|
+
cfg += cmd('cat /etc/bgpd.conf')
|
53
|
+
|
54
|
+
cfg += add_comment('OSPFD FILE')
|
55
|
+
cfg += cmd('cat /etc/ospfd.conf')
|
56
|
+
|
57
|
+
cfg += add_comment('OSPF6D FILE')
|
58
|
+
cfg += cmd('cat /etc/ospf6d.conf')
|
59
|
+
|
51
60
|
cfg += add_small_comment('END')
|
52
61
|
cfg
|
53
62
|
end
|
@@ -2,16 +2,24 @@ class OpnSense < Oxidized::Model
|
|
2
2
|
# minimum required permissions: "System: Shell account access"
|
3
3
|
# must enable SSH and password-based SSH access
|
4
4
|
|
5
|
-
cmd :all do |cfg|
|
6
|
-
cfg.cut_head
|
7
|
-
end
|
8
|
-
|
9
5
|
cmd 'cat /conf/config.xml' do |cfg|
|
10
6
|
cfg.gsub! /\s<revision>\s*<time>\d*<\/time>\s*.*\s*.*\s*<\/revision>/, ''
|
11
7
|
cfg.gsub! /\s<last_rule_upd_time>\d*<\/last_rule_upd_time>/, ''
|
12
8
|
cfg
|
13
9
|
end
|
14
10
|
|
11
|
+
# The comment output has to be at the end since and XML file may not start
|
12
|
+
# with a comment.
|
13
|
+
|
14
|
+
# This gets the version using the opnsense-version command, or from the
|
15
|
+
# /usr/local/opnsense/version/opnsense file for earlier versions of OPNsense
|
16
|
+
# that lack the opnsense-version command. Newer versions of OPNsense no longer
|
17
|
+
# store the version information in this file, so both versions have to be
|
18
|
+
# supported here for now.
|
19
|
+
cmd 'opnsense-version 2>/dev/null || echo "OPNsense "`cat /usr/local/opnsense/version/opnsense`' do |version|
|
20
|
+
xmlcomment version
|
21
|
+
end
|
22
|
+
|
15
23
|
cfg :ssh do
|
16
24
|
exec true
|
17
25
|
pre_logout 'exit'
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# PanOS API-based model for Oxidized
|
2
|
+
#
|
3
|
+
# The API-based model produced an XML configuration file that can actually be
|
4
|
+
# restored as a configuration backup. Make sure to use the "http" input for
|
5
|
+
# this module.
|
6
|
+
|
7
|
+
begin
|
8
|
+
# Nokogiri is required because the PanOS API, as well as the
|
9
|
+
# configuration file format uses XML. It is required to parse API
|
10
|
+
# responses, as well as to pretty-print the configuration XML file
|
11
|
+
# when saving it.
|
12
|
+
require 'nokogiri'
|
13
|
+
rescue LoadError
|
14
|
+
# Oxidized itself depends on mechanize, which in turn depends on
|
15
|
+
# nokogiri, so this should never happen.
|
16
|
+
raise Oxidized::OxidizedError, 'nokogiri not found: sudo gem install nokogiri'
|
17
|
+
end
|
18
|
+
|
19
|
+
class PanOS_API < Oxidized::Model # rubocop:disable Naming/ClassAndModuleCamelCase
|
20
|
+
# Callback function for getting the configuration file.
|
21
|
+
cfg_cb = lambda do
|
22
|
+
url_param = URI.encode_www_form(
|
23
|
+
user: @node.auth[:username],
|
24
|
+
password: @node.auth[:password],
|
25
|
+
type: 'keygen'
|
26
|
+
)
|
27
|
+
|
28
|
+
kg_r = get_http "/api?#{url_param}"
|
29
|
+
|
30
|
+
# Parse the XML API response for the keygen request.
|
31
|
+
kg_x = Nokogiri::XML(kg_r)
|
32
|
+
|
33
|
+
# Check if keygen was successful. If not we'll throw an error.
|
34
|
+
status = kg_x.xpath('//response/@status').first
|
35
|
+
if status.to_s != 'success'
|
36
|
+
msg = kg_x.xpath('//response/result/msg').text
|
37
|
+
raise Oxidized::OxidizedError, "Could not generate PanOS API key: #{msg}"
|
38
|
+
end
|
39
|
+
|
40
|
+
# If we reach here, keygen was successful, so get the API key
|
41
|
+
# out of the keygen XML response.
|
42
|
+
apikey = kg_x.xpath('//response/result/key').text.to_s
|
43
|
+
|
44
|
+
# Now that we have the API key, we can request a configuration
|
45
|
+
# export.
|
46
|
+
url_param = URI.encode_www_form(
|
47
|
+
key: apikey,
|
48
|
+
category: 'configuration',
|
49
|
+
type: 'export'
|
50
|
+
)
|
51
|
+
|
52
|
+
cfg = get_http "/api?#{url_param}"
|
53
|
+
|
54
|
+
# The configuration export is in XML format. Unfortunately,
|
55
|
+
# it's just one long line of XML that's not especially human
|
56
|
+
# readable or diffable.
|
57
|
+
#
|
58
|
+
# Thus, we will load the XML document and then emit it again
|
59
|
+
# with indentation set up, so that it's still a valid
|
60
|
+
# configuration, and also possible to read.
|
61
|
+
Nokogiri::XML(cfg).to_xml(indent: 2)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Define the command based on the callback above.
|
65
|
+
cmd cfg_cb
|
66
|
+
|
67
|
+
cfg :http do
|
68
|
+
# Palo Alto's API always requires HTTPS as far as I know.
|
69
|
+
@secure = true
|
70
|
+
end
|
71
|
+
end
|
@@ -1,23 +1,28 @@
|
|
1
1
|
class PfSense < Oxidized::Model
|
2
2
|
# use other use than 'admin' user, 'admin' user cannot get ssh/exec. See issue #535
|
3
3
|
|
4
|
-
cmd :all do |cfg|
|
5
|
-
cfg.cut_head
|
6
|
-
end
|
7
|
-
|
8
4
|
cmd :secret do |cfg|
|
9
|
-
cfg.gsub! /(\s+<bcrypt-hash>)
|
10
|
-
cfg.gsub! /(\s+<password>)
|
11
|
-
cfg.gsub! /(\s+<lighttpd_ls_password>)
|
5
|
+
cfg.gsub! /(\s+<bcrypt-hash>).+?(<\/bcrypt-hash>)/, '\\1[secret hidden]\\2'
|
6
|
+
cfg.gsub! /(\s+<password>).+?(<\/password>)/, '\\1[secret hidden]\\2'
|
7
|
+
cfg.gsub! /(\s+<lighttpd_ls_password>).+?(<\/lighttpd_ls_password>)/, '\\1[secret hidden]\\2'
|
12
8
|
cfg
|
13
9
|
end
|
14
10
|
|
15
11
|
cmd 'cat /cf/conf/config.xml' do |cfg|
|
12
|
+
raise "<pfsense> missing in config file!" unless cfg.include? "<pfsense>"
|
13
|
+
|
16
14
|
cfg.gsub! /\s<revision>\s*<time>\d*<\/time>\s*.*\s*.*\s*<\/revision>/, ''
|
17
15
|
cfg.gsub! /\s<last_rule_upd_time>\d*<\/last_rule_upd_time>/, ''
|
18
16
|
cfg
|
19
17
|
end
|
20
18
|
|
19
|
+
# The comment output has to be at the end since and XML file may not start
|
20
|
+
# with a comment.
|
21
|
+
|
22
|
+
cmd 'cat /etc/version' do |version|
|
23
|
+
xmlcomment "PFsense #{version}"
|
24
|
+
end
|
25
|
+
|
21
26
|
cfg :ssh do
|
22
27
|
exec true
|
23
28
|
pre_logout 'exit'
|
@@ -19,9 +19,7 @@ class PowerConnect < Oxidized::Model
|
|
19
19
|
end
|
20
20
|
|
21
21
|
cmd 'show version' do |cfg|
|
22
|
-
if @stackable.nil?
|
23
|
-
@stackable = true if cfg =~ /(U|u)nit\s/
|
24
|
-
end
|
22
|
+
@stackable = true if @stackable.nil? && (cfg =~ /(U|u)nit\s/)
|
25
23
|
cfg = cfg.split("\n").reject { |line| line[/Up\sTime/] }
|
26
24
|
comment cfg.join("\n") + "\n"
|
27
25
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class Procurve < Oxidized::Model
|
2
2
|
# previous command is repeated followed by "\eE", which sometimes ends up on last line
|
3
3
|
# ssh switches prompt may start with \r, followed by the prompt itself, regex ([\w\s.-]+[#>] ), which ends the line
|
4
|
-
# telnet
|
4
|
+
# telnet switches may start with various vt100 control characters, regex (\e\[24;[0-9][hH]), followed by the prompt, followed
|
5
5
|
# by at least 3 other vt100 characters
|
6
|
-
prompt /(^\r|\e\[24;[0-9][hH])?([\w\s.-]+[
|
6
|
+
prompt /(^\r|\e\[24;[0-9][hH])?([\w\s.-]+(\((config|vlan-[0-9]{1,4}|y\/n)\)|\(o\)nce)?[#>:?\]] {1,2})($|(\e\[24;[0-9][0-9]?[hH]){3})/
|
7
7
|
|
8
8
|
comment '! '
|
9
9
|
|
@@ -4,9 +4,16 @@ class PurityOS < Oxidized::Model
|
|
4
4
|
prompt /\w+@\S+(\s+\S+)*\s?>\s?$/
|
5
5
|
comment '# '
|
6
6
|
|
7
|
-
cmd 'pureconfig list'
|
7
|
+
cmd 'pureconfig list' do |cfg|
|
8
|
+
cfg.gsub! /^purealert flag \d+$/, ''
|
9
|
+
cfg.gsub! /(.*VEEAM-StorageLUNSnap-[0-9a-f].*)/, ''
|
10
|
+
cfg.gsub! /(.*VEEAM-ExportLUNSnap-[0-9A-F].*)/, ''
|
11
|
+
# remove empty lines
|
12
|
+
cfg.each_line.reject { |line| line.match /^[\r\n\s\u0000#]+$/ }.join
|
13
|
+
end
|
8
14
|
|
9
15
|
cfg :ssh do
|
16
|
+
pty_options(term: "dumb")
|
10
17
|
pre_logout 'exit'
|
11
18
|
end
|
12
19
|
end
|
@@ -13,11 +13,14 @@ class RouterOS < Oxidized::Model
|
|
13
13
|
end
|
14
14
|
|
15
15
|
cmd '/system routerboard print without-paging' do |cfg|
|
16
|
+
cfg = cfg.each_line.grep(/(model|firmware-type|current-firmware|serial-number):/).join
|
16
17
|
comment cfg
|
17
18
|
end
|
18
19
|
|
19
20
|
cmd '/system package update print without-paging' do |cfg|
|
20
|
-
|
21
|
+
version_line = cfg.each_line.grep(/installed-version: /)[0]
|
22
|
+
@ros_version = /: ([0-9])/.match(version_line)[1].to_i
|
23
|
+
comment version_line
|
21
24
|
end
|
22
25
|
|
23
26
|
cmd '/system history print without-paging' do |cfg|
|
@@ -25,11 +28,21 @@ class RouterOS < Oxidized::Model
|
|
25
28
|
end
|
26
29
|
|
27
30
|
post do
|
28
|
-
|
31
|
+
Oxidized.logger.debug "lib/oxidized/model/routeros.rb: running /export for routeros version #{@ros_version}"
|
32
|
+
run_cmd = if vars(:remove_secret)
|
33
|
+
'/export hide-sensitive'
|
34
|
+
elsif (not @ros_version.nil?) && (@ros_version >= 7)
|
35
|
+
'/export show-sensitive'
|
36
|
+
else
|
37
|
+
'/export'
|
38
|
+
end
|
29
39
|
cmd run_cmd do |cfg|
|
30
40
|
cfg.gsub! /\\\r?\n\s+/, '' # strip new line
|
31
41
|
cfg.gsub! /# inactive time\r\n/, '' # Remove time based system comment
|
32
42
|
cfg.gsub! /# received packet from \S+ bad format\r\n/, '' # Remove intermittent VRRP/CARP collision comment
|
43
|
+
cfg.gsub! /# poe-out status: short_circuit\r\n/, '' # Remove intermittent POE short_circuit comment
|
44
|
+
cfg.gsub! /# Firmware upgraded successfully, please reboot for changes to take effect!\r\n/, '' # Remove transient firmware upgrade comment
|
45
|
+
cfg.gsub! /# \S+ not ready\r\n/, '' # Remove intermittent $interface not ready comment
|
33
46
|
cfg = cfg.split("\n").reject { |line| line[/^#\s\w{3}\/\d{2}\/\d{4}.*$/] }
|
34
47
|
cfg.join("\n") + "\n"
|
35
48
|
end
|
data/lib/oxidized/model/slxos.rb
CHANGED
@@ -12,6 +12,7 @@ class SLXOS < Oxidized::Model
|
|
12
12
|
cmd 'show chassis' do |cfg|
|
13
13
|
cfg.encode!("UTF-8", invalid: :replace, undef: :replace) # sometimes ironware returns broken encoding
|
14
14
|
cfg.gsub! /.*Power Usage.*/, '' # remove unwanted lines power usage
|
15
|
+
cfg.gsub! /^Update\:.*$/, '' # remove unwanted current date
|
15
16
|
cfg.gsub! /Time A(live|wake).*/, '' # remove unwanted lines time alive/awake
|
16
17
|
cfg.gsub! /([\[]*)1([\]]*)<->([\[]*)2([\]]*)(<->([\[]*)3([\]]*))*/, ''
|
17
18
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class SmartCS < Oxidized::Model
|
2
|
+
prompt /^\r?([\w.@() -]+[#>]\s?)$/
|
3
|
+
comment '# '
|
4
|
+
|
5
|
+
expect /-more <Press SPACE for another page, 'q' to quit>-/ do |data, re|
|
6
|
+
send ' '
|
7
|
+
data.sub re, ''
|
8
|
+
end
|
9
|
+
|
10
|
+
cmd :all do |cfg|
|
11
|
+
cfg
|
12
|
+
end
|
13
|
+
|
14
|
+
cmd 'show version' do |cfg|
|
15
|
+
comment cfg.insert(0, "--------------------------------------------------------------------------------! \n")
|
16
|
+
# Unhash below to write a comment in the config file.
|
17
|
+
cfg.insert(0, "Starting: show version cmd \n")
|
18
|
+
cfg << "\n \nEnding: show version cmd"
|
19
|
+
comment cfg << "\n--------------------------------------------------------------------------------! \n \n"
|
20
|
+
comment cfg
|
21
|
+
end
|
22
|
+
|
23
|
+
cmd 'show config' do |cfg|
|
24
|
+
# remove "Press SPACE for another page" add SPACE(\s)
|
25
|
+
cfg.gsub! /\s{5,}/, ""
|
26
|
+
end
|
27
|
+
|
28
|
+
cfg :telnet, :ssh do
|
29
|
+
# preferred way to handle additional passwords
|
30
|
+
post_login do
|
31
|
+
pw = vars(:enable)
|
32
|
+
pw ||= ""
|
33
|
+
send "su\r"
|
34
|
+
expect /[pP]assword:\s?$/
|
35
|
+
cmd pw
|
36
|
+
end
|
37
|
+
pre_logout 'exit'
|
38
|
+
pre_logout 'exit'
|
39
|
+
end
|
40
|
+
end
|
@@ -17,6 +17,12 @@ class SonicOS < Oxidized::Model
|
|
17
17
|
cfg.gsub! /bind-password \d\,(\S+)/, 'bind-password <secret hidden> \2'
|
18
18
|
cfg.gsub! /authentication sha1 \d\,(\S+)/, 'authentication sha1 <secret hidden> \2'
|
19
19
|
cfg.gsub! /encryption aes \d\,(\S+)/, 'encryption aes <secret hidden> \2'
|
20
|
+
cfg.gsub! /smtp-pass \d\,(\S+)/, 'smtp-pass <secret hidden> \2'
|
21
|
+
cfg.gsub! /pop-pass \d\,(\S+)/, 'pop-pass <secret hidden> \2'
|
22
|
+
cfg.gsub! /sslvpn password \d\,(\S+)/, 'sslvpn password <secret hidden> \2'
|
23
|
+
cfg.gsub! /administrator password \d\,(\S+)/, 'administrator password <secret hidden> \2'
|
24
|
+
cfg.gsub! /ftp password \d\,(\S+)/, 'ftp password <secret hidden> \2'
|
25
|
+
cfg.gsub! /shared-key \d\,(\S+)/, 'shared-key <secret hidden> \2'
|
20
26
|
cfg
|
21
27
|
end
|
22
28
|
|
@@ -38,8 +44,10 @@ class SonicOS < Oxidized::Model
|
|
38
44
|
def clean(cfg)
|
39
45
|
out = []
|
40
46
|
cfg.each_line do |line|
|
47
|
+
next if line =~ /date \d{4}\:\d{2}\:\d{2}/
|
48
|
+
next if line =~ /time \d{2}\:\d{2}:\d{2}/
|
41
49
|
next if line =~ /system-time \"\d{2}\/\d{2}\/\d{4} \d{2}\:\d{2}:\d{2}.\d+\"/
|
42
|
-
next if line =~ /system-uptime "(\s+up\s+\d+\s+)|(
|
50
|
+
next if line =~ /system-uptime "((\s+up\s+\d+\s+)|(\d+\s\w+(,\s)?)*)"/
|
43
51
|
next if line =~ /checksum \d+/
|
44
52
|
|
45
53
|
line = line[1..-1] if line[0] == "\r"
|
@@ -0,0 +1,97 @@
|
|
1
|
+
class SROSMD < Oxidized::Model
|
2
|
+
#
|
3
|
+
# Nokia SR OS (TiMOS) (formerly TiMetra, Alcatel, Alcatel-Lucent)
|
4
|
+
# Working in Model-Driven CLI mode.
|
5
|
+
# Used in 7705 SAR, 7210 SAS, 7450 ESS, 7750 SR, 7950 XRS, and NSP.
|
6
|
+
#
|
7
|
+
|
8
|
+
comment '# '
|
9
|
+
|
10
|
+
prompt /^([-\w.@:>*]+\s?[#>]\s?)$/
|
11
|
+
|
12
|
+
cmd :all do |cfg, cmdstring|
|
13
|
+
new_cfg = comment "COMMAND: #{cmdstring}\n"
|
14
|
+
cfg.gsub! /# Finished .*/, ''
|
15
|
+
cfg.gsub! /# Generated .*/, ''
|
16
|
+
cfg.delete! "\r"
|
17
|
+
new_cfg << cfg.cut_both
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Show the system information.
|
22
|
+
#
|
23
|
+
cmd 'show system information' do |cfg|
|
24
|
+
#
|
25
|
+
# Strip uptime.
|
26
|
+
#
|
27
|
+
cfg.sub! /^System Up Time.*\n/, ''
|
28
|
+
comment cfg
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# Show the card state.
|
33
|
+
#
|
34
|
+
cmd 'show card state' do |cfg|
|
35
|
+
comment cfg
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Show the chassis information.
|
40
|
+
#
|
41
|
+
cmd 'show chassis' do |cfg|
|
42
|
+
comment cfg.lines.to_a[0..25].reject { |line| line.match /state|Time|Temperature|Status/ }.join
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# Show the boot log.
|
47
|
+
#
|
48
|
+
cmd 'file show bootlog.txt' do |cfg|
|
49
|
+
cfg.gsub! /[\b][\b][\b]/, "\n"
|
50
|
+
comment cfg
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# Show the running debug configuration.
|
55
|
+
#
|
56
|
+
cmd 'admin show configuration debug full-context' do |cfg|
|
57
|
+
comment cfg
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Show the saved debug configuration (admin debug-save).
|
62
|
+
#
|
63
|
+
cmd 'file show config.dbg' do |cfg|
|
64
|
+
comment cfg
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# Show the running persistent indices.
|
69
|
+
#
|
70
|
+
cmd 'admin show configuration configure | match persistent-indices post-lines 10000' do |cfg|
|
71
|
+
comment cfg
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# Show the boot options file.
|
76
|
+
#
|
77
|
+
cmd 'admin show configuration bof full-context' do |cfg|
|
78
|
+
cfg
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# Show the running configuration.
|
83
|
+
#
|
84
|
+
cmd 'admin show configuration configure full-context' do |cfg|
|
85
|
+
cfg
|
86
|
+
end
|
87
|
+
|
88
|
+
cfg :telnet do
|
89
|
+
username /^Login: /
|
90
|
+
password /^Password: /
|
91
|
+
end
|
92
|
+
|
93
|
+
cfg :telnet, :ssh do
|
94
|
+
post_login 'environment more false'
|
95
|
+
pre_logout 'logout'
|
96
|
+
end
|
97
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class StoneOS < Oxidized::Model
|
2
2
|
# Hillstone Networks StoneOS software
|
3
3
|
|
4
|
-
prompt /^\r?[\w.()-]
|
4
|
+
prompt /^\r?[\w.()-]+~?[#>](\s)?$/
|
5
5
|
comment '# '
|
6
6
|
|
7
7
|
expect /^\s.*--More--.*$/ do |data, re|
|
@@ -10,12 +10,16 @@ class StoneOS < Oxidized::Model
|
|
10
10
|
end
|
11
11
|
|
12
12
|
cmd :all do |cfg|
|
13
|
+
cfg.gsub! /+.*+/, '' # Linebreak handling
|
13
14
|
cfg.cut_both
|
14
15
|
end
|
15
16
|
|
16
|
-
cmd 'show configuration running'
|
17
|
+
cmd 'show configuration running' do |cfg|
|
18
|
+
cfg.gsub! /^Building configuration.*$/, ''
|
19
|
+
end
|
17
20
|
|
18
21
|
cmd 'show version' do |cfg|
|
22
|
+
cfg.gsub! /^Uptime is .*$/, ''
|
19
23
|
comment cfg
|
20
24
|
end
|
21
25
|
|
data/lib/oxidized/model/timos.rb
CHANGED
data/lib/oxidized/model/tmos.rb
CHANGED
@@ -18,6 +18,7 @@ class TMOS < Oxidized::Model
|
|
18
18
|
cmd 'tmsh -q show sys hardware field-fmt' do |cfg|
|
19
19
|
cfg.gsub!(/fan-speed (\S+)/, '')
|
20
20
|
cfg.gsub!(/temperature (\S+)/, '')
|
21
|
+
cfg.gsub!(/humidity (\S+)/, '')
|
21
22
|
comment cfg
|
22
23
|
end
|
23
24
|
|
@@ -47,7 +48,7 @@ class TMOS < Oxidized::Model
|
|
47
48
|
|
48
49
|
cmd('[ -d "/config/zebos" ] && cat /config/zebos/*/ZebOS.conf') { |cfg| comment cfg }
|
49
50
|
|
50
|
-
cmd('cat /config/partitions/*/bigip
|
51
|
+
cmd('cat /config/partitions/*/bigip*.conf') { |cfg| comment cfg }
|
51
52
|
|
52
53
|
cfg :ssh do
|
53
54
|
exec true # don't run shell, run each command in exec channel
|
@@ -9,16 +9,16 @@ class Trango < Oxidized::Model
|
|
9
9
|
comments = []
|
10
10
|
cfg.each_line do |line|
|
11
11
|
if line =~ /\[Opmode\] (off|on) \[Default Opmode\] (off|on)/
|
12
|
-
out << "opmode " + Regexp.last_match[1]
|
13
|
-
out << "defaultopmode " + Regexp.last_match[2]
|
12
|
+
out << ("opmode " + Regexp.last_match[1])
|
13
|
+
out << ("defaultopmode " + Regexp.last_match[2])
|
14
14
|
end
|
15
|
-
out << "power " + Regexp.last_match[1] if line =~ /\[Tx Power\] ([\-\d]+) dBm/
|
16
|
-
out << "freq " + Regexp.last_match[1] + ' ' + Regexp.last_match[2] if line =~ /\[Active Channel\] (\d+) (v|h)/
|
17
|
-
out << "peerid " + Regexp.last_match[1] if line =~ /\[Peer ID\] ([A-F0-9]+)/
|
18
|
-
out << "utype " + Regexp.last_match[1] if line =~ /\[Unit Type\] (\S+)/
|
19
|
-
comments << '# ' + Regexp.last_match[1] + ': ' + Regexp.last_match[2] if line =~ /\[(Hardware Version|Firmware Version|Model|S\/N)\] (\S+)/
|
20
|
-
out << "remarks " + Regexp.last_match[1] if line =~ /\[Remarks\] (\S+)/
|
21
|
-
out << "rssiled " + Regexp.last_match[1] if line =~ /\[RSSI LED\] (on|off)/
|
15
|
+
out << ("power " + Regexp.last_match[1]) if line =~ /\[Tx Power\] ([\-\d]+) dBm/
|
16
|
+
out << ("freq " + Regexp.last_match[1] + ' ' + Regexp.last_match[2]) if line =~ /\[Active Channel\] (\d+) (v|h)/
|
17
|
+
out << ("peerid " + Regexp.last_match[1]) if line =~ /\[Peer ID\] ([A-F0-9]+)/
|
18
|
+
out << ("utype " + Regexp.last_match[1]) if line =~ /\[Unit Type\] (\S+)/
|
19
|
+
comments << ('# ' + Regexp.last_match[1] + ': ' + Regexp.last_match[2]) if line =~ /\[(Hardware Version|Firmware Version|Model|S\/N)\] (\S+)/
|
20
|
+
out << ("remarks " + Regexp.last_match[1]) if line =~ /\[Remarks\] (\S+)/
|
21
|
+
out << ("rssiled " + Regexp.last_match[1]) if line =~ /\[RSSI LED\] (on|off)/
|
22
22
|
speed = Regexp.last_match[1] if line =~ /\[Speed\] (\d+) Mbps/
|
23
23
|
out << "mir ".concat(Regexp.last_match[1]) if line =~ /\[Tx MIR\] (\d+) Kbps/
|
24
24
|
if line =~ /\[Auto Rate Shift\] (on|off)/
|
@@ -27,9 +27,9 @@ class Trango < Oxidized::Model
|
|
27
27
|
end
|
28
28
|
next unless line =~ /\[IP\] (\S+) \[Subnet Mask\] (\S+) \[Gateway\] (\S+)/
|
29
29
|
|
30
|
-
out << "ipconfig " + Regexp.last_match[1] + ' ' +
|
30
|
+
out << ("ipconfig " + Regexp.last_match[1] + ' ' +
|
31
31
|
Regexp.last_match[2] + ' ' +
|
32
|
-
Regexp.last_match[3]
|
32
|
+
Regexp.last_match[3])
|
33
33
|
end
|
34
34
|
comments.push(*out).join "\n"
|
35
35
|
end
|