From 3757099103ed1bf56f85ccf5bb861a331287cbbb Mon Sep 17 00:00:00 2001 From: Dan Klein Date: Mon, 4 Jan 2016 23:31:18 +0200 Subject: updated stats --- .../trex_control_plane/common/trex_stats.py | 48 +++++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'scripts/automation/trex_control_plane/common') 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 -- cgit 1.2.3-korg