eae62b42ac
This patch fixes the following exception. ryu/controller/ofp_event.py: update cd /opt/stack/ryu && /opt/stack/ryu/bin/ryu-mana ^Mger --config-file /etc/ryu/ryu.conf || touch "/opt/stack/status/stack/ryu.failur ^Me" > Traceback (most recent call last): > File "/opt/stack/ryu/bin/ryu-manager", line 41, in <module> > from ryu.base.app_manager import AppManager > File "/opt/stack/ryu/ryu/base/app_manager.py", line 22, in <module> > from ryu.controller.handler import register_instance > File "/opt/stack/ryu/ryu/controller/handler.py", line 20, in <module> > from ryu.controller import ofp_event > File "/opt/stack/ryu/ryu/controller/ofp_event.py", line 69, in <module> > for ofp_mods in ofproto.get_ofp_module(): > TypeError: get_ofp_module() takes exactly 1 argument (0 given) Reported-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
78 lines
2.1 KiB
Python
78 lines
2.1 KiB
Python
# Copyright (C) 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");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
# implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import inspect
|
|
|
|
from ryu import ofproto
|
|
from ryu import utils
|
|
from . import event
|
|
|
|
|
|
class EventOFPMsgBase(event.EventBase):
|
|
def __init__(self, msg):
|
|
super(EventOFPMsgBase, self).__init__()
|
|
self.msg = msg
|
|
|
|
|
|
#
|
|
# Create ofp_event type corresponding to OFP Msg
|
|
#
|
|
|
|
_OFP_MSG_EVENTS = {}
|
|
|
|
|
|
def _ofp_msg_name_to_ev_name(msg_name):
|
|
return 'Event' + msg_name
|
|
|
|
|
|
def ofp_msg_to_ev(msg):
|
|
name = _ofp_msg_name_to_ev_name(msg.__class__.__name__)
|
|
return _OFP_MSG_EVENTS[name](msg)
|
|
|
|
|
|
def _create_ofp_msg_ev_class(msg_cls):
|
|
name = _ofp_msg_name_to_ev_name(msg_cls.__name__)
|
|
# print 'creating ofp_event %s' % name
|
|
|
|
if name in _OFP_MSG_EVENTS:
|
|
return
|
|
|
|
cls = type(name, (EventOFPMsgBase,),
|
|
dict(__init__=lambda self, msg:
|
|
super(self.__class__, self).__init__(msg)))
|
|
globals()[name] = cls
|
|
_OFP_MSG_EVENTS[name] = cls
|
|
|
|
|
|
def _create_ofp_msg_ev_from_module(ofp_praser):
|
|
# print mod
|
|
for _k, cls in inspect.getmembers(ofp_parser, inspect.isclass):
|
|
if not hasattr(cls, 'cls_msg_type'):
|
|
continue
|
|
_create_ofp_msg_ev_class(cls)
|
|
|
|
|
|
for ofp_mods in ofproto.get_ofp_modules().values():
|
|
ofp_parser = ofp_mods[1]
|
|
# print 'loading module %s' % ofp_parser
|
|
_create_ofp_msg_ev_from_module(ofp_parser)
|
|
|
|
|
|
class EventOFPStateChange(event.EventBase):
|
|
def __init__(self, dp):
|
|
super(EventOFPStateChange, self).__init__()
|
|
self.datapath = dp
|