controller: use ProtocolDesc
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
5467e8b4a2
commit
c0fd8a0a95
@ -25,6 +25,7 @@ from ryu.controller.controller import Datapath
|
||||
from ryu.controller import event
|
||||
from ryu.controller.event import EventRequestBase, EventReplyBase
|
||||
from ryu.lib import hub
|
||||
from ryu.ofproto import ofproto_protocol
|
||||
|
||||
LOG = logging.getLogger('ryu.base.app_manager')
|
||||
|
||||
@ -346,12 +347,7 @@ class AppManager(object):
|
||||
LOG.info('instantiating app %s of %s', app_name, cls.__name__)
|
||||
|
||||
if hasattr(cls, 'OFP_VERSIONS') and not cls.OFP_VERSIONS is None:
|
||||
for k in Datapath.supported_ofp_version.keys():
|
||||
if not k in cls.OFP_VERSIONS:
|
||||
del Datapath.supported_ofp_version[k]
|
||||
|
||||
assert len(Datapath.supported_ofp_version), \
|
||||
'No OpenFlow version is available'
|
||||
ofproto_protocol.set_app_supported_versions(cls.OFP_VERSIONS)
|
||||
|
||||
if app_name is not None:
|
||||
assert app_name not in self.applications
|
||||
|
@ -27,14 +27,8 @@ import ryu.base.app_manager
|
||||
|
||||
from ryu.ofproto import ofproto_common
|
||||
from ryu.ofproto import ofproto_parser
|
||||
from ryu.ofproto import ofproto_protocol
|
||||
from ryu.ofproto import ofproto_v1_0
|
||||
from ryu.ofproto import ofproto_v1_0_parser
|
||||
from ryu.ofproto import ofproto_v1_2
|
||||
from ryu.ofproto import ofproto_v1_2_parser
|
||||
from ryu.ofproto import ofproto_v1_3
|
||||
from ryu.ofproto import ofproto_v1_3_parser
|
||||
from ryu.ofproto import ofproto_v1_4
|
||||
from ryu.ofproto import ofproto_v1_4_parser
|
||||
from ryu.ofproto import nx_match
|
||||
|
||||
from ryu.controller import handler
|
||||
@ -102,18 +96,7 @@ def _deactivate(method):
|
||||
return deactivate
|
||||
|
||||
|
||||
class Datapath(object):
|
||||
supported_ofp_version = {
|
||||
ofproto_v1_0.OFP_VERSION: (ofproto_v1_0,
|
||||
ofproto_v1_0_parser),
|
||||
ofproto_v1_2.OFP_VERSION: (ofproto_v1_2,
|
||||
ofproto_v1_2_parser),
|
||||
ofproto_v1_3.OFP_VERSION: (ofproto_v1_3,
|
||||
ofproto_v1_3_parser),
|
||||
ofproto_v1_4.OFP_VERSION: (ofproto_v1_4,
|
||||
ofproto_v1_4_parser),
|
||||
}
|
||||
|
||||
class Datapath(ofproto_protocol.ProtocolDesc):
|
||||
def __init__(self, socket, address):
|
||||
super(Datapath, self).__init__()
|
||||
|
||||
@ -125,7 +108,6 @@ class Datapath(object):
|
||||
# prevent it from eating memory up
|
||||
self.send_q = hub.Queue(16)
|
||||
|
||||
self.set_version(max(self.supported_ofp_version))
|
||||
self.xid = random.randint(0, self.ofproto.MAX_XID)
|
||||
self.id = None # datapath_id is unknown yet
|
||||
self.ports = None
|
||||
@ -142,10 +124,6 @@ class Datapath(object):
|
||||
ev.state = state
|
||||
self.ofp_brick.send_event_to_observers(ev, state)
|
||||
|
||||
def set_version(self, version):
|
||||
assert version in self.supported_ofp_version
|
||||
self.ofproto, self.ofproto_parser = self.supported_ofp_version[version]
|
||||
|
||||
# Low level socket handling layer
|
||||
@_deactivate
|
||||
def _recv_loop(self):
|
||||
|
Loading…
Reference in New Issue
Block a user