def main(): """ Main entry point """ # parse command line arguments parser = argparse.ArgumentParser() parser.add_argument('-c', '--config', metavar="PATH", default=common.CONFIG_FILENAME, help="Configuration file path") parser.add_argument('--port', metavar=("PORT"), default=[5000], type=int, nargs=1, help="REST API port") parser.add_argument('-V', '--verbose', action='store_true', help="Verbose mode") cmd_args = parser.parse_args() # configure syslog output syslog.openlog("AppQoS") if cmd_args.verbose: log.enable_verbose() # initialize libpqos/Intel RDT interface result = common.PQOS_API.init() if result != 0: log.error("libpqos initialization failed, Terminating...") return # initialize capabilities result = caps.caps_init() if result == 0: # initialize main logic app_qos = AppQoS() # start REST API server server = rest.Server() result = server.start("127.0.0.1", cmd_args.port[0], cmd_args.verbose) if result == 0: # run main logic app_qos.run(cmd_args) # stop REST API server server.terminate() else: log.error("Failed to start REST API server, Terminating...") else: log.error("Required capabilities not supported, Terminating...") # de-initialize libpqos common.PQOS_API.fini()
def main(): """ Main entry point """ parser = argparse.ArgumentParser() parser.add_argument('-c', '--config', metavar="PATH", default=common.CONFIG_FILENAME, help="Configuration file path") parser.add_argument('--port', metavar=("PORT"), default=[5000], type=int, nargs=1, help="REST API port") parser.add_argument('-V', '--verbose', action='store_true', help="Verbose mode") cmd_args = parser.parse_args() # configure syslog output syslog.openlog("AppQoS") if cmd_args.verbose: log.enable_verbose() result = common.PQOS_API.init() if result != 0: log.error("libpqos initialization failed, Terminating...") return # initialize capabilities result = caps.caps_init() if result == 0: # initialize main logic app_qos = AppQoS() # start REST API server server = rest.Server() result = server.start("0.0.0.0", cmd_args.port[0], cmd_args.verbose) if result == 0: # run main logic app_qos.run(cmd_args) # stop REST API server server.terminate() else: log.error("Failed to start REST API server, Terminating...") else: log.error("Required capabilities not supported, Terminating...") # de-initialize libpqos common.PQOS_API.fini()
def main(): """ Main entry point """ # parse command line arguments parser = argparse.ArgumentParser() parser.add_argument('-c', '--config', metavar="PATH", default=common.CONFIG_FILENAME, help="Configuration file path") parser.add_argument('--port', metavar=("PORT"), default=[5000], type=int, nargs=1, help="REST API port") parser.add_argument('-V', '--verbose', action='store_true', help="Verbose mode") parser.add_argument('-a', '--address', metavar="INET_ADDRESS", default=common.DEFAULT_ADDRESS, help="AppQoS inet address") cmd_args = parser.parse_args() # configure syslog output syslog.openlog("AppQoS") if cmd_args.verbose: log.enable_verbose() # detect supported RDT interfaces common.PQOS_API.detect_supported_ifaces() # Load config file if load_config(cmd_args.config): log.error("Failed to load config file, Terminating...") return # initialize libpqos/Intel RDT interface result = common.PQOS_API.init(common.CONFIG_STORE.get_rdt_iface()) if result != 0: log.error("libpqos initialization failed, Terminating...") return log.info( f"RDT initialized with '{common.PQOS_API.current_iface()}' interface") # initialize capabilities result = caps.caps_init() if result == 0: # initialize main logic app_qos = AppQoS() # start REST API server server = rest_server.Server() result = server.start(cmd_args.address, cmd_args.port[0], cmd_args.verbose) if result == 0: # run main logic app_qos.run() # stop REST API server server.terminate() else: log.error("Failed to start REST API server, Terminating...") else: log.error("Required capabilities not supported, Terminating...") # de-initialize libpqos common.PQOS_API.fini()