summaryrefslogtreecommitdiff
path: root/lib/oxidized/model
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/model')
-rw-r--r--lib/oxidized/model/airos.rb13
-rw-r--r--lib/oxidized/model/boss.rb76
-rw-r--r--lib/oxidized/model/firewareos.rb8
-rw-r--r--lib/oxidized/model/fortios.rb3
-rw-r--r--lib/oxidized/model/hirschmann.rb41
-rw-r--r--lib/oxidized/model/ios.rb88
-rw-r--r--lib/oxidized/model/mlnxos.rb2
-rw-r--r--lib/oxidized/model/netgear.rb32
-rw-r--r--lib/oxidized/model/pfsense.rb2
-rw-r--r--lib/oxidized/model/powerconnect.rb1
-rw-r--r--lib/oxidized/model/quantaos.rb2
-rw-r--r--lib/oxidized/model/routeros.rb8
-rw-r--r--lib/oxidized/model/siklu.rb19
-rw-r--r--lib/oxidized/model/voltaire.rb56
-rw-r--r--lib/oxidized/model/voss.rb36
-rw-r--r--lib/oxidized/model/vrp.rb6
16 files changed, 376 insertions, 17 deletions
diff --git a/lib/oxidized/model/airos.rb b/lib/oxidized/model/airos.rb
index 775005f..7d82956 100644
--- a/lib/oxidized/model/airos.rb
+++ b/lib/oxidized/model/airos.rb
@@ -1,14 +1,19 @@
class Airos < Oxidized::Model
# Ubiquiti AirOS circa 5.x
-
+
prompt /^[^#]+# /
-
+ comment '# '
+
cmd 'cat /etc/board.info' do |cfg|
cfg.split("\n").map { |line| "# #{line}" }.join("\n") + "\n"
end
-
+
+ cmd 'cat /etc/version' do |cfg|
+ comment "airos version: #{cfg}"
+ end
+
cmd 'sort /tmp/system.cfg'
-
+
cmd :secret do |cfg|
cfg.gsub! /^(users\.\d+\.password|snmp\.community)=.+/, "# \\1=<hidden>"
cfg
diff --git a/lib/oxidized/model/boss.rb b/lib/oxidized/model/boss.rb
new file mode 100644
index 0000000..02201a1
--- /dev/null
+++ b/lib/oxidized/model/boss.rb
@@ -0,0 +1,76 @@
+class Boss < Oxidized::Model
+ # Avaya Baystack Operating System Software(BOSS)
+ # Created by danielcoxman@gmail.com
+ # May 15, 2017
+ # This was tested on ers3510, ers5530, ers4850, ers5952
+ # ssh and telnet were tested with banner and without
+
+ comment '! '
+
+ prompt /^[^\s#>]+[#>]$/
+
+ # Handle the banner
+ # to disable the banner on BOSS the configuration parameter is "banner disabled"
+ expect /Enter Ctrl-Y to begin\./ do |data, re|
+ send "\cY"
+ data.sub re, ''
+ end
+
+ # Handle the Failed retries since last login
+ # no known way to disable other than to implement radius authentication
+ expect /Press ENTER to continue/ do |data, re|
+ send "\n"
+ data.sub re, ''
+ end
+
+ # Handle the menu on the older BOSS example ers55xx, ers56xx
+ # to disable them menu on BOSS the configuration parameter is "cmd-interface cli"
+ expect /ommand Line Interface\.\.\./ do |data, re|
+ send "c"
+ data.sub re, ''
+ end
+
+ # needed for proper formatting
+ cmd('') { |cfg| comment "#{cfg}\n" }
+
+ # Do a sys-info and check and see if it supports stack
+ cmd 'show sys-info' do |cfg|
+ @stack = true if cfg.match /Stack/
+ cfg.gsub! /(^((.*)sysUpTime(.*))$)/, 'removed sysUpTime'
+ cfg.gsub! /(^((.*)sysNtpTime(.*))$)/, 'removed sysNtpTime'
+ cfg.gsub! /(^((.*)sysRtcTime(.*))$)/, 'removed sysNtpTime'
+ # remove timestamp
+ cfg.gsub! /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} .*/, ''
+ comment "#{cfg}\n"
+ end
+
+ # if a stack then collect the stacking information
+ cmd 'show stack-info' do |cfg|
+ if @stack
+ # remove timestamp
+ cfg.gsub! /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} .*/, ''
+ comment "#{cfg}\n"
+ end
+ end
+
+ cmd 'show running-config' do |cfg|
+ cfg.gsub! /^show running-config/, '! show running-config'
+ # remove timestamp
+ cfg.gsub! /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} .*/, ''
+ cfg.gsub! /^[^\s#>]+[#>]$/, ''
+ cfg.gsub! /^! clock set.*/, '! removed clock set'
+ cfg
+ end
+
+ cfg :telnet do
+ username /Username: /
+ password /Password: /
+ end
+
+ cfg :telnet, :ssh do
+ pre_logout 'logout'
+ post_login 'terminal length 0'
+ post_login 'terminal width 132'
+ end
+
+end
diff --git a/lib/oxidized/model/firewareos.rb b/lib/oxidized/model/firewareos.rb
index f2bef4c..f456c60 100644
--- a/lib/oxidized/model/firewareos.rb
+++ b/lib/oxidized/model/firewareos.rb
@@ -1,12 +1,18 @@
class FirewareOS < Oxidized::Model
- prompt /^\[?\w*\]?\w*<?\w*>?#\s*$/
+ prompt /^([\w.@-]+[#>]\s?)$/
comment '-- '
cmd :all do |cfg|
cfg.each_line.to_a[1..-2].join
end
+ # Handle Logon Disclaimer added in XTM 11.9.3
+ expect /^I have read and accept the Logon Disclaimer message. \(yes or no\)\? $/ do |data, re|
+ send "yes\n"
+ data.sub re, ''
+ end
+
cmd 'show sysinfo' do |cfg|
# avoid commits due to uptime
cfg = cfg.each_line.select { |line| not line.match /(.*time.*)|(.*memory.*)|(.*cpu.*)/ }
diff --git a/lib/oxidized/model/fortios.rb b/lib/oxidized/model/fortios.rb
index 2415537..0249933 100644
--- a/lib/oxidized/model/fortios.rb
+++ b/lib/oxidized/model/fortios.rb
@@ -15,7 +15,7 @@ class FortiOS < Oxidized::Model
end
cmd :secret do |cfg|
- cfg.gsub! /(set (?:passwd|password|psksecret)).*/, '\\1 <configuration removed>'
+ cfg.gsub! /(set (?:passwd|password|psksecret|secret|key ENC)).*/, '\\1 <configuration removed>'
cfg.gsub! /(set private-key).*-+END ENCRYPTED PRIVATE KEY-*"$/m , '\\1 <configuration removed>'
cfg
end
@@ -38,6 +38,7 @@ class FortiOS < Oxidized::Model
#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|
+ cfg.gsub! /(FDS Address\n---------\n).*/, '\\1IP Address removed'
comment cfg.each_line.reject { |line| line.match /Last Update|Result/ }.join
end
end
diff --git a/lib/oxidized/model/hirschmann.rb b/lib/oxidized/model/hirschmann.rb
new file mode 100644
index 0000000..82432d7
--- /dev/null
+++ b/lib/oxidized/model/hirschmann.rb
@@ -0,0 +1,41 @@
+class Hirschmann < Oxidized::Model
+
+ prompt /^[\(\w\s\w\)]+\s[>|#]+?$/
+
+ comment '## '
+
+ #Handle pager
+ expect /^--More--.*$/ do |data, re|
+ send 'a'
+ data.sub re, ''
+ end
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[1..-2].join
+ end
+
+ cmd 'show sysinfo' do |cfg|
+ cfg.gsub! /^System Up Time.*\n/, ""
+ cfg.gsub! /^System Date and Time.*\n/, ""
+ cfg.gsub! /^CPU Utilization.*\n/, ""
+ cfg.gsub! /^Memory.*\n/, ""
+ cfg.gsub! /^Average CPU Utilization.*\n/, ""
+ comment cfg
+ end
+
+ cmd 'show running-config' do |cfg|
+ cfg.gsub! /^users.*\n/, ""
+ cfg
+ end
+
+ cfg :telnet do
+ username /^User:/
+ password /^Password:/
+ end
+
+ cfg :telnet, :ssh do
+ post_login 'enable'
+ pre_logout 'logout'
+ end
+
+end
diff --git a/lib/oxidized/model/ios.rb b/lib/oxidized/model/ios.rb
index 94a3ab0..c3d5543 100644
--- a/lib/oxidized/model/ios.rb
+++ b/lib/oxidized/model/ios.rb
@@ -19,24 +19,96 @@ class IOS < Oxidized::Model
cmd :all do |cfg|
#cfg.gsub! /\cH+\s{8}/, '' # example how to handle pager
#cfg.gsub! /\cH+/, '' # example how to handle pager
+ # get rid of errors for commands that don't work on some devices
+ cfg.gsub! /^% Invalid input detected at '\^' marker\.$|^\s+\^$/, ''
cfg.each_line.to_a[1..-2].join
end
cmd :secret do |cfg|
cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
- 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|secret) \d \S+/, '<secret hidden>'
+ 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! /wpa-psk ascii \d \S+/, '<secret hidden>'
- cfg.gsub! /key 7 \d.+/, '<secret hidden>'
- cfg.gsub! /^tacacs-server key \d \S+/, '<secret hidden>'
+ cfg.gsub! /^(.*wpa-psk ascii \d) (\S+)/, '\\1 <secret hidden>'
+ cfg.gsub! /^(.*key 7) (\d.+)/, '\\1 <secret hidden>'
+ cfg.gsub! /^(tacacs-server key \d) (\S+)/, '\\1 <secret hidden>'
+ cfg.gsub! /^(crypto isakmp key) (\S+) (.*)/, '\\1 <secret hidden> \\3'
cfg
end
cmd 'show version' do |cfg|
- comment cfg.lines.first
+ comments = []
+ comments << cfg.lines.first
+ lines = cfg.lines
+ lines.each_with_index do |line,i|
+ slave = ''
+ slaveslot = ''
+
+ if line.match /^Slave in slot (\d+) is running/
+ slave = " Slave:";
+ slaveslot = ", slot #{$1}";
+ end
+
+ if line.match /^Compiled (.*)$/
+ comments << "Image:#{slave} Compiled: #{$1}"
+ end
+
+ if line.match /^(?:Cisco )?IOS .* Software,? \(([A-Za-z0-9_-]*)\), .*Version\s+(.*)$/
+ comments << "Image:#{slave} Software: #{$1}, #{$2}"
+ end
+
+ if line.match /^ROM: (IOS \S+ )?(System )?Bootstrap.*(Version.*)$/
+ comments << "ROM Bootstrap: #{$3}"
+ end
+
+ if line.match /^BOOTFLASH: .*(Version.*)$/
+ comments << "BOOTFLASH: #{$1}"
+ end
+
+ if line.match /^(\d+[kK]) bytes of (non-volatile|NVRAM)/
+ comments << "Memory: nvram #{$1}"
+ end
+
+ if line.match /^(\d+[kK]) bytes of (flash memory|flash internal|processor board System flash|ATA CompactFlash)/i
+ comments << "Memory: flash #{$1}"
+ end
+
+ if line.match (/^(\d+[kK]) bytes of (Flash|ATA)?.*PCMCIA .*(slot|disk) ?(\d)/i)
+ comments << "Memory: pcmcia #{$2} #{$3}#{$4} #{$1}";
+ end
+
+ if line.match /(\S+(?:\sseries)?)\s+(?:\((\S+)\)\s+processor|\(revision[^)]+\)).*\s+with (\S+k) bytes/i
+ sproc = $1
+ cpu = $2
+ mem = $3
+ cpuxtra = ''
+ comments << "Chassis type:#{slave} #{sproc}";
+ comments << "Memory:#{slave} main #{mem}";
+ # check the next two lines for more CPU info
+ if cfg.lines[i+1].match /processor board id (\S+)/i
+ comments << "Processor ID: #{$1}";
+ end
+ if cfg.lines[i+2].match /(cpu at |processor: |#{cpu} processor,)/i
+ # change implementation to impl and prepend comma
+ cpuxtra = cfg.lines[i+2].gsub(/implementation/,'impl').gsub(/^/,', ').chomp;
+ end
+ comments << "CPU:#{slave} #{cpu}#{cpuxtra}#{slaveslot}";
+ end
+
+ if line.match /^System image file is "([^\"]*)"$/
+ comments << "Image: #{$1}"
+ end
+ end
+ comments << "\n"
+ comment comments.join "\n"
+ end
+
+ cmd 'show vtp status' do |cfg|
+ cfg.gsub! /^$\n/, ''
+ cfg.gsub! /^/, 'VTP: ' if (!cfg.empty?)
+ comment "#{cfg}\n"
end
cmd 'show inventory' do |cfg|
diff --git a/lib/oxidized/model/mlnxos.rb b/lib/oxidized/model/mlnxos.rb
index 97e7098..49f3369 100644
--- a/lib/oxidized/model/mlnxos.rb
+++ b/lib/oxidized/model/mlnxos.rb
@@ -42,6 +42,6 @@ class MLNXOS < Oxidized::Model
cfg :ssh do
password /^Password:\s*/
- pre_logout 'exit'
+ pre_logout "\nexit"
end
end
diff --git a/lib/oxidized/model/netgear.rb b/lib/oxidized/model/netgear.rb
new file mode 100644
index 0000000..08c64d3
--- /dev/null
+++ b/lib/oxidized/model/netgear.rb
@@ -0,0 +1,32 @@
+class Netgear < Oxidized::Model
+
+ comment '!'
+ prompt /^(\([\w-]+\)\s[#>])$/
+
+ cmd :secret do |cfg|
+ cfg.gsub!(/password (\S+)/, 'password <hidden>')
+ cfg
+ end
+
+ cfg :telnet, :ssh do
+ if vars :enable
+ post_login do
+ cmd 'enable'
+ # Interpret enable: true as meaning we won't be prompted for a password
+ unless vars(:enable).is_a? TrueClass
+ expect /[pP]assword:\s?$/
+ cmd vars(:enable) + "\n"
+ end
+ expect /^.+[#]$/
+ end
+ end
+ post_login 'terminal length 0'
+ pre_logout 'exit'
+ pre_logout 'quit'
+ end
+
+ cmd 'show running-config' do |cfg|
+ cfg.gsub! /^(!.*Time).*$/, '\1'
+ end
+
+end
diff --git a/lib/oxidized/model/pfsense.rb b/lib/oxidized/model/pfsense.rb
index 782969e..5849160 100644
--- a/lib/oxidized/model/pfsense.rb
+++ b/lib/oxidized/model/pfsense.rb
@@ -3,7 +3,7 @@ class PfSense < Oxidized::Model
# use other use than 'admin' user, 'admin' user cannot get ssh/exec. See issue #535
cmd :all do |cfg|
- cfg.each_line.to_a[1..-2].join
+ cfg.each_line.to_a[1..-1].join
end
cmd 'cat /cf/conf/config.xml' do |cfg|
diff --git a/lib/oxidized/model/powerconnect.rb b/lib/oxidized/model/powerconnect.rb
index ac36c26..618f05a 100644
--- a/lib/oxidized/model/powerconnect.rb
+++ b/lib/oxidized/model/powerconnect.rb
@@ -67,6 +67,7 @@ class PowerConnect < Oxidized::Model
end
out << line.strip
end
+ out = out.select { |line| not line[/Up\sTime/] }
out = comment out.join "\n"
out << "\n"
end
diff --git a/lib/oxidized/model/quantaos.rb b/lib/oxidized/model/quantaos.rb
index 274440d..5197aa8 100644
--- a/lib/oxidized/model/quantaos.rb
+++ b/lib/oxidized/model/quantaos.rb
@@ -12,7 +12,7 @@ class QuantaOS < Oxidized::Model
end
cfg :telnet do
- username /^Username:/
+ username /^User(name)?:/
password /^Password:/
end
diff --git a/lib/oxidized/model/routeros.rb b/lib/oxidized/model/routeros.rb
index 5717100..31650c7 100644
--- a/lib/oxidized/model/routeros.rb
+++ b/lib/oxidized/model/routeros.rb
@@ -10,6 +10,10 @@ class RouterOS < Oxidized::Model
comment cfg
end
+ cmd '/system history 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
@@ -22,6 +26,10 @@ class RouterOS < Oxidized::Model
password /^Password:/
end
+ cfg :telnet, :ssh do
+ pre_logout 'quit'
+ end
+
cfg :ssh do
exec true
end
diff --git a/lib/oxidized/model/siklu.rb b/lib/oxidized/model/siklu.rb
new file mode 100644
index 0000000..2bdfbc3
--- /dev/null
+++ b/lib/oxidized/model/siklu.rb
@@ -0,0 +1,19 @@
+class Siklu < Oxidized::Model
+
+ # Siklu EtherHaul #
+
+ prompt /^[\w-]+>$/
+
+ cmd 'copy startup-configuration display' do |cfg|
+ cfg.each_line.to_a[2..2].join
+ end
+
+ cmd 'copy running-configuration display' do |cfg|
+ cfg.each_line.to_a[3..-2].join
+ end
+
+ cfg :ssh do
+ pre_logout 'exit'
+ end
+
+end
diff --git a/lib/oxidized/model/voltaire.rb b/lib/oxidized/model/voltaire.rb
new file mode 100644
index 0000000..1e7fad2
--- /dev/null
+++ b/lib/oxidized/model/voltaire.rb
@@ -0,0 +1,56 @@
+class VOLTAIRE < Oxidized::Model
+
+ prompt /([\w.@()-\[:\s\]]+[#>]\s|(One or more tests have failed.*))$/
+ comment '## '
+
+ # Pager Handling
+ expect /.+lines\s\d+\-\d+([\s]|\/\d+\s\(END\)\s).+$/ do |data, re|
+ send ' '
+ data.sub re, ''
+ end
+
+
+ cmd :all do |cfg|
+ cfg.gsub! /\[\?1h=\r/, '' # Pager Handling
+ cfg.gsub! /\r\[K/,'' # Pager Handling
+ cfg.gsub! /\s/, '' # Linebreak Handling
+ cfg.gsub! /^CPU\ load\ averages\:\s.+/, '' # Omit constantly changing CPU info
+ cfg.gsub! /^System\ memory\:\s.+/, '' # Omit constantly changing memory info
+ cfg.gsub! /^Uptime\:\s.+/, '' # Omit constantly changing uptime info
+ cfg.gsub! /.+Generated\ at\s\d+.+/, '' # Omit constantly changing generation time info
+ cfg = cfg.lines.to_a[2..-3].join
+ end
+
+ cmd :secret do |cfg|
+ cfg.gsub! /(snmp-server community).*/, ' <snmp-server community configuration removed>'
+ cfg.gsub! /username (\S+) password (\d+) (\S+).*/, '<secret hidden>'
+ cfg
+ end
+
+
+ cmd 'version show' do |cfg|
+ comment cfg
+ end
+
+ cmd 'firmware-version show' do |cfg|
+ comment cfg
+ end
+
+ cmd 'remote show' do |cfg|
+ cfg
+ end
+
+ cmd 'sm-info show' do |cfg|
+ cfg
+ end
+
+ cmd ' show' do |cfg|
+ cfg
+ end
+
+ cfg :ssh do
+ post_login "no\n"
+ password /^Password:\s*/
+ pre_logout 'exit'
+ end
+end
diff --git a/lib/oxidized/model/voss.rb b/lib/oxidized/model/voss.rb
new file mode 100644
index 0000000..599462a
--- /dev/null
+++ b/lib/oxidized/model/voss.rb
@@ -0,0 +1,36 @@
+class Voss < Oxidized::Model
+ # Avaya VSP Operating System Software(VOSS)
+ # Created by danielcoxman@gmail.com
+ # May 15, 2017
+ # This was tested on vsp4k and vsp8k
+
+ comment '# '
+
+ prompt /^[^\s#>]+[#>]$/
+
+ # needed for proper formatting after post_login
+ cmd('') { |cfg| comment "#{cfg}\n" }
+ # get some general information about switch
+ cmd('show sys-info card') { |cfg| comment "#{cfg}\n" }
+ cmd('show sys-info fan') { |cfg| comment "#{cfg}\n" }
+ cmd('show sys-info power') { |cfg| comment "#{cfg}\n" }
+
+ # more the config rather than doing a show run
+ cmd 'more config.cfg' do |cfg|
+ cfg
+ cfg.gsub! /^[^\s#>]+[#>]$/, ''
+ cfg.gsub! /^more config.cfg/, '# more config.cfg'
+ end
+
+ cfg :telnet do
+ username /Login: $/
+ password /Password: $/
+ end
+
+ cfg :telnet, :ssh do
+ pre_logout 'exit'
+ post_login 'enable'
+ post_login 'terminal more disable'
+ end
+
+end
diff --git a/lib/oxidized/model/vrp.rb b/lib/oxidized/model/vrp.rb
index 12a9ca3..98229c3 100644
--- a/lib/oxidized/model/vrp.rb
+++ b/lib/oxidized/model/vrp.rb
@@ -4,6 +4,12 @@ class VRP < Oxidized::Model
prompt /^(<[\w.-]+>)$/
comment '# '
+ cmd :secret do |cfg|
+ cfg.gsub! /(pin verify (?:auto|)).*/, '\\1 <PIN hidden>'
+ cfg.gsub! /(%\^%#.*%\^%#)/, '<secret hidden>'
+ cfg
+ end
+
cmd :all do |cfg|
cfg.each_line.to_a[1..-2].join
end