summaryrefslogtreecommitdiff
path: root/lib/oxidized/model
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/model')
-rw-r--r--lib/oxidized/model/acos.rb22
-rw-r--r--lib/oxidized/model/asa.rb18
-rw-r--r--lib/oxidized/model/catos.rb36
-rw-r--r--lib/oxidized/model/comware.rb2
-rw-r--r--lib/oxidized/model/datacom.rb33
-rw-r--r--lib/oxidized/model/edgeswitch.rb23
-rw-r--r--lib/oxidized/model/fortios.rb2
-rw-r--r--lib/oxidized/model/iosxr.rb2
-rw-r--r--lib/oxidized/model/ipos.rb61
-rw-r--r--lib/oxidized/model/ironware.rb1
-rw-r--r--lib/oxidized/model/mtrlrfs.rb37
-rw-r--r--lib/oxidized/model/netonix.rb15
-rw-r--r--lib/oxidized/model/netscaler.rb24
-rw-r--r--lib/oxidized/model/nos.rb2
-rw-r--r--lib/oxidized/model/procurve.rb37
-rw-r--r--lib/oxidized/model/supermicro.rb45
-rw-r--r--lib/oxidized/model/tmos.rb26
-rw-r--r--lib/oxidized/model/xos.rb6
18 files changed, 346 insertions, 46 deletions
diff --git a/lib/oxidized/model/acos.rb b/lib/oxidized/model/acos.rb
index 75fbacf..7db8b00 100644
--- a/lib/oxidized/model/acos.rb
+++ b/lib/oxidized/model/acos.rb
@@ -1,5 +1,5 @@
class ACOS < Oxidized::Model
- # A10 ACOS model for AX and Thunder series
+ # A10 ACOS model for AX and Thunder series
comment '! '
@@ -17,10 +17,14 @@ class ACOS < Oxidized::Model
cmd 'show running-config all-partitions'
cmd 'show aflex all-partitions' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show aflex all-partitions' do |cfg|
@partitions_aflex = cfg.lines.each_with_object({}) do |l,h|
h[$1] = [] if l.match /partition: (.+)/
# only consider scripts that have passed syntax check
- h[h.keys.last] << $1 if l.match /^([\w-]+) +Check/
+ h[h.keys.last] << $1 if l.match /^([\w-]+) +Check/
end
''
end
@@ -52,18 +56,18 @@ class ACOS < Oxidized::Model
username /login:/
password /^Password:/
end
-
+
cfg :telnet, :ssh do
# preferred way to handle additional passwords
- if vars :enable
- post_login do
- send "enable\n"
- send vars(:enable) + "\n"
- end
+ post_login do
+ pw = vars(:enable)
+ pw ||= ""
+ send "enable\r\n"
+ cmd pw
end
post_login 'terminal length 0'
post_login 'terminal width 0'
- pre_logout "exit\nexit\ny"
+ pre_logout "exit\nexit\nY\r\n"
end
end
diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb
index 547afd7..48e6bf4 100644
--- a/lib/oxidized/model/asa.rb
+++ b/lib/oxidized/model/asa.rb
@@ -18,7 +18,7 @@ class ASA < Oxidized::Model
cmd 'show version' do |cfg|
# avoid commits due to uptime / ixo-router01 up 2 mins 28 secs / ixo-router01 up 1 days 2 hours
- cfg = cfg.each_line.select { |line| not line.match /\s+up\s+\d+\s+/ }
+ cfg = cfg.each_line.select { |line| not line.match /(\s+up\s+\d+\s+)|(.*days.*)/ }
cfg = cfg.join
comment cfg
end
@@ -30,6 +30,22 @@ class ASA < Oxidized::Model
cmd 'more system:running-config' do |cfg|
cfg = cfg.each_line.to_a[3..-1].join
cfg.gsub! /^: [^\n]*\n/, ''
+ # backup any xml referenced in the configuration.
+ anyconnect_profiles = cfg.scan(Regexp.new('(\sdisk0:/.+\.xml)')).flatten
+ anyconnect_profiles.each do |profile|
+ cfg << (comment profile + "\n" )
+ cmd ("more" + profile) do |xml|
+ cfg << (comment xml)
+ end
+ end
+ # if DAP is enabled, also backup dap.xml
+ if cfg.rindex(/dynamic-access-policy-record\s(?!DfltAccessPolicy)/)
+ cfg << (comment "disk0:/dap.xml\n")
+ cmd "more disk0:/dap.xml" do |xml|
+ cfg << (comment xml)
+ puts xml
+ end
+ end
cfg
end
diff --git a/lib/oxidized/model/catos.rb b/lib/oxidized/model/catos.rb
new file mode 100644
index 0000000..874ebbc
--- /dev/null
+++ b/lib/oxidized/model/catos.rb
@@ -0,0 +1,36 @@
+class Catos < Oxidized::Model
+
+ prompt /^[\w.@-]+> \(enable\) $/
+ comment '# '
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[1..-2].join
+ end
+
+ cmd 'show system' do |cfg|
+ cfg = cfg.gsub /(\s+)\d+,\d+:\d+:\d+(\s+)/, '\1X\2'
+ comment cfg
+ end
+
+ cmd 'show version' do |cfg|
+ cfg = cfg.gsub /\d+(K)/, 'X\1'
+ cfg = cfg.gsub /^(Uptime is ).*/, '\1X'
+ comment cfg
+ end
+
+ cmd 'show conf all' do |cfg|
+ cfg = cfg.sub /^(#time: ).*/, '\1X'
+ cfg.each_line.drop_while { |line| not line.match /^begin/ }.join
+ end
+
+ cfg :telnet do
+ username /^Username: /
+ password /^Password:/
+ end
+
+ cfg :ssh, :telnet do
+ post_login 'set length 0'
+ pre_logout 'exit'
+ end
+
+end
diff --git a/lib/oxidized/model/comware.rb b/lib/oxidized/model/comware.rb
index 9b36e8b..27b70ae 100644
--- a/lib/oxidized/model/comware.rb
+++ b/lib/oxidized/model/comware.rb
@@ -13,6 +13,8 @@ class Comware < Oxidized::Model
cmd :all do |cfg|
#cfg.gsub! /^.*\e\[42D/, '' # example how to handle pager
+ #skip rogue ^M
+ cfg = cfg.gsub /\r/, ''
cfg.each_line.to_a[1..-2].join
end
diff --git a/lib/oxidized/model/datacom.rb b/lib/oxidized/model/datacom.rb
new file mode 100644
index 0000000..54091ed
--- /dev/null
+++ b/lib/oxidized/model/datacom.rb
@@ -0,0 +1,33 @@
+class DataCom < Oxidized::Model
+
+ comment '! '
+
+ expect /^--More--\s+$/ do |data, re|
+ send ' '
+ data.sub re, ''
+ end
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[1..-2].join
+ cfg.cut_head.cut_tail
+ end
+
+ cmd 'show firmware' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show system' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show running-config' do |cfg|
+ cfg.cut_head
+ end
+
+ cfg :telnet, :ssh do
+ username /login:\s$/
+ password /^Password:\s$/
+ pre_logout 'exit'
+ end
+
+end
diff --git a/lib/oxidized/model/edgeswitch.rb b/lib/oxidized/model/edgeswitch.rb
index 89a5690..7c82639 100644
--- a/lib/oxidized/model/edgeswitch.rb
+++ b/lib/oxidized/model/edgeswitch.rb
@@ -4,22 +4,29 @@ class EdgeSwitch < Oxidized::Model
comment '!'
- prompt /[(]\w*\s\w*[)][\s#>]*[\s#>]/
+ prompt /\(.*\)\s[#>]/
cmd 'show running-config' do |cfg|
- comment cfg.each_line.reject { |line| line.match /System Up Time.*/ or line.match /Current SNTP Synchronized Time.*/ }.join
+ cfg.each_line.to_a[2..-2].reject { |line| line.match /System Up Time.*/ or line.match /Current SNTP Synchronized Time.*/ }.join
end
cfg :telnet do
username /Username:\s/
- passsword /^Password:\s/
+ password /^Password:\s/
end
cfg :telnet, :ssh do
- post_login 'enable'
- post_login 'terminal length 0'
- pre_logout 'exit'
- pre_logout 'exit'
+ post_login do
+ if vars :enable
+ send "enable\n"
+ cmd vars(:enable)
+ else
+ cmd 'enable'
+ end
+ cmd 'terminal length 0'
+ end
+ pre_logout 'quit'
+ pre_logout 'n'
end
-end \ No newline at end of file
+end
diff --git a/lib/oxidized/model/fortios.rb b/lib/oxidized/model/fortios.rb
index 92add0e..aad3a6e 100644
--- a/lib/oxidized/model/fortios.rb
+++ b/lib/oxidized/model/fortios.rb
@@ -2,7 +2,7 @@ class FortiOS < Oxidized::Model
comment '# '
- prompt /^([-\w\.]+(\s[\(\w\-\.\)]+)?\~?\s?[#>]\s?)$/
+ prompt /^([-\w\.]+(\s[\(\w\-\.\)]+)?\~?\s?[#>$]\s?)$/
expect /^--More--\s$/ do |data, re|
send ' '
diff --git a/lib/oxidized/model/iosxr.rb b/lib/oxidized/model/iosxr.rb
index a622b66..bf01140 100644
--- a/lib/oxidized/model/iosxr.rb
+++ b/lib/oxidized/model/iosxr.rb
@@ -30,7 +30,7 @@ class IOSXR < Oxidized::Model
cfg :telnet do
username /^Username:/
- password /^Password:/
+ password /^\r?Password:/
end
cfg :telnet, :ssh do
diff --git a/lib/oxidized/model/ipos.rb b/lib/oxidized/model/ipos.rb
new file mode 100644
index 0000000..5efd831
--- /dev/null
+++ b/lib/oxidized/model/ipos.rb
@@ -0,0 +1,61 @@
+class IPOS < Oxidized::Model
+
+ # Ericsson SSR (IPOS)
+ # Redback SE (SEOS)
+
+ prompt /^([\[\]\w.@-]+[#>]\s?)$/
+ comment '! '
+
+ cmd 'show chassis' do |cfg|
+ comment cfg.each_line.to_a[0..-2].join
+ end
+
+ cmd 'show hardware' do |cfg|
+ comment cfg.each_line.to_a[0..-2].join
+ end
+
+ cmd 'show release' do |cfg|
+ comment cfg.each_line.to_a[0..-2].join
+ end
+
+ cmd 'show configuration' do |cfg|
+ # SEOS regularly adds some odd line breaks in random places
+ # when showing the config, triggering changes.
+ cfg.gsub! "\r\n", "\n"
+
+ cfg = cfg.each_line.to_a
+
+ # Keeps the issued command commented but removes the uncommented "Building configuration..."
+ # and "Current configuration:" lines as well as the last prompt at the end.
+ cfg = cfg[4..-2].unshift comment cfg[0]
+
+ # Later IPOS releases add this line in addition to the usual "last changed" line.
+ # It's touched regularly (as often as multiple times per minute) by the OS without actual visible config changes.
+ cfg = cfg.reject { |line| line.match "Configuration last changed by system user" }
+
+ # Earlier IPOS releases lack the "changed by system user" line and instead overwrite
+ # the single "last changed by user" line. Because the line has a timestamp it will
+ # trigger constant changes if not removed. By doing so there will only be a single
+ # extra change trigged after an actual config change by a user but still have the
+ # real user.
+ cfg = cfg.reject { |line| line.match "Configuration last changed by user '%LICM%' at" }
+ cfg = cfg.reject { |line| line.match "Configuration last changed by user '<NO USER>' at" }
+ cfg = cfg.reject { |line| line.match "Configuration last changed by user '' at" }
+
+ cfg.join
+ end
+
+ cfg :telnet do
+ username /^login:/
+ password /^\r*password:/
+ end
+
+ cfg :telnet, :ssh do
+ post_login 'terminal length 0'
+ pre_logout do
+ send "exit\n"
+ send "n\n"
+ end
+ end
+
+end
diff --git a/lib/oxidized/model/ironware.rb b/lib/oxidized/model/ironware.rb
index 55b6e57..1e8c30e 100644
--- a/lib/oxidized/model/ironware.rb
+++ b/lib/oxidized/model/ironware.rb
@@ -23,6 +23,7 @@ class IronWare < Oxidized::Model
cmd 'show version' do |cfg|
cfg.gsub! /(^((.*)[Ss]ystem uptime(.*))$)/, '' #remove unwanted line system uptime
+ cfg.gsub! /(^((.*)[Tt]he system started at(.*))$)/, ''
cfg.gsub! /[Uu]p\s?[Tt]ime is .*/,''
comment cfg
diff --git a/lib/oxidized/model/mtrlrfs.rb b/lib/oxidized/model/mtrlrfs.rb
new file mode 100644
index 0000000..8baa4e9
--- /dev/null
+++ b/lib/oxidized/model/mtrlrfs.rb
@@ -0,0 +1,37 @@
+class Mtrlrfs < Oxidized::Model
+
+ # Motorola RFS/Extreme WM
+
+ comment '# '
+
+ cmd :all do |cfg|
+ # xos inserts leading \r characters and other trailing white space.
+ # this deletes extraneous \r and trailing white space.
+ cfg.each_line.to_a[1..-2].map{|line|line.delete("\r").rstrip}.join("\n") + "\n"
+ end
+
+ cmd 'show version' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show licenses' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show running-config'
+
+ cfg :telnet do
+ username /^login:/
+ password /^\r*password:/
+ end
+
+ cfg :telnet, :ssh do
+ post_login 'terminal length 0'
+ pre_logout do
+ send "exit\n"
+ send "n\n"
+ end
+ end
+
+end
+
diff --git a/lib/oxidized/model/netonix.rb b/lib/oxidized/model/netonix.rb
new file mode 100644
index 0000000..4624f83
--- /dev/null
+++ b/lib/oxidized/model/netonix.rb
@@ -0,0 +1,15 @@
+class Netonix < Oxidized::Model
+ prompt /^[\w\s.@_\/:-]+#/
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[1..-2].join
+ end
+
+ cmd 'cat config.json;echo'
+
+ cfg :ssh do
+ post_login 'cmdline'
+ pre_logout 'exit'
+ pre_logout 'exit'
+ end
+end
diff --git a/lib/oxidized/model/netscaler.rb b/lib/oxidized/model/netscaler.rb
new file mode 100644
index 0000000..9ca66b6
--- /dev/null
+++ b/lib/oxidized/model/netscaler.rb
@@ -0,0 +1,24 @@
+class NetScaler < Oxidized::Model
+
+ prompt /^\>\s*$/
+ comment '# '
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[1..-3].join
+ end
+
+ cmd 'show version' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show hardware' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show ns ns.conf'
+
+ cfg :ssh do
+ pre_logout 'exit'
+ end
+
+end
diff --git a/lib/oxidized/model/nos.rb b/lib/oxidized/model/nos.rb
index 18ca6a2..bd2cb0f 100644
--- a/lib/oxidized/model/nos.rb
+++ b/lib/oxidized/model/nos.rb
@@ -33,7 +33,7 @@ class NOS < Oxidized::Model
cfg :telnet do
username /^.* login: /
- username /^Password:/
+ password /^Password:/
end
cfg :telnet, :ssh do
diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb
index 684a4b6..392f510 100644
--- a/lib/oxidized/model/procurve.rb
+++ b/lib/oxidized/model/procurve.rb
@@ -1,36 +1,49 @@
class Procurve < Oxidized::Model
- # FIXME: this is way too unsafe
- prompt /.*?(\w+# ).*/m
+ # some models start lines with \r
+ # previous command is repeated followed by "\eE", which sometimes ends up on last line
+ prompt /^\r?([\w -]+\eE)?([\w.-]+# )$/
comment '! '
+ # replace all used vt100 control sequences
+ expect /\e\[\??\d+(;\d+)*[A-Za-z]/ do |data, re|
+ data.gsub re, ''
+ end
+
expect /Press any key to continue/ do
- send ' '
- ""
+ send ' '
+ ""
end
cmd :all do |cfg|
cfg = cfg.each_line.to_a[1..-3].join
- cfg = cfg.gsub /\r/, ''
- new_cfg = ''
- cfg.each_line do |line|
- line.sub! /^\e.*(\e.*)/, '\1' #leave last escape
- line.sub! /\e\[24;1H/, '' #remove last escape, is it always this?
- new_cfg << line
- end
- new_cfg
+ cfg = cfg.gsub /^\r/, ''
+ end
+
+ cmd :secret do |cfg|
+ cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
+ cfg.gsub! /^(snmp-server host).*/, '\\1 <configuration removed>'
+ cfg.gsub! /^(radius-server host).*/, '\\1 <configuration removed>'
+ cfg
end
cmd 'show version' do |cfg|
comment cfg
end
+ # not supported on all models
cmd 'show system-information' do |cfg|
cfg = cfg.split("\n")[0..-8].join("\n")
comment cfg
end
+ # not supported on all models
+ cmd 'show system information' do |cfg|
+ cfg = cfg.split("\n")[0..-8].join("\n")
+ comment cfg
+ end
+
cmd 'show running-config'
cfg :telnet do
diff --git a/lib/oxidized/model/supermicro.rb b/lib/oxidized/model/supermicro.rb
new file mode 100644
index 0000000..361244c
--- /dev/null
+++ b/lib/oxidized/model/supermicro.rb
@@ -0,0 +1,45 @@
+class Supermicro < Oxidized::Model
+ comment '! '
+
+ cmd :secret do |cfg|
+ cfg.gsub!(/password \d+ (\S+).*/, '<secret removed>')
+ cfg.gsub!(/community (\S+)/, 'community <hidden>')
+ cfg
+ end
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[2..-2].join
+ end
+
+ cmd 'show running-config'
+
+ cmd 'show access-list tcam-utilization' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show memory' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show system' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show version' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show watchdog' do |cfg|
+ comment cfg
+ end
+
+ cfg :telnet do
+ username /^Username:/
+ password /^Password:/
+ end
+
+ cfg :telnet, :ssh do
+ post_login 'terminal length 0'
+ pre_logout 'exit'
+ end
+end \ No newline at end of file
diff --git a/lib/oxidized/model/tmos.rb b/lib/oxidized/model/tmos.rb
index 4841b98..390046d 100644
--- a/lib/oxidized/model/tmos.rb
+++ b/lib/oxidized/model/tmos.rb
@@ -3,18 +3,20 @@ class TMOS < Oxidized::Model
comment '# '
cmd :secret do |cfg|
- cfg.gsub!(/password (\S+)/, 'password <secret removed>')
- cfg.gsub!(/passphrase (\S+)/, 'passphrase <secret removed>')
- cfg.gsub!(/community (\S+)/, 'community <secret removed>')
- cfg.gsub!(/community-name (\S+)/, 'community-name <secret removed>')
+ cfg.gsub!(/^([\s\t]*)secret \S+/, '\1secret <secret removed>')
+ cfg.gsub!(/^([\s\t]*\S*)password \S+/, '\1password <secret removed>')
+ cfg.gsub!(/^([\s\t]*\S*)passphrase \S+/, '\1passphrase <secret removed>')
+ cfg.gsub!(/community \S+/, 'community <secret removed>')
+ cfg.gsub!(/community-name \S+/, 'community-name <secret removed>')
+ cfg.gsub!(/^([\s\t]*\S*)encrypted \S+$/, '\1encrypted <secret removed>')
cfg
end
- cmd('tmsh show sys version') { |cfg| comment cfg }
+ cmd('tmsh -q show sys version') { |cfg| comment cfg }
- cmd('tmsh show sys software') { |cfg| comment cfg }
+ cmd('tmsh -q show sys software') { |cfg| comment cfg }
- cmd 'tmsh show sys hardware field-fmt' do |cfg|
+ cmd 'tmsh -q show sys hardware field-fmt' do |cfg|
cfg.gsub!(/fan-speed (\S+)/, '')
cfg.gsub!(/temperature (\S+)/, '')
comment cfg
@@ -22,25 +24,27 @@ class TMOS < Oxidized::Model
cmd('cat /config/bigip.license') { |cfg| comment cfg }
- cmd 'tmsh list' do |cfg|
- cfg.gsub!(/state (up|down)/, '')
+ cmd 'tmsh -q list' do |cfg|
+ cfg.gsub!(/state (up|down|checking|irule-down)/, '')
cfg.gsub!(/errors (\d+)/, '')
cfg
end
- cmd('tmsh list net route all') { |cfg| comment cfg }
+ cmd('tmsh -q list net route all') { |cfg| comment cfg }
cmd('/bin/ls --full-time --color=never /config/ssl/ssl.crt') { |cfg| comment cfg }
cmd('/bin/ls --full-time --color=never /config/ssl/ssl.key') { |cfg| comment cfg }
- cmd 'tmsh show running-config sys db all-properties' do |cfg|
+ cmd 'tmsh -q show running-config sys db all-properties' do |cfg|
cfg.gsub!(/sys db configsync.localconfigtime {[^}]+}/m, '')
cfg.gsub!(/sys db gtm.configtime {[^}]+}/m, '')
cfg.gsub!(/sys db ltm.configtime {[^}]+}/m, '')
comment cfg
end
+ cmd('cat /config/partitions/*/bigip.conf') { |cfg| comment cfg }
+
cfg :ssh do
exec true # don't run shell, run each command in exec channel
end
diff --git a/lib/oxidized/model/xos.rb b/lib/oxidized/model/xos.rb
index de8ec39..6f1323f 100644
--- a/lib/oxidized/model/xos.rb
+++ b/lib/oxidized/model/xos.rb
@@ -36,8 +36,10 @@ class XOS < Oxidized::Model
cfg :telnet, :ssh do
post_login 'disable clipaging'
- pre_logout 'exit'
- pre_logout 'n'
+ pre_logout do
+ send "exit\n"
+ send "n\n"
+ end
end
end