diff options
Diffstat (limited to 'src/sbin/bcfg2-lint')
-rwxr-xr-x | src/sbin/bcfg2-lint | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/sbin/bcfg2-lint b/src/sbin/bcfg2-lint index 2d371f4aa..78b833f02 100755 --- a/src/sbin/bcfg2-lint +++ b/src/sbin/bcfg2-lint @@ -1,7 +1,6 @@ #!/usr/bin/env python """This tool examines your Bcfg2 specifications for errors.""" -__revision__ = '$Revision$' import sys import inspect @@ -63,7 +62,9 @@ def get_errorhandler(config): def load_server(setup): """ load server """ core = Bcfg2.Server.Core.Core(setup['repo'], setup['plugins'], - setup['password'], setup['encoding']) + setup['password'], setup['encoding'], + filemonitor=setup['filemonitor'], + setup=setup) if setup['event debug']: core.fam.debug = True core.fam.handle_events_in_interval(4) @@ -74,8 +75,6 @@ if __name__ == '__main__': 'configfile': Bcfg2.Options.CFILE, 'help': Bcfg2.Options.HELP, 'verbose': Bcfg2.Options.VERBOSE, - } - optinfo.update({ 'event debug': Bcfg2.Options.DEBUG, 'encoding': Bcfg2.Options.ENCODING, # Server options @@ -102,7 +101,7 @@ if __name__ == '__main__': 'showerrors': Bcfg2.Options.Option('Show error handling', False, cmd='--list-errors', long_arg=True), - }) + } setup = Bcfg2.Options.OptionParser(optinfo) setup.parse(sys.argv[1:]) @@ -115,21 +114,6 @@ if __name__ == '__main__': config.read(setup['configfile']) config.read(setup['config']) - if setup['showerrors']: - if config.has_section("errors"): - econf = dict(config.items("errors")) - else: - econf = dict() - - print("%-35s %-35s" % ("Error name", "Handler (Default)")) - for err, default in Bcfg2.Server.Lint.ErrorHandler._errors.items(): - if err in econf and econf[err] != default: - handler = "%s (%s)" % (econf[err], default) - else: - handler = default - print("%-35s %-35s" % (err, handler)) - raise SystemExit(0) - # get list of plugins to run if setup['args']: allplugins = setup['args'] @@ -170,6 +154,15 @@ if __name__ == '__main__': errorhandler = get_errorhandler(config) + if setup['showerrors']: + for plugin in serverplugins.values() + serverlessplugins.values(): + errorhandler.RegisterErrors(getattr(plugin, 'Errors')()) + + print("%-35s %-35s" % ("Error name", "Handler")) + for err, handler in errorhandler._handlers.items(): + print("%-35s %-35s" % (err, handler.__name__)) + raise SystemExit(0) + run_serverless_plugins(serverlessplugins, errorhandler=errorhandler, config=config, setup=setup) |