summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2012-06-09 20:06:19 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2012-06-09 20:06:19 +0900
commit63cc49360e89a337faa6f76d4d143d34de9fdf9f (patch)
tree0ec207b6d44d7c840dc2272097a728b509158f42
parent1b6b0c49d94b9e735dc389cf1805dad857b8fdfd (diff)
Pass AppManager module name instead of class name
RyuApp class is used as a base class for Ryu network application. So let's pass Ryu application module name instead of class name. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Reviewed-by: Isaku Yamahata <yamahata@valinux.co.jp>
-rwxr-xr-xbin/ryu-manager5
-rw-r--r--ryu/base/app_manager.py17
2 files changed, 17 insertions, 5 deletions
diff --git a/bin/ryu-manager b/bin/ryu-manager
index 2437275d..43e0cba4 100755
--- a/bin/ryu-manager
+++ b/bin/ryu-manager
@@ -35,9 +35,8 @@ from ryu.controller import controller
FLAGS = gflags.FLAGS
gflags.DEFINE_multistring('app_lists',
- ['ryu.app.simple_isolation.SimpleIsolation',
- 'ryu.app.rest.restapi',
- # 'ryu.app.event_dumper.EventDumper',
+ ['ryu.app.simple_isolation',
+ 'ryu.app.rest',
],
'application module name to run')
diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py
index 19e93160..7b44eed0 100644
--- a/ryu/base/app_manager.py
+++ b/ryu/base/app_manager.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2011 Nippon Telegraph and Telephone Corporation.
+# Copyright (C) 2011, 2012 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2011 Isaku Yamahata <yamahata at valinux co jp>
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -69,6 +69,16 @@ class AppManager(object):
self.contexts_cls = {}
self.contexts = {}
+ def load_app(self, name):
+ mod = utils.import_module(name)
+ for k, v in mod.__dict__.items():
+ try:
+ if issubclass(v, RyuApp):
+ return getattr(mod, k)
+ except TypeError:
+ pass
+ return None
+
def load_apps(self, app_lists):
for app_cls_name in itertools.chain.from_iterable([app_list.split(',')
for app_list
@@ -80,7 +90,10 @@ class AppManager(object):
# Yes, maybe for slicing.
assert app_cls_name not in self.applications_cls
- cls = utils.import_object(app_cls_name)
+ cls = self.load_app(app_cls_name)
+ if cls is None:
+ continue
+
self.applications_cls[app_cls_name] = cls
for key, context_cls in cls.context_iteritems():