summaryrefslogtreecommitdiffstats
path: root/scripts/automation
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2015-09-21 18:27:02 +0300
committerimarom <imarom@cisco.com>2015-09-21 18:27:02 +0300
commitd9e1cc14540431aa8baf8480625aa54c2a7c7175 (patch)
tree5372329a16edcae2851d203337a046b29d35143c /scripts/automation
parent3f4249b20c0edfb6902d1e4b5ebd13244f5a17b7 (diff)
more refinments on the console
Diffstat (limited to 'scripts/automation')
-rw-r--r--scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py58
-rw-r--r--scripts/automation/trex_control_plane/console/trex_console.py7
-rw-r--r--scripts/automation/trex_control_plane/console/trex_status.py22
3 files changed, 86 insertions, 1 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 0d46ba11..893fd5e3 100644
--- a/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py
+++ b/scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py
@@ -389,4 +389,60 @@ class TrexStatelessClient(JsonRpcClient):
return rc, resp_list
- \ No newline at end of file
+ # snapshot will take a snapshot of all your owned ports for streams and etc.
+ def snapshot(self):
+
+
+ if len(self.get_owned_ports()) == 0:
+ return {}
+
+ snap = {}
+
+ batch = self.create_batch()
+
+ for port_id in self.get_owned_ports():
+
+ batch.add("get_port_stats", params = {"port_id": port_id, "handler": self.port_handlers[port_id]})
+ batch.add("get_stream_list", params = {"port_id": port_id, "handler": self.port_handlers[port_id]})
+
+ rc, resp_list = batch.invoke()
+ if not rc:
+ return rc, resp_list
+
+ # split the list to 2s
+ index = 0
+ for port_id in self.get_owned_ports():
+ if not resp_list[index] or not resp_list[index + 1]:
+ snap[port_id] = None
+ continue
+
+ # fetch the first two
+ stats = resp_list[index][1]
+ stream_list = resp_list[index + 1][1]
+
+ port = {}
+ port['status'] = stats['status']
+ port['stream_list'] = []
+
+ # get all the streams
+ if len(stream_list) > 0:
+ batch = self.create_batch()
+ for stream_id in stream_list:
+ batch.add("get_stream", params = {"port_id": port_id, "stream_id": stream_id, "handler": self.port_handlers[port_id]})
+
+ rc, stream_resp_list = batch.invoke()
+ if not rc:
+ port = {}
+
+ port['streams'] = {}
+ for i, resp in enumerate(stream_resp_list):
+ if resp[0]:
+ port['streams'][stream_list[i]] = resp[1]
+
+ snap[port_id] = port
+
+ # move to next one
+ index += 2
+
+
+ return snap \ No newline at end of file
diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py
index 509ec3ee..3aeab901 100644
--- a/scripts/automation/trex_control_plane/console/trex_console.py
+++ b/scripts/automation/trex_control_plane/console/trex_console.py
@@ -313,6 +313,13 @@ class TrexConsole(cmd.Cmd):
print "{:<30} {:<30}".format(cmd + " - ", help)
+ # do
+ #def do_snapshot (self, line):
+
+ #for key, value in self.rpc_client.snapshot()[1]['streams'].iteritems():
+ #print str(key) + " " + str(value)
+
+
# aliasing
do_exit = do_EOF = do_q = do_quit
diff --git a/scripts/automation/trex_control_plane/console/trex_status.py b/scripts/automation/trex_control_plane/console/trex_status.py
index 301b71f5..b881f9f5 100644
--- a/scripts/automation/trex_control_plane/console/trex_status.py
+++ b/scripts/automation/trex_control_plane/console/trex_status.py
@@ -235,6 +235,26 @@ class SinglePortPanel(TrexStatusPanel):
self.getwin().addstr(y, 2, "Streams:", curses.A_UNDERLINE)
y += 2
+ # stream table header
+ self.getwin().addstr(y, 2, "{:^15} {:^15} {:^15} {:^15} {:^15} {:^15} {:^15}".format(
+ "Stream ID", "Enabled", "Type", "Self Start", "ISG", "Next Stream", "VM"))
+ y += 2
+
+ # streams
+ if 'streams' in self.status_obj.snapshot[self.port_id]:
+ for stream_id, stream in self.status_obj.snapshot[self.port_id]['streams'].iteritems():
+ self.getwin().addstr(y, 2, "{:^15} {:^15} {:^15} {:^15} {:^15} {:^15} {:^15}".format(
+ stream_id,
+ ("True" if stream['stream']['enabled'] else "False"),
+ stream['stream']['mode']['type'],
+ ("True" if stream['stream']['self_start'] else "False"),
+ stream['stream']['isg'],
+ (stream['stream']['next_stream_id'] if stream['stream']['next_stream_id'] != -1 else "None"),
+ ("{0} instr.".format(len(stream['stream']['vm'])) if stream['stream']['vm'] else "None")))
+
+ y += 1
+
+ # new section - traffic
y += 2
self.getwin().addstr(y, 2, "Traffic:", curses.A_UNDERLINE)
@@ -279,6 +299,8 @@ class TrexStatus():
self.log = []
self.rpc_client = rpc_client
+ self.snapshot = self.rpc_client.snapshot()
+
# fetch server info
self.get_server_info()