Age | Commit message (Collapse) | Author |
|
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.
|
|
We needed this, because use of 'def inherited' not idempotent, in
Oxidized::Script use case we may need to restart Oxidized, even though
it's already loaded, and we won't get class names populated via 'def
inherited' anymore.
There are quite many optiosn to do this
a) filename == class name
+ no discovery/mapping, very clean
- user 'source' must give us model name in exactly right
capitalization
b) add 'self' at end of files, so eval will return class name
+ deterministic with arbitrary name
- DSL cruft, DSL being light is our main value
(can we do this via parent class? I couldn't find way)
c) load in new module via Module.module_eval X
+ module will contain only consts we just created
- but which one is the one we want?
- if we use eval, load errors won't tell line error
But at least now we got rid of 'inherited' methods and not adding too
much cruft, hope it's better than before.
|
|
Main benefits
a) we get support for system wide configs
b) we don't use symbols in config file, they're confusing to
non-rubyist
|
|
Silly for shit-and-giggles attempt at rancid
|