summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/common
diff options
context:
space:
mode:
authorDan Klein <danklein10@gmail.com>2016-01-04 23:31:18 +0200
committerDan Klein <danklein10@gmail.com>2016-01-04 23:31:18 +0200
commit3757099103ed1bf56f85ccf5bb861a331287cbbb (patch)
treefe512d642c210fd0f1e4818ec6dce75d09c99b5a /scripts/automation/trex_control_plane/common
parent4ca24cf31919870a684fe78f17c856e0d220e6d5 (diff)
updated stats
Diffstat (limited to 'scripts/automation/trex_control_plane/common')
-rwxr-xr-xscripts/automation/trex_control_plane/common/trex_stats.py48
1 files changed, 46 insertions, 2 deletions
diff --git a/scripts/automation/trex_control_plane/common/trex_stats.py b/scripts/automation/trex_control_plane/common/trex_stats.py
index 9562f1f5..d77d3558 100755
--- a/scripts/automation/trex_control_plane/common/trex_stats.py
+++ b/scripts/automation/trex_control_plane/common/trex_stats.py
@@ -17,9 +17,9 @@ COMPACT = {GLOBAL_STATS, PORT_STATS}
ExportableStats = namedtuple('ExportableStats', ['raw_data', 'text_table'])
-class CTRexStatsGenerator(object):
+class CTRexInfoGenerator(object):
"""
- This object is responsible of generating stats from objects maintained at
+ This object is responsible of generating stats and information from objects maintained at
CTRexStatelessClient and the ports.
"""
@@ -39,6 +39,20 @@ class CTRexStatsGenerator(object):
# ignore by returning empty object
return {}
+ def generate_streams_info(self, port_id_list, stream_id_list):
+ relevant_ports = self.__get_relevant_ports(port_id_list)
+
+ # TODO: change to dict comperhantion
+ return_data = {}
+ for port_id in relevant_ports:
+ return_data[port_id] = self._generate_single_port_streams_info(port_id, stream_id_list)
+
+ return return_data
+
+ @staticmethod
+ def _trim_packet_headers(headers_str):
+ pass
+
def _generate_global_stats(self):
# stats_obj = self._async_stats.get_general_stats()
stats_data = self._global_stats.generate_stats()
@@ -131,6 +145,36 @@ class CTRexStatsGenerator(object):
return {"port_status": ExportableStats(return_stats_data, stats_table)}
+ def _generate_single_port_streams_info(self, port_id, stream_id_list):
+
+ return_stream_data = []
+ port_status = port_obj.generate_port_status()
+
+ for stream_id in sorted(stream_id_list):
+ return_stream_data.append(OrderedDict([("packet_type", self._trim_packet_headers()),
+ ("length", ),
+ ("mode",),
+ ("rate",),
+ ("next_stream",)
+ ]))
+
+ per_field_stats = OrderedDict([("owner", []),
+ ("state", []),
+ ("--", []),])
+
+
+ info_table = text_tables.TRexTextTable()
+ info_table.set_cols_align(["l"] + ["c"]*len(relevant_ports))
+ info_table.set_cols_width([10] + [20] * len(relevant_ports))
+
+ info_table.add_rows([[k] + v
+ for k, v in per_field_status.iteritems()],
+ header=False)
+ info_table.header(["stream id", "packet type", "length", "mode", "rate", "next stream"])
+
+ return ExportableStats(return_stats_data, info_table)
+
+
def __get_relevant_ports(self, port_id_list):
# fetch owned ports
ports = [port_obj