message: convert lists passed as keyword arguments to action_lists
The basic module has been changed to use the new API.
diff --git a/tests/basic.py b/tests/basic.py
index a1540a1..3fa902b 100644
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -203,9 +203,8 @@
logging.info("PKT OUT test with %s, port %s" % (opt, dp_port))
msg = message.packet_out(in_port=ofp.OFPP_NONE,
- data=str(outpkt))
- act = action.action_output(port=dp_port)
- msg.actions.add(act)
+ data=str(outpkt),
+ actions=[action.action_output(port=dp_port)])
logging.info("PacketOut to: " + str(dp_port))
self.controller.message_send(msg)
@@ -255,11 +254,10 @@
dp_ports = of_ports[0:num_ports]
logging.info("PKT OUT test with " + opt +
", ports " + str(dp_ports))
+ actions = [action.action_output(port=port) for port in dp_ports]
msg = message.packet_out(in_port=ofp.OFPP_NONE,
- data=str(outpkt))
- for i in range(0,num_ports):
- act = action.action_output(port=dp_ports[i])
- msg.actions.add(act)
+ data=str(outpkt),
+ actions=actions)
logging.info("PacketOut to: " + str(dp_ports))
self.controller.message_send(msg)
diff --git a/tools/munger/scripts/message_gen.py b/tools/munger/scripts/message_gen.py
index 34036d3..053170a 100644
--- a/tools/munger/scripts/message_gen.py
+++ b/tools/munger/scripts/message_gen.py
@@ -302,10 +302,7 @@
_p2("self.header = ofp_header()")
_p2("self.header.type = " + msg_name)
if has_list:
- if list_type == None:
- _p2('self.' + list_var + ' = []')
- else:
- _p2('self.' + list_var + ' = ' + list_type + '()')
+ _p2('self.' + list_var + ' = []')
if has_string:
_p2('self.data = ""')
_p2('for (k, v) in kwargs.items():')
@@ -313,6 +310,9 @@
_p4('setattr(self, k, v)')
_p3('else:')
_p4('raise NameError("field %s does not exist in %s" % (k, self.__class__))')
+ if has_list and list_type != None:
+ _p2('# Coerce keyword arg into list type')
+ _p2('self.%(list_var)s = %(list_type)s(self.%(list_var)s)' % dict(list_type=list_type, list_var=list_var))
print """