From afeeb2b6430875cc3979ae4ad690d2a3efc0ac68 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Fri, 11 May 2012 13:27:07 -0400 Subject: moved plugin-specific configs to main config file; propagate "setup" object to server Core --- src/sbin/bcfg2-admin | 3 +-- src/sbin/bcfg2-info | 12 ++++++++---- src/sbin/bcfg2-lint | 8 ++++---- src/sbin/bcfg2-server | 44 ++++++++++++++++++++------------------------ src/sbin/bcfg2-test | 3 ++- 5 files changed, 35 insertions(+), 35 deletions(-) (limited to 'src/sbin') diff --git a/src/sbin/bcfg2-admin b/src/sbin/bcfg2-admin index d3b06733f..007dd0af3 100755 --- a/src/sbin/bcfg2-admin +++ b/src/sbin/bcfg2-admin @@ -3,7 +3,6 @@ import sys import logging -import Bcfg2.Server.Core import Bcfg2.Logger import Bcfg2.Options import Bcfg2.Server.Admin @@ -31,7 +30,7 @@ def create_description(): for mode in modes: try: description.write((" %-15s %s\n" % - (mode, mode_import(mode).__shorthelp__))) + (mode, mode_import(mode).__shorthelp__))) except (ImportError, SystemExit): pass return description.getvalue() diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index 5e260d94d..8598a58eb 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -133,11 +133,13 @@ def displayTrace(trace, num=80, sort=('time', 'calls')): class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): """Main class for bcfg2-info.""" - def __init__(self, repo, plgs, passwd, encoding, event_debug, filemonitor='default'): + def __init__(self, repo, plgs, passwd, encoding, event_debug, + filemonitor='default', setup=None): cmd.Cmd.__init__(self) try: Bcfg2.Server.Core.Core.__init__(self, repo, plgs, passwd, - encoding, filemonitor=filemonitor) + encoding, filemonitor=filemonitor, + setup=setup) if event_debug: self.fam.debug = True except Bcfg2.Server.Core.CoreInitError: @@ -668,12 +670,14 @@ if __name__ == '__main__': prof = profile.Profile() loop = prof.runcall(infoCore, setup['repo'], setup['plugins'], setup['password'], setup['encoding'], - setup['event debug'], setup['filemonitor']) + setup['event debug'], setup['filemonitor'], + setup) displayTrace(prof) else: if setup['profile']: print("Profiling functionality not available.") loop = infoCore(setup['repo'], setup['plugins'], setup['password'], - setup['encoding'], setup['event debug'], setup['filemonitor']) + setup['encoding'], setup['event debug'], + setup['filemonitor'], setup) loop.Run(setup['args']) diff --git a/src/sbin/bcfg2-lint b/src/sbin/bcfg2-lint index 5ee88535d..78b833f02 100755 --- a/src/sbin/bcfg2-lint +++ b/src/sbin/bcfg2-lint @@ -62,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) @@ -73,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 @@ -101,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:]) diff --git a/src/sbin/bcfg2-server b/src/sbin/bcfg2-server index 89bc7c331..757172464 100755 --- a/src/sbin/bcfg2-server +++ b/src/sbin/bcfg2-server @@ -15,7 +15,6 @@ from Bcfg2.Server.Core import CoreInitError logger = logging.getLogger('bcfg2-server') if __name__ == '__main__': - OPTINFO = { 'configfile': Bcfg2.Options.CFILE, 'daemon' : Bcfg2.Options.DAEMON, @@ -23,26 +22,22 @@ if __name__ == '__main__': 'help' : Bcfg2.Options.HELP, 'verbose' : Bcfg2.Options.VERBOSE, 'to_file' : Bcfg2.Options.LOGGING_FILE_PATH, + 'repo' : Bcfg2.Options.SERVER_REPOSITORY, + 'plugins' : Bcfg2.Options.SERVER_PLUGINS, + 'password' : Bcfg2.Options.SERVER_PASSWORD, + 'fm' : Bcfg2.Options.SERVER_FILEMONITOR, + 'key' : Bcfg2.Options.SERVER_KEY, + 'cert' : Bcfg2.Options.SERVER_CERT, + 'ca' : Bcfg2.Options.SERVER_CA, + 'listen_all': Bcfg2.Options.SERVER_LISTEN_ALL, + 'location' : Bcfg2.Options.SERVER_LOCATION, + 'passwd' : Bcfg2.Options.SERVER_PASSWORD, + 'static' : Bcfg2.Options.SERVER_STATIC, + 'encoding' : Bcfg2.Options.ENCODING, + 'filelog' : Bcfg2.Options.LOGGING_FILE_PATH, + 'protocol' : Bcfg2.Options.SERVER_PROTOCOL, } - OPTINFO.update({'repo' : Bcfg2.Options.SERVER_REPOSITORY, - 'plugins' : Bcfg2.Options.SERVER_PLUGINS, - 'password' : Bcfg2.Options.SERVER_PASSWORD, - 'fm' : Bcfg2.Options.SERVER_FILEMONITOR, - }) - - OPTINFO.update({'key' : Bcfg2.Options.SERVER_KEY, - 'cert' : Bcfg2.Options.SERVER_CERT, - 'ca' : Bcfg2.Options.SERVER_CA, - 'listen_all' : Bcfg2.Options.SERVER_LISTEN_ALL, - 'location' : Bcfg2.Options.SERVER_LOCATION, - 'passwd' : Bcfg2.Options.SERVER_PASSWORD, - 'static' : Bcfg2.Options.SERVER_STATIC, - 'encoding' : Bcfg2.Options.ENCODING, - 'filelog' : Bcfg2.Options.LOGGING_FILE_PATH, - 'protocol' : Bcfg2.Options.SERVER_PROTOCOL, - }) - setup = Bcfg2.Options.OptionParser(OPTINFO) setup.parse(sys.argv[1:]) try: @@ -53,9 +48,9 @@ if __name__ == '__main__': Bcfg2.Component.run_component(Bcfg2.Server.Core.Core, listen_all=setup['listen_all'], location=setup['location'], - daemon = setup['daemon'], - pidfile_name = setup['daemon'], - protocol = setup['protocol'], + daemon=setup['daemon'], + pidfile_name=setup['daemon'], + protocol=setup['protocol'], to_file=setup['to_file'], cfile=setup['configfile'], register=False, @@ -65,10 +60,11 @@ if __name__ == '__main__': 'encoding':setup['encoding'], 'ca':setup['ca'], 'filemonitor':setup['fm'], - 'start_fam_thread':True}, + 'start_fam_thread':True, + 'setup':setup}, keyfile=setup['key'], certfile=setup['cert'], - ca=setup['ca'], + ca=setup['ca'] ) except CoreInitError: msg = sys.exc_info()[1] diff --git a/src/sbin/bcfg2-test b/src/sbin/bcfg2-test index 01a2a4893..472534152 100755 --- a/src/sbin/bcfg2-test +++ b/src/sbin/bcfg2-test @@ -86,7 +86,8 @@ def main(): setup['plugins'], setup['password'], setup['encoding'], - filemonitor='pseudo' + filemonitor='pseudo', + setup=setup ) ignore = dict() -- cgit v1.2.3-1-g7c22