From 5dfb0ffb45cb9516aa06188bb16454db7bdfae0e Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Mon, 25 Nov 2013 09:37:25 +0900 Subject: [PATCH] ofp: use RyuApp start() to return Greenlet thread starts OFP like other applications. Kill the original way to start OFP (start_service). Signed-off-by: FUJITA Tomonori Reviewed-by: YAMAMOTO Takashi --- ryu/cmd/manager.py | 6 ------ ryu/controller/controller.py | 6 ------ ryu/controller/ofp_handler.py | 6 ++++++ 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/ryu/cmd/manager.py b/ryu/cmd/manager.py index 474dcec3..234b96c5 100755 --- a/ryu/cmd/manager.py +++ b/ryu/cmd/manager.py @@ -72,12 +72,6 @@ def main(): services = [] services.extend(app_mgr.instantiate_apps(**contexts)) - # 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) diff --git a/ryu/controller/controller.py b/ryu/controller/controller.py index 5d71d3c5..f9b592f9 100644 --- a/ryu/controller/controller.py +++ b/ryu/controller/controller.py @@ -322,9 +322,3 @@ def datapath_connection_factory(socket, address): dpid_str = dpid_to_str(datapath.id) LOG.error("Error in the datapath %s from %s", dpid_str, address) raise - - -def start_service(app_mgr): - for app in app_mgr.applications.values(): - if app.__class__.__name__.endswith('OFPHandler'): - return OpenFlowController() diff --git a/ryu/controller/ofp_handler.py b/ryu/controller/ofp_handler.py index 642cec84..b95ff0ce 100644 --- a/ryu/controller/ofp_handler.py +++ b/ryu/controller/ofp_handler.py @@ -19,8 +19,10 @@ import logging import ryu.base.app_manager +from ryu.lib import hub from ryu import utils from ryu.controller import ofp_event +from ryu.controller.controller import OpenFlowController from ryu.controller.handler import set_ev_handler from ryu.controller.handler import HANDSHAKE_DISPATCHER, CONFIG_DISPATCHER,\ MAIN_DISPATCHER @@ -45,6 +47,10 @@ class OFPHandler(ryu.base.app_manager.RyuApp): super(OFPHandler, self).__init__(*args, **kwargs) self.name = 'ofp_event' + def start(self): + super(OFPHandler, self).start() + return hub.spawn(OpenFlowController()) + def _hello_failed(self, datapath, error_desc): self.logger.error(error_desc) error_msg = datapath.ofproto_parser.OFPErrorMsg(datapath)