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.tomon...@lab.ntt.co.jp>
---
 bin/ryu-manager         |    5 ++---
 ryu/base/app_manager.py |   17 +++++++++++++++--
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/bin/ryu-manager b/bin/ryu-manager
index 2437275..43e0cba 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 19e9316..75aba54 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:
+                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():
-- 
1.7.4.4


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to