diff options
author | Saku Ytti <saku@ytti.fi> | 2014-08-08 09:38:25 +0300 |
---|---|---|
committer | Saku Ytti <saku@ytti.fi> | 2014-08-08 09:38:25 +0300 |
commit | 9d258c9e17a1b200060424cdaccb0355f757f124 (patch) | |
tree | c407e2b9fa0ab01002709f912abe071137927117 /lib/oxidized/model | |
parent | 7aa9299971a2cacad29ab86e82cc780354d659e0 (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/model')
-rw-r--r-- | lib/oxidized/model/model.rb | 2 | ||||
-rw-r--r-- | lib/oxidized/model/outputs.rb | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/oxidized/model/model.rb b/lib/oxidized/model/model.rb index 3dd3f98..7258912 100644 --- a/lib/oxidized/model/model.rb +++ b/lib/oxidized/model/model.rb @@ -155,7 +155,7 @@ module Oxidized if output.class != Oxidized::String output = Oxidized::String.new output end - output.cmd = name + output.set_cmd(name) output end diff --git a/lib/oxidized/model/outputs.rb b/lib/oxidized/model/outputs.rb index 406f886..10015f8 100644 --- a/lib/oxidized/model/outputs.rb +++ b/lib/oxidized/model/outputs.rb @@ -3,7 +3,7 @@ module Oxidized class Outputs def to_cfg - type_to_str('cfg') + type_to_str(nil) end def type_to_str want_type @@ -23,7 +23,7 @@ module Oxidized end def types - @outputs.map { |out| out.type }.uniq - ['cfg'] + @outputs.map { |out| out.type }.uniq.compact end private |