diff options
author | Yuichi Ito <ito.yuichi0@gmail.com> | 2014-05-21 17:20:54 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-05-21 17:50:52 +0900 |
commit | d73d3bb136e9b2a2dd38f814d48305b2ef19107e (patch) | |
tree | 0731af8ad48c552c106a9c4c8a7beffe7269e629 | |
parent | fea1f610aa3c1c09cd976c1442f6b8e32e96b2b5 (diff) |
sw test tool: Reduce similar classes
TargetSw and TesterSw are merged as OpenFlowSw.
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 | 82 |
1 files changed, 36 insertions, 46 deletions
diff --git a/ryu/tests/switch/tester.py b/ryu/tests/switch/tester.py index 7468c74c..56b38cf1 100644 --- a/ryu/tests/switch/tester.py +++ b/ryu/tests/switch/tester.py @@ -257,8 +257,8 @@ class OfTester(app_manager.RyuApp): test_dir = CONF['test-switch']['dir'] self.logger.info('Test files directory = %s', test_dir) - self.target_sw = TargetSw(DummyDatapath(), self.logger) - self.tester_sw = TesterSw(DummyDatapath(), self.logger) + self.target_sw = OpenFlowSw(DummyDatapath(), self.logger) + self.tester_sw = OpenFlowSw(DummyDatapath(), self.logger) self.state = STATE_INIT_FLOW self.sw_waiter = None self.waiter = None @@ -1061,39 +1061,24 @@ class OpenFlowSw(object): match=match, instructions=inst) return self.send_msg(mod) - def send_barrier_request(self): - """ send a BARRIER_REQUEST message.""" - parser = self.dp.ofproto_parser - req = parser.OFPBarrierRequest(self.dp) - return self.send_msg(req) - - def send_port_stats(self): - """ Get port stats.""" - ofp = self.dp.ofproto - parser = self.dp.ofproto_parser - flags = 0 - req = parser.OFPPortStatsRequest(self.dp, flags, ofp.OFPP_ANY) - return self.send_msg(req) - - def send_flow_stats(self): - """ Get all flow. """ + def del_test_flow(self): + """ Delete all flow except default flow. """ ofp = self.dp.ofproto parser = self.dp.ofproto_parser - req = parser.OFPFlowStatsRequest(self.dp, 0, ofp.OFPTT_ALL, - ofp.OFPP_ANY, ofp.OFPG_ANY, - 0, 0, parser.OFPMatch()) - return self.send_msg(req) - - -class TargetSw(OpenFlowSw): - def __init__(self, dp, logger): - super(TargetSw, self).__init__(dp, logger) + mod = parser.OFPFlowMod(self.dp, + table_id=ofp.OFPTT_ALL, + command=ofp.OFPFC_DELETE, + out_port=ofp.OFPP_ANY, + out_group=ofp.OFPG_ANY) + return self.send_msg(mod) - def del_test_flow(self): + def del_flows_for_throughput_analysis(self): """ Delete all flow except default flow. """ ofp = self.dp.ofproto parser = self.dp.ofproto_parser mod = parser.OFPFlowMod(self.dp, + cookie=THROUGHPUT_COOKIE, + cookie_mask=0xffffffffffffffff, table_id=ofp.OFPTT_ALL, command=ofp.OFPFC_DELETE, out_port=ofp.OFPP_ANY, @@ -1110,6 +1095,29 @@ class TargetSw(OpenFlowSw): meter_id=ofp.OFPM_ALL) return self.send_msg(mod) + def send_barrier_request(self): + """ send a BARRIER_REQUEST message.""" + parser = self.dp.ofproto_parser + req = parser.OFPBarrierRequest(self.dp) + return self.send_msg(req) + + def send_port_stats(self): + """ Get port stats.""" + ofp = self.dp.ofproto + parser = self.dp.ofproto_parser + flags = 0 + req = parser.OFPPortStatsRequest(self.dp, flags, ofp.OFPP_ANY) + return self.send_msg(req) + + def send_flow_stats(self): + """ Get all flow. """ + ofp = self.dp.ofproto + parser = self.dp.ofproto_parser + req = parser.OFPFlowStatsRequest(self.dp, 0, ofp.OFPTT_ALL, + ofp.OFPP_ANY, ofp.OFPG_ANY, + 0, 0, parser.OFPMatch()) + return self.send_msg(req) + def send_meter_config_stats(self): """ Get all meter. """ parser = self.dp.ofproto_parser @@ -1122,24 +1130,6 @@ class TargetSw(OpenFlowSw): req = parser.OFPTableStatsRequest(self.dp, 0) return self.send_msg(req) - -class TesterSw(OpenFlowSw): - def __init__(self, dp, logger): - super(TesterSw, self).__init__(dp, logger) - - def del_flows_for_throughput_analysis(self): - """ Delete all flow except default flow. """ - ofp = self.dp.ofproto - parser = self.dp.ofproto_parser - mod = parser.OFPFlowMod(self.dp, - cookie=THROUGHPUT_COOKIE, - cookie_mask=0xffffffffffffffff, - table_id=ofp.OFPTT_ALL, - command=ofp.OFPFC_DELETE, - out_port=ofp.OFPP_ANY, - out_group=ofp.OFPG_ANY) - return self.send_msg(mod) - def send_packet_out(self, data): """ send a PacketOut message.""" ofp = self.dp.ofproto |