diff options
Diffstat (limited to 'lib/oxidized/model')
-rw-r--r-- | lib/oxidized/model/aireos.rb | 2 | ||||
-rw-r--r-- | lib/oxidized/model/aosw.rb | 28 | ||||
-rw-r--r-- | lib/oxidized/model/comware.rb | 6 | ||||
-rw-r--r-- | lib/oxidized/model/fabricos.rb | 3 | ||||
-rw-r--r-- | lib/oxidized/model/fiberdriver.rb | 4 | ||||
-rw-r--r-- | lib/oxidized/model/fortios.rb | 19 | ||||
-rw-r--r-- | lib/oxidized/model/ios.rb | 8 | ||||
-rw-r--r-- | lib/oxidized/model/ironware.rb | 9 | ||||
-rw-r--r-- | lib/oxidized/model/nxos.rb | 15 | ||||
-rw-r--r-- | lib/oxidized/model/opengear.rb | 2 | ||||
-rw-r--r-- | lib/oxidized/model/procurve.rb | 5 | ||||
-rw-r--r-- | lib/oxidized/model/routeros.rb | 4 | ||||
-rw-r--r-- | lib/oxidized/model/timos.rb | 16 | ||||
-rw-r--r-- | lib/oxidized/model/tplink.rb | 65 | ||||
-rw-r--r-- | lib/oxidized/model/zhoneolt.rb | 52 |
15 files changed, 216 insertions, 22 deletions
diff --git a/lib/oxidized/model/aireos.rb b/lib/oxidized/model/aireos.rb index 7e9d49e..7056e3f 100644 --- a/lib/oxidized/model/aireos.rb +++ b/lib/oxidized/model/aireos.rb @@ -44,7 +44,7 @@ class Aireos < Oxidized::Model out = [] cfg.each_line do |line| next if line.match /^\s*$/ - next if line.match /rogue adhoc alert [\da-f]{2}:/ + next if line.match /rogue (adhoc|client) alert [\da-f]{2}:/ line = line[1..-1] if line[0] == "\r" out << line.strip end diff --git a/lib/oxidized/model/aosw.rb b/lib/oxidized/model/aosw.rb index 11d8442..a85ead7 100644 --- a/lib/oxidized/model/aosw.rb +++ b/lib/oxidized/model/aosw.rb @@ -1,45 +1,61 @@ class AOSW < Oxidized::Model - # AOSW Aruba Wireless + # AOSW Aruba Wireless, IAP, Instant Controller and Mobility Access Switches # Used in Alcatel OAW-4750 WLAN controller # Also Dell controllers + + # HPE Aruba Switches should use a different model as the software is based on the HP Procurve line. + + # Support for IAP & Instant Controller tested with 115, 205, 215 & 325 running 6.4.4.8-4.2.4.5_57965 + # Support for Mobility Access Switches tested with S2500-48P & S2500-24P running 7.4.1.4_54199 and S2500-24P running 7.4.1.7_57823 + # All IAPs connected to a Instant Controller will have the same config output. Only the controller needs to be monitored. comment '# ' - prompt /^\([^)]+\) [#>]/ + prompt /^\(?.+\)?\s?[#>]/ cmd :all do |cfg| cfg.each_line.to_a[1..-2].join end cmd :secret do |cfg| + cfg.gsub!(/secret (\S+)$/, 'secret <secret removed>') + cfg.gsub!(/enable secret (\S+)$/, 'enable secret <secret removed>') cfg.gsub!(/PRE-SHARE (\S+)$/, 'PRE-SHARE <secret removed>') cfg.gsub!(/ipsec (\S+)$/, 'ipsec <secret removed>') cfg.gsub!(/community (\S+)$/, 'community <secret removed>') cfg.gsub!(/ sha (\S+)/, ' sha <secret removed>') cfg.gsub!(/ des (\S+)/, ' des <secret removed>') cfg.gsub!(/mobility-manager (\S+) user (\S+) (\S+)/, 'mobility-manager \1 user \2 <secret removed>') - cfg.gsub!(/mgmt-user (\S+) (\S+) (\S+)$/, 'mgmt-user \1 \2 <secret removed>') + 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 + cfg.gsub!(/mgmt-user (\S+) (\S+)( (read\-only|guest\-mgmt))?$/, 'mgmt-user \1 <secret removed> \3') #IAP +#MAS format: mgmt-user <username> <accesslevel> <password hash> +#IAP format (root user): mgmt-user <username> <password hash> +#IAP format: mgmt-user <username> <password hash> <access level> cfg.gsub!(/key (\S+)$/, 'key <secret removed>') - cfg.gsub!(/secret (\S+)$/, 'secret <secret removed>') cfg.gsub!(/wpa-passphrase (\S+)$/, 'wpa-passphrase <secret removed>') cfg.gsub!(/bkup-passwords (\S+)$/, 'bkup-passwords <secret removed>') + cfg.gsub!(/user (\S+) (\S+) (\S+)$/, 'user \1 <secret removed> \3') + cfg.gsub!(/virtual-controller-key (\S+)$/, 'virtual-controller-key <secret removed>') cfg end cmd 'show version' do |cfg| - cfg = cfg.each_line.select { |line| not line.match /Switch uptime/i } + cfg = cfg.each_line.select { |line| not line.match /(Switch|AP) uptime/i } rstrip_cfg comment cfg.join end cmd 'show inventory' do |cfg| + cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ #Don't show for unsupported devices (IAP and MAS) rstrip_cfg clean cfg end cmd 'show slots' do |cfg| + cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ #Don't show for unsupported devices (IAP and MAS) rstrip_cfg comment cfg end cmd 'show license' do |cfg| + cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ #Don't show for unsupported devices (IAP and MAS) rstrip_cfg comment cfg end @@ -90,7 +106,7 @@ class AOSW < Oxidized::Model next if line.match /Output \d Config/i next if line.match /(Tachometers|Temperatures|Voltages)/ next if line.match /((Card|CPU) Temperature|Chassis Fan|VMON1[0-9])/ - next if line.match /[0-9]+ (RPMS?|m?V|C)/i + next if line.match /[0-9]+\s+(RPMS?|m?V|C)/i out << line.strip end out = comment out.join "\n" diff --git a/lib/oxidized/model/comware.rb b/lib/oxidized/model/comware.rb index 27b70ae..d926854 100644 --- a/lib/oxidized/model/comware.rb +++ b/lib/oxidized/model/comware.rb @@ -18,6 +18,12 @@ class Comware < Oxidized::Model cfg.each_line.to_a[1..-2].join end + cmd :secret do |cfg| + cfg.gsub! /^( snmp-agent community).*/, '\\1 <configuration removed>' + cfg.gsub! /^( password hash).*/, '\\1 <configuration removed>' + cfg + end + cfg :telnet do username /^Username:$/ password /^Password:$/ diff --git a/lib/oxidized/model/fabricos.rb b/lib/oxidized/model/fabricos.rb index 7ab9fd5..e6d921e 100644 --- a/lib/oxidized/model/fabricos.rb +++ b/lib/oxidized/model/fabricos.rb @@ -7,10 +7,11 @@ class FabricOS < Oxidized::Model comment '# ' cmd 'chassisShow' do |cfg| - comment cfg + comment cfg.each_line.reject { |line| line.match /Time Awake:/ or line.match /Power Usage \(Watts\):/ or line.match /Time Alive:/ or line.match /Update:/ }.join end cmd 'configShow -all' do |cfg| + cfg = cfg.each_line.reject { |line| line.match /date = /}.join cfg end diff --git a/lib/oxidized/model/fiberdriver.rb b/lib/oxidized/model/fiberdriver.rb index 8f8eb07..abe8f68 100644 --- a/lib/oxidized/model/fiberdriver.rb +++ b/lib/oxidized/model/fiberdriver.rb @@ -11,6 +11,10 @@ class FiberDriver < Oxidized::Model cmd "show running-config" do |cfg| cfg.each_line.to_a[3..-1].join + cfg.gsub! /^Building configuration.*$/, '' + cfg.gsub! /^Current configuration:.*$$/, '' + cfg.gsub! /^! Configuration saved on .*$/, '' + cfg end cfg :ssh do diff --git a/lib/oxidized/model/fortios.rb b/lib/oxidized/model/fortios.rb index cd379b7..2415537 100644 --- a/lib/oxidized/model/fortios.rb +++ b/lib/oxidized/model/fortios.rb @@ -14,6 +14,12 @@ class FortiOS < Oxidized::Model new_cfg << cfg.each_line.to_a[1..-2].map { |line| line.gsub(/(conf_file_ver=)(.*)/, '\1<stripped>\3') }.join end + cmd :secret do |cfg| + cfg.gsub! /(set (?:passwd|password|psksecret)).*/, '\\1 <configuration removed>' + cfg.gsub! /(set private-key).*-+END ENCRYPTED PRIVATE KEY-*"$/m , '\\1 <configuration removed>' + cfg + end + cmd 'get system status' do |cfg| @vdom_enabled = cfg.include? 'Virtual domain configuration: enable' cfg.gsub!(/(System time: )(.*)/, '\1<stripped>\3') @@ -25,14 +31,18 @@ class FortiOS < Oxidized::Model cfg << cmd('config global') if @vdom_enabled cfg << cmd('get hardware status') do |cfg| - comment cfg + comment cfg end - cfg << cmd('diagnose autoupdate version') do |cfg| - comment cfg + #default behaviour: include autoupdate output (backwards compatibility) + #do not include if variable "show_autoupdate" is set to false + if defined?(vars(:fortios_autoupdate)).nil? || vars(:fortios_autoupdate) + cfg << cmd('diagnose autoupdate version') do |cfg| + comment cfg.each_line.reject { |line| line.match /Last Update|Result/ }.join + end end - cfg << cmd('end') if @vdom_enabled +cfg << cmd('end') if @vdom_enabled cfg << cmd('show') cfg.join "\n" @@ -48,3 +58,4 @@ class FortiOS < Oxidized::Model end end + diff --git a/lib/oxidized/model/ios.rb b/lib/oxidized/model/ios.rb index aa64847..94a3ab0 100644 --- a/lib/oxidized/model/ios.rb +++ b/lib/oxidized/model/ios.rb @@ -27,8 +27,8 @@ class IOS < Oxidized::Model cfg.gsub! /username (\S+) privilege (\d+) (\S+).*/, '<secret hidden>' cfg.gsub! /^username \S+ password \d \S+/, '<secret hidden>' cfg.gsub! /^username \S+ secret \d \S+/, '<secret hidden>' - cfg.gsub! /^enable password \d \S+/, '<secret hidden>' - cfg.gsub! /^enable secret \d \S+/, '<secret hidden>' + cfg.gsub! /^enable (password|secret) \d \S+/, '<secret hidden>' + cfg.gsub! /^(\s+(?:password|secret)) (?:\d )?\S+/, '\\1 <secret hidden>' cfg.gsub! /wpa-psk ascii \d \S+/, '<secret hidden>' cfg.gsub! /key 7 \d.+/, '<secret hidden>' cfg.gsub! /^tacacs-server key \d \S+/, '<secret hidden>' @@ -59,8 +59,6 @@ class IOS < Oxidized::Model end cfg :telnet, :ssh do - post_login 'terminal length 0' - post_login 'terminal width 0' # preferred way to handle additional passwords if vars :enable post_login do @@ -68,6 +66,8 @@ class IOS < Oxidized::Model cmd vars(:enable) end end + post_login 'terminal length 0' + post_login 'terminal width 0' pre_logout 'exit' end diff --git a/lib/oxidized/model/ironware.rb b/lib/oxidized/model/ironware.rb index db341d1..c7c2197 100644 --- a/lib/oxidized/model/ironware.rb +++ b/lib/oxidized/model/ironware.rb @@ -30,10 +30,11 @@ class IronWare < Oxidized::Model end cmd 'show chassis' do |cfg| - cfg.encode!("UTF-8", :invalid => :replace) #sometimes ironware returns broken encoding + cfg.encode!("UTF-8", :invalid => :replace, :undef => :replace) #sometimes ironware returns broken encoding cfg.gsub! /(^((.*)Current temp(.*))$)/, '' #remove unwanted lines current temperature cfg.gsub! /Speed = [A-Z-]{2,6} \(\d{2,3}\%\)/, '' #remove unwanted lines Speed Fans cfg.gsub! /current speed is [A-Z]{2,6} \(\d{2,3}\%\)/, '' + cfg.gsub! /([\[]*)1([\]]*)<->([\[]*)2([\]]*)(<->([\[]*)3([\]]*))*/, '' cfg.gsub! /\d{2}\.\d deg-C/, 'XX.X deg-C' if cfg.include? "TEMPERATURE" sc = StringScanner.new cfg @@ -73,16 +74,14 @@ class IronWare < Oxidized::Model cfg :telnet, :ssh do if vars :enable post_login do - send "enable\r\n" + send "enable\n" cmd vars(:enable) end end post_login '' post_login 'skip-page-display' post_login 'terminal length 0' - pre_logout 'logout' - pre_logout 'exit' - pre_logout 'exit' + pre_logout "logout\nexit\nexit\n" end end diff --git a/lib/oxidized/model/nxos.rb b/lib/oxidized/model/nxos.rb index 6163724..e743415 100644 --- a/lib/oxidized/model/nxos.rb +++ b/lib/oxidized/model/nxos.rb @@ -3,6 +3,14 @@ class NXOS < Oxidized::Model prompt /^(\r?[\w.@_()-]+[#]\s?)$/ comment '! ' + cmd :secret do |cfg| + cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>' + cfg.gsub! /^(snmp-server user (\S+) (\S+) auth (\S+)) (\S+) (priv) (\S+)/, '\\1 <configuration removed> ' + cfg.gsub! /^(username \S+ password \d) (\S+)/, '\\1 <secret hidden>' + cfg.gsub! /^(radius-server key).*/, '\\1 <secret hidden>' + cfg + end + cmd 'show version' do |cfg| cfg = cfg.each_line.take_while { |line| not line.match(/uptime/i) } comment cfg.join "" @@ -16,8 +24,13 @@ class NXOS < Oxidized::Model cfg.gsub! /^!Time:[^\n]*\n/, '' end - cfg :ssh do + cfg :ssh, :telnet do post_login 'terminal length 0' pre_logout 'exit' end + + cfg :telnet do + username /^login:/ + password /^Password:/ + end end diff --git a/lib/oxidized/model/opengear.rb b/lib/oxidized/model/opengear.rb index 7f801f8..b7c697f 100644 --- a/lib/oxidized/model/opengear.rb +++ b/lib/oxidized/model/opengear.rb @@ -1,6 +1,8 @@ class OpenGear < Oxidized::Model comment '# ' + + prompt /^(\$\s)?$/ cmd :secret do |cfg| cfg.gsub!(/password (\S+)/, 'password <secret removed>') diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb index c117df3..0b8b672 100644 --- a/lib/oxidized/model/procurve.rb +++ b/lib/oxidized/model/procurve.rb @@ -6,6 +6,11 @@ class Procurve < Oxidized::Model comment '! ' + # replace next line control sequence with a new line + expect /\eE/ do |data, re| + data.gsub re, "\n" + end + # replace all used vt100 control sequences expect /\e\[\??\d+(;\d+)*[A-Za-z]/ do |data, re| data.gsub re, '' diff --git a/lib/oxidized/model/routeros.rb b/lib/oxidized/model/routeros.rb index a92ad5e..5717100 100644 --- a/lib/oxidized/model/routeros.rb +++ b/lib/oxidized/model/routeros.rb @@ -6,6 +6,10 @@ class RouterOS < Oxidized::Model comment cfg end + cmd '/system package update print' do |cfg| + comment cfg + end + cmd '/export' 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 diff --git a/lib/oxidized/model/timos.rb b/lib/oxidized/model/timos.rb index d40e845..c230a8f 100644 --- a/lib/oxidized/model/timos.rb +++ b/lib/oxidized/model/timos.rb @@ -18,6 +18,8 @@ class TiMOS < Oxidized::Model # Show the boot options file. # cmd 'show bof' do |cfg| + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' comment cfg end @@ -29,6 +31,8 @@ class TiMOS < Oxidized::Model # Strip uptime. # cfg.sub! /^System Up Time.*\n/, '' + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' comment cfg end @@ -36,6 +40,8 @@ class TiMOS < Oxidized::Model # Show the card state. # cmd 'show card state' do |cfg| + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' comment cfg end @@ -48,6 +54,8 @@ class TiMOS < Oxidized::Model # cfg.gsub! /\r/, '' cfg.gsub! /[\b][\b][\b]/, "\n" + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' comment cfg end @@ -55,6 +63,8 @@ class TiMOS < Oxidized::Model # Show the running debug configuration. # cmd 'show debug' do |cfg| + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' comment cfg end @@ -66,6 +76,8 @@ class TiMOS < Oxidized::Model # Strip carriage returns. # cfg.gsub! /\r/, '' + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' comment cfg end @@ -77,6 +89,8 @@ class TiMOS < Oxidized::Model # Strip carriage returns. # cfg.gsub! /\r/, '' + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' comment cfg end @@ -88,6 +102,8 @@ class TiMOS < Oxidized::Model # Strip carriage returns. # cfg.gsub! /\r/, '' + cfg.gsub! /# Finished .*/, '' + cfg.gsub! /# Generated .*/, '' end cfg :telnet do diff --git a/lib/oxidized/model/tplink.rb b/lib/oxidized/model/tplink.rb new file mode 100644 index 0000000..bf13803 --- /dev/null +++ b/lib/oxidized/model/tplink.rb @@ -0,0 +1,65 @@ +class TPLink < Oxidized::Model + + # tp-link prompt + prompt /^\r?([\w.@()-]+[#>]\s?)$/ + comment '! ' + + # handle paging + # workaround for sometimes missing whitespaces with "\s?" + expect /Press\s?any\s?key\s?to\s?continue\s?\(Q\s?to\s?quit\)/ do |data, re| + send ' ' + data.sub re, '' + end + + # send carriage return because \n with the command is not enough + # checks if line ends with prompt >,# or \r,\nm otherwise send \r + expect /[^>#\r\n]$/ do |data, re| + send "\r" + data.sub re, '' + end + + cmd :all do |cfg| + # normalize linefeeds + cfg.gsub! /(\r|\r\n|\n\r)/,"\n" + # remove empty lines + cfg.each_line.reject { |line| line.match /^[\r\n\s\u0000#]+$/ }.join + end + + cmd :secret do |cfg| + cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>' + cfg.gsub! /secret (\d+) (\S+).*/, '<secret hidden>' + cfg + end + + cmd 'show system-info' do |cfg| + comment cfg.each_line.to_a[3..-3].join + end + + cmd 'show running-config' do |cfg| + lines = cfg.each_line.to_a[1..-1] + # cut config after "end" + lines[0..lines.index("end\n")].join + end + + cfg :telnet, :ssh do + username /^User ?[nN]ame:/ + password /^\r?Password:/ + end + + cfg :telnet, :ssh do + if vars :enable + post_login do + send "enable\r" + cmd vars(:enable) + end + end + + pre_logout do + send "exit\r" + send "logout\r" + end + + end + +end + diff --git a/lib/oxidized/model/zhoneolt.rb b/lib/oxidized/model/zhoneolt.rb new file mode 100644 index 0000000..b60edb2 --- /dev/null +++ b/lib/oxidized/model/zhoneolt.rb @@ -0,0 +1,52 @@ +class ZhoneOLT < Oxidized::Model + # Zhone OLT/MetroE/DSL devices (ONT uses a completely different CLI) + + # the prompt can be anything on zhone, but it defaults to 'zXX>' and we + # always use hostname> + prompt /^(\r*[\w.@():-]+[>]\s?)$/ + comment '# ' + + cmd :secret do |cfg| + cfg.gsub! /^(set configsyncpasswd = ) \S+/, '\\1 <removed>' + cfg.gsub! /^(set user-pass = ) \S+/, '\\1 <removed>' + cfg.gsub! /^(set auth-key = ) \S+/, '\\1 <removed>' + cfg.gsub! /^(set priv-key = ) \S+/, '\\1 <removed>' + cfg.gsub! /^(set ftp-password = ) \S+/, '\\1 <removed>' + cfg.gsub! /^(set community-name = ) \S+/, '\\1 <removed>' + cfg.gsub! /^(set communityname = ) \S+/, '\\1 <removed>' + cfg + end + + cmd :all do |cfg| + cfg.each_line.to_a[1..-2].map{|line|line.delete("\r").rstrip}.join("\n") + "\n" + end + + cmd 'swversion' do |cfg| + comment cfg + end + + cmd 'slots' do |cfg| + comment cfg + end + + cmd 'eeshow card' do |cfg| + comment cfg + end + + cmd 'ethrpshow' do |cfg| + cfg = cfg.each_line.select { |line| line.match /Vendor (Name|OUI|Part|Revision)|Serial Number|Manufacturing Date/ }.join + comment cfg + end + + cmd 'dump console' do |cfg| + cfg = cfg.each_line.select { |line| not line.match /To Abort the operation enter Ctrl-C/ }.join + end + + # zhone technically supports ssh, but it locks up a ton. Especially when + # showing large amounts of output, like "dump console" + cfg :telnet do + username /\r*login:/ + password /\r*password:/ + pre_logout 'logout' + end +end |