base/app_manager.py: sort out registering bricks

When registering RyuApps to observers with _EVENTS,
it should applied to @set_ev_cls methods, and dispatchers should be
honored.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Isaku Yamahata 2013-04-04 13:36:27 +09:00 committed by FUJITA Tomonori
parent e48512f555
commit d763da58bc

View File

@ -200,19 +200,20 @@ class AppManager(object):
for i in SERVICE_BRICKS.values():
for _k, m in inspect.getmembers(i, inspect.ismethod):
if hasattr(m, 'observer'):
# name is module name of ev_cls
name = m.observer.split('.')[-1]
if name in SERVICE_BRICKS:
brick = SERVICE_BRICKS[name]
brick.register_observer(m.ev_cls, i.name,
m.dispatchers)
if not hasattr(m, 'observer'):
continue
# name is module name of ev_cls
name = m.observer.split('.')[-1]
if name in SERVICE_BRICKS:
brick = SERVICE_BRICKS[name]
brick.register_observer(m.ev_cls, i.name, m.dispatchers)
# allow RyuApp and Event class are in different module
if hasattr(m, 'ev_cls'):
for brick in SERVICE_BRICKS.itervalues():
if m.ev_cls in brick._EVENTS:
brick.register_observer(m.ev_cls, i.name)
for brick in SERVICE_BRICKS.itervalues():
if m.ev_cls in brick._EVENTS:
brick.register_observer(m.ev_cls, i.name,
m.dispatchers)
for brick, i in SERVICE_BRICKS.items():
LOG.debug("BRICK %s" % brick)