Signed-off-by: YAMADA Hideki <yamada.hid...@po.ntts.co.jp>
---
 ryu/app/ofctl/api.py               |    2 +-
 ryu/base/app_manager.py            |   16 +++++++++++-----
 ryu/services/protocols/vrrp/api.py |    2 +-
 ryu/topology/api.py                |    2 +-
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/ryu/app/ofctl/api.py b/ryu/app/ofctl/api.py
index 569fd6a..64f06f0 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 c649fbe..d433c59 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 3357d45..288ca88 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 ed56ce7..7485a8e 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)
-- 
1.7.9.5


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to