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)