summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorytti <saku@ytti.fi>2017-07-02 12:58:54 +0300
committerGitHub <noreply@github.com>2017-07-02 12:58:54 +0300
commit449d3bf9f4950c0f8f2fc7304389793cc0608e2e (patch)
tree0c39f49a7f4a58d31f5b3aefaf38489375fc30e6 /lib
parent2aa2a03ab794c6a04ddfa0b38ba3d82798c85533 (diff)
parent0dcc9a0215f7ee3e10f864c04dcc09c4b0050aeb (diff)
Merge pull request #907 from spinza/routeros-hide-sensitive
RouterOS: Use `/export hide-sensitive` when `remove_secret` is set in Oxidized
Diffstat (limited to 'lib')
-rw-r--r--lib/oxidized/model/routeros.rb13
1 files changed, 8 insertions, 5 deletions
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