def parse_command_line(config, args): parser = argparse.ArgumentParser() parser.add_argument( '--logfile', help='Name of the log file, __screen__ for standard output', type=str) parser.add_argument('--loglevel', help='Logging level', type=str) parser.add_argument( '--bind', help='URI to listen for requests ', type=str) options = parser.parse_args(args) if config.get('Logging') is None: config['Logging'] = { 'LogFile': '__screen__', 'LogLevel': 'INFO' } if options.logfile: config['Logging']['LogFile'] = options.logfile if options.loglevel: config['Logging']['LogLevel'] = options.loglevel.upper() if options.bind: host_name, port = parse_bind_url(options.bind) else: if config.get("KMEListener") is None or \ config["KMEListener"].get("bind") is None: logger.error("Quit : no bind config found for KMEListener") sys.exit(-1) host_name, port = parse_bind_url( config["KMEListener"].get("bind")) return host_name, port
def _start_kme_listener(self): """ This function reads the host_name and port for the listener to bind. It instantiates the KMEListener and starts it. This listener runs indefinitely processing requests received from WPEs. It terminates only when an exception occurs within start method os the listener instance. """ host_name, port = parse_bind_url( self._config["KMEListener"].get("bind")) rpc_methods = [ self.GetUniqueVerificationKey, self.RegisterWorkOrderProcessor, self.PreProcessWorkOrder ] self._kme_listener = KMEListener(rpc_methods) self._kme_listener.start(host_name, port)
def parse_command_line(config, args): parser = argparse.ArgumentParser() parser.add_argument( '--logfile', help='Name of the log file, __screen__ for standard output', type=str) parser.add_argument('--loglevel', help='Logging level', type=str) parser.add_argument('--bind', help='URI to listen for requests ', type=str) parser.add_argument('--lmdb_url', help='DB url to connect to LMDB ', type=str) parser.add_argument('--sync_mode', help='Work order execution in synchronous mode', type=bool, default=False) parser.add_argument('--zmq_url', help='ZMQ url to connect to enclave manager ', type=str) options = parser.parse_args(args) if config.get('Logging') is None: config['Logging'] = {'LogFile': '__screen__', 'LogLevel': 'INFO'} if options.logfile: config['Logging']['LogFile'] = options.logfile if options.loglevel: config['Logging']['LogLevel'] = options.loglevel.upper() if options.bind: host_name, port = parse_bind_url(options.bind) else: if config.get("Listener") is None or \ config["Listener"].get("bind") is None: logger.error("Quit : no bind config found for Listener") sys.exit(-1) host_name, port = parse_bind_url(config["Listener"].get("bind")) if options.lmdb_url: config["KvStorage"]["remote_storage_url"] = options.lmdb_url else: if config.get("KvStorage") is None or \ config["KvStorage"].get("remote_storage_url") is None: logger.error("Quit : remote_storage_url is not \ present in config for Listener") sys.exit(-1) # Check if listener is running in sync work order if options.sync_mode: is_sync = True else: is_sync = config["WorkloadExecution"]["sync_workload_execution"] if options.zmq_url: if not is_sync: logger.warn("Option zmq_url has no effect!" "It is be supported " "in work order sync mode ON") if config.get("Listener") is None or \ config["Listener"].get("zmq_url") is None: logger.error("Quit : no zmq_url config found for Listener") sys.exit(-1) parse_res = urlparse(options.zmq_url) if parse_res.scheme != "tcp" or parse_res.port == "": logger.error("Invalid zmq url. It should be tcp://<host>:<port>") sys.exit(-1) config["Listener"]["zmq_url"] = options.zmq_url return host_name, port