summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYAMAMOTO Takashi <yamamoto@valinux.co.jp>2014-06-12 18:05:23 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-06-19 11:50:13 +0900
commitecbb8640f5934831d086172676f3bab29a9c32a4 (patch)
treed9703966b824b3e2ae3d212ef2026348b3c64fa5
parent771fb7950182d1b9e21b00d9dc0deefdfaef69ed (diff)
AppManager: Add a convenient method to run apps
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/base/app_manager.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py
index 357d34d6..c28ed74a 100644
--- a/ryu/base/app_manager.py
+++ b/ryu/base/app_manager.py
@@ -31,6 +31,7 @@ import os
from ryu import cfg
from ryu import utils
+from ryu.app import wsgi
from ryu.controller.handler import register_instance, get_dependent_services
from ryu.controller.controller import Datapath
from ryu.controller import event
@@ -326,6 +327,25 @@ class AppManager(object):
_instance = None
@staticmethod
+ def run_apps(app_lists):
+ """Run a set of Ryu applications
+
+ A convenient method to load and instantiate apps.
+ This blocks until all relevant apps stop.
+ """
+ app_mgr = AppManager.get_instance()
+ app_mgr.load_apps(app_lists)
+ contexts = app_mgr.create_contexts()
+ services = app_mgr.instantiate_apps(**contexts)
+ webapp = wsgi.start_service(app_mgr)
+ if webapp:
+ services.append(hub.spawn(webapp))
+ try:
+ hub.joinall(services)
+ finally:
+ app_mgr.close()
+
+ @staticmethod
def get_instance():
if not AppManager._instance:
AppManager._instance = AppManager()