From: Isaku Yamahata <yamah...@valinux.co.jp>

Later VRRP service creates/deletes RyuApp dynamically as VRRP router
is enabled/disabled.
When creating/deleting RyuApp, unique RyuManager should be used.
There needs a way to get a unique RyuApp. So introduce singleton pattern

Signed-off-by: Isaku Yamahata <yamah...@valinux.co.jp>
Signed-off-by: YAMAMOTO Takashi <yamam...@valinux.co.jp>
---
 ryu/base/app_manager.py | 9 +++++++++
 ryu/cmd/manager.py      | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py
index fc034db..76abecc 100644
--- a/ryu/base/app_manager.py
+++ b/ryu/base/app_manager.py
@@ -149,6 +149,15 @@ class RyuApp(object):
 
 
 class AppManager(object):
+    # singletone
+    _instance = None
+
+    @staticmethod
+    def get_instance():
+        if not AppManager._instance:
+            AppManager._instance = AppManager()
+        return AppManager._instance
+
     def __init__(self):
         self.applications_cls = {}
         self.applications = {}
diff --git a/ryu/cmd/manager.py b/ryu/cmd/manager.py
index 8386705..82dc60a 100755
--- a/ryu/cmd/manager.py
+++ b/ryu/cmd/manager.py
@@ -63,7 +63,7 @@ def main():
 
     app_lists = CONF.app_lists + CONF.app
 
-    app_mgr = AppManager()
+    app_mgr = AppManager.get_instance()
     app_mgr.load_apps(app_lists)
     contexts = app_mgr.create_contexts()
     app_mgr.instantiate_apps(**contexts)
-- 
1.8.3.1


------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to