summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorytti <saku@ytti.fi>2018-05-07 23:34:50 +0300
committerGitHub <noreply@github.com>2018-05-07 23:34:50 +0300
commit4f7ccac68649d6505ba7bb287799c964ae848664 (patch)
treee72bc729bdb248dc885af56b3deac19260e893f8
parent65ac41fe761903f72e6e1ab642a33a8c13abf483 (diff)
parent42d7ca19b5615e0ef9e4f1290e6bfeebce760a01 (diff)
Merge pull request #1334 from gs-kamnas/nxos-refactor
Fix debug mode, properly comment NX-OS configs and normalize their line endings.
-rwxr-xr-xbin/oxidized2
-rw-r--r--lib/oxidized/model/nxos.rb10
2 files changed, 11 insertions, 1 deletions
diff --git a/bin/oxidized b/bin/oxidized
index 92730ee..1152833 100755
--- a/bin/oxidized
+++ b/bin/oxidized
@@ -8,6 +8,6 @@ begin
Oxidized::CLI.new.run
rescue => error
warn "#{error}"
- debug = Oxidied.config.debug rescue true
+ debug = Oxidized.config.debug rescue true
raise if debug
end
diff --git a/lib/oxidized/model/nxos.rb b/lib/oxidized/model/nxos.rb
index d1449dd..ec1f807 100644
--- a/lib/oxidized/model/nxos.rb
+++ b/lib/oxidized/model/nxos.rb
@@ -2,6 +2,11 @@ class NXOS < Oxidized::Model
prompt /^(\r?[\w.@_()-]+[#]\s?)$/
comment '! '
+ def filter cfg
+ cfg.gsub! /\r\n?/, "\n"
+ cfg.gsub! prompt, ''
+ end
+
cmd :secret do |cfg|
cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
cfg.gsub! /^(snmp-server user (\S+) (\S+) auth (\S+)) (\S+) (priv) (\S+)/, '\\1 <configuration removed> '
@@ -11,16 +16,21 @@ class NXOS < Oxidized::Model
end
cmd 'show version' do |cfg|
+ cfg = filter cfg
cfg = cfg.each_line.take_while { |line| not line.match(/uptime/i) }
comment cfg.join ""
end
cmd 'show inventory' do |cfg|
+ cfg = filter cfg
comment cfg
end
cmd 'show running-config' do |cfg|
+ cfg = filter cfg
+ cfg.gsub! /^(show run.*)$/, '! \1'
cfg.gsub! /^!Time:[^\n]*\n/, ''
+ cfg.gsub! /^[\w.@_()-]+[#].*$/, ''
cfg
end