action_list: throw exception if value is not an action
This is a programmer error, not a switch issue.
diff --git a/src/python/oftest/action_list.py b/src/python/oftest/action_list.py
index 628e067..75c014d 100644
--- a/src/python/oftest/action_list.py
+++ b/src/python/oftest/action_list.py
@@ -112,14 +112,11 @@
@param action The action to add
- @return True if successful, False if not an action object
-
"""
- if isinstance(action, action_class_list):
- tmp = copy.deepcopy(action)
- self.actions.append(tmp)
- return True
- return False
+ if not isinstance(action, action_class_list):
+ raise ValueError("%s is not an action" % type(action))
+ self.actions.append(copy.deepcopy(action))
+ return True # for backwards compatibility
def remove_type(self, type):
"""
@@ -163,9 +160,8 @@
"""
for act in other.actions:
- if not self.add(act):
- return False
- return True
+ self.add(act)
+ return True # for backwards compatibility
def __len__(self):
length = 0
diff --git a/src/python/oftest/testutils.py b/src/python/oftest/testutils.py
index 8ee212b..de7b52a 100644
--- a/src/python/oftest/testutils.py
+++ b/src/python/oftest/testutils.py
@@ -535,8 +535,7 @@
if action_list is not None:
for act in action_list:
logging.debug("Adding action " + act.show())
- rv = request.actions.add(act)
- parent.assertTrue(rv, "Could not add action" + act.show())
+ request.actions.add(act)
# Set up output/enqueue action if directed
if egr_queue is not None:
@@ -545,16 +544,12 @@
for egr_port in egr_port_list:
act.port = egr_port
act.queue_id = egr_queue
- rv = request.actions.add(act)
- parent.assertTrue(rv, "Could not add enqueue action " +
- str(egr_port) + " Q: " + str(egr_queue))
+ request.actions.add(act)
elif egr_ports is not None:
for egr_port in egr_port_list:
act = action.action_output()
act.port = egr_port
- rv = request.actions.add(act)
- parent.assertTrue(rv, "Could not add output action " +
- str(egr_port))
+ request.actions.add(act)
logging.debug(request.show())
@@ -637,14 +632,14 @@
msg.data = str(pkt)
if action_list is not None:
for act in action_list:
- assert(msg.actions.add(act))
+ msg.actions.add(act)
# Set up output action
if egr_ports is not None:
for egr_port in egr_ports:
act = action.action_output()
act.port = egr_port
- assert(msg.actions.add(act))
+ msg.actions.add(act)
logging.debug(msg.show())
rv = parent.controller.message_send(msg)
diff --git a/tests/FuncUtils.py b/tests/FuncUtils.py
index 82f1a4f..4d420da 100644
--- a/tests/FuncUtils.py
+++ b/tests/FuncUtils.py
@@ -39,7 +39,7 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
rv = self.controller.message_send(msg)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -67,7 +67,7 @@
act = action.action_output()
act.port = of_ports[2]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
rv = self.controller.message_send(msg)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -96,7 +96,7 @@
act1 = action.action_output()
act1.port = of_ports[1]
- self.assertTrue(msg1.actions.add(act1), "could not add action")
+ msg1.actions.add(act1)
rv = self.controller.message_send(msg1)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -124,7 +124,7 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
rv = self.controller.message_send(msg)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -151,7 +151,7 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
rv = self.controller.message_send(msg)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -176,7 +176,7 @@
msg2.match = match2
act2 = action.action_output()
act2.port = of_ports[1]
- self.assertTrue(msg2.actions.add(act2), "could not add action")
+ msg2.actions.add(act2)
if priority != None :
msg2.priority = priority
@@ -209,7 +209,7 @@
act3 = action.action_output()
act3.port = of_ports[1]
- self.assertTrue(msg3.actions.add(act3), "could not add action")
+ msg3.actions.add(act3)
if priority != None :
msg3.priority = priority
@@ -243,7 +243,7 @@
act3 = action.action_output()
act3.port = of_ports[2]
- self.assertTrue(msg3.actions.add(act3), "could not add action")
+ msg3.actions.add(act3)
if priority != None :
msg3.priority = priority
@@ -273,7 +273,7 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
rv = self.controller.message_send(msg)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -300,7 +300,7 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
rv = self.controller.message_send(msg)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -328,7 +328,7 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
rv = self.controller.message_send(msg)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -355,7 +355,7 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
rv = self.controller.message_send(msg)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -381,7 +381,7 @@
msg.priority = priority
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
rv = self.controller.message_send(msg)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -407,7 +407,7 @@
msg.priority = priority
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
rv = self.controller.message_send(msg)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -435,7 +435,7 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
rv = self.controller.message_send(msg)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -461,7 +461,7 @@
msg.priority = priority
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
rv = self.controller.message_send(msg)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -489,7 +489,7 @@
act = action.action_output()
act.port = of_ports[1]
- self.assertTrue(msg.actions.add(act), "could not add action")
+ msg.actions.add(act)
rv = self.controller.message_send(msg)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -510,7 +510,7 @@
msg5.buffer_id = 0xffffffff
act5 = action.action_output()
act5.port = egress_port
- self.assertTrue(msg5.actions.add(act5), "could not add action")
+ msg5.actions.add(act5)
if priority != None :
msg5.priority = priority
@@ -533,7 +533,7 @@
msg8.buffer_id = 0xffffffff
act8 = action.action_output()
act8.port = of_ports[2]
- self.assertTrue(msg8.actions.add(act8), "could not add action")
+ msg8.actions.add(act8)
if priority != None :
msg8.priority = priority
@@ -559,7 +559,7 @@
act = action.action_enqueue()
act.port = egress_port
act.queue_id = egress_queue_id
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
logging.info("Inserting flow")
rv = self.controller.message_send(request)
diff --git a/tests/basic.py b/tests/basic.py
index 862b6df..84c4d63 100644
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -212,7 +212,7 @@
msg.data = str(outpkt)
act = action.action_output()
act.port = dp_port
- self.assertTrue(msg.actions.add(act), 'Could not add action to msg')
+ msg.actions.add(act)
logging.info("PacketOut to: " + str(dp_port))
rv = self.controller.message_send(msg)
@@ -270,8 +270,7 @@
act = action.action_output()
for i in range(0,num_ports):
act.port = dp_ports[i]
- self.assertTrue(msg.actions.add(act),
- 'Could not add action to msg')
+ msg.actions.add(act)
logging.info("PacketOut to: " + str(dp_ports))
rv = self.controller.message_send(msg)
diff --git a/tests/bsn_mirror.py b/tests/bsn_mirror.py
index c0ecc07..fd211c8 100644
--- a/tests/bsn_mirror.py
+++ b/tests/bsn_mirror.py
@@ -149,9 +149,9 @@
act3.port = ports[1]
flow_mod = message.flow_mod()
flow_mod.match = match
- self.assertTrue(flow_mod.actions.add(act1), "Could not add mirror action")
- self.assertTrue(flow_mod.actions.add(act2), "Could not add mirror action")
- self.assertTrue(flow_mod.actions.add(act3), "Could not add output action")
+ flow_mod.actions.add(act1)
+ flow_mod.actions.add(act2)
+ flow_mod.actions.add(act3)
self.assertEqual(delete_all_flows(self.controller), 0,
"Failed to delete all flows")
self.assertNotEqual(self.controller.message_send(flow_mod), -1,
diff --git a/tests/detailed_contr_sw_messages.py b/tests/detailed_contr_sw_messages.py
index da1b046..25fc683 100644
--- a/tests/detailed_contr_sw_messages.py
+++ b/tests/detailed_contr_sw_messages.py
@@ -64,7 +64,8 @@
act3 = action.action_output()
act3.port = of_ports[1]
- self.assertTrue(msg3.actions.add(act3), "could not add action")
+ msg3.actions.add(act3)
+ msg3.actions.add(1)
rv = self.controller.message_send(msg3)
self.assertTrue(rv != -1, "Error installing flow mod")
self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
@@ -237,7 +238,7 @@
request.buffer_id = 0xffffffff
act3 = action.action_output()
act3.port = of_ports[1]
- self.assertTrue(request.actions.add(act3), "could not add action")
+ request.actions.add(act3)
logging.info("Inserting flow")
rv = self.controller.message_send(request)
@@ -780,7 +781,7 @@
msg3.match = match3
act3 = action.action_output()
act3.port = of_ports[1]
- self.assertTrue(msg3.actions.add(act3), "could not add action")
+ msg3.actions.add(act3)
rv = self.controller.message_send(msg3)
self.assertTrue(rv != -1, "Error installing flow mod")
diff --git a/tests/flow_expire.py b/tests/flow_expire.py
index ad35f23..93df5f8 100644
--- a/tests/flow_expire.py
+++ b/tests/flow_expire.py
@@ -65,7 +65,7 @@
request.idle_timeout = 1
request.flags |= ofp.OFPFF_SEND_FLOW_REM
act.port = egress_port
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
logging.info("Inserting flow")
rv = self.controller.message_send(request)
diff --git a/tests/flow_stats.py b/tests/flow_stats.py
index 040fec8..da12071 100644
--- a/tests/flow_stats.py
+++ b/tests/flow_stats.py
@@ -144,7 +144,7 @@
flow_mod_msg.hard_timeout = 65000
flow_mod_msg.priority = 100
act.port = egress_port
- self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
+ flow_mod_msg.actions.add(act)
# send flow
logging.info("Inserting flow")
@@ -197,7 +197,7 @@
flow_mod_msg.hard_timeout = 0
act = action.action_output()
act.port = egress_port
- self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
+ flow_mod_msg.actions.add(act)
logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
@@ -325,7 +325,7 @@
flow_mod_msg.hard_timeout = 0
act = action.action_output()
act.port = egress_port
- self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
+ flow_mod_msg.actions.add(act)
logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
@@ -504,7 +504,7 @@
flow_mod_msg.priority = 100
flow_mod_msg.flags = ofp.OFPFF_SEND_FLOW_REM
act.port = egress_port
- self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
+ flow_mod_msg.actions.add(act)
# send flow
logging.info("Inserting flow")
diff --git a/tests/load.py b/tests/load.py
index 6c8bda4..b35abc1 100644
--- a/tests/load.py
+++ b/tests/load.py
@@ -69,11 +69,11 @@
request.hard_timeout = 2 * barrier_count
request.buffer_id = 0xffffffff
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
act = action.action_output()
act.port = ofp.OFPP_CONTROLLER
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
rv = self.controller.message_send(request)
self.assertTrue(rv != -1, "Error installing flow mod")
@@ -85,7 +85,7 @@
msg.data = str(pkt)
act = action.action_output()
act.port = lb_port + 1
- self.assertTrue(msg.actions.add(act), 'Could not add action to msg')
+ msg.actions.add(act)
logging.info("Sleeping before starting storm")
time.sleep(1) # Root causing issue with fast disconnects
logging.info("Sending packet out to %d" % (lb_port + 1))
@@ -180,7 +180,7 @@
msg.data = str(outpkt)
act = action.action_output()
act.port = dp_port
- self.assertTrue(msg.actions.add(act), 'Could not add action to msg')
+ msg.actions.add(act)
logging.info("PacketOutLoad to: " + str(dp_port))
for count in range(100):
diff --git a/tests/openflow_protocol_messages.py b/tests/openflow_protocol_messages.py
index 80828c1..2d57978 100644
--- a/tests/openflow_protocol_messages.py
+++ b/tests/openflow_protocol_messages.py
@@ -232,7 +232,7 @@
msg.data = str(outpkt)
act = action.action_output()
act.port = dp_port
- self.assertTrue(msg.actions.add(act), 'Could not add action to msg')
+ msg.actions.add(act)
logging.info("PacketOut to: " + str(dp_port))
rv = self.controller.message_send(msg)
diff --git a/tests/pktact.py b/tests/pktact.py
index dff4420..5a1bedf 100644
--- a/tests/pktact.py
+++ b/tests/pktact.py
@@ -122,7 +122,7 @@
request.buffer_id = 0xffffffff
act.port = egress_port
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
logging.info("Inserting flow")
rv = self.controller.message_send(request)
@@ -188,7 +188,7 @@
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_CONTROLLER
act.max_len = 65535
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
logging.info("Inserting flow")
rv = self.controller.message_send(request)
@@ -277,7 +277,7 @@
request.buffer_id = 0xffffffff
act.port = egress_port
act.queue_id = egress_queue_id
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
logging.info("Inserting flow")
rv = self.controller.message_send(request)
@@ -408,7 +408,7 @@
request.buffer_id = 0xffffffff
act.port = egress_port
act.queue_id = egress_queue_id
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
logging.info("Inserting flow")
rv = self.controller.message_send(request)
@@ -527,9 +527,9 @@
request.match = match
request.buffer_id = 0xffffffff
act.port = egress_port1
- self.assertTrue(request.actions.add(act), "Could not add action1")
+ request.actions.add(act)
act.port = egress_port2
- self.assertTrue(request.actions.add(act), "Could not add action2")
+ request.actions.add(act)
# logging.info(request.show())
logging.info("Inserting flow")
@@ -585,8 +585,7 @@
if egress_port == ingress_port:
continue
act.port = egress_port
- self.assertTrue(request.actions.add(act),
- "Could not add output to " + str(egress_port))
+ request.actions.add(act)
logging.debug(request.show())
logging.info("Inserting flow")
@@ -640,8 +639,7 @@
act.port = ofp.OFPP_IN_PORT
else:
act.port = egress_port
- self.assertTrue(request.actions.add(act),
- "Could not add output to " + str(egress_port))
+ request.actions.add(act)
# logging.info(request.show())
logging.info("Inserting flow")
@@ -686,8 +684,7 @@
request.match = match
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_FLOOD
- self.assertTrue(request.actions.add(act),
- "Could not add flood port action")
+ request.actions.add(act)
logging.info(request.show())
logging.info("Inserting flow")
@@ -735,11 +732,9 @@
request.match = match
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_FLOOD
- self.assertTrue(request.actions.add(act),
- "Could not add flood port action")
+ request.actions.add(act)
act.port = ofp.OFPP_IN_PORT
- self.assertTrue(request.actions.add(act),
- "Could not add ingress port for output")
+ request.actions.add(act)
logging.info(request.show())
logging.info("Inserting flow")
@@ -784,8 +779,7 @@
request.match = match
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_ALL
- self.assertTrue(request.actions.add(act),
- "Could not add ALL port action")
+ request.actions.add(act)
logging.info(request.show())
logging.info("Inserting flow")
@@ -833,11 +827,9 @@
request.match = match
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_ALL
- self.assertTrue(request.actions.add(act),
- "Could not add ALL port action")
+ request.actions.add(act)
act.port = ofp.OFPP_IN_PORT
- self.assertTrue(request.actions.add(act),
- "Could not add ingress port for output")
+ request.actions.add(act)
logging.info(request.show())
logging.info("Inserting flow")
@@ -896,8 +888,7 @@
request.match = match
request.buffer_id = 0xffffffff
act.port = ofp.OFPP_FLOOD
- self.assertTrue(request.actions.add(act),
- "Could not add flood port action")
+ request.actions.add(act)
logging.info(request.show())
logging.info("Inserting flow")
@@ -1978,7 +1969,7 @@
request.priority = priority
act = action.action_output()
act.port = output_port
- self.assertTrue(request.actions.add(act), "Could not add action")
+ request.actions.add(act)
logging.info("Inserting flow")
self.controller.message_send(request)
@@ -2110,8 +2101,7 @@
request.buffer_id = 0xffffffff
for act in acts:
act.port = egress_port
- rv = request.actions.add(act)
- self.assertTrue(rv, "Could not add action")
+ request.actions.add(act)
logging.info("Inserting flow")
rv = self.controller.message_send(request)
diff --git a/tests/port_stats.py b/tests/port_stats.py
index 89b2cf6..eb7e612 100644
--- a/tests/port_stats.py
+++ b/tests/port_stats.py
@@ -172,7 +172,7 @@
flow_mod_msg.idle_timeout = 0
flow_mod_msg.hard_timeout = 0
act.port = egress_port
- self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
+ flow_mod_msg.actions.add(act)
# send flow
logging.info("Inserting flow")
@@ -219,7 +219,7 @@
flow_mod_msg.hard_timeout = 0
act = action.action_output()
act.port = egress_port
- self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
+ flow_mod_msg.actions.add(act)
logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))
@@ -299,7 +299,7 @@
flow_mod_msg.hard_timeout = 0
act = action.action_output()
act.port = egress_port
- self.assertTrue(flow_mod_msg.actions.add(act), "Could not add action")
+ flow_mod_msg.actions.add(act)
logging.info("Ingress " + str(ingress_port) +
" to egress " + str(egress_port))