def main(): try: CONF(project='ryu', version='ryu-manager %s' % version, default_config_files=['/usr/local/etc/ryu/ryu.conf']) except cfg.ConfigFilesNotFoundError: CONF(project='ryu', version='ryu-manager %s' % version) log.init_log() app_lists = CONF.app_lists + CONF.app app_mgr = AppManager() app_mgr.load_apps(app_lists) contexts = app_mgr.create_contexts() app_mgr.instantiate_apps(**contexts) services = [] # TODO: do the following in app_manager's instantiate_apps() ofpapp = controller.start_service(app_mgr) if ofpapp: thr = hub.spawn(ofpapp) services.append(thr) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) services.append(thr) try: hub.joinall(services) finally: app_mgr.close()
def close(self): if self.test_thread is not None: hub.kill(self.test_thread) if self.ingress_event: self.ingress_event.set() hub.joinall([self.test_thread]) self._test_end('--- Test terminated ---')
def _disable_router(self): if self._arp_thread is not None: self._arp_thread.kill() hub.joinall([self._arp_thread]) self._arp_thread = None # TODO: implement real routing logic self.logger.debug('TODO:_disable_router')
def _activate_subscriber_rules(self): def activate_flows(): ip_addr = convert_ip_str_to_ip_proto(self.cfg.ip) self._ec.activate_rules( imsi=self.cfg.imsi, msisdn=None, uplink_tunnel=None, ip_addr=ip_addr, apn_ambr=default_ambr_config, policies=self._policies, shard_id=0, local_f_teid_ng=0, ) if self._esc: self._esc.activate_rules( imsi=self.cfg.imsi, msisdn=None, uplink_tunnel=None, ip_addr=ip_addr, apn_ambr=default_ambr_config, policies=self._policies, shard_id=0, local_f_teid_ng=0, ) hub.joinall([hub.spawn(activate_flows)])
def main(): try: CONF(project='ryu', version='ryu-manager %s' % version, default_config_files=['/usr/local/etc/ryu/ryu.conf']) except cfg.ConfigFilesNotFoundError: CONF(project='ryu', version='ryu-manager %s' % version) log.init_log() app_lists = CONF.app_lists + CONF.app # keep old behaivor, run ofp if no application is specified. if not app_lists: app_lists = ['ryu.controller.ofp_handler'] app_mgr = AppManager.get_instance() app_mgr.load_apps(app_lists) contexts = app_mgr.create_contexts() services = [] services.extend(app_mgr.instantiate_apps(**contexts)) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) services.append(thr) try: hub.joinall(services) finally: app_mgr.close()
def main(): try: CONF(project='ryu', version='ryu-manager %s' % version, default_config_files=['/usr/local/etc/ryu/ryu.conf']) except cfg.ConfigFilesNotFoundError: CONF(project='ryu', version='ryu-manager %s' % version) log.init_log() # always enable ofp for now. app_lists = CONF.app_lists + CONF.app + ['ryu.controller.ofp_handler'] app_mgr = AppManager() app_mgr.load_apps(app_lists) contexts = app_mgr.create_contexts() app_mgr.instantiate_apps(**contexts) services = [] ctlr = controller.OpenFlowController() thr = hub.spawn(ctlr) services.append(thr) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) services.append(thr) try: hub.joinall(services) finally: app_mgr.close()
def main(args=None, prog=None): # 加载函数库 _parse_user_flags() # 加载配置文件 try: CONF(args=args, prog=prog, project='ryu', version='ryu-manager %s' % version, default_config_files=['/usr/local/etc/ryu/ryu.conf']) except cfg.ConfigFilesNotFoundError: CONF(args=args, prog=prog, project='ryu', version='ryu-manager %s' % version) log.init_log() logger = logging.getLogger(__name__) if CONF.enable_debugger: msg = 'debugging is available (--enable-debugger option is turned on)' logger.info(msg) else: hub.patch(thread=True) if CONF.pid_file: with open(CONF.pid_file, 'w') as pid_file: pid_file.write(str(os.getpid())) app_lists = CONF.app_lists + CONF.app # keep old behavior, run ofp if no application is specified. # 如果配置文件的列表为空,则加载ryu.controller.ofp_handler if not app_lists: app_lists = ['ryu.controller.ofp_handler'] # 创建实例,调用get_instance,实现单例模式 app_mgr = AppManager.get_instance() # 加载app_lists中的app app_mgr.load_apps(app_lists) # 创建上下文 contexts = app_mgr.create_contexts() services = [] services.extend(app_mgr.instantiate_apps(**contexts)) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) # 加入services列表 services.append(thr) try: # 对server服务列表遍历wait hub.joinall(services) except KeyboardInterrupt: # KeyboardInterrupt 用户中断执行(通常是输入^C) logger.debug("Keyboard Interrupt received. " "Closing RYU application manager...") finally: app_mgr.close()
def close(self): self.is_active = False if self.link_discovery: self.lldp_event.set() self.link_event.set() self.msg_event.set() hub.joinall(self.threads)
def _deactivate_subscriber_rules(self): if self._nuke_flows_on_exit: def deactivate_flows(): self._ec.deactivate_rules(imsi=self.cfg.imsi, rule_ids=None) hub.joinall([hub.spawn(deactivate_flows)])
def main(): try: CONF(project='ryu', version='ofa_neutron_agent %s' % version, default_config_files=['/usr/local/etc/ryu/ryu.conf']) except cfg.ConfigFilesNotFoundError: CONF(project='ryu', version='ofa_neutron_agent %s' % version) osn_config.setup_logging(CONF) app_lists = CONF.app_lists + CONF.app if not app_lists: app_lists = ['neutron.plugins.ofagent.agent.ofa_neutron_agent'] app_mgr = AppManager.get_instance() app_mgr.load_apps(app_lists) contexts = app_mgr.create_contexts() services = [] services.extend(app_mgr.instantiate_apps(**contexts)) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) services.append(thr) try: hub.joinall(services) finally: app_mgr.close()
def stop(self): super(GaugeThreadPoller, self).stop() self._running = False if self.is_active(): hub.kill(self.thread) hub.joinall([self.thread]) self.thread = None
def main(): try: CONF(project='ryu', version='ofa_neutron_agent %s' % version, default_config_files=['/usr/local/etc/ryu/ryu.conf']) except cfg.ConfigFilesNotFoundError: CONF(project='ryu', version='ofa_neutron_agent %s' % version) osn_config.setup_logging(CONF) app_lists = CONF.app_lists + CONF.app if not app_lists: app_lists = [ 'ryu.app.ofctl.service', 'neutron.plugins.ofagent.agent.ofa_neutron_agent' ] app_mgr = AppManager.get_instance() app_mgr.load_apps(app_lists) contexts = app_mgr.create_contexts() services = [] services.extend(app_mgr.instantiate_apps(**contexts)) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) services.append(thr) try: hub.joinall(services) finally: app_mgr.close()
def stop(self): if self.main_thread: hub.kill(self.main_thread) # 将标识设置为False self.is_active = False self._send_event(self._event_stop, None) hub.joinall(self.threads)
def stop(self): # NOTE(jkoelker) Stop the idl and event_proxy threads first # letting them finish their current loop. self.is_active = False hub.joinall(self.threads) self._idl.close() super(RemoteOvsdb, self).stop()
def serve(self): send_thr = hub.spawn(self._send_loop) try: self._recv_loop() finally: hub.kill(send_thr) hub.joinall([send_thr])
def _activate_subscriber_rules(self): def activate_flows(): self._ec.activate_flows(imsi=self.cfg.imsi, ip_addr=self.cfg.ip, static_rule_ids=self._static_rule_names, dynamic_rules=self._dynamic_rules, fut=Future()) hub.joinall([hub.spawn(activate_flows)])
def main(args=None, prog=None): _parse_user_flags() try: CONF(args=args, prog=prog, project='ryu', version='ryu-manager %s' % version, default_config_files=['/usr/local/etc/ryu/ryu.conf']) except cfg.ConfigFilesNotFoundError: CONF(args=args, prog=prog, project='ryu', version='ryu-manager %s' % version) log.init_log() logger = logging.getLogger(__name__) if CONF.enable_debugger: msg = 'debugging is available (--enable-debugger option is turned on)' logger.info(msg) else: hub.patch(thread=True) if CONF.pid_file: with open(CONF.pid_file, 'w') as pid_file: pid_file.write(str(os.getpid())) app_lists = CONF.app_lists + CONF.app # print('1:app_lists:',app_lists) #('1:app_lists:', []) # keep old behavior, run ofp if no application is specified. if not app_lists: app_lists = ['ryu.controller.ofp_handler'] app_mgr = AppManager.get_instance() # print('2:app_mgr',app_mgr) #('2:app_mgr', <ryu.base.app_manager.AppManager object at 0x7ff3ce974450>) app_mgr.load_apps(app_lists) # print('17:app_lists:',app_lists) #('17:app_lists:', ['ryu.controller.ofp_handler']) contexts = app_mgr.create_contexts() # print('22:contexts',contexts) #('22:contexts', {}) services = [] services.extend(app_mgr.instantiate_apps(**contexts)) # print('services:',services) #('services:', [<eventlet.greenthread.GreenThread object at 0x7f4f3540c190>]) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) services.append(thr) try: hub.joinall(services) except KeyboardInterrupt: logger.debug("Keyboard Interrupt received. " "Closing RYU application manager...") finally: app_mgr.close()
def test_spawn_exception_joinall(self): def _child(): raise Exception("hoge") threads = [] with hub.Timeout(2): threads.append(hub.spawn(_child)) threads.append(hub.spawn(_child)) hub.sleep(0.5) hub.joinall(threads)
def _deactivate_subscriber_rules(self): ip_addr = convert_ip_str_to_ip_proto(self.cfg.ip) if self._nuke_flows_on_exit: def deactivate_flows(): self._ec.deactivate_rules(imsi=self.cfg.imsi, ip_addr=ip_addr, rule_ids=None) hub.joinall([hub.spawn(deactivate_flows)])
def main(args=None, prog=None): _parse_user_flags() try: CONF(args=args, prog=prog, project='ryu', version='ryu-manager %s' % version, default_config_files=['/usr/local/etc/ryu/ryu.conf']) except cfg.ConfigFilesNotFoundError: CONF(args=args, prog=prog, project='ryu', version='ryu-manager %s' % version) log.init_log() logger = logging.getLogger(__name__) if CONF.enable_debugger: msg = 'debugging is available (--enable-debugger option is turned on)' logger.info(msg) else: hub.patch(thread=True) if CONF.pid_file: with open(CONF.pid_file, 'w') as pid_file: pid_file.write(str(os.getpid())) app_lists = CONF.app_lists + CONF.app # keep old behavior, run ofp if no application is specified. if not app_lists: app_lists = ['ryu.controller.ofp_handler'] app_mgr = AppManager.get_instance() app_mgr.load_apps(app_lists) # sys.stdout.write("hello world!\n") contexts = app_mgr.create_contexts() services = [] services.extend(app_mgr.instantiate_apps(**contexts)) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) services.append(thr) try: hub.joinall(services) except KeyboardInterrupt: logger.debug("Keyboard Interrupt received. " "Closing RYU application manager...") finally: for name, app in app_mgr.applications.items(): if getattr(app, "set_xml", None): app.set_xml() app_mgr.close()
def serve(self): send_thr = hub.spawn(self._send_loop) hello = self.oxproto_parser.OXPHello(self) self.send_msg(hello) try: self._recv_loop() finally: hub.kill(send_thr) hub.joinall([send_thr])
def get_table_stats(test_controller): """ Send an ovs request to retrieve all table stats, wait on queue """ queue = hub.Queue() def request_table_stats(): test_controller.table_stats_lookup(queue) hub.joinall([hub.spawn(request_table_stats)]) return queue.get(block=True)
def main(args=None, prog=None): _parse_user_flags() try: CONF(args=args, prog=prog, project='ryu', version='ryu-manager %s' % version, default_config_files=['/usr/local/etc/ryu/ryu.conf']) except cfg.ConfigFilesNotFoundError: CONF(args=args, prog=prog, project='ryu', version='ryu-manager %s' % version) log.init_log() logger = logging.getLogger(__name__) if CONF.enable_debugger: msg = 'debugging is available (--enable-debugger option is turned on)' logger.info(msg) else: hub.patch(thread=True) if CONF.pid_file: with open(CONF.pid_file, 'w') as pid_file: pid_file.write(str(os.getpid())) app_lists = CONF.app_lists + CONF.app # keep old behavior, run ofp if no application is specified. if not app_lists: app_lists = ['ryu.controller.ofp_handler'] # step1: 实例化AppManager,是之后管理的基础 app_mgr = AppManager.get_instance() # step2:加载需要的服务,并不实例化,只是保存在对应字典中,还要加载每个app所需要的app app_mgr.load_apps(app_lists) # step3:实例化依赖模块,上面的APP可能需要其他模块服务,进行实例化 contexts = app_mgr.create_contexts() services = [] # step4:关键的一步,实例化app services.extend(app_mgr.instantiate_apps(**contexts)) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) services.append(thr) try: hub.joinall(services) except KeyboardInterrupt: logger.debug("Keyboard Interrupt received. " "Closing RYU application manager...") finally: app_mgr.close()
def serve(self): send_thr = hub.spawn(self._send_loop) # send hello message immediately hello = self.ofproto_parser.OFPHello(self) self.send_msg(hello) try: self._recv_loop() finally: hub.kill(send_thr) hub.joinall([send_thr])
def main(args=None, prog=None): try: CONF(args=args, prog=prog, project='ryu', version='ryu-manager %s' % version, default_config_files=['/usr/local/etc/ryu/ryu.conf']) except cfg.ConfigFilesNotFoundError: CONF(args=args, prog=prog, project='ryu', version='ryu-manager %s' % version) log.init_log() if CONF.pid_file: import os with open(CONF.pid_file, 'w') as pid_file: pid_file.write(str(os.getpid())) app_lists = CONF.app_lists + CONF.app # keep old behaivor, run ofp if no application is specified. if not app_lists: app_lists = ['ryu.controller.ofp_handler'] #if CONF.oxp_role == 'super': # app_lists.extend(['ryu.openexchange.super.oxp_server_handler', # 'ryu.openexchange.super.topology', # 'ryu.openexchange.super.routing']) #elif CONF.oxp_role == 'domain': # app_lists.extend( # ['ryu.openexchange.domain.oxp_client_handler', # 'ryu.openexchange.network.abstract', # 'ryu.openexchange.network.topo_reply', # 'ryu.openexchange.network.echo_loop', # 'ryu.openexchange.domain.translation']) app_mgr = AppManager.get_instance() app_mgr.load_apps(app_lists) contexts = app_mgr.create_contexts() services = [] services.extend(app_mgr.instantiate_apps(**contexts)) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) services.append(thr) try: hub.joinall(services) finally: app_mgr.close()
def start(self): self.is_active = True self.sock.settimeout(GLOBAL_CONF.socket_timeout) self._threads.append(hub.spawn(self._send_loop)) self._threads.append(hub.spawn(self._recv_loop)) self.server.send_event_to_observers( zserver_event.EventZClientConnected(self)) hub.joinall(self._threads) self.server.send_event_to_observers( zserver_event.EventZClientDisconnected(self))
def lookup(self): queue = hub.Queue() def get_stats(): self._tc.ryu_query_lookup( _generate_ryu_req(self._table_id, self._match, self._cookie), queue) hub.joinall([hub.spawn(get_stats)]) flows = queue.get(block=True) return [ FlowStats(flow.packet_count, flow.byte_count, flow.duration_sec, flow.cookie) for flow in flows ]
def test_spawn_kill_die_joinall(self): def _child(result): result.append(1) threads = [] result = [] with hub.Timeout(2): threads.append(hub.spawn(_child, result)) threads.append(hub.spawn(_child, result)) hub.sleep(0.5) for t in threads: hub.kill(t) hub.joinall(threads) assert len(result) == 2
def main(args=None, prog=None): try: CONF( args=args, prog=prog, project="ryu", version="ryu-manager {}".format(version), default_config_files=["/usr/local/etc/ryu/ryu.conf"], ) except cfg.ConfigFilesNotFoundError: CONF(args=args, prog=prog, project="ryu", version="ryu-manager {}".format(version)) log.init_log() hub.patch(thread=True) if CONF.pid_file: LOG.info("Pid file : %s", CONF.pid_file) import os with open(CONF.pid_file, "w") as pid_file: pid_file.write(str(os.getpid())) app_lists = CONF.app_lists + CONF.app if not app_lists: app_lists = ["ryu.controller.ofp_handler", "dragon_knight.dk_plugin"] if "ryu.controller.ofp_handler" not in app_lists: app_lists.append("ryu.controller.ofp_handler") if "dragon_knight.dk_plugin" not in app_lists: app_lists.append("dragon_knight.dk_plugin") app_mgr = AppManager.get_instance() app_mgr.load_apps(app_lists) contexts = app_mgr.create_contexts() services = [] services.extend(app_mgr.instantiate_apps(**contexts)) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) services.append(thr) try: hub.joinall(services) finally: app_mgr.close()
def main(args=None, prog=None): try: CONF(args=args, prog=prog, project='ryu', version='ryu-manager {}'.format(version), default_config_files=['/usr/local/etc/ryu/ryu.conf']) except cfg.ConfigFilesNotFoundError: CONF(args=args, prog=prog, project='ryu', version='ryu-manager {}'.format(version)) log.init_log() hub.patch(thread=True) if CONF.pid_file: LOG.info('Pid file : %s', CONF.pid_file) import os with open(CONF.pid_file, 'w') as pid_file: pid_file.write(str(os.getpid())) app_lists = CONF.app_lists + CONF.app if not app_lists: app_lists = ['ryu.controller.ofp_handler', 'dragon_knight.dk_plugin'] if 'ryu.controller.ofp_handler' not in app_lists: app_lists.append('ryu.controller.ofp_handler') if 'dragon_knight.dk_plugin' not in app_lists: app_lists.append('dragon_knight.dk_plugin') app_mgr = AppManager.get_instance() app_mgr.load_apps(app_lists) contexts = app_mgr.create_contexts() services = [] services.extend(app_mgr.instantiate_apps(**contexts)) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) services.append(thr) try: hub.joinall(services) finally: app_mgr.close()
def test_spawn_kill_nowait_joinall(self): # XXX this test relies on the scheduling behaviour. # the intention here is, killing threads before they get active. def _child(result): result.append(1) threads = [] result = [] with hub.Timeout(2): threads.append(hub.spawn(_child, result)) for t in threads: hub.kill(t) hub.joinall(threads) assert len(result) == 0
def _activate_subscriber_rules(self): def activate_flows(): self._ec.activate_rules(imsi=self.cfg.imsi, ip_addr=self.cfg.ip, apn_ambr=default_ambr_config, static_rule_ids=self._static_rule_names, dynamic_rules=self._dynamic_rules) if self._esc: self._esc.activate_rules( imsi=self.cfg.imsi, ip_addr=self.cfg.ip, apn_ambr=default_ambr_config, static_rule_ids=self._static_rule_names, dynamic_rules=self._dynamic_rules) hub.joinall([hub.spawn(activate_flows)])
def serve(self): # TODO: entry point send_thr = hub.spawn(self._send_loop) # send hello message immediately #hello = self.ofproto_parser.OFPHello(self) #self.send_msg(hello) buf = "Server" self.socket.sendall(buf) try: self._recv_loop() finally: hub.kill(send_thr) hub.joinall([send_thr])
def test_spawn_kill_joinall(self): def _child(ev2, result): ev2.wait() result.append(1) ev2 = hub.Event() threads = [] result = [] with hub.Timeout(2): threads.append(hub.spawn(_child, ev2, result)) threads.append(hub.spawn(_child, ev2, result)) hub.sleep(0.5) for t in threads: hub.kill(t) hub.joinall(threads) assert len(result) == 0
def serve(self): send_thr = hub.spawn(self._send_loop) # send hello message immediately hello = self.ofproto_parser.OFPHello(self) self.send_msg(hello) echo_thr = hub.spawn(self._echo_request_loop) try: self._recv_loop() finally: hub.kill(send_thr) hub.kill(echo_thr) hub.joinall([send_thr, echo_thr]) self.is_active = False
def test_spawn_joinall(self): def _child(ev2, result): ev2.wait() hub.sleep(0.5) result.append(1) raise BaseException("this exception should not be propagated") ev2 = hub.Event() threads = [] result = [] with hub.Timeout(2): threads.append(hub.spawn(_child, ev2, result)) threads.append(hub.spawn(_child, ev2, result)) hub.sleep(0.5) ev2.set() # this should wake up the above created two threads hub.joinall(threads) assert len(result) == 2
def main(args=None, prog=None): try: CONF(args=args, prog=prog, project='ryu', version='ryu-manager %s' % version, default_config_files=['/usr/local/etc/ryu/ryu.conf']) except cfg.ConfigFilesNotFoundError: CONF(args=args, prog=prog, project='ryu', version='ryu-manager %s' % version) log.init_log() logger = logging.getLogger(__name__) if CONF.enable_debugger: msg = 'debugging is available (--enable-debugger option is turned on)' logger.info(msg) else: hub.patch(thread=True) if CONF.pid_file: import os with open(CONF.pid_file, 'w') as pid_file: pid_file.write(str(os.getpid())) app_lists = CONF.app_lists + CONF.app # keep old behavior, run ofp if no application is specified. if not app_lists: app_lists = ['ryu.controller.ofp_handler'] app_mgr = AppManager.get_instance() app_mgr.load_apps(app_lists) contexts = app_mgr.create_contexts() services = [] services.extend(app_mgr.instantiate_apps(**contexts)) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) services.append(thr) try: hub.joinall(services) except KeyboardInterrupt: logger.debug("Keyboard Interrupt received. " "Closing RYU application manager...") finally: app_mgr.close()
def run_apps(app_lists): """Run a set of Ryu applications A convenient method to load and instantiate apps. This blocks until all relevant apps stop. """ app_mgr = AppManager.get_instance() app_mgr.load_apps(app_lists) contexts = app_mgr.create_contexts() services = app_mgr.instantiate_apps(**contexts) webapp = wsgi.start_service(app_mgr) if webapp: services.append(hub.spawn(webapp)) try: hub.joinall(services) finally: app_mgr.close()
def _bulk_read_handler(self, ev): results = [] def done(gt, *args, **kwargs): if gt in self.threads: self.threads.remove(gt) results.append(gt.wait()) threads = [] for c in self._clients.values(): gt = hub.spawn(c.read_request_handler, ev, bulk=True) threads.append(gt) self.threads.append(gt) gt.link(done) hub.joinall(threads) rep = event.EventReadReply(None, results) self.reply_to_request(ev, rep)
def main(): log.init_log() app_mgr = AppManager.get_instance() app_mgr.load_apps(['./ryu_controller.py']) contexts = app_mgr.create_contexts() services = [] services.extend(app_mgr.instantiate_apps(**contexts)) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) services.append(thr) print services try: hub.joinall(services) finally: app_mgr.close()
def start(self): self.is_active = True try: self.sock = create_connection(self.client.zserv_addr) except socket.error as e: self.logger.exception( 'Cannot connect to Zebra server%s: %s', self.client.zserv_addr, e) self.stop() return None self.sock.settimeout(GLOBAL_CONF.socket_timeout) self.threads.append(hub.spawn(self._send_loop)) self.threads.append(hub.spawn(self._recv_loop)) # Send the following messages at starting connection. # - ZEBRA_HELLO to register route_type # - ZEBRA_ROUTER_ID_ADD to get router_id # - ZEBRA_INTERFACE_ADD to get info for interfaces self.client.send_msg( zebra.ZebraMessage( version=self.client.zserv_ver, body=zebra.ZebraHello( route_type=self.client.route_type, instance=0))) self.client.send_msg( zebra.ZebraMessage( version=self.client.zserv_ver, body=zebra.ZebraRouterIDAdd())) self.client.send_msg( zebra.ZebraMessage( version=self.client.zserv_ver, body=zebra.ZebraInterfaceAdd())) self.client.send_event_to_observers( zclient_event.EventZServConnected(self)) hub.joinall(self.threads) self.client.send_event_to_observers( zclient_event.EventZServDisconnected(self))
def real_main(): LOGGER.info('I win leader election, Ryu controller start running') app_lists = CONF.app_lists + CONF.app # keep old behaivor, run ofp if no application is specified. if not app_lists: app_lists = ['ryu.controller.ofp_handler'] app_mgr = AppManager.get_instance() app_mgr.load_apps(app_lists) contexts = app_mgr.create_contexts() services = [] services.extend(app_mgr.instantiate_apps(**contexts)) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) services.append(thr) try: hub.joinall(services) finally: app_mgr.close()
def main(args=None, prog=None): try: CONF(args=args, prog=prog, project='ryu', version='ryu-manager %s' % version, default_config_files=['/usr/local/etc/ryu/ryu.conf']) except cfg.ConfigFilesNotFoundError: CONF(args=args, prog=prog, project='ryu', version='ryu-manager %s' % version) log.init_log() if CONF.pid_file: import os with open(CONF.pid_file, 'w') as pid_file: pid_file.write(str(os.getpid())) app_lists = CONF.app_lists + CONF.app # keep old behaivor, run ofp if no application is specified. if not app_lists: app_lists = ['ryu.controller.ofp_handler'] # add oxp_handler #app_lists.append('ryu.openexchange.oxp_handler') app_mgr = AppManager.get_instance() app_mgr.load_apps(app_lists) contexts = app_mgr.create_contexts() services = [] services.extend(app_mgr.instantiate_apps(**contexts)) webapp = wsgi.start_service(app_mgr) if webapp: thr = hub.spawn(webapp) services.append(thr) try: hub.joinall(services) finally: app_mgr.close()
def stop(self): if self.main_thread: hub.kill(self.main_thread) self.is_active = False self._send_event(self._event_stop, None) hub.joinall(self.threads)