diff options
author | Isaku Yamahata <yamahata@valinux.co.jp> | 2013-04-04 13:36:27 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2013-04-07 11:11:11 +0900 |
commit | d763da58bc6afaddcade0883b3b25244c1e55f62 (patch) | |
tree | be84268d44d2c340e852830945897599d90c6e0a | |
parent | e48512f555307cbcd4175e73a4292ef8f4467b0c (diff) |
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>
-rw-r--r-- | ryu/base/app_manager.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py index f285322e..ab6175ac 100644 --- a/ryu/base/app_manager.py +++ b/ryu/base/app_manager.py @@ -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) |