Hi, I need something to test nx stuff by actually talking with ovs. I use something crappy like the following. A tool like oftest tool to get a test description and do testings might be nice but doing all the testings is fine by me now. Can we integrate such stuff into our tools including some testings nicely? Or better to have stuff as a different mechanism?
Opinions? diff --git a/ryu/app/oftest.py b/ryu/app/oftest.py new file mode 100644 index 0000000..733fb2d --- /dev/null +++ b/ryu/app/oftest.py @@ -0,0 +1,92 @@ +# Copyright (C) 2012 Nippon Telegraph and Telephone Corporation. +# +# 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. + +from ryu.controller import handler +from ryu.controller import dpset +from ryu.ofproto import nx_match + + +class OFtest(object): + def __init__(self, *_args, **kwargs): + super(OFtest, self).__init__() + + @staticmethod + def _make_command(table, command): + return table << 8 | command + + def nx_action_bundle(self, dp): + wildcards = dp.ofproto.OFPFW_ALL & ~dp.ofproto.OFPFW_IN_PORT + in_port = 0 + match = dp.ofproto_parser.OFPMatch(wildcards, in_port, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + + actions = [] + actions.append(dp.ofproto_parser.NXActionBundle( + dp.ofproto.NX_BD_ALG_HRW, + dp.ofproto.NX_HASH_FIELDS_ETH_SRC, + 0, + dp.ofproto.NXM_OF_IN_PORT, + 2, + 0, + 0, + (0, 1))) + + command = self._make_command(0, dp.ofproto.OFPFC_ADD) + flow_mod = dp.ofproto_parser.OFPFlowMod(dp, match=match, + cookie=0, + command=command, + idle_timeout=0, + hard_timeout=0, + priority=0x1, + actions=actions) + dp.send_msg(flow_mod) + + def nx_action_bundle_load(self, dp): + wildcards = dp.ofproto.OFPFW_ALL & ~dp.ofproto.OFPFW_IN_PORT + in_port = 1 + match = dp.ofproto_parser.OFPMatch(wildcards, in_port, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + + actions = [] + actions.append(dp.ofproto_parser.NXActionBundleLoad( + dp.ofproto.NX_BD_ALG_HRW, + dp.ofproto.NX_HASH_FIELDS_ETH_SRC, + 0, + dp.ofproto.NXM_OF_IN_PORT, + 2, + 16, + dp.ofproto.nxm_nx_reg(1), + (0, 1))) + + command = self._make_command(0, dp.ofproto.OFPFC_ADD) + flow_mod = dp.ofproto_parser.OFPFlowMod(dp, match=match, + cookie=0, + command=command, + idle_timeout=0, + hard_timeout=0, + priority=0x1, + actions=actions) + dp.send_msg(flow_mod) + + + def test(self, dp): + self.nx_action_bundle(dp) + self.nx_action_bundle_load(dp) + + @handler.set_ev_cls(dpset.EventDP, dpset.DPSET_EV_DISPATCHER) + def handler_datapath(self, ev): + if ev.enter: + self.test(ev.dp) + ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
