summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2015-12-08 11:42:59 -0500
committerimarom <imarom@cisco.com>2015-12-08 11:42:59 -0500
commit1355327e97e6d5ce5800fa4d6f879695922e8637 (patch)
tree8bb978ba68fa1c49585bca623cb3a5c883c976c0
parent8ed7433b1509c21e8840e8152c55e69b1a564dd4 (diff)
some modifications to the tables
added clear stats as well
-rwxr-xr-xscripts/automation/trex_control_plane/client/trex_stateless_client.py28
-rwxr-xr-xscripts/automation/trex_control_plane/common/trex_stats.py47
-rwxr-xr-xscripts/automation/trex_control_plane/console/trex_console.py9
-rw-r--r--scripts/automation/trex_control_plane/console/trex_tui.py29
4 files changed, 91 insertions, 22 deletions
diff --git a/scripts/automation/trex_control_plane/client/trex_stateless_client.py b/scripts/automation/trex_control_plane/client/trex_stateless_client.py
index 72dc5e1b..db0ed5bf 100755
--- a/scripts/automation/trex_control_plane/client/trex_stateless_client.py
+++ b/scripts/automation/trex_control_plane/client/trex_stateless_client.py
@@ -539,11 +539,19 @@ class Port(object):
class CTRexStatelessClient(object):
"""docstring for CTRexStatelessClient"""
+ # verbose levels
+ VERBOSE_SILENCE = 0
+ VERBOSE_REGULAR = 1
+ VERBOSE_HIGH = 2
+
def __init__(self, username, server="localhost", sync_port = 5050, async_port = 4500, virtual=False):
super(CTRexStatelessClient, self).__init__()
self.user = username
self.comm_link = CTRexStatelessClient.CCommLink(server, sync_port, virtual)
- self.verbose = False
+
+ # default verbose level
+ self.verbose = self.VERBOSE_REGULAR
+
self.ports = {}
self._connection_info = {"server": server,
"sync_port": sync_port,
@@ -571,6 +579,7 @@ class CTRexStatelessClient(object):
def get_port (self, port_id):
return self.ports.get(port_id, None)
+
################# events handler ######################
def add_event_log (self, msg, ev_type, show = False):
@@ -583,7 +592,7 @@ class CTRexStatelessClient(object):
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
self.events.append("{:<10} - {:^8} - {:}".format(st, prefix, format_text(msg, 'bold')))
- if show:
+ if show and self.check_verbose(self.VERBOSE_REGULAR):
print format_text("\n{:^8} - {:}".format(prefix, format_text(msg, 'bold')))
@@ -850,9 +859,22 @@ class CTRexStatelessClient(object):
if port_obj.is_transmitting()]
def set_verbose(self, mode):
- self.comm_link.set_verbose(mode)
+
+ # on high - enable link verbose
+ if mode == self.VERBOSE_HIGH:
+ self.comm_link.set_verbose(True)
+ else:
+ self.comm_link.set_verbose(False)
+
self.verbose = mode
+
+ def check_verbose (self, level):
+ return (self.verbose >= level)
+
+ def get_verbose (self):
+ return self.verbose
+
############# server actions ################
# ping server
diff --git a/scripts/automation/trex_control_plane/common/trex_stats.py b/scripts/automation/trex_control_plane/common/trex_stats.py
index 1f9d59e3..671a0656 100755
--- a/scripts/automation/trex_control_plane/common/trex_stats.py
+++ b/scripts/automation/trex_control_plane/common/trex_stats.py
@@ -11,6 +11,8 @@ GLOBAL_STATS = 'g'
PORT_STATS = 'p'
PORT_STATUS = 'ps'
ALL_STATS_OPTS = {GLOBAL_STATS, PORT_STATS, PORT_STATUS}
+COMPACT = {GLOBAL_STATS, PORT_STATS}
+
ExportableStats = namedtuple('ExportableStats', ['raw_data', 'text_table'])
@@ -54,15 +56,24 @@ class CTRexStatsGenerator(object):
return_stats_data = {}
per_field_stats = OrderedDict([("owner", []),
- ("active", []),
+ ("state", []),
+ ("--", []),
+ ("opackets", []),
+ ("obytes", []),
+ ("ipackets", []),
+ ("ibytes", []),
+ ("ierrors", []),
+ ("oerrors", []),
("tx-bytes", []),
("rx-bytes", []),
("tx-pkts", []),
("rx-pkts", []),
- ("tx-errors", []),
- ("rx-errors", []),
- ("tx-BW", []),
- ("rx-BW", [])
+ ("---", []),
+ ("Tx bps", []),
+ ("Rx bps", []),
+ ("----", []),
+ ("Tx pps", []),
+ ("Rx pps", [])
]
)
@@ -76,6 +87,9 @@ class CTRexStatsGenerator(object):
stats_table = text_tables.TRexTextTable()
stats_table.set_cols_align(["l"] + ["r"]*len(relevant_ports))
+ stats_table.set_cols_width([10] + [20] * len(relevant_ports))
+ stats_table.set_cols_dtype(['t'] + ['t'] * len(relevant_ports))
+
stats_table.add_rows([[k] + v
for k, v in per_field_stats.iteritems()],
header=False)
@@ -106,6 +120,8 @@ class CTRexStatsGenerator(object):
stats_table = text_tables.TRexTextTable()
stats_table.set_cols_align(["l"] + ["c"]*len(relevant_ports))
+ stats_table.set_cols_width([10] + [20] * len(relevant_ports))
+
stats_table.add_rows([[k] + v
for k, v in per_field_status.iteritems()],
header=False)
@@ -250,15 +266,26 @@ class CPortStats(CTRexStats):
def generate_stats(self):
return {"owner": self._port_obj.user,
- "active": "YES" if self._port_obj.is_active() else "NO",
+ "state": self._port_obj.get_port_state_name(),
+ "--": "",
+ "opackets" : self.get_rel("opackets"),
+ "obytes" : self.get_rel("obytes"),
+ "ipackets" : self.get_rel("ipackets"),
+ "ibytes" : self.get_rel("ibytes"),
+ "ierrors" : self.get_rel("ierrors"),
+ "oerrors" : self.get_rel("oerrors"),
+
"tx-bytes": self.get_rel("obytes", format = True, suffix = "B"),
"rx-bytes": self.get_rel("ibytes", format = True, suffix = "B"),
"tx-pkts": self.get_rel("opackets", format = True, suffix = "pkts"),
"rx-pkts": self.get_rel("ipackets", format = True, suffix = "pkts"),
- "tx-errors": self.get_rel("oerrors", format = True),
- "rx-errors": self.get_rel("ierrors", format = True),
- "tx-BW": self.get("m_total_tx_bps", format = True, suffix = "bps"),
- "rx-BW": self.get("m_total_rx_bps", format = True, suffix = "bps")
+
+ "---": "",
+ "Tx bps": self.get("m_total_tx_bps", format = True, suffix = "bps"),
+ "Rx bps": self.get("m_total_rx_bps", format = True, suffix = "bps"),
+ "----": "",
+ "Tx pps": self.get("m_total_tx_pps", format = True, suffix = "pps"),
+ "Rx pps": self.get("m_total_rx_pps", format = True, suffix = "pps"),
}
diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py
index 8d52b2a4..9140977a 100755
--- a/scripts/automation/trex_control_plane/console/trex_console.py
+++ b/scripts/automation/trex_control_plane/console/trex_console.py
@@ -238,12 +238,12 @@ class TRexConsole(TRexGeneralCmd):
elif line == "on":
self.verbose = True
- self.stateless_client.set_verbose(True)
+ self.stateless_client.set_verbose(self.stateless_client.VERBOSE_HIGH)
print format_text("\nverbose set to on\n", 'green', 'bold')
elif line == "off":
self.verbose = False
- self.stateless_client.set_verbose(False)
+ self.stateless_client.set_verbose(self.stateless_client.VERBOSE_REGULAR)
print format_text("\nverbose set to off\n", 'green', 'bold')
else:
@@ -424,8 +424,11 @@ class TRexConsole(TRexGeneralCmd):
def do_tui (self, line):
'''Shows a graphical console\n'''
- self.do_verbose('off')
+ save_verbose = self.stateless_client.get_verbose()
+
+ self.stateless_client.set_verbose(self.stateless_client.VERBOSE_SILENCE)
self.tui.show()
+ self.stateless_client.set_verbose(save_verbose)
# quit function
def do_quit(self, line):
diff --git a/scripts/automation/trex_control_plane/console/trex_tui.py b/scripts/automation/trex_control_plane/console/trex_tui.py
index ea271985..c44efe15 100644
--- a/scripts/automation/trex_control_plane/console/trex_tui.py
+++ b/scripts/automation/trex_control_plane/console/trex_tui.py
@@ -33,16 +33,18 @@ class TrexTUIDashBoard(TrexTUIPanel):
super(TrexTUIDashBoard, self).__init__(mng, "dashboard")
self.key_actions = OrderedDict()
- self.key_actions['p'] = {'action': self.action_pause, 'legend': 'pause', 'show': True}
+
+ self.key_actions['c'] = {'action': self.action_clear, 'legend': 'clear', 'show': True}
+ self.key_actions['p'] = {'action': self.action_pause, 'legend': 'pause', 'show': True}
self.key_actions['r'] = {'action': self.action_resume, 'legend': 'resume', 'show': True}
- self.key_actions['+'] = {'action': self.action_raise, 'legend': 'up 5%', 'show': True}
- self.key_actions['-'] = {'action': self.action_lower, 'legend': 'low 5%', 'show': True}
+ self.key_actions['+'] = {'action': self.action_raise, 'legend': 'up 5%', 'show': True}
+ self.key_actions['-'] = {'action': self.action_lower, 'legend': 'low 5%', 'show': True}
self.ports = self.stateless_client.get_acquired_ports()
def show (self):
- stats = self.stateless_client.cmd_stats(self.ports, trex_stats.ALL_STATS_OPTS)
+ stats = self.stateless_client.cmd_stats(self.ports, trex_stats.COMPACT)
# print stats to screen
for stat_type, stat_data in stats.iteritems():
text_tables.print_table_with_header(stat_data.text_table, stat_type)
@@ -51,6 +53,8 @@ class TrexTUIDashBoard(TrexTUIPanel):
def get_key_actions (self):
allowed = {}
+ allowed['c'] = self.key_actions['c']
+
if len(self.stateless_client.get_transmitting_ports()) > 0:
allowed['p'] = self.key_actions['p']
allowed['+'] = self.key_actions['+']
@@ -121,6 +125,11 @@ class TrexTUIDashBoard(TrexTUIPanel):
return ""
+ def action_clear (self):
+ self.stateless_client.cmd_clear(self.mng.acquired_ports)
+ return "cleared all stats"
+
+
# port panel
class TrexTUIPort(TrexTUIPanel):
def __init__ (self, mng, port_id):
@@ -130,6 +139,8 @@ class TrexTUIPort(TrexTUIPanel):
self.port = self.mng.stateless_client.get_port(port_id)
self.key_actions = OrderedDict()
+
+ self.key_actions['c'] = {'action': self.action_clear, 'legend': 'clear', 'show': True}
self.key_actions['p'] = {'action': self.action_pause, 'legend': 'pause', 'show': True}
self.key_actions['r'] = {'action': self.action_resume, 'legend': 'resume', 'show': True}
self.key_actions['+'] = {'action': self.action_raise, 'legend': 'up 5%', 'show': True}
@@ -138,7 +149,7 @@ class TrexTUIPort(TrexTUIPanel):
def show (self):
- stats = self.stateless_client.cmd_stats([self.port_id], trex_stats.ALL_STATS_OPTS)
+ stats = self.stateless_client.cmd_stats([self.port_id], trex_stats.COMPACT)
# print stats to screen
for stat_type, stat_data in stats.iteritems():
text_tables.print_table_with_header(stat_data.text_table, stat_type)
@@ -147,6 +158,8 @@ class TrexTUIPort(TrexTUIPanel):
allowed = {}
+ allowed['c'] = self.key_actions['c']
+
if self.port.state == self.port.STATE_TX:
allowed['p'] = self.key_actions['p']
allowed['+'] = self.key_actions['+']
@@ -191,6 +204,10 @@ class TrexTUIPort(TrexTUIPanel):
else:
return ""
+ def action_clear (self):
+ self.stateless_client.cmd_clear([self.port_id])
+ return "port {0}: cleared stats".format(self.port_id)
+
# log
class TrexTUILog():
def __init__ (self):
@@ -239,7 +256,7 @@ class TrexTUIPanelManager():
def generate_legend (self):
- self.legend = "{:<12}".format("browse:")
+ self.legend = "\n{:<12}".format("browse:")
for k, v in self.key_actions.iteritems():
if v['show']: