From 27f76c58e706233664a70504c220da3a55c0e06a Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Tue, 8 Jan 2008 05:07:17 +0000 Subject: Switch all parsing to outer scripts for Component git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4206 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Component.py | 20 ++------------------ src/sbin/bcfg2-server | 13 ++++++++++++- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/lib/Component.py b/src/lib/Component.py index fd9201cd1..c1f87dbe7 100644 --- a/src/lib/Component.py +++ b/src/lib/Component.py @@ -7,7 +7,6 @@ from base64 import decodestring import BaseHTTPServer, SimpleXMLRPCServer import Bcfg2.tlslite.errors import Bcfg2.tlslite.api -import Bcfg2.Options import Bcfg2.Client.Proxy as Proxy from Bcfg2.tlslite.TLSConnection import TLSConnection @@ -138,33 +137,18 @@ class Component(TLSServer, fork_funcs = [] child_limit = 32 - def __init__(self, setup): + def __init__(self, keyfile, password, location): # need to get addr - self.setup = setup self.shut = False signal.signal(signal.SIGINT, self.start_shutdown) signal.signal(signal.SIGTERM, self.start_shutdown) self.logger = logging.getLogger('Component') self.children = [] self.static = True - options = { - 'key' : Bcfg2.Options.SERVER_KEY, - 'location' : Bcfg2.Options.SERVER_LOCATION, - 'passwd' : Bcfg2.Options.SERVER_PASSWORD, - 'static' : Bcfg2.Options.SERVER_STATIC, - } - opts = Bcfg2.Options.OptionParser(options) - opts.parse([]) - location = opts['location'] uparsed = urlparse.urlparse(location)[1].split(':') sock_loc = (uparsed[0], int(uparsed[1])) - if not opts['key']: - print "No key specified in '%s'" % setup['configfile'] - raise SystemExit, 1 - keyfile = opts['key'] - - self.password = opts['passwd'] + self.password = password try: TLSServer.__init__(self, sock_loc, keyfile, CobaltXMLRPCRequestHandler) diff --git a/src/sbin/bcfg2-server b/src/sbin/bcfg2-server index 8d8c65170..cb27e9c89 100755 --- a/src/sbin/bcfg2-server +++ b/src/sbin/bcfg2-server @@ -33,7 +33,9 @@ class Bcfg2Serv(Bcfg2.Component.Component): def __init__(self, setup): try: - Bcfg2.Component.Component.__init__(self, setup) + Bcfg2.Component.Component.__init__(self, setup['key'], + setup['password'], + setup['location']) except Bcfg2.Component.ComponentInitError: raise SetupError @@ -190,6 +192,12 @@ if __name__ == '__main__': 'structures': Bcfg2.Options.SERVER_STRUCTURES, 'generators': Bcfg2.Options.SERVER_GENERATORS, 'password': Bcfg2.Options.SERVER_PASSWORD}) + OPTINFO.update({'key' : Bcfg2.Options.SERVER_KEY, + 'location' : Bcfg2.Options.SERVER_LOCATION, + 'passwd' : Bcfg2.Options.SERVER_PASSWORD, + 'static' : Bcfg2.Options.SERVER_STATIC, + }) + setup = Bcfg2.Options.OptionParser(OPTINFO) setup.parse(sys.argv[1:]) @@ -203,6 +211,9 @@ if __name__ == '__main__': else: Bcfg2.Logging.setup_logging('bcfg2-server', level=level) + if not setup['key']: + print "No key specified in '%s'" % setup['configfile'] + raise SystemExit, 1 try: BSERV = Bcfg2Serv(setup) -- cgit v1.2.3-1-g7c22