summaryrefslogtreecommitdiff
path: root/lib/oxidized/output/file.rb
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2014-08-08 09:38:25 +0300
committerSaku Ytti <saku@ytti.fi>2014-08-08 09:38:25 +0300
commit9d258c9e17a1b200060424cdaccb0355f757f124 (patch)
treec407e2b9fa0ab01002709f912abe071137927117 /lib/oxidized/output/file.rb
parent7aa9299971a2cacad29ab86e82cc780354d659e0 (diff)
refactor cfg as object
- now default type is 'nil', which is collapsed to flat config via Outputs#to_cfg - if type is not 'nil' then name is automatically set if not set by model - if name and type is set, separate file is created - if name is not set, but type is set, outputs from type are collapsed as with 'nil' types This model: cmd 'show ip cef' do |out| out.type = 'poop' out.name = false out end cmd 'show process cpu' do |out| out.type = 'poop' out.name = 'my_cpu' out end cmd 'show memory statistics' do |out| out.type = 'poop' out.name = false out end cmd 'show ip bgp summary' do |out| out.type = 'poop' end Would produce git output: [ytti@ytti.fi ~/.config/oxidized]% ls poop bu.ip.fi bu.ip.fi--cpu bu.ip.fi--show_ip_bgp_summary [ytti@ytti.fi ~/.config/oxidized]% bu.ip.fi contains the collapsed stuff bu.ip.fi--cpu is manually named bu.ip.fi--show_ip_bgp_summary is automatically named
Diffstat (limited to 'lib/oxidized/output/file.rb')
-rw-r--r--lib/oxidized/output/file.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/oxidized/output/file.rb b/lib/oxidized/output/file.rb
index 2d08106..03c878a 100644
--- a/lib/oxidized/output/file.rb
+++ b/lib/oxidized/output/file.rb
@@ -14,14 +14,14 @@ class OxidizedFile < Output
end
end
- def store node, data, opt={}
+ def store node, outputs, opt={}
file = @cfg.directory
if opt[:group]
file = File.join File.dirname(file), opt[:group]
end
FileUtils.mkdir_p file
file = File.join file, node
- open(file, 'w') { |fh| fh.write data }
+ open(file, 'w') { |fh| fh.write outputs.to_cfg }
end
def fetch node, group