summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYAMADA Hideki <yamada.hideki@po.ntts.co.jp>2014-06-13 17:34:18 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-06-14 22:44:56 +0900
commita5c1841e449bd4455b9ebd48b8a65ec1206dbda7 (patch)
tree49ab351358725ee02962e40ac57a9d91c8b3d829
parent5474bf214c22ca459719ddbe786a3c9a8f967757 (diff)
app_manager: Let application module to use require_app()
Signed-off-by: YAMADA Hideki <yamada.hideki@po.ntts.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/app/ofctl/api.py2
-rw-r--r--ryu/base/app_manager.py16
-rw-r--r--ryu/services/protocols/vrrp/api.py2
-rw-r--r--ryu/topology/api.py2
4 files changed, 14 insertions, 8 deletions
diff --git a/ryu/app/ofctl/api.py b/ryu/app/ofctl/api.py
index 569fd6a9..64f06f0a 100644
--- a/ryu/app/ofctl/api.py
+++ b/ryu/app/ofctl/api.py
@@ -38,4 +38,4 @@ def send_msg(app, msg, reply_cls=None, reply_multi=False):
reply_multi=reply_multi))()
-app_manager.require_app('ryu.app.ofctl.service')
+app_manager.require_app('ryu.app.ofctl.service', api_style=True)
diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py
index c649fbea..d433c59a 100644
--- a/ryu/base/app_manager.py
+++ b/ryu/base/app_manager.py
@@ -65,17 +65,23 @@ def unregister_app(app):
SERVICE_BRICKS.pop(app.name)
-def require_app(app_name):
+def require_app(app_name, api_style=False):
"""
- Request the application to be loaded.
+ Request the application to be automatically loaded.
- This is used for "api" style modules, which is imported by a client
- application, to automatically load the corresponding server application.
+ If this is used for "api" style modules, which is imported by a client
+ application, set api_style=True.
+
+ If this is used for client application module, set api_style=False.
"""
- frm = inspect.stack()[2] # skip a frame for "api" module
+ if api_style:
+ frm = inspect.stack()[2] # skip a frame for "api" module
+ else:
+ frm = inspect.stack()[1]
m = inspect.getmodule(frm[0]) # client module
m._REQUIRED_APP = getattr(m, '_REQUIRED_APP', [])
m._REQUIRED_APP.append(app_name)
+ LOG.debug('require_app: %s is required by %s', app_name, m.__name__)
class RyuApp(object):
diff --git a/ryu/services/protocols/vrrp/api.py b/ryu/services/protocols/vrrp/api.py
index 3357d45f..288ca886 100644
--- a/ryu/services/protocols/vrrp/api.py
+++ b/ryu/services/protocols/vrrp/api.py
@@ -66,4 +66,4 @@ def vrrp_config_change(app, instance_name,
return app.send_event(vrrp_event.VRRP_MANAGER_NAME, config_change)
-app_manager.require_app('ryu.services.protocols.vrrp.manager')
+app_manager.require_app('ryu.services.protocols.vrrp.manager', api_style=True)
diff --git a/ryu/topology/api.py b/ryu/topology/api.py
index ed56ce78..7485a8e6 100644
--- a/ryu/topology/api.py
+++ b/ryu/topology/api.py
@@ -35,4 +35,4 @@ def get_all_link(app):
return get_link(app)
-app_manager.require_app('ryu.topology.switches')
+app_manager.require_app('ryu.topology.switches', api_style=True)