diff options
author | Yuichi Ito <ito.yuichi0@gmail.com> | 2014-06-23 14:40:24 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-06-23 17:10:24 +0900 |
commit | b9034c18bf894d66ba6b3836480f749ae5ac9354 (patch) | |
tree | 19e60d27f7c282145ff764580f8a3b34f9569223 | |
parent | 7aa71165d77aeb34cf7b7242d83577569a3baebe (diff) |
sw test tool: Add support for using user-specified versions
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/tests/switch/tester.py | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/ryu/tests/switch/tester.py b/ryu/tests/switch/tester.py index 98788a92..d104a58c 100644 --- a/ryu/tests/switch/tester.py +++ b/ryu/tests/switch/tester.py @@ -47,8 +47,10 @@ from ryu.lib import dpid as dpid_lib from ryu.lib import hub from ryu.lib import stringify from ryu.lib.packet import packet +from ryu.ofproto import ofproto_protocol from ryu.ofproto import ofproto_v1_3 from ryu.ofproto import ofproto_v1_3_parser +from ryu.ofproto import ofproto_v1_4 """ Required test network: @@ -255,7 +257,8 @@ class TestError(TestMessageBase): class OfTester(app_manager.RyuApp): """ OpenFlow Switch Tester. """ - OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION] + tester_ver = None + target_ver = None def __init__(self): super(OfTester, self).__init__() @@ -267,6 +270,31 @@ class OfTester(app_manager.RyuApp): dpid_lib.dpid_to_str(self.target_dpid)) self.logger.info('tester_dpid=%s', dpid_lib.dpid_to_str(self.tester_dpid)) + + def __get_version(opt): + vers = { + 'openflow13': ofproto_v1_3.OFP_VERSION, + 'openflow14': ofproto_v1_4.OFP_VERSION + } + ver = vers.get(opt.lower()) + if ver is None: + self.logger.error( + '%s is not supported. ' + 'Supported versions are openflow13 and openflow14.', + opt) + self._test_end() + return ver + + target_opt = CONF['test-switch']['target_version'] + self.logger.info('target ofp version=%s', target_opt) + OfTester.target_ver = __get_version(target_opt) + tester_opt = CONF['test-switch']['tester_version'] + self.logger.info('tester ofp version=%s', tester_opt) + OfTester.tester_ver = __get_version(tester_opt) + # set app_supported_versions later. + ofproto_protocol.set_app_supported_versions( + [OfTester.target_ver, OfTester.tester_ver]) + test_dir = CONF['test-switch']['dir'] self.logger.info('Test files directory = %s', test_dir) @@ -317,15 +345,27 @@ class OfTester(app_manager.RyuApp): self._unregister_sw(ev.datapath) def _register_sw(self, dp): + vers = { + ofproto_v1_3.OFP_VERSION: 'openflow13', + ofproto_v1_4.OFP_VERSION: 'openflow14' + } if dp.id == self.target_dpid: - self.target_sw.dp = dp - msg = 'Join target SW.' + if dp.ofproto.OFP_VERSION != OfTester.target_ver: + msg = 'Join target SW, but ofp version is not %s.' % \ + vers[OfTester.target_ver] + else: + self.target_sw.dp = dp + msg = 'Join target SW.' elif dp.id == self.tester_dpid: - self.tester_sw.dp = dp - self.tester_sw.add_flow( - in_port=TESTER_RECEIVE_PORT, - out_port=dp.ofproto.OFPP_CONTROLLER) - msg = 'Join tester SW.' + if dp.ofproto.OFP_VERSION != OfTester.tester_ver: + msg = 'Join tester SW, but ofp version is not %s.' % \ + vers[OfTester.tester_ver] + else: + self.tester_sw.dp = dp + self.tester_sw.add_flow( + in_port=TESTER_RECEIVE_PORT, + out_port=dp.ofproto.OFPP_CONTROLLER) + msg = 'Join tester SW.' else: msg = 'Connect unknown SW.' if dp.id: |