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>
This commit is contained in:
parent
1b6b0c49d9
commit
63cc49360e
@ -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')
|
||||
|
||||
|
@ -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():
|
||||
|
Loading…
Reference in New Issue
Block a user