From: Isaku Yamahata <[email protected]> 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 <[email protected]> --- Changes v1 -> v2: - improve commit message Signed-off-by: YAMAMOTO Takashi <[email protected]> --- 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 cc1ea74..771301a 100755 --- a/bin/ryu-manager +++ b/bin/ryu-manager @@ -64,7 +64,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 94196c5..518ecd6 100644 --- a/ryu/base/app_manager.py +++ b/ryu/base/app_manager.py @@ -148,6 +148,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.8.1.5 ------------------------------------------------------------------------------ Get your SQL database under version control now! Version control is standard for application code, but databases havent caught up. So what steps can you take to put your SQL databases under version control? Why should you start doing it? Read more to find out. http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
