summaryrefslogtreecommitdiff
path: root/lib/oxidized/output/output.rb
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2014-08-07 13:27:03 +0300
committerSaku Ytti <saku@ytti.fi>2014-08-07 13:27:03 +0300
commit2a77796a7caf10601ae8edea5bf996f951694985 (patch)
treee38454fe9e78f16231049ed8c44365b7ea476244 /lib/oxidized/output/output.rb
parentbf299889f54b468412df4822b515cf7c4d60f90d (diff)
Pass model config as Outputs object instead of str
These objects have some keys, such as 'type' and 'name', which allows our output model to discriminate on them. If ios.rb contains this: cmd 'show ip cef' do |out| { output: out, type: 'poop' } end cmd 'show process cpu' do |out| { output: out, type: 'poop' } end cmd 'show memory statistics' do |out| { output: out, type: 'poop' } end Our git output looks like this: [ytti@ytti.fi ~/.config/oxidized]% git clone oxidized.git Cloning into 'oxidized'... done. [ytti@ytti.fi ~/.config/oxidized]% git clone poop.git Cloning into 'poop'... done. [ytti@ytti.fi ~/.config/oxidized]% ls poop bu.ip.fi--show_ip_cef bu.ip.fi--show_memory_statistics bu.ip.fi--show_process_cpu [ytti@ytti.fi ~/.config/oxidized]% ls oxidized bu.ip.fi [ytti@ytti.fi ~/.config/oxidized]% Where oxidized repo contains standard config for all unspecified types (type is then 'cfg'), for all specified types instead of collapsing it into single string, we store them in 'type' repo with filename including 'name' of the command.
Diffstat (limited to 'lib/oxidized/output/output.rb')
-rw-r--r--lib/oxidized/output/output.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/oxidized/output/output.rb b/lib/oxidized/output/output.rb
index eaf149a..1355d03 100644
--- a/lib/oxidized/output/output.rb
+++ b/lib/oxidized/output/output.rb
@@ -1,5 +1,10 @@
module Oxidized
class Output
class NoConfig < OxidizedError; end
+
+ def cfg_to_str cfg
+ cfg.select{ |h| h[:type]=='cfg' }.map{ |h| h[:data] }.join
+ end
+
end
end