summaryrefslogtreecommitdiff
path: root/lib/oxidized/model
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/model')
-rw-r--r--lib/oxidized/model/asa.rb71
-rw-r--r--lib/oxidized/model/audiocodes.rb32
-rw-r--r--lib/oxidized/model/ciscosma.rb45
-rw-r--r--lib/oxidized/model/dlink.rb1
-rw-r--r--lib/oxidized/model/ironware.rb3
-rw-r--r--lib/oxidized/model/panos.rb2
-rw-r--r--lib/oxidized/model/planet.rb3
-rw-r--r--lib/oxidized/model/procurve.rb13
-rw-r--r--lib/oxidized/model/routeros.rb13
-rw-r--r--lib/oxidized/model/voss.rb16
10 files changed, 169 insertions, 30 deletions
diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb
index 038dd6b..9df4206 100644
--- a/lib/oxidized/model/asa.rb
+++ b/lib/oxidized/model/asa.rb
@@ -20,6 +20,11 @@ class ASA < Oxidized::Model
cfg
end
+ # check for multiple contexts
+ cmd 'show mode' do |cfg|
+ @is_multiple_context = cfg.include? 'multiple'
+ end
+
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+)|(.*days.*)/ }
@@ -31,25 +36,12 @@ class ASA < Oxidized::Model
comment cfg
end
- 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
+ post do
+ if @is_multiple_context
+ multiple_context
+ else
+ single_context
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
cfg :ssh do
@@ -62,5 +54,48 @@ class ASA < Oxidized::Model
post_login 'terminal pager 0'
pre_logout 'exit'
end
+
+ def single_context
+ # Single context mode
+ 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
+ end
+
+ def multiple_context
+ # Multiple context mode
+ cmd 'changeto system' do |cfg|
+ cmd 'show running-config' do |systemcfg|
+ allcfg = "\n\n" + systemcfg + "\n\n"
+ contexts = systemcfg.scan(/^context (\S+)$/)
+ files = systemcfg.scan(/config-url (\S+)$/)
+ contexts.each_with_index do |cont, i|
+ allcfg = allcfg + "\n\n----------========== [ CONTEXT " + cont.join(" ") + " FILE " + files[i].join(" ") + " ] ==========----------\n\n"
+ cmd "more " + files[i].join(" ") do |cfgcontext|
+ allcfg = allcfg + "\n\n" + cfgcontext
+ end
+ end
+ cfg = allcfg
+ end
+ cfg
+ end
+ end
end
diff --git a/lib/oxidized/model/audiocodes.rb b/lib/oxidized/model/audiocodes.rb
new file mode 100644
index 0000000..b7ee70e
--- /dev/null
+++ b/lib/oxidized/model/audiocodes.rb
@@ -0,0 +1,32 @@
+class AudioCodes < Oxidized::Model
+
+# Pull config from AudioCodes Mediant devices from version > 7.0
+
+ prompt /^\r?([\w.@() -]+[#>]\s?)$/
+ comment '## '
+
+ expect /\s*--MORE--$/ do |data, re|
+
+ send ' '
+
+ data.sub re, ''
+
+ end
+
+ cmd 'show running-config' do |cfg|
+ cfg
+ end
+
+ cfg :ssh do
+ username /^login as:\s$/
+ password /^.+password:\s$/
+ pre_logout 'exit'
+ end
+
+ cfg :telnet do
+ username /^Username:\s$/
+ password /^Password:\s$/
+ pre_logout 'exit'
+ end
+
+end
diff --git a/lib/oxidized/model/ciscosma.rb b/lib/oxidized/model/ciscosma.rb
new file mode 100644
index 0000000..a52e38a
--- /dev/null
+++ b/lib/oxidized/model/ciscosma.rb
@@ -0,0 +1,45 @@
+class CiscoSMA < Oxidized::Model
+
+ # SMA prompt "mail.example.com> "
+ prompt /^\r*([-\w. ]+\.[-\w. ]+\.[-\w. ]+[#>]\s+)$/
+ comment '! '
+
+ # Select passphrase display option
+ expect /using loadconfig command\. \[Y\]\>/ do |data, re|
+ send "y\n"
+ data.sub re, ''
+ end
+
+ # handle paging
+ expect /-Press Any Key For More-+.*$/ do |data, re|
+ send " "
+ data.sub re, ''
+ end
+
+ cmd 'version' do |cfg|
+ comment cfg
+ end
+
+ cmd 'showconfig' do |cfg|
+ #Delete hour and date which change each run
+ #cfg.gsub! /\sCurrent Time: \S+\s\S+\s+\S+\s\S+\s\S+/, ' Current Time:'
+ # Delete select passphrase display option
+ cfg.gsub! /Do you want to mask the password\? Files with masked passwords cannot be loaded/, ''
+ cfg.gsub! /^\s+y/, ''
+ # Delete space
+ cfg.gsub! /\n\s{25}/, ''
+ # Delete after line
+ cfg.gsub! /([\/\-,.\w><@]+)(\s{27})/,"\\1"
+ # Add a carriage return
+ cfg.gsub! /([\/\-,.\w><@]+)(\s{6,8})([\/\-,.\w><@]+)/,"\\1\n\\2\\3"
+ # Delete prompt
+ cfg.gsub! /^\r*([-\w. ]+\.[-\w. ]+\.[-\w. ]+[#>]\s+)$/, ''
+ cfg
+
+ end
+
+ cfg :ssh do
+ pre_logout "exit"
+ end
+
+end
diff --git a/lib/oxidized/model/dlink.rb b/lib/oxidized/model/dlink.rb
index 5756bad..0d08793 100644
--- a/lib/oxidized/model/dlink.rb
+++ b/lib/oxidized/model/dlink.rb
@@ -15,6 +15,7 @@ class Dlink < Oxidized::Model
end
cmd 'show switch' do |cfg|
+ cfg.gsub! /^System\ Uptime\s.+/, '' # Omit constantly changing uptime info
comment cfg
end
diff --git a/lib/oxidized/model/ironware.rb b/lib/oxidized/model/ironware.rb
index 9715c65..3ab8da1 100644
--- a/lib/oxidized/model/ironware.rb
+++ b/lib/oxidized/model/ironware.rb
@@ -34,6 +34,8 @@ class IronWare < Oxidized::Model
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! /Fan \d* - STATUS: OK \D*\d*./, '' # Fix for ADX Fan speed reporting
+ cfg.gsub! /\d* deg C/, '' # Fix for ADX temperature reporting
cfg.gsub! /([\[]*)1([\]]*)<->([\[]*)2([\]]*)(<->([\[]*)3([\]]*))*/, ''
cfg.gsub! /\d{2}\.\d deg-C/, 'XX.X deg-C'
if cfg.include? "TEMPERATURE"
@@ -50,6 +52,7 @@ class IronWare < Oxidized::Model
end
cmd 'show flash' do |cfg|
+ cfg.gsub! /(\d+) bytes/, '' # Fix for ADX flash size
comment cfg
end
diff --git a/lib/oxidized/model/panos.rb b/lib/oxidized/model/panos.rb
index 68d80c3..67ccaec 100644
--- a/lib/oxidized/model/panos.rb
+++ b/lib/oxidized/model/panos.rb
@@ -28,6 +28,6 @@ class PanOS < Oxidized::Model
cfg :ssh do
post_login 'set cli pager off'
- pre_logout 'exit'
+ pre_logout 'quit'
end
end
diff --git a/lib/oxidized/model/planet.rb b/lib/oxidized/model/planet.rb
index 05a369a..9ce9cf9 100644
--- a/lib/oxidized/model/planet.rb
+++ b/lib/oxidized/model/planet.rb
@@ -39,9 +39,10 @@ class Planet < Oxidized::Model
cfg = cfg.each_line.to_a[0...-2]
- # Strip system time and system uptime from planet gs switches
+ # Strip system (up)time and temperature
cfg = cfg.reject { |line| line.match /System Time\s*:.*/ }
cfg = cfg.reject { |line| line.match /System Uptime\s*:.*/ }
+ cfg = cfg.reject { |line| line.match /Temperature\s*:.*/ }
comment cfg.join
end
diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb
index 7dcf1fd..180b703 100644
--- a/lib/oxidized/model/procurve.rb
+++ b/lib/oxidized/model/procurve.rb
@@ -30,6 +30,7 @@ class Procurve < Oxidized::Model
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.gsub! /^(radius-server key).*/, '\\1 <configuration removed>'
cfg
end
@@ -37,6 +38,18 @@ class Procurve < Oxidized::Model
comment cfg
end
+ cmd 'show modules' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show interfaces transceiver' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show flash' do |cfg|
+ comment cfg
+ end
+
# not supported on all models
cmd 'show system-information' do |cfg|
cfg = cfg.split("\n")[0..-8].join("\n")
diff --git a/lib/oxidized/model/routeros.rb b/lib/oxidized/model/routeros.rb
index 31650c7..f391fb9 100644
--- a/lib/oxidized/model/routeros.rb
+++ b/lib/oxidized/model/routeros.rb
@@ -14,11 +14,14 @@ class RouterOS < Oxidized::Model
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
- cfg = cfg.split("\n").select { |line| not line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] }
- cfg.join("\n") + "\n"
+ post do
+ run_cmd = vars(:remove_secret) ? '/export hide-sensitive' : '/export'
+ 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 = cfg.split("\n").select { |line| not line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] }
+ cfg.join("\n") + "\n"
+ end
end
cfg :telnet do
diff --git a/lib/oxidized/model/voss.rb b/lib/oxidized/model/voss.rb
index 599462a..6b15fb3 100644
--- a/lib/oxidized/model/voss.rb
+++ b/lib/oxidized/model/voss.rb
@@ -1,7 +1,7 @@
class Voss < Oxidized::Model
# Avaya VSP Operating System Software(VOSS)
# Created by danielcoxman@gmail.com
- # May 15, 2017
+ # May 25, 2017
# This was tested on vsp4k and vsp8k
comment '# '
@@ -10,10 +10,16 @@ class Voss < Oxidized::Model
# 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" }
+
+ # Get sys-info and remove information that changes such has temperature and power
+ cmd 'show sys-info' do |cfg|
+ cfg.gsub! /(^((.*)SysUpTime(.*))$)/, 'removed SysUpTime'
+ cfg.gsub! /^((.*)Temperature Info \:(.*\r?\n){4})/, 'removed Temperature Info and 3 more lines'
+ cfg.gsub! /(^((.*)AmbientTemperature(.*)\:(.*))$)/, 'removed AmbientTemperature'
+ cfg.gsub! /(^((.*)Temperature(.*)\:(.*))$)/, 'removed Temperature'
+ cfg.gsub! /(^((.*)Total Power Usage(.*)\:(.*))$)/, 'removed Total Power Usage'
+ comment "#{cfg}\n"
+ end
# more the config rather than doing a show run
cmd 'more config.cfg' do |cfg|