diff options
author | 2016-01-13 11:26:18 +0200 | |
---|---|---|
committer | 2016-01-13 11:26:18 +0200 | |
commit | ed203f303921a8d88fb32d2a5f8ff5097b6018fe (patch) | |
tree | fd281832552296a5629c3feb4318bf751b80aae3 | |
parent | 6092cc6f8b7d6d5f44b9c6cc600fc819257996e3 (diff) |
update pkt builder vm
-rwxr-xr-x | scripts/automation/trex_control_plane/client_utils/packet_builder.py | 20 |
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 |