summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/client_utils
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-01-13 11:26:18 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2016-01-13 11:26:18 +0200
commited203f303921a8d88fb32d2a5f8ff5097b6018fe (patch)
treefd281832552296a5629c3feb4318bf751b80aae3 /scripts/automation/trex_control_plane/client_utils
parent6092cc6f8b7d6d5f44b9c6cc600fc819257996e3 (diff)
update pkt builder vm
Diffstat (limited to 'scripts/automation/trex_control_plane/client_utils')
-rwxr-xr-xscripts/automation/trex_control_plane/client_utils/packet_builder.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/scripts/automation/trex_control_plane/client_utils/packet_builder.py b/scripts/automation/trex_control_plane/client_utils/packet_builder.py
index e7fdb5d9..fe96789e 100755
--- a/scripts/automation/trex_control_plane/client_utils/packet_builder.py
+++ b/scripts/automation/trex_control_plane/client_utils/packet_builder.py
@@ -730,9 +730,10 @@ class CTRexPktBuilder(object):
None
"""
super(CTRexPktBuilder.CTRexVM, self).__init__()
- self.vm_variables = {'instructions': [], 'split_by_var': ""}
+ self.vm_variables = {}
self._inst_by_offset = {} # this data structure holds only offset-related instructions, ordered in tuples
self._off_inst_by_name = {}
+ self.split_by_var = ''
def set_vm_var_field(self, var_name, field_name, val, offset_inst=False):
"""
@@ -836,26 +837,23 @@ class CTRexPktBuilder(object):
def dump(self):
"""
- dumps a VM variables (instructions) into a list data structure.
+ dumps a VM variables (instructions) and split_by_var into a dict data structure.
:parameters:
None
:return:
- list holds variables data of VM
+ dict with VM instructions as list and split_by_var as str
"""
- return self.vm_variables
- # !!! TODO: review code below !!!
-
# at first, dump all CTRexVMFlowVariable instructions
- ret_val = [var.dump()
- for key, var in self.vm_variables.items()]
+ inst_array = [var.dump() if hasattr(var, 'dump') else var
+ for key, var in self.vm_variables.items()]
# then, dump all the CTRexVMWrtFlowVarInst and CTRexVMChecksumInst instructions
- ret_val += [self._inst_by_offset.get(key).inst.dump()
- for key in sorted(self._inst_by_offset)]
- return ret_val
+ inst_array += [self._inst_by_offset.get(key).inst.dump()
+ for key in sorted(self._inst_by_offset)]
+ return {'instructions': inst_array, 'split_by_var': self.split_by_var}
class CVMAbstractInstruction(object):
__metaclass__ = ABCMeta