base/app_manager: introduce singleton pattern to AppManager
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 <yamahata@valinux.co.jp> Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
5dd45aea0c
commit
2a10dfbd9c
@ -149,6 +149,15 @@ class RyuApp(object):
|
|||||||
|
|
||||||
|
|
||||||
class AppManager(object):
|
class AppManager(object):
|
||||||
|
# singletone
|
||||||
|
_instance = None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_instance():
|
||||||
|
if not AppManager._instance:
|
||||||
|
AppManager._instance = AppManager()
|
||||||
|
return AppManager._instance
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.applications_cls = {}
|
self.applications_cls = {}
|
||||||
self.applications = {}
|
self.applications = {}
|
||||||
|
@ -63,7 +63,7 @@ def main():
|
|||||||
|
|
||||||
app_lists = CONF.app_lists + CONF.app
|
app_lists = CONF.app_lists + CONF.app
|
||||||
|
|
||||||
app_mgr = AppManager()
|
app_mgr = AppManager.get_instance()
|
||||||
app_mgr.load_apps(app_lists)
|
app_mgr.load_apps(app_lists)
|
||||||
contexts = app_mgr.create_contexts()
|
contexts = app_mgr.create_contexts()
|
||||||
app_mgr.instantiate_apps(**contexts)
|
app_mgr.instantiate_apps(**contexts)
|
||||||
|
Loading…
Reference in New Issue
Block a user