summaryrefslogtreecommitdiff
path: root/lib/oxidized/model
diff options
context:
space:
mode:
authorWild Kat <wk@futureinquestion.net>2018-03-17 11:30:47 +0100
committerWild Kat <wk@futureinquestion.net>2018-03-17 11:30:47 +0100
commitf17736cabf0edda6788eff206aa12c9e35a22341 (patch)
tree113fa19d95571137018e5465e07f499cfa551bd1 /lib/oxidized/model
parent81fc3a4b423d8ce9fe69def57007312a96db6f67 (diff)
parent7ecd5abe1cc2f2bbc6b29687352564cb7f087a5a (diff)
refactor supermicro support
Diffstat (limited to 'lib/oxidized/model')
-rw-r--r--lib/oxidized/model/aosw.rb2
-rw-r--r--lib/oxidized/model/arbos.rb27
-rw-r--r--lib/oxidized/model/aricentiss.rb (renamed from lib/oxidized/model/supermicro2.rb)7
-rw-r--r--lib/oxidized/model/awplus.rb85
-rw-r--r--lib/oxidized/model/br6910.rb2
-rw-r--r--lib/oxidized/model/ciscosmb.rb5
-rw-r--r--lib/oxidized/model/comware.rb4
-rw-r--r--lib/oxidized/model/edgecos.rb (renamed from lib/oxidized/model/supermicro.rb)6
-rw-r--r--lib/oxidized/model/edgeos.rb2
-rw-r--r--lib/oxidized/model/fiberdriver.rb2
-rw-r--r--lib/oxidized/model/fortios.rb9
-rw-r--r--lib/oxidized/model/gcombnps.rb85
-rw-r--r--lib/oxidized/model/ios.rb1
-rw-r--r--lib/oxidized/model/netgear.rb2
-rw-r--r--lib/oxidized/model/opnsense.rb21
-rw-r--r--lib/oxidized/model/procurve.rb9
-rw-r--r--lib/oxidized/model/routeros.rb1
-rw-r--r--lib/oxidized/model/slxos.rb61
-rw-r--r--lib/oxidized/model/vyatta.rb2
19 files changed, 315 insertions, 18 deletions
diff --git a/lib/oxidized/model/aosw.rb b/lib/oxidized/model/aosw.rb
index a85ead7..71fde2e 100644
--- a/lib/oxidized/model/aosw.rb
+++ b/lib/oxidized/model/aosw.rb
@@ -11,7 +11,7 @@ class AOSW < Oxidized::Model
# All IAPs connected to a Instant Controller will have the same config output. Only the controller needs to be monitored.
comment '# '
- prompt /^\(?.+\)?\s?[#>]/
+ prompt /^\(?.+\)?\s[#>]/
cmd :all do |cfg|
cfg.each_line.to_a[1..-2].join
diff --git a/lib/oxidized/model/arbos.rb b/lib/oxidized/model/arbos.rb
new file mode 100644
index 0000000..389f3f6
--- /dev/null
+++ b/lib/oxidized/model/arbos.rb
@@ -0,0 +1,27 @@
+class ARBOS < Oxidized::Model
+
+ # Arbor OS model #
+
+ prompt /^[\S\s]+\n([\w.@-]+[:\/#>]+)\s?$/
+ comment '# '
+
+ cmd 'system hardware' do |cfg|
+ cfg.gsub! /^Boot\ time\:\s.+/, '' # Remove boot timer
+ cfg.gsub! /^Load\ averages\:\s.+/, '' # Remove CPU load info
+ cfg = cfg.each_line.to_a[2..-1].join
+ comment cfg
+ end
+
+ cmd 'system version' do |cfg|
+ comment cfg
+ end
+
+ cmd 'config show' do |cfg|
+ cfg
+ end
+
+ cfg :ssh do
+ exec true
+ pre_logout 'exit'
+ end
+end
diff --git a/lib/oxidized/model/supermicro2.rb b/lib/oxidized/model/aricentiss.rb
index 710603c..8675263 100644
--- a/lib/oxidized/model/supermicro2.rb
+++ b/lib/oxidized/model/aricentiss.rb
@@ -1,9 +1,5 @@
-# Developed against:
-# #show version
-# Switch ID Hardware Version Firmware Version
-# 0 SSE-G48-TG4 (P2-01) 1.0.16-9
+class AricentISS < Oxidized::Model
-class Supermicro2 < Oxidized::Model
prompt (/^(\e\[27m)?[ \r]*\w+# ?$/)
cfg :ssh do
@@ -45,4 +41,5 @@ class Supermicro2 < Oxidized::Model
l
}.join.gsub(/ +$/, '')
end
+
end
diff --git a/lib/oxidized/model/awplus.rb b/lib/oxidized/model/awplus.rb
new file mode 100644
index 0000000..1d8fbcd
--- /dev/null
+++ b/lib/oxidized/model/awplus.rb
@@ -0,0 +1,85 @@
+class AWPlus < Oxidized::Model
+
+ #Allied Telesis Alliedware Plus Model#
+ #https://www.alliedtelesis.com/products/software/AlliedWare-Plus
+
+ prompt /^(\r?[\w.@:\/-]+[#>]\s?)$/
+ comment '! '
+
+ #Avoids needing "term length 0" to display full config file.
+ expect /--More--/ do |data, re|
+ send ' '
+ data.sub re, ''
+ end
+
+ #Removes gibberish pager output e.g. VT100 escape codes
+ cmd :all do |cfg|
+ cfg.gsub! /\e\[K/, '' # example how to handle pager - cleareol EL0
+ cfg.gsub! /\e\[7m\e\[m/, '' # example how to handle pager - Reverse SGR7
+ cfg.gsub! /\r/, '' # Filters rogue ^M - see issue #415
+ cfg.each_line.to_a[1..-2].join
+ end
+
+ #Remove passwords from config file.
+ #Add vars "remove_secret: true" to global oxidized config file to enable.
+
+ cmd :secret do |cfg|
+ cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
+ cfg.gsub! /^(username \S+ privilege \d+) (\S+).*/, '\\1 <secret hidden>'
+ cfg.gsub! /^(username \S+ password \d) (\S+)/, '\\1 <secret hidden>'
+ cfg.gsub! /^(username \S+ secret \d) (\S+)/, '\\1 <secret hidden>'
+ cfg.gsub! /^(enable (password|secret) \d) (\S+)/, '\\1 <secret hidden>'
+ cfg.gsub! /^(\s+(?:password|secret)) (?:\d )?\S+/, '\\1 <secret hidden>'
+ cfg.gsub! /^(tacacs-server key \d) (\S+)/, '\\1 <secret hidden>'
+ cfg
+ end
+
+ #Adds "Show system" output to start of config.
+
+ cmd 'Show System' do |cfg|
+ comment cfg.insert(0,"--------------------------------------------------------------------------------! \n")
+ #Unhash below to write a comment in the config file.
+ cfg.insert(0,"Starting: Show system cmd \n")
+ cfg << "\n \nEnding: show system cmd"
+ comment cfg << "\n--------------------------------------------------------------------------------! \n \n"
+ #Removes the following lines from "show system" in output file. This ensures oxidized diffs are meaningful.
+ comment cfg.each_line.reject { |line|
+ line.match /^$\n/ or #Remove blank lines in "sh sys"
+ line.match /System Status\s*.*/ or
+ line.match /RAM\s*:.*/ or
+ line.match /Uptime\s*:.*/ or
+ line.match /Flash\s*:.*/ or
+ line.match /Current software\s*:.*/ or
+ line.match /Software version\s*:.*/ or
+ line.match /Build date\s*:.*/ }.join
+ end
+
+ #Actually get the devices running config#
+ cmd 'show running-config' do |cfg|
+ cfg
+ end
+
+ #Config required for telnet to detect username prompt
+ cfg :telnet do
+ username /login:\s/
+ end
+
+ #Main login config
+ cfg :telnet, :ssh do
+ post_login do
+ if vars :enable
+ send "enable\n"
+ expect /^Password:\s/
+ cmd vars(:enable) + "\r\n"
+ else
+ cmd 'enable' # Required for Priv-Exec users without enable PW to be put into "enable mode".
+ end
+# cmd 'terminal length 0' #set so the entire config is output without intervention.
+ end
+ pre_logout do
+# cmd 'terminal no length' #Sets term length back to default on exit.
+ send "exit\r\n"
+ end
+ end
+
+end
diff --git a/lib/oxidized/model/br6910.rb b/lib/oxidized/model/br6910.rb
index b5c9bcf..df93793 100644
--- a/lib/oxidized/model/br6910.rb
+++ b/lib/oxidized/model/br6910.rb
@@ -1,7 +1,7 @@
class BR6910 < Oxidized::Model
- prompt /^Vty-[0-9]\#$/
+ prompt /^([\w.@()-]+[#>]\s?)$/
comment '! '
# not possible to disable paging prior to show running-config
diff --git a/lib/oxidized/model/ciscosmb.rb b/lib/oxidized/model/ciscosmb.rb
index 9453059..deb4768 100644
--- a/lib/oxidized/model/ciscosmb.rb
+++ b/lib/oxidized/model/ciscosmb.rb
@@ -17,6 +17,7 @@ class CiscoSMB < Oxidized::Model
cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
cfg.gsub! /username (\S+) privilege (\d+) (\S+).*/, '<secret hidden>'
cfg.gsub! /^(encrypted radius-server key).*/, '\\1 <configuration removed>'
+ cfg.gsub! /System Up Time.*/, ''
cfg
end
@@ -24,6 +25,10 @@ class CiscoSMB < Oxidized::Model
comment cfg
end
+ cmd 'show system' do |cfg|
+ comment cfg
+ end
+
cmd 'show bootvar' do |cfg|
comment cfg
end
diff --git a/lib/oxidized/model/comware.rb b/lib/oxidized/model/comware.rb
index d926854..a5b7190 100644
--- a/lib/oxidized/model/comware.rb
+++ b/lib/oxidized/model/comware.rb
@@ -1,8 +1,8 @@
class Comware < Oxidized::Model
# HP (A-series)/H3C/3Com Comware
- # sometimes the prompt might have a leading nul
- prompt /^\0*(<[\w.-]+>)$/
+ # sometimes the prompt might have a leading nul or trailing ASCII Bell (^G)
+ prompt /^\0*(<[\w.-]+>).?$/
comment '# '
# example how to handle pager
diff --git a/lib/oxidized/model/supermicro.rb b/lib/oxidized/model/edgecos.rb
index 361244c..bc205f5 100644
--- a/lib/oxidized/model/supermicro.rb
+++ b/lib/oxidized/model/edgecos.rb
@@ -1,4 +1,5 @@
-class Supermicro < Oxidized::Model
+class EdgeCOS < Oxidized::Model
+
comment '! '
cmd :secret do |cfg|
@@ -42,4 +43,5 @@ class Supermicro < Oxidized::Model
post_login 'terminal length 0'
pre_logout 'exit'
end
-end \ No newline at end of file
+
+end
diff --git a/lib/oxidized/model/edgeos.rb b/lib/oxidized/model/edgeos.rb
index 2a8d663..bb0aab5 100644
--- a/lib/oxidized/model/edgeos.rb
+++ b/lib/oxidized/model/edgeos.rb
@@ -13,7 +13,7 @@ class Edgeos < Oxidized::Model
cfg
end
- cmd 'show configuration | no-more'
+ cmd 'show configuration commands | no-more'
cfg :telnet do
username /login:\s/
diff --git a/lib/oxidized/model/fiberdriver.rb b/lib/oxidized/model/fiberdriver.rb
index abe8f68..7cfa847 100644
--- a/lib/oxidized/model/fiberdriver.rb
+++ b/lib/oxidized/model/fiberdriver.rb
@@ -13,7 +13,7 @@ class FiberDriver < Oxidized::Model
cfg.each_line.to_a[3..-1].join
cfg.gsub! /^Building configuration.*$/, ''
cfg.gsub! /^Current configuration:.*$$/, ''
- cfg.gsub! /^! Configuration saved on .*$/, ''
+ cfg.gsub! /^! Configuration (saved|generated) on .*$/, ''
cfg
end
diff --git a/lib/oxidized/model/fortios.rb b/lib/oxidized/model/fortios.rb
index 605a596..bffaf3c 100644
--- a/lib/oxidized/model/fortios.rb
+++ b/lib/oxidized/model/fortios.rb
@@ -15,9 +15,12 @@ class FortiOS < Oxidized::Model
end
cmd :secret do |cfg|
- cfg.gsub! /(set (?:passwd|password|secondary-secret|rsso-secret|psksecret|secret|key ENC)).*/, '\\1 <configuration removed>'
+ cfg.gsub! /(set (?:passwd|password|psksecret|secret|key|group-password|secondary-secret|tertiary-secret|auth-password-l1|auth-password-l2|rsso|history0|history1|inter-controller-key ENC)).*/, '\\1 <configuration removed>'
cfg.gsub! /(set private-key).*-+END ENCRYPTED PRIVATE KEY-*"$/m , '\\1 <configuration removed>'
- cfg.gsub! /(IPS Malicious URL Database).*/, '\\1 <configuration removed>'
+ cfg.gsub! /(set ca ).*-+END CERTIFICATE-*"$/m , '\\1 <configuration removed>'
+ cfg.gsub! /(set csr ).*-+END CERTIFICATE REQUEST-*"$/m , '\\1 <configuration removed>'
+ cfg.gsub! /(Virus-DB|Extended DB|IPS-DB|IPS-ETDB|APP-DB|INDUSTRIAL-DB|Botnet DB|IPS Malicious URL Database).*/, '\\1 <configuration removed>'
+ cfg.gsub! /(Cluster uptime:).*/, '\\1 <configuration removed>'
cfg
end
@@ -46,7 +49,7 @@ class FortiOS < Oxidized::Model
cfg << cmd('end') if @vdom_enabled
- cfg << cmd('show')
+ cfg << cmd('show full-configuration')
cfg.join "\n"
end
diff --git a/lib/oxidized/model/gcombnps.rb b/lib/oxidized/model/gcombnps.rb
new file mode 100644
index 0000000..4a97162
--- /dev/null
+++ b/lib/oxidized/model/gcombnps.rb
@@ -0,0 +1,85 @@
+class GcomBNPS < Oxidized::Model
+ # For switches from GCOM Technologies Co.,Ltd. running the "Broadband Network Platform Software"
+ # Author: Frederik Kriewitz <frederik@kriewitz.eu>
+ #
+ # tested with:
+ # - S5330 (aka Fiberstore S3800)
+
+ prompt /^\r?([\w.@()-]+?(\(1-16 chars\))?[#>:]\s?)$/ # also match SSH password promt (post_login commands are sent after the first prompt)
+ comment '! '
+
+# alternative to handle the SSH login, but this breaks telnet
+# expect /^Password\(1-16 chars\):/ do |data|
+# send @node.auth[:password] + "\n"
+# ''
+# end
+
+ # handle pager (can't be disabled?)
+ expect /^\.\.\.\.press ENTER to next line, CTRL_C to quit, other key to next page\.\.\.\.$/ do |data, re|
+ send ' '
+ data.sub re, ''
+ end
+
+ cmd :all do |cfg|
+ cfg = cfg.gsub " \e[73D\e[K", '' # remove garbage remaining from the pager
+ cfg.each_line.to_a[1..-2].join
+ end
+
+ cmd :secret do |cfg|
+ cfg.gsub! /^(snmp-server community)\s+[^\s]+\s+(.*)/, '\\1 <community hidden> \\2'
+ cfg
+ end
+
+ cmd 'show running-config' do |cfg|
+ cfg
+ end
+
+ cmd 'show interface sfp' do |cfg|
+ out = []
+ cfg.each_line do |line|
+ next if line.match /^ Temperature/
+ next if line.match /^ Voltage\(V\)/
+ next if line.match /^ Bias Current\(mA\)/
+ next if line.match /^ RX Power\(dBM\)/
+ next if line.match /^ TX Power\(dBM\)/
+ out << line
+ end
+
+ comment out.join
+ end
+
+
+ cmd 'show version' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show system' do |cfg|
+ out = []
+ cfg.each_line do |line|
+ next if line.match /^system run time :/
+ next if line.match /^switch temperature :/
+ out << line
+ end
+
+ comment out.join
+ end
+
+ cfg :telnet do
+ username /^Username\(1-32 chars\):/
+ password /^Password\(1-16 chars\):/
+ end
+
+ cfg :ssh do
+ # the switch blindy accepts the SSH connection without password validation and then spawns a telnet login prompt
+ # first thing we've to send is the password
+ post_login do
+ send @node.auth[:password] + "\n"
+ end
+ end
+
+ cfg :telnet, :ssh do
+ pre_logout 'exit'
+ end
+
+end
+
diff --git a/lib/oxidized/model/ios.rb b/lib/oxidized/model/ios.rb
index 0cb2f3a..4e7d223 100644
--- a/lib/oxidized/model/ios.rb
+++ b/lib/oxidized/model/ios.rb
@@ -26,6 +26,7 @@ class IOS < Oxidized::Model
cmd :secret do |cfg|
cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
+ cfg.gsub! /^(snmp-server host \S+( vrf \S+)?( version (1|2c|3))?)\s+\S+((\s+\S*)*)\s*/, '\\1 <secret hidden> \\5'
cfg.gsub! /^(username \S+ privilege \d+) (\S+).*/, '\\1 <secret hidden>'
cfg.gsub! /^(username \S+ password \d) (\S+)/, '\\1 <secret hidden>'
cfg.gsub! /^(username \S+ secret \d) (\S+)/, '\\1 <secret hidden>'
diff --git a/lib/oxidized/model/netgear.rb b/lib/oxidized/model/netgear.rb
index 38aaca7..0ab1349 100644
--- a/lib/oxidized/model/netgear.rb
+++ b/lib/oxidized/model/netgear.rb
@@ -1,7 +1,7 @@
class Netgear < Oxidized::Model
comment '!'
- prompt /^(\([\w-]+\)\s[#>])$/
+ prompt /^(\([\w\-.]+\)\s[#>])$/
cmd :secret do |cfg|
cfg.gsub!(/password (\S+)/, 'password <hidden>')
diff --git a/lib/oxidized/model/opnsense.rb b/lib/oxidized/model/opnsense.rb
new file mode 100644
index 0000000..b874fca
--- /dev/null
+++ b/lib/oxidized/model/opnsense.rb
@@ -0,0 +1,21 @@
+class OpnSense < Oxidized::Model
+
+ # minimum required permissions: "System: Shell account access"
+ # must enable SSH and password-based SSH access
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[1..-1].join
+ end
+
+ cmd 'cat /conf/config.xml' do |cfg|
+ cfg.gsub! /\s<revision>\s*<time>\d*<\/time>\s*.*\s*.*\s*<\/revision>/, ''
+ cfg.gsub! /\s<last_rule_upd_time>\d*<\/last_rule_upd_time>/, ''
+ cfg
+ end
+
+ cfg :ssh do
+ exec true
+ pre_logout 'exit'
+ end
+
+end
diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb
index 180b703..444fb5b 100644
--- a/lib/oxidized/model/procurve.rb
+++ b/lib/oxidized/model/procurve.rb
@@ -21,6 +21,11 @@ class Procurve < Oxidized::Model
""
end
+ expect /Enter switch number/ do
+ send "\n"
+ ""
+ end
+
cmd :all do |cfg|
cfg = cfg.each_line.to_a[1..-2].join
cfg = cfg.gsub /^\r/, ''
@@ -42,6 +47,10 @@ class Procurve < Oxidized::Model
comment cfg
end
+ cmd 'show system power-supply' do |cfg|
+ comment cfg
+ end
+
cmd 'show interfaces transceiver' do |cfg|
comment cfg
end
diff --git a/lib/oxidized/model/routeros.rb b/lib/oxidized/model/routeros.rb
index f391fb9..6717446 100644
--- a/lib/oxidized/model/routeros.rb
+++ b/lib/oxidized/model/routeros.rb
@@ -19,6 +19,7 @@ class RouterOS < Oxidized::Model
cmd run_cmd do |cfg|
cfg.gsub! /\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]/, '' # strip ANSI colours
cfg.gsub! /\\\r\n\s+/, '' # strip new line
+ cfg.gsub! /# inactive time\r\n/, '' # Remove time based system comment
cfg = cfg.split("\n").select { |line| not line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] }
cfg.join("\n") + "\n"
end
diff --git a/lib/oxidized/model/slxos.rb b/lib/oxidized/model/slxos.rb
new file mode 100644
index 0000000..934da5b
--- /dev/null
+++ b/lib/oxidized/model/slxos.rb
@@ -0,0 +1,61 @@
+class SLXOS < Oxidized::Model
+
+ prompt /^.*[>#]\s?$/i
+ comment '! '
+
+ cmd 'show version' do |cfg|
+ cfg.gsub! /(^((.*)[Ss]ystem [Uu]ptime(.*))$)/, '' #remove unwanted line system uptime
+ cfg.gsub! /[Uu]p\s?[Tt]ime is .*/,''
+
+ comment cfg
+ end
+
+ cmd 'show chassis' do |cfg|
+ cfg.encode!("UTF-8", :invalid => :replace, :undef => :replace) #sometimes ironware returns broken encoding
+ cfg.gsub! /.*Power Usage.*/, '' #remove unwanted lines power usage
+ cfg.gsub! /Time A(live|wake).*/, '' #remove unwanted lines time alive/awake
+ cfg.gsub! /([\[]*)1([\]]*)<->([\[]*)2([\]]*)(<->([\[]*)3([\]]*))*/, ''
+
+ comment cfg
+ end
+
+ cmd 'show system' do |cfg|
+ cfg.gsub! /Up Time.*/, '' #removes uptime line
+ cfg.gsub! /Current Time.*/, '' #remove current time line
+ cfg.gsub! /.*speed is.*/, '' #removes fan speed lines
+
+ comment cfg
+ end
+
+ cmd 'show slots' do |cfg|
+ cfg.gsub! /^-*^$/, '' # some slx devices are fixed config
+ cfg.gsub! /syntax error: element does not exist/, '' # same as above
+
+ comment cfg
+ end
+
+ cmd 'show running-config' do |cfg|
+ arr = cfg.each_line.to_a
+ arr[2..-1].join unless arr.length < 2
+ end
+
+ cfg :telnet do
+ # match expected prompts
+ username /^(Please Enter Login Name|Username):/
+ password /^(Please Enter Password ?|Password):/
+ end
+
+ #handle pager with enable
+ cfg :telnet, :ssh do
+ if vars :enable
+ post_login do
+ send "enable\n"
+ cmd vars(:enable)
+ end
+ end
+ post_login ''
+ post_login 'terminal length 0'
+ pre_logout 'exit'
+ end
+
+end
diff --git a/lib/oxidized/model/vyatta.rb b/lib/oxidized/model/vyatta.rb
index 8d977aa..aa0bc74 100644
--- a/lib/oxidized/model/vyatta.rb
+++ b/lib/oxidized/model/vyatta.rb
@@ -13,7 +13,7 @@ class Vyatta < Oxidized::Model
cfg
end
- cmd 'show configuration | no-more'
+ cmd 'show configuration commands | no-more'
cfg :telnet do
username /login:\s/