summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py
diff options
context:
space:
mode:
authorDan Klein <danklei@cisco.com>2015-10-20 03:17:08 +0300
committerDan Klein <danklei@cisco.com>2015-10-20 03:17:08 +0300
commitd09df99769f67819c64a7a025dbdcd39811c7b44 (patch)
tree83295a4dab4caead57a2abb9478671389547b936 /scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py
parent80bd7895112cba0b3cbb6d56995def6ffbdccf33 (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/jsonrpc_client.py')
-rwxr-xr-xscripts/automation/trex_control_plane/client_utils/jsonrpc_client.py81
1 files changed, 52 insertions, 29 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)