summaryrefslogtreecommitdiff
path: root/lib/oxidized/manager.rb
AgeCommit message (Collapse)Author
2018-06-07Refactor manager, take2Saku Ytti
Make all the add_* return falsy valuem and make all the callers raise, this has benefit that the caller has more information, like it can tell what node we were trying to load when model failed to load. We were only failing to do this in two places in the code, source and plugin.
2018-06-07oops, actually add the class to sourceSaku Ytti
2018-06-07Fix local file loadingSaku Ytti
Local files could never be loaded, as the name does not contain file extension, so check for their existance would always fail.
2018-06-07Refactor managerSaku Ytti
Main problem we're trying to solve is the silent failures. Requiring files will never fail, one user had problem loading their souce http.rb, which is obviously mandatory for them, but because it didn't fail, it lead to a much harder to understand bug down the line, as we tried to instansiate the 'nil' source. Reason why I did it like this was laziness, because I didn't have to care if or not the file exists, I always tried to load locally defined models, and just return empty hash if I couldn't find any. There may be other reasons and reliances that I've forgotten, but we'll fix them as they come. Such is life without proper testing.
2018-04-21the great makeover - standardize layout, alignment, indentationWild Kat
2018-04-11standardize on verbose hash methodsWild Kat
2015-08-28Initial implementation of the hook featureAnton Aksola
The current implementation is modular and allows users to define hooks in several ways: * Use one of the built-in hook types (currently only 'exec') * Define their own Hook classes inside ~/.config/oxidized/hook Exec hook type runs a user defined command with or without shell. It populates a bunch of environment variables with metadata. The command can either be run as synchronous or asynchronous. The default is synchronous.
2014-07-11support local modelsSaku Ytti
if ~/.config/oxidized/model/ios.rb exists it is used, iinstead of the system-wide model
2014-07-03Fix class name resolutionSaku Ytti
In new method, where we no long explicitly set loaded class name for later resolution we depend on file name being same as class name. However for File output, this is not true, because I didn't want plain File in code to resolve to Oxidized::File, and din't want to always write ::File, File ouput has class name OxFile. This change allows class names to start optionally with string 'Oxidized' if so, they still match.
2014-06-11Fix dynamic loading matchSaku Ytti
We can't use #match, if IOSXR is seen in source list before IOS, then IOS will #match on IOSXR class and wrong model is used for IOS devices. And obviously stupid to use regexp if you don't atbsolutely have to.
2014-06-11Change dynamic discover of file => class nameSaku Ytti
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.
2014-03-02Change dynamic loadingSaku Ytti
If we use assignment method (#method=) we don't get return value, so we never know that manager fails to load. Also we do not want to rescue failures of input/output/source loading, they are catastrophic and should fail whole process, loading of model is not catastrophic.
2014-02-23Migrate to sinatra/puma from webrickSaku Ytti
As I can't do IO#select on sinatra/puma to run it when I have time, I have to run it on separate thread. This means Nodes container needs to be thread safe, it now has ghetto mutex locking, but I probably need to be be more focused what are the external methods that can be called and wrap those in @mutex.synchronize Provide also HTML UI not just JSON for ghetto UI to people who don't want to integrate
2013-04-19Add restful APISaku Ytti
2013-04-17Initial commitSaku Ytti
Silly for shit-and-giggles attempt at rancid