#!/usr/bin/env python """The XML-RPC Bcfg2 server.""" import logging import os.path import sys import Bcfg2.Logger import Bcfg2.Options import Bcfg2.Component import Bcfg2.Server.Plugins.Metadata from Bcfg2.Server.Core import CoreInitError logger = logging.getLogger('bcfg2-server') if __name__ == '__main__': optinfo = dict() optinfo.update(Bcfg2.Options.CLI_COMMON_OPTIONS) optinfo.update(Bcfg2.Options.SERVER_COMMON_OPTIONS) optinfo.update(Bcfg2.Options.DAEMON_COMMON_OPTIONS) setup = Bcfg2.Options.OptionParser(optinfo) setup.parse(sys.argv[1:]) try: # check whether the specified bcfg2.conf exists if not os.path.exists(setup['configfile']): print("Could not read %s" % setup['configfile']) sys.exit(1) 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'], to_file=setup['logging'], cfile=setup['configfile'], register=False, cls_kwargs={'repo':setup['repo'], 'plugins':setup['plugins'], 'password':setup['password'], 'encoding':setup['encoding'], 'ca':setup['ca'], 'filemonitor':setup['filemonitor'], 'start_fam_thread':True, 'setup':setup}, keyfile=setup['key'], certfile=setup['cert'], ca=setup['ca'] ) except CoreInitError: msg = sys.exc_info()[1] logger.error(msg) logger.error("exiting") sys.exit(1) except KeyboardInterrupt: sys.exit(1) sys.exit(0)