def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._dp = DataProcessor.get_instance(hostname=etcd_ip, port=etcd_port, username=username, password=password, xtc_ip=xtc_ip)
etcd_ip = opt_value print("[*] Etcd IP is {}".format(etcd_ip)) if opt_name in ('-e', '--etcd-port'): etcd_port = int(opt_value) print("[*] Etcd Port is {}".format(etcd_port)) if opt_name in ('-x', '--xtc-ip'): xtc_ip = opt_value print("[*] XTC IP is {}".format(xtc_ip)) if None in [username, password, etcd_ip, etcd_port, xtc_ip]: print( "[*] Help: Please enter username, password, Etcd IP, Etcd Port in parameters. Example: \n python main.py -u cisco -p cisco -e 127.0.0.1 -ep 2379" ) exit() application = tornado.web.Application([ (r"/api/v1/devices", DeviceListHandler), (r"/api/v1/calculate", RouterCalcHandler) ]) application.listen(9888) loop = asyncio.get_event_loop() dp = DataProcessor.get_instance(hostname=etcd_ip, port=etcd_port, username=username, password=password, xtc_ip=xtc_ip) asyncio.ensure_future(dp.start_watch()) loop.run_forever() # tornado.ioloop.IOLoop.current().start()