def switch_features_handler(self, ev): datapath = ev.msg.datapath ofproto = datapath.ofproto parser = datapath.ofproto_parser actions = ofproto_parser.ofp_instruction_from_jsondict( datapath, ofp_instruction_from_str(ofproto, 'drop')) match = parser.OFPMatch(eth_dst='00:00:00:00:00:00') self.add_flow(datapath, 4, match, actions, 0) actions = [parser.NXActionResubmitTable(table_id=1)] match = parser.OFPMatch(ip_proto=0x06, eth_type=0x0800) self.add_flow(datapath, 2, match, actions, 0) actions = [parser.NXActionResubmitTable(table_id=2)] match = parser.OFPMatch() self.add_flow(datapath, 1, match, actions, 0) match = parser.OFPMatch() actions = [ parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, ofproto.OFPCML_NO_BUFFER) ] self.add_flow(datapath, 0, match, actions, 2) match = parser.OFPMatch() actions = [ parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, ofproto.OFPCML_NO_BUFFER) ] self.add_flow(datapath, 0, match, actions, 1)
def _test_str(self, dp, ofctl_str, *jsondict): json = ofctl_string.ofp_instruction_from_str( ofproto_v1_5, ofctl_str) inst = ofproto_parser.ofp_instruction_from_jsondict(dp, json) self.assertEqual(len(inst), len(jsondict)) for i in range(len(inst)): self.assertEqual(jsondict[i], inst[i].to_jsondict())
def _test_str(self, dp, ofctl_str, *jsondict): json = ofctl_string.ofp_instruction_from_str( ofproto_v1_5, ofctl_str) inst = ofproto_parser.ofp_instruction_from_jsondict(dp, json) self.assertEqual(len(inst), len(jsondict)) for i in range(len(inst)): self.assertEqual(jsondict[i], inst[i].to_jsondict())
def install_instructions(self, instructions, table_id=0, priority=0, match=None, active_bundle=None, **match_kwargs): (dp, ofp, ofpp) = self._get_dp() match = self._match(ofp, ofpp, match, **match_kwargs) if isinstance(instructions, six.string_types): # NOTE: instructions must be str for the ofctl of_interface. # After the ofctl driver is removed, a deprecation warning # could be added here. jsonlist = ofctl_string.ofp_instruction_from_str( ofp, instructions) instructions = ofproto_parser.ofp_instruction_from_jsondict( dp, jsonlist) msg = ofpp.OFPFlowMod(dp, table_id=table_id, cookie=self.default_cookie, match=match, priority=priority, instructions=instructions) self._send_msg(msg, active_bundle=active_bundle)
def install_instructions(self, instructions, table_id=0, priority=0, match=None, active_bundle=None, **match_kwargs): (dp, ofp, ofpp) = self._get_dp() match = self._match(ofp, ofpp, match, **match_kwargs) if isinstance(instructions, six.string_types): # NOTE: instructions must be str for the ofctl of_interface. # After the ofctl driver is removed, a deprecation warning # could be added here. jsonlist = ofctl_string.ofp_instruction_from_str( ofp, instructions) instructions = ofproto_parser.ofp_instruction_from_jsondict( dp, jsonlist) msg = ofpp.OFPFlowMod(dp, table_id=table_id, cookie=self.default_cookie, match=match, priority=priority, instructions=instructions) self._send_msg(msg, active_bundle=active_bundle)