summaryrefslogtreecommitdiff
path: root/lib/oxidized/model/asa.rb
diff options
context:
space:
mode:
authorNeil Lathwood <neil@lathwood.co.uk>2018-04-27 11:38:06 +0100
committerNeil Lathwood <neil@lathwood.co.uk>2018-04-27 11:38:06 +0100
commitb1194745929043b578c409f794ecb433aa515fa9 (patch)
tree133e7103073b707aaca855eb3df4d5025bebae06 /lib/oxidized/model/asa.rb
parent9156243b9debfc0bc2b05dfe98a910ce5153bf49 (diff)
parent34fd5369feee94ab45c5a81d7769b1df717e4c8c (diff)
Rebased and fixed conflicts
Diffstat (limited to 'lib/oxidized/model/asa.rb')
-rw-r--r--lib/oxidized/model/asa.rb68
1 files changed, 33 insertions, 35 deletions
diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb
index 9df4206..dfd94b1 100644
--- a/lib/oxidized/model/asa.rb
+++ b/lib/oxidized/model/asa.rb
@@ -1,5 +1,4 @@
class ASA < Oxidized::Model
-
# Cisco ASA model #
# Only SSH supported for the sake of security
@@ -27,7 +26,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+)|(.*days.*)/ }
+ cfg = cfg.each_line.reject { |line| line.match /(\s+up\s+\d+\s+)|(.*days.*)/ }
cfg = cfg.join
comment cfg
end
@@ -54,48 +53,47 @@ 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
+ # 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
- # 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
+ # 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
- cfg
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
+ # 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
- cfg = allcfg
end
- cfg
+ cfg = allcfg
end
+ cfg
+ end
end
-
end