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> --- Changes v1 -> v2: - improve commit message --- bin/ryu-manager | 2 +- ryu/base/app_manager.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/ryu-manager b/bin/ryu-manager index 5a3e76b..3208693 100755 --- a/bin/ryu-manager +++ b/bin/ryu-manager @@ -66,7 +66,7 @@ def main(): # always enable ofp for now. app_lists = CONF.app_lists + CONF.app + ['ryu.controller.ofp_handler'] - app_mgr = AppManager() + app_mgr = AppManager.get_instance() app_mgr.load_apps(app_lists) contexts = app_mgr.create_contexts() app_mgr.instantiate_apps(**contexts) diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py index 0112aab..aece004 100644 --- a/ryu/base/app_manager.py +++ b/ryu/base/app_manager.py @@ -144,6 +144,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 = {} -- 1.7.10.4 ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter _______________________________________________ Ryu-devel mailing list Ryu-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ryu-devel