Update _existed_flow_var_names. Now it returns all Flow var names. 81/5181/1
authorVyacheslav Ogai <[email protected]>
Wed, 30 Nov 2016 10:08:27 +0000 (12:08 +0200)
committerHanoh Haim <[email protected]>
Mon, 19 Dec 2016 14:04:07 +0000 (16:04 +0200)
Signed-off-by: Vyacheslav Ogai <[email protected]>
scripts/automation/trex_control_plane/stl/services/scapy_server/field_engine.json
scripts/automation/trex_control_plane/stl/services/scapy_server/scapy_service.py

index 30c8dc1..b5356eb 100644 (file)
       "name": "L4 offset",
       "type": "STRING",
       "required": true,
-      "defaultValue": "0"
+      "defaultValue": "TCP"
     },
     {
       "id": "ip_min",
index 9e617a8..9598ea9 100755 (executable)
@@ -807,7 +807,14 @@ class Scapy_service(Scapy_service_api):
         return {}
 
     def _existed_flow_var_names(self, instructions):
-        return {"map": dict((instruction['parameters']['name'], instruction['parameters']['name']) for instruction in instructions if instruction['id'] == "STLVmFlowVar")}
+        return {"map": dict((instruction['parameters']['name'], instruction['parameters']['name']) for instruction in instructions if self._nameParamterExist(instruction))}
+
+    def _nameParamterExist(self, instruction):
+        try:
+            instruction['parameters']['name']
+            return True
+        except KeyError:
+            return False
 
     def _curent_pkt_protocol_fields(self, given_protocol_ids, delimiter):
         given_protocol_classes = [c for c in Packet.__subclasses__() if c.__name__ in given_protocol_ids and c.__name__ != "Ether"]