diff options
author | 2015-10-20 03:17:08 +0300 | |
---|---|---|
committer | 2015-10-20 03:17:08 +0300 | |
commit | d09df99769f67819c64a7a025dbdcd39811c7b44 (patch) | |
tree | 83295a4dab4caead57a2abb9478671389547b936 /scripts/automation/trex_control_plane/client_utils | |
parent | 80bd7895112cba0b3cbb6d56995def6ffbdccf33 (diff) |
Major progress in console, yaml utils, and trex_streams
basically done, minor changes remianing
BIG ISSUE LEFT: rewire console to work with trexstateless client module
Diffstat (limited to 'scripts/automation/trex_control_plane/client_utils')
3 files changed, 67 insertions, 44 deletions
diff --git a/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py b/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py index 8c8987b6..b2d83cff 100755 --- a/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py +++ b/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py @@ -458,32 +458,55 @@ class TrexStatelessClient(JsonRpcClient): return snap # add stream - def add_stream (self, port_id, stream_id, isg, next_stream_id, packet): - if not port_id in self.get_owned_ports(): - return False, "Port {0} is not owned... please take ownership before adding streams".format(port_id) - - handler = self.port_handlers[port_id] - - stream = {} - stream['enabled'] = True - stream['self_start'] = True - stream['isg'] = isg - stream['next_stream_id'] = next_stream_id - stream['packet'] = {} - stream['packet']['binary'] = packet - stream['packet']['meta'] = "" - stream['vm'] = [] - stream['rx_stats'] = {} - stream['rx_stats']['enabled'] = False - - stream['mode'] = {} - stream['mode']['type'] = 'continuous' - stream['mode']['pps'] = 10.0 - - params = {} - params['handler'] = handler - params['stream'] = stream - params['port_id'] = port_id - params['stream_id'] = stream_id - - return self.invoke_rpc_method('add_stream', params = params) + # def add_stream (self, port_id, stream_id, isg, next_stream_id, packet, vm=[]): + # if not port_id in self.get_owned_ports(): + # return False, "Port {0} is not owned... please take ownership before adding streams".format(port_id) + # + # handler = self.port_handlers[port_id] + # + # stream = {} + # stream['enabled'] = True + # stream['self_start'] = True + # stream['isg'] = isg + # stream['next_stream_id'] = next_stream_id + # stream['packet'] = {} + # stream['packet']['binary'] = packet + # stream['packet']['meta'] = "" + # stream['vm'] = vm + # stream['rx_stats'] = {} + # stream['rx_stats']['enabled'] = False + # + # stream['mode'] = {} + # stream['mode']['type'] = 'continuous' + # stream['mode']['pps'] = 10.0 + # + # params = {} + # params['handler'] = handler + # params['stream'] = stream + # params['port_id'] = port_id + # params['stream_id'] = stream_id + # + # print params + # return self.invoke_rpc_method('add_stream', params = params) + + def add_stream(self, port_id_array, stream_pack_list): + batch = self.create_batch() + + for port_id in port_id_array: + for stream_pack in stream_pack_list: + params = {"port_id": port_id, + "handler": self.port_handlers[port_id], + "stream_id": stream_pack.stream_id, + "stream": stream_pack.stream} + batch.add("add_stream", params=params) + rc, resp_list = batch.invoke() + if not rc: + return rc, resp_list + + for i, rc in enumerate(resp_list): + if rc[0]: + self.port_handlers[port_id_array[i]] = rc[1] + + return True, resp_list + + # return self.invoke_rpc_method('add_stream', params = params) 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 caa6eab3..3aeb6a34 100755 --- a/scripts/automation/trex_control_plane/client_utils/packet_builder.py +++ b/scripts/automation/trex_control_plane/client_utils/packet_builder.py @@ -889,7 +889,7 @@ class CTRexPktBuilder(object): dictionary holds variable data of VM variable """ - return {"ins_name": "flow_var", # VM variable dump always refers to manipulate instruction. + return {"type": "flow_var", # VM variable dump always refers to manipulate instruction. "name": self.name, "size": self.size, "op": self.operation, diff --git a/scripts/automation/trex_control_plane/client_utils/yaml_utils.py b/scripts/automation/trex_control_plane/client_utils/yaml_utils.py index 024b73c2..414744fc 100755 --- a/scripts/automation/trex_control_plane/client_utils/yaml_utils.py +++ b/scripts/automation/trex_control_plane/client_utils/yaml_utils.py @@ -31,18 +31,18 @@ class CTRexYAMLLoader(object): self.ref_obj = None def check_term_param_type(self, val, val_field, ref_val, multiplier): - print val, val_field, ref_val + # print val, val_field, ref_val tmp_type = ref_val.get('type') if isinstance(tmp_type, list): # item can be one of multiple types - print "multiple choice!" + # print "multiple choice!" python_types = set() for t in tmp_type: if t in self.TYPE_DICT: python_types.add(self.TYPE_DICT.get(t)) else: return False, TypeError("Unknown resolving for type {0}".format(t)) - print "python legit types: ", python_types + # print "python legit types: ", python_types if type(val) not in python_types: return False, TypeError("Type of object field '{0}' is not allowed".format(val_field)) else: @@ -58,7 +58,7 @@ class CTRexYAMLLoader(object): return True, CTRexYAMLLoader._calc_final_value(val, multiplier, ref_val.get('multiply', False)) def get_reference_default(self, root_obj, sub_obj, key): - print root_obj, sub_obj, key + # print root_obj, sub_obj, key if sub_obj: ref_field = self.ref_obj.get(root_obj).get(sub_obj).get(key) else: @@ -77,7 +77,7 @@ class CTRexYAMLLoader(object): if isinstance(evaluated_obj, dict) and evaluated_obj.keys() == [root_obj]: evaluated_obj = evaluated_obj.get(root_obj) if not self.ref_obj: - self.ref_obj = load_yaml_to_any_obj(self.yaml_path) + self.ref_obj = load_yaml_to_obj(self.yaml_path) # self.load_reference() ref_item = self.ref_obj.get(root_obj) if ref_item is not None: @@ -85,30 +85,30 @@ class CTRexYAMLLoader(object): typed_obj = [False, None] # first item stores validity (multiple object "shapes"), second stored type if "type" in evaluated_obj: ref_item = ref_item[evaluated_obj.get("type")] - print "lower resolution with typed object" + # print "lower resolution with typed object" typed_obj = [True, evaluated_obj.get("type")] if isinstance(ref_item, dict) and "type" not in ref_item: # this is not a terminal result_obj = {} if typed_obj[0]: result_obj["type"] = typed_obj[1] - print "processing dictionary non-terminal value" + # print "processing dictionary non-terminal value" for k, v in ref_item.items(): - print "processing element '{0}' with value '{1}'".format(k,v) + # print "processing element '{0}' with value '{1}'".format(k,v) if k in evaluated_obj: # validate with ref obj - print "found in evaluated object!" + # print "found in evaluated object!" tmp_type = v.get('type') - print tmp_type - print evaluated_obj + # print tmp_type + # print evaluated_obj if tmp_type == "object": # go deeper into nesting hierarchy - print "This is an object type, recursion!" + # print "This is an object type, recursion!" result_obj[k] = self.validate_yaml(evaluated_obj.get(k), k, fill_defaults, multiplier) else: # validation on terminal type - print "Validating terminal type %s" % k + # print "Validating terminal type %s" % k res_ok, data = self.check_term_param_type(evaluated_obj.get(k), k, v, multiplier) - print "Validating: ", res_ok + # print "Validating: ", res_ok if res_ok: # data field contains the value to save result_obj[k] = data |