Example #1
0
 def flowmod(self,
             match=None,
             priority=None,
             inst=None,
             command=valve_of.ofp.OFPFC_ADD,
             out_port=0,
             out_group=0,
             hard_timeout=0,
             idle_timeout=0,
             cookie=None):
     """Helper function to construct a flow mod message with cookie."""
     if match is None:
         match = self.match()
     if priority is None:
         priority = 0  # self.dp.lowest_priority
     if inst is None:
         inst = []
     if cookie is None:
         cookie = self.flow_cookie
     flags = 0
     if self.notify_flow_removed:
         flags = valve_of.ofp.OFPFF_SEND_FLOW_REM
     return valve_of.flowmod(cookie, command, self.table_id, priority,
                             out_port, out_group, match, inst, hard_timeout,
                             idle_timeout, flags)
Example #2
0
 def flowmod(
         self,
         match=None,
         priority=None,  # pylint: disable=too-many-arguments
         inst=None,
         command=valve_of.ofp.OFPFC_ADD,
         out_port=0,
         out_group=0,
         hard_timeout=0,
         idle_timeout=0,
         cookie=None):
     """Helper function to construct a flow mod message with cookie."""
     if priority is None:
         priority = 0  # self.dp.lowest_priority
     if not match:
         match = self.match()
     if inst is None:
         inst = []
     if cookie is None:
         cookie = self.flow_cookie
     flags = 0
     if self.notify_flow_removed:
         flags = valve_of.ofp.OFPFF_SEND_FLOW_REM
     if inst:
         inst = self._trim_inst(inst)
     flowmod = valve_of.flowmod(cookie, command, self.table_id, priority,
                                out_port, out_group, match, inst,
                                hard_timeout, idle_timeout, flags)
     self._verify_flowmod(flowmod)
     return flowmod
Example #3
0
 def flowmod(self, match=None, priority=None, # pylint: disable=too-many-arguments
             inst=None, command=valve_of.ofp.OFPFC_ADD, out_port=0,
             out_group=0, hard_timeout=0, idle_timeout=0, cookie=None):
     """Helper function to construct a flow mod message with cookie."""
     if priority is None:
         priority = 0 # self.dp.lowest_priority
     if not match:
         match = self.match()
     if inst is None:
         inst = []
     if cookie is None:
         cookie = self.flow_cookie
     flags = 0
     if self.notify_flow_removed:
         flags = valve_of.ofp.OFPFF_SEND_FLOW_REM
     flowmod = valve_of.flowmod(
         cookie,
         command,
         self.table_id,
         priority,
         out_port,
         out_group,
         match,
         inst,
         hard_timeout,
         idle_timeout,
         flags)
     self._verify_flowmod(flowmod)
     return flowmod
Example #4
0
 def test_delete_order(self):
     """Test delete ordering/deupdlication."""
     global_groupdel = valve_of.groupdel(group_id=valve_of.ofp.OFPG_ALL)
     global_flowdel = valve_of.flowmod(cookie=None,
                                       hard_timeout=None,
                                       idle_timeout=None,
                                       match_fields=None,
                                       out_port=None,
                                       table_id=valve_of.ofp.OFPTT_ALL,
                                       inst=(),
                                       priority=0,
                                       command=valve_of.ofp.OFPFC_DELETE,
                                       out_group=valve_of.ofp.OFPG_ANY)
     flowdel = valve_of.flowmod(cookie=None,
                                hard_timeout=None,
                                idle_timeout=None,
                                match_fields=None,
                                out_port=None,
                                table_id=9,
                                inst=(),
                                priority=0,
                                command=valve_of.ofp.OFPFC_DELETE,
                                out_group=valve_of.ofp.OFPG_ANY)
     flow = valve_of.output_port(1)
     flows = [flowdel, flow, flow, flow, global_flowdel, global_groupdel]
     reordered = valve_of.valve_flowreorder(flows, use_barriers=True)
     reordered_str = [str(flow) for flow in reordered]
     # global deletes come first
     self.assertTrue(valve_of.is_global_groupdel(reordered[0]),
                     msg=reordered)
     self.assertTrue(valve_of.is_global_flowdel(reordered[1]),
                     msg=reordered)
     # with a berrier
     self.assertEqual(str(valve_of.barrier()),
                      str(reordered[2]),
                      msg=reordered)
     # without the individual delete
     self.assertTrue(str(flowdel) not in reordered_str, msg=reordered)
     # with regular flow last
     self.assertEqual(str(flow), reordered_str[-1], msg=reordered)