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)