summaryrefslogtreecommitdiff
path: root/lib/oxidized/model
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/model')
-rw-r--r--lib/oxidized/model/acos.rb37
-rw-r--r--lib/oxidized/model/asa.rb19
-rw-r--r--lib/oxidized/model/catos.rb36
-rw-r--r--lib/oxidized/model/comware.rb2
-rw-r--r--lib/oxidized/model/edgeswitch.rb12
-rw-r--r--lib/oxidized/model/firewareos.rb24
-rw-r--r--lib/oxidized/model/iosxr.rb2
-rw-r--r--lib/oxidized/model/ironware.rb1
-rw-r--r--lib/oxidized/model/mlnxos.rb43
-rw-r--r--lib/oxidized/model/model.rb3
-rw-r--r--lib/oxidized/model/mtrlrfs.rb2
-rw-r--r--lib/oxidized/model/netonix.rb15
-rw-r--r--lib/oxidized/model/nos.rb4
-rw-r--r--lib/oxidized/model/panos.rb9
-rw-r--r--lib/oxidized/model/procurve.rb5
-rw-r--r--lib/oxidized/model/quantaos.rb35
-rw-r--r--lib/oxidized/model/tmos.rb16
17 files changed, 237 insertions, 28 deletions
diff --git a/lib/oxidized/model/acos.rb b/lib/oxidized/model/acos.rb
index 75fbacf..bb9846e 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 '! '
@@ -7,6 +7,14 @@ class ACOS < Oxidized::Model
prompt /^([-\w.\/:?\[\]\(\)]+[#>]\s?)$/
cmd 'show version' do |cfg|
+ cfg.gsub! /\s(Last configuration saved at).*/, ' \\1 <removed>'
+ cfg.gsub! /\s(Memory).*/, ' \\1 <removed>'
+ cfg.gsub! /\s(Current time is).*/, ' \\1 <removed>'
+ cfg.gsub! /\s(The system has been up).*/, ' \\1 <removed>'
+ comment cfg
+ end
+
+ cmd 'show bootimage' do |cfg|
comment cfg
end
@@ -14,13 +22,22 @@ class ACOS < Oxidized::Model
comment cfg
end
- cmd 'show running-config all-partitions'
+ cmd 'show running-config all-partitions' do |cfg|
+ cfg.gsub! /(Current configuration).*/, '\\1 <removed>'
+ cfg.gsub! /(Configuration last updated at).*/, '\\1 <removed>'
+ cfg.gsub! /(Configuration last saved at).*/, '\\1 <removed>'
+ cfg.gsub! /(Configuration last synchronized at).*/, '\\1 <removed>'
+ end
+
+ 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 +69,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..1e45a91 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,21 @@ 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)
+ end
+ end
cfg
end
@@ -37,7 +52,7 @@ class ASA < Oxidized::Model
if vars :enable
post_login do
send "enable\n"
- send vars(:enable) + "\n"
+ cmd vars(:enable)
end
end
post_login 'terminal pager 0'
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/edgeswitch.rb b/lib/oxidized/model/edgeswitch.rb
index cb921b8..7c82639 100644
--- a/lib/oxidized/model/edgeswitch.rb
+++ b/lib/oxidized/model/edgeswitch.rb
@@ -16,9 +16,17 @@ class EdgeSwitch < Oxidized::Model
end
cfg :telnet, :ssh do
- post_login 'enable'
- post_login 'terminal length 0'
+ 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
diff --git a/lib/oxidized/model/firewareos.rb b/lib/oxidized/model/firewareos.rb
new file mode 100644
index 0000000..f2bef4c
--- /dev/null
+++ b/lib/oxidized/model/firewareos.rb
@@ -0,0 +1,24 @@
+class FirewareOS < Oxidized::Model
+
+ prompt /^\[?\w*\]?\w*<?\w*>?#\s*$/
+ comment '-- '
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[1..-2].join
+ end
+
+ cmd 'show sysinfo' do |cfg|
+ # avoid commits due to uptime
+ cfg = cfg.each_line.select { |line| not line.match /(.*time.*)|(.*memory.*)|(.*cpu.*)/ }
+ cfg = cfg.join
+ comment cfg
+ end
+
+ cmd 'export config to console'
+
+ cfg :ssh do
+ pre_logout 'exit'
+ end
+
+end
+
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/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/mlnxos.rb b/lib/oxidized/model/mlnxos.rb
new file mode 100644
index 0000000..9542c88
--- /dev/null
+++ b/lib/oxidized/model/mlnxos.rb
@@ -0,0 +1,43 @@
+class MLNXOS < Oxidized::Model
+
+ prompt /([\w.@()-\[:\s\]]+[#>]\s)$/
+ 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 = 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 'show version' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show inventory' do |cfg|
+ comment cfg
+ end
+
+ cmd 'enable'
+
+ cmd 'show running-config' do |cfg|
+ cfg
+ end
+
+ cfg :ssh do
+ password /^Password:\s*/
+ pre_logout 'exit'
+ end
+end
diff --git a/lib/oxidized/model/model.rb b/lib/oxidized/model/model.rb
index 9185d43..4a15a45 100644
--- a/lib/oxidized/model/model.rb
+++ b/lib/oxidized/model/model.rb
@@ -35,6 +35,7 @@ module Oxidized
else
@cmd[:cmd] << [_cmd, block]
end
+ Oxidized.logger.debug "lib/oxidized/model/model.rb Added #{_cmd} to the commands list"
end
def cmds
@cmd
@@ -79,6 +80,7 @@ module Oxidized
attr_accessor :input, :node
def cmd string, &block
+ Oxidized.logger.debug "lib/oxidized/model/model.rb Executing #{string}"
out = @input.cmd(string)
return false unless out
self.class.cmds[:all].each do |all_block|
@@ -127,6 +129,7 @@ module Oxidized
end
def get
+ Oxidized.logger.debug 'lib/oxidized/model/model.rb Collecting commands\' outputs'
outputs = Outputs.new
procs = self.class.procs
self.class.cmds[:cmd].each do |command, block|
diff --git a/lib/oxidized/model/mtrlrfs.rb b/lib/oxidized/model/mtrlrfs.rb
index 84bcfe1..8baa4e9 100644
--- a/lib/oxidized/model/mtrlrfs.rb
+++ b/lib/oxidized/model/mtrlrfs.rb
@@ -1,4 +1,4 @@
-class mtrlrfs < Oxidized::Model
+class Mtrlrfs < Oxidized::Model
# Motorola RFS/Extreme WM
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/nos.rb b/lib/oxidized/model/nos.rb
index bd2cb0f..ec7c818 100644
--- a/lib/oxidized/model/nos.rb
+++ b/lib/oxidized/model/nos.rb
@@ -22,14 +22,14 @@ class NOS < Oxidized::Model
end
cmd 'show chassis' do |cfg|
- comment cfg.each_line.reject { |line| line.match /Time/ }.join
+ comment cfg.each_line.reject { |line| line.match /Time/ or line.match /Update/ }.join
end
cfg 'show system' do |cfg|
comment cfg.each_line.reject { |line| line.match /Time/ or line.match /speed/ }
end
- cmd 'show running-config'
+ cmd 'show running-config | nomore'
cfg :telnet do
username /^.* login: /
diff --git a/lib/oxidized/model/panos.rb b/lib/oxidized/model/panos.rb
index 35624b7..68d80c3 100644
--- a/lib/oxidized/model/panos.rb
+++ b/lib/oxidized/model/panos.rb
@@ -11,7 +11,14 @@ class PanOS < Oxidized::Model
end
cmd 'show system info' do |cfg|
- cfg.gsub! /^(up)?time:\ .*\n/, ''
+ cfg.gsub! /^(up)?time:\ .*$/, ''
+ cfg.gsub! /^app-.*?:\ .*$/, ''
+ cfg.gsub! /^av-.*?:\ .*$/, ''
+ cfg.gsub! /^threat-.*?:\ .*$/, ''
+ cfg.gsub! /^wildfire-.*?:\ .*$/, ''
+ cfg.gsub! /^wf-private.*?:\ .*$/, ''
+ cfg.gsub! /^url-filtering.*?:\ .*$/, ''
+ cfg.gsub! /^global-.*?:\ .*$/, ''
comment cfg
end
diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb
index e667f48..0dc6f8f 100644
--- a/lib/oxidized/model/procurve.rb
+++ b/lib/oxidized/model/procurve.rb
@@ -2,7 +2,7 @@ class Procurve < Oxidized::Model
# 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-]+# )$/
+ prompt /^\r?([\w -]+\eE)?([\w.-]+# )$/
comment '! '
@@ -40,7 +40,8 @@ class Procurve < Oxidized::Model
# not supported on all models
cmd 'show system information' do |cfg|
- cfg = cfg.split("\n")[0..-8].join("\n")
+ cfg = cfg.each_line.select { |line| not line.match /(.*CPU.*)|(.*Up Time.*)|(.*Total.*)|(.*Free.*)|(.*Lowest.*)|(.*Missed.*)/ }
+ cfg = cfg.join
comment cfg
end
diff --git a/lib/oxidized/model/quantaos.rb b/lib/oxidized/model/quantaos.rb
new file mode 100644
index 0000000..274440d
--- /dev/null
+++ b/lib/oxidized/model/quantaos.rb
@@ -0,0 +1,35 @@
+class QuantaOS < Oxidized::Model
+
+ prompt /^\((\w|\S)+\) (>|#)$/
+ comment '! '
+
+ cmd 'show run' do |cfg|
+ cfg.each_line.select do |line|
+ not line.match /^!.*$/ and
+ not line.match /^\((\w|\S)+\) (>|#)$/ and
+ not line.match /^show run$/
+ end.join
+ end
+
+ cfg :telnet do
+ username /^Username:/
+ password /^Password:/
+ end
+
+ cfg :telnet, :ssh do
+ post_login do
+ send "enable\n"
+ if vars :enable
+ cmd vars(:enable)
+ else
+ cmd ""
+ end
+ end
+ post_login 'terminal length 0'
+ pre_logout do
+ send "quit\n"
+ send "n\n"
+ end
+ end
+
+end
diff --git a/lib/oxidized/model/tmos.rb b/lib/oxidized/model/tmos.rb
index abaec9f..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