summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-01-24 08:27:22 -0500
committerimarom <imarom@cisco.com>2016-01-24 08:28:19 -0500
commit7294d7f162e19e0ccd3a37eafbafe22cf63df6a4 (patch)
tree69300aec21fbd1fd6dd93c0ada94fdf4137dfdc5 /scripts
parent42160bad7056d26b6f5b8c42efc0a8bf5302dfef (diff)
fixed issue trex-172: Console -m 100% is L2 and no L1
http://trex-tgn.cisco.com/youtrack/issue/trex-172
Diffstat (limited to 'scripts')
-rw-r--r--scripts/automation/trex_control_plane/client/trex_port.py25
-rwxr-xr-xscripts/automation/trex_control_plane/client/trex_stateless_client.py41
-rwxr-xr-xscripts/automation/trex_control_plane/client_utils/parsing_opts.py4
-rwxr-xr-xscripts/automation/trex_control_plane/common/text_opts.py8
-rwxr-xr-xscripts/automation/trex_control_plane/common/trex_stats.py66
-rw-r--r--scripts/automation/trex_control_plane/console/trex_status.py525
6 files changed, 85 insertions, 584 deletions
diff --git a/scripts/automation/trex_control_plane/client/trex_port.py b/scripts/automation/trex_control_plane/client/trex_port.py
index 94240f2a..d32d2a01 100644
--- a/scripts/automation/trex_control_plane/client/trex_port.py
+++ b/scripts/automation/trex_control_plane/client/trex_port.py
@@ -6,12 +6,12 @@ from client_utils import packet_builder
StreamOnPort = namedtuple('StreamOnPort', ['compiled_stream', 'metadata'])
########## utlity ############
-def mult_to_factor (mult, max_bps, max_pps, line_util):
+def mult_to_factor (mult, max_bps_l2, max_pps, line_util):
if mult['type'] == 'raw':
return mult['value']
if mult['type'] == 'bps':
- return mult['value'] / max_bps
+ return mult['value'] / max_bps_l2
if mult['type'] == 'pps':
return mult['value'] / max_pps
@@ -398,16 +398,19 @@ class Port(object):
print format_text("Profile Map Per Port\n", 'underline', 'bold')
- factor = mult_to_factor(mult, rate['max_bps'], rate['max_pps'], rate['max_line_util'])
+ factor = mult_to_factor(mult, rate['max_bps_l2'], rate['max_pps'], rate['max_line_util'])
- print "Profile max BPS (base / req): {:^12} / {:^12}".format(format_num(rate['max_bps'], suffix = "bps"),
- format_num(rate['max_bps'] * factor, suffix = "bps"))
+ print "Profile max BPS L2 (base / req): {:^12} / {:^12}".format(format_num(rate['max_bps_l2'], suffix = "bps"),
+ format_num(rate['max_bps_l2'] * factor, suffix = "bps"))
- print "Profile max PPS (base / req): {:^12} / {:^12}".format(format_num(rate['max_pps'], suffix = "pps"),
- format_num(rate['max_pps'] * factor, suffix = "pps"),)
+ print "Profile max BPS L1 (base / req): {:^12} / {:^12}".format(format_num(rate['max_bps_l1'], suffix = "bps"),
+ format_num(rate['max_bps_l1'] * factor, suffix = "bps"))
- print "Profile line util. (base / req): {:^12} / {:^12}".format(format_percentage(rate['max_line_util'] * 100),
- format_percentage(rate['max_line_util'] * factor * 100))
+ print "Profile max PPS (base / req): {:^12} / {:^12}".format(format_num(rate['max_pps'], suffix = "pps"),
+ format_num(rate['max_pps'] * factor, suffix = "pps"),)
+
+ print "Profile line util. (base / req): {:^12} / {:^12}".format(format_percentage(rate['max_line_util']),
+ format_percentage(rate['max_line_util'] * factor))
# duration
@@ -422,8 +425,8 @@ class Port(object):
exp_time_factor_sec = duration
- print "Duration (base / req): {:^12} / {:^12}".format(format_time(exp_time_base_sec),
- format_time(exp_time_factor_sec))
+ print "Duration (base / req): {:^12} / {:^12}".format(format_time(exp_time_base_sec),
+ format_time(exp_time_factor_sec))
print "\n"
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 c1a4d1d1..c59da7b4 100755
--- a/scripts/automation/trex_control_plane/client/trex_stateless_client.py
+++ b/scripts/automation/trex_control_plane/client/trex_stateless_client.py
@@ -54,7 +54,7 @@ class STLStateError(STLError):
# port state error
class STLPortStateError(STLError):
def __init__ (self, port, op, state):
- self.msg = "Operation '{0}' on port '{1}' is not valid for state '{2}'".format(op, port, state)
+ self.msg = "Operation '{0}' on port(s) '{1}' is not valid while port(s) '{2}'".format(op, port, state)
# raised when argument is not valid for operation
@@ -766,18 +766,6 @@ class STLClient(object):
# start command
def __start (self, port_id_list, stream_list, mult, force, duration, dry):
- active_ports = list(set(self.get_active_ports()).intersection(port_id_list))
-
- if active_ports:
- if not force:
- msg = "Port(s) {0} are active - please stop them or add '--force'".format(active_ports)
- self.logger.log(format_text(msg, 'bold'))
- return RC_ERR(msg)
- else:
- rc = self.__stop(active_ports)
- if not rc:
- return rc
-
self.logger.pre_cmd("Removing all streams from port(s) {0}:".format(port_id_list))
rc = self.__remove_all_streams(port_id_list)
@@ -804,11 +792,7 @@ class STLClient(object):
return rc
else:
- self.logger.pre_cmd("Validating traffic profile on port(s) {0}:".format(port_id_list))
rc = self.__validate(port_id_list)
- self.logger.post_cmd(rc)
-
-
if rc.bad():
return rc
@@ -1335,6 +1319,19 @@ class STLClient(object):
if not rc:
raise STLError(rc)
+
+ # verify ports are stopped or force stop them
+ active_ports = list(set(self.get_active_ports()).intersection(ports))
+ if active_ports:
+ if not force:
+ msg = "Port(s) {0} are active - please stop them or specify 'force'".format(active_ports)
+ raise STLError(msg)
+ else:
+ rc = self.__stop(active_ports)
+ if not rc:
+ raise STLError(rc)
+
+
# dry run
if dry:
self.logger.log(format_text("\n*** DRY RUN ***", 'bold'))
@@ -1582,6 +1579,16 @@ class STLClient(object):
if opts is None:
return
+
+ active_ports = list(set(self.get_active_ports()).intersection(opts.ports))
+
+ if active_ports:
+ if not opts.force:
+ msg = "Port(s) {0} are active - please stop them or add '--force'\n".format(active_ports)
+ self.logger.log(format_text(msg, 'bold'))
+ return
+
+
# pack the profile
profiles = [opts.file[0]]
diff --git a/scripts/automation/trex_control_plane/client_utils/parsing_opts.py b/scripts/automation/trex_control_plane/client_utils/parsing_opts.py
index ba60c191..968bbb7e 100755
--- a/scripts/automation/trex_control_plane/client_utils/parsing_opts.py
+++ b/scripts/automation/trex_control_plane/client_utils/parsing_opts.py
@@ -182,13 +182,13 @@ def is_valid_file(filename):
OPTIONS_DB = {MULTIPLIER: ArgumentPack(['-m', '--multiplier'],
{'help': match_multiplier_help,
'dest': "mult",
- 'default': {'type':'raw', 'value':1, 'op': 'abs'},
+ 'default': "1",
'type': match_multiplier}),
MULTIPLIER_STRICT: ArgumentPack(['-m', '--multiplier'],
{'help': match_multiplier_help,
'dest': "mult",
- 'default': {'type':'raw', 'value':1, 'op': 'abs'},
+ 'default': "1",
'type': match_multiplier_strict}),
TOTAL: ArgumentPack(['-t', '--total'],
diff --git a/scripts/automation/trex_control_plane/common/text_opts.py b/scripts/automation/trex_control_plane/common/text_opts.py
index 30d38d3f..78a0ab1f 100755
--- a/scripts/automation/trex_control_plane/common/text_opts.py
+++ b/scripts/automation/trex_control_plane/common/text_opts.py
@@ -38,15 +38,17 @@ def format_num (size, suffix = "", compact = True, opts = ()):
if compact:
for unit in ['','K','M','G','T','P']:
if abs(size) < 1000.0:
- #txt = "%3.2f %s%s" % (size, unit, suffix)
u = unit
break
size /= 1000.0
if isinstance(size, float):
- txt = "%3.2f %s%s" % (size, u, suffix)
+ txt = "%3.2f" % (size)
else:
- txt = "{:,} {:}{:}".format(size, u, suffix)
+ txt = "{:,}".format(size)
+
+ if u or suffix:
+ txt += " {:}{:}".format(u, suffix)
if isinstance(opts, tuple):
return format_text(txt, *opts)
diff --git a/scripts/automation/trex_control_plane/common/trex_stats.py b/scripts/automation/trex_control_plane/common/trex_stats.py
index 3f64310f..52c0c0a1 100755
--- a/scripts/automation/trex_control_plane/common/trex_stats.py
+++ b/scripts/automation/trex_control_plane/common/trex_stats.py
@@ -115,22 +115,27 @@ class CTRexInfoGenerator(object):
per_field_stats = OrderedDict([("owner", []),
("state", []),
("--", []),
+ ("Tx bps", []),
+ ("Tx pps", []),
+
+ ("---", []),
+ ("Rx bps", []),
+ ("Rx pps", []),
+
+ ("----", []),
("opackets", []),
("ipackets", []),
("obytes", []),
("ibytes", []),
- ("oerrors", []),
- ("ierrors", []),
("tx-bytes", []),
("rx-bytes", []),
("tx-pkts", []),
("rx-pkts", []),
- ("---", []),
- ("Tx bps", []),
- ("Rx bps", []),
- ("----", []),
- ("Tx pps", []),
- ("Rx pps", [])
+
+ ("-----", []),
+ ("oerrors", []),
+ ("ierrors", []),
+
]
)
@@ -259,8 +264,8 @@ class CTRexStats(object):
""" This is an abstract class to represent a stats object """
def __init__(self):
- self.reference_stats = None
- self.latest_stats = None
+ self.reference_stats = {}
+ self.latest_stats = {}
self.last_update_ts = time.time()
self.history = deque(maxlen = 10)
@@ -309,7 +314,7 @@ class CTRexStats(object):
diff_time = time.time() - self.last_update_ts
# 3 seconds is too much - this is the new reference
- if (self.reference_stats == None) or (diff_time > 3):
+ if (not self.reference_stats) or (diff_time > 3):
self.reference_stats = self.latest_stats
self.last_update_ts = time.time()
@@ -520,33 +525,42 @@ class CPortStats(CTRexStats):
return {"owner": self._port_obj.user if self._port_obj else "",
"state": self._port_obj.get_port_state_name() if self._port_obj else "",
+
"--": " ",
- "opackets" : self.get_rel("opackets"),
- "ipackets" : self.get_rel("ipackets"),
- "obytes" : self.get_rel("obytes"),
- "ibytes" : self.get_rel("ibytes"),
- "oerrors" : self.get_rel("oerrors"),
- "ierrors" : self.get_rel("ierrors"),
-
- "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 bps": u"{0} {1}".format(self.get_trend_gui("m_total_tx_bps", show_value = False),
self.get("m_total_tx_bps", format = True, suffix = "bps")),
"Rx bps": u"{0} {1}".format(self.get_trend_gui("m_total_rx_bps", show_value = False),
self.get("m_total_rx_bps", format = True, suffix = "bps")),
-
- "----": "",
+
"Tx pps": u"{0} {1}".format(self.get_trend_gui("m_total_tx_pps", show_value = False),
self.get("m_total_tx_pps", format = True, suffix = "pps")),
"Rx pps": u"{0} {1}".format(self.get_trend_gui("m_total_rx_pps", show_value = False),
self.get("m_total_rx_pps", format = True, suffix = "pps")),
+ "opackets" : self.get_rel("opackets"),
+ "ipackets" : self.get_rel("ipackets"),
+ "obytes" : self.get_rel("obytes"),
+ "ibytes" : self.get_rel("ibytes"),
+
+ "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"),
+
+ "oerrors" : format_num(self.get_rel("oerrors"),
+ compact = False,
+ opts = 'green' if (self.get_rel("oerrors")== 0) else 'red'),
+
+ "ierrors" : format_num(self.get_rel("ierrors"),
+ compact = False,
+ opts = 'green' if (self.get_rel("ierrors")== 0) else 'red'),
+
}
diff --git a/scripts/automation/trex_control_plane/console/trex_status.py b/scripts/automation/trex_control_plane/console/trex_status.py
deleted file mode 100644
index 45769693..00000000
--- a/scripts/automation/trex_control_plane/console/trex_status.py
+++ /dev/null
@@ -1,525 +0,0 @@
-#from time import sleep
-#
-#import os
-#
-#import curses
-#from curses import panel
-#import random
-#import collections
-#import operator
-#import datetime
-#
-#g_curses_active = False
-#
-#################### utils #################
-#
-## simple percetange show
-#def percentage (a, total):
-# x = int ((float(a) / total) * 100)
-# return str(x) + "%"
-#
-#################### panels #################
-#
-## panel object
-#class TrexStatusPanel(object):
-# def __init__ (self, h, l, y, x, headline, status_obj):
-#
-# self.status_obj = status_obj
-#
-# self.log = status_obj.log
-# self.stateless_client = status_obj.stateless_client
-#
-# self.stats = status_obj.stats
-# self.general_stats = status_obj.general_stats
-#
-# self.h = h
-# self.l = l
-# self.y = y
-# self.x = x
-# self.headline = headline
-#
-# self.win = curses.newwin(h, l, y, x)
-# self.win.erase()
-# self.win.box()
-#
-# self.win.addstr(1, 2, headline, curses.A_UNDERLINE)
-# self.win.refresh()
-#
-# panel.new_panel(self.win)
-# self.panel = panel.new_panel(self.win)
-# self.panel.top()
-#
-# def clear (self):
-# self.win.erase()
-# self.win.box()
-# self.win.addstr(1, 2, self.headline, curses.A_UNDERLINE)
-#
-# def getwin (self):
-# return self.win
-#
-#
-## various kinds of panels
-#
-## Server Info Panel
-#class ServerInfoPanel(TrexStatusPanel):
-# def __init__ (self, h, l, y, x, status_obj):
-#
-# super(ServerInfoPanel, self).__init__(h, l, y ,x ,"Server Info:", status_obj)
-#
-# def draw (self):
-#
-# if not self.status_obj.server_version :
-# return
-#
-# if not self.status_obj.server_sys_info:
-# return
-#
-#
-# self.clear()
-#
-# self.getwin().addstr(3, 2, "{:<30} {:30}".format("Server:",self.status_obj.server_sys_info["hostname"] + ":" + str(self.stateless_client.get_connection_port())))
-# self.getwin().addstr(4, 2, "{:<30} {:30}".format("Version:", self.status_obj.server_version["version"]))
-# self.getwin().addstr(5, 2, "{:<30} {:30}".format("Build:",
-# self.status_obj.server_version["build_date"] + " @ " +
-# self.status_obj.server_version["build_time"] + " by " +
-# self.status_obj.server_version["built_by"]))
-#
-# self.getwin().addstr(6, 2, "{:<30} {:30}".format("Server Uptime:", self.status_obj.server_sys_info["uptime"]))
-# self.getwin().addstr(7, 2, "{:<30} {:<3} / {:<30}".format("DP Cores:", str(self.status_obj.server_sys_info["dp_core_count"]) +
-# " cores", self.status_obj.server_sys_info["core_type"]))
-#
-# self.getwin().addstr(9, 2, "{:<30} {:<30}".format("Ports Count:", self.status_obj.server_sys_info["port_count"]))
-#
-# ports_owned = " ".join(str(x) for x in self.status_obj.owned_ports_list)
-#
-# if not ports_owned:
-# ports_owned = "None"
-#
-# self.getwin().addstr(10, 2, "{:<30} {:<30}".format("Ports Owned:", ports_owned))
-#
-## general info panel
-#class GeneralInfoPanel(TrexStatusPanel):
-# def __init__ (self, h, l, y, x, status_obj):
-#
-# super(GeneralInfoPanel, self).__init__(h, l, y ,x ,"General Info:", status_obj)
-#
-# def draw (self):
-# self.clear()
-#
-# if not self.general_stats.is_online():
-# self.getwin().addstr(3, 2, "No Published Data From TRex Server")
-# return
-#
-# self.getwin().addstr(3, 2, "{:<30} {:0.2f} %".format("CPU util.:", self.general_stats.get("m_cpu_util")))
-#
-# self.getwin().addstr(6, 2, "{:<30} {:} / {:}".format("Total Tx. rate:",
-# self.general_stats.get("m_tx_bps", format = True, suffix = "bps"),
-# self.general_stats.get("m_tx_pps", format = True, suffix = "pps")))
-#
-#
-# self.getwin().addstr(8, 2, "{:<30} {:} / {:}".format("Total Tx:",
-# self.general_stats.get_rel("m_total_tx_bytes", format = True, suffix = "B"),
-# self.general_stats.get_rel("m_total_tx_pkts", format = True, suffix = "pkts")))
-#
-# self.getwin().addstr(11, 2, "{:<30} {:} / {:}".format("Total Rx. rate:",
-# self.general_stats.get("m_rx_bps", format = True, suffix = "bps"),
-# self.general_stats.get("m_rx_pps", format = True, suffix = "pps")))
-#
-#
-# self.getwin().addstr(13, 2, "{:<30} {:} / {:}".format("Total Rx:",
-# self.general_stats.get_rel("m_total_rx_bytes", format = True, suffix = "B"),
-# self.general_stats.get_rel("m_total_rx_pkts", format = True, suffix = "pkts")))
-#
-## all ports stats
-#class PortsStatsPanel(TrexStatusPanel):
-# def __init__ (self, h, l, y, x, status_obj):
-#
-# super(PortsStatsPanel, self).__init__(h, l, y ,x ,"Trex Ports:", status_obj)
-#
-#
-# def draw (self):
-#
-# self.clear()
-#
-# owned_ports = self.status_obj.owned_ports_list
-# if not owned_ports:
-# self.getwin().addstr(3, 2, "No Owned Ports - Please Acquire One Or More Ports")
-# return
-#
-# # table header
-# self.getwin().addstr(3, 2, "{:^15} {:^30} {:^30} {:^30}".format(
-# "Port ID", "Tx Rate [bps/pps]", "Rx Rate [bps/pps]", "Total Bytes [tx/rx]"))
-#
-#
-#
-# for i, port_index in enumerate(owned_ports):
-#
-# port_stats = self.status_obj.stats.get_port_stats(port_index)
-#
-# if port_stats:
-# self.getwin().addstr(5 + (i * 4), 2, "{:^15} {:^30} {:^30} {:^30}".format(
-# "{0} ({1})".format(str(port_index), self.status_obj.server_sys_info["ports"][port_index]["speed"]),
-# "{0} / {1}".format(port_stats.get("m_total_tx_bps", format = True, suffix = "bps"),
-# port_stats.get("m_total_tx_pps", format = True, suffix = "pps")),
-#
-# "{0} / {1}".format(port_stats.get("m_total_rx_bps", format = True, suffix = "bps"),
-# port_stats.get("m_total_rx_pps", format = True, suffix = "pps")),
-# "{0} / {1}".format(port_stats.get_rel("obytes", format = True, suffix = "B"),
-# port_stats.get_rel("ibytes", format = True, suffix = "B"))))
-#
-# else:
-#
-# self.getwin().addstr(5 + (i * 4), 2, "{:^15} {:^30} {:^30} {:^30}".format(
-# "{0} ({1})".format(str(port_index), self.status_obj.server_sys_info["ports"][port_index]["speed"]),
-# "N/A",
-# "N/A",
-# "N/A",
-# "N/A"))
-#
-#
-# # old format
-## if port_stats:
-## self.getwin().addstr(5 + (i * 4), 2, "{:^15} {:^15} {:^15} {:^15} {:^15} {:^15} {:^15}".format(
-## "{0} ({1})".format(str(port_index), self.status_obj.server_sys_info["ports"][port_index]["speed"]),
-## port_stats.get("m_total_tx_pps", format = True, suffix = "pps"),
-## port_stats.get("m_total_tx_bps", format = True, suffix = "bps"),
-## port_stats.get_rel("obytes", format = True, suffix = "B"),
-## port_stats.get("m_total_rx_pps", format = True, suffix = "pps"),
-## port_stats.get("m_total_rx_bps", format = True, suffix = "bps"),
-## port_stats.get_rel("ibytes", format = True, suffix = "B")))
-##
-## else:
-## self.getwin().addstr(5 + (i * 4), 2, "{:^15} {:^15} {:^15} {:^15} {:^15} {:^15} {:^15}".format(
-## "{0} ({1})".format(str(port_index), self.status_obj.server_sys_info["ports"][port_index]["speed"]),
-## "N/A",
-## "N/A",
-## "N/A",
-## "N/A",
-## "N/A",
-## "N/A"))
-#
-## control panel
-#class ControlPanel(TrexStatusPanel):
-# def __init__ (self, h, l, y, x, status_obj):
-#
-# super(ControlPanel, self).__init__(h, l, y, x, "", status_obj)
-#
-#
-# def draw (self):
-# self.clear()
-#
-# self.getwin().addstr(1, 2, "'g' - general, '0-{0}' - specific port, 'f' - freeze, 'c' - clear stats, 'p' - ping server, 'q' - quit"
-# .format(self.status_obj.stateless_client.get_port_count() - 1))
-#
-# self.log.draw(self.getwin(), 2, 3)
-#
-## specific ports panels
-#class SinglePortPanel(TrexStatusPanel):
-# def __init__ (self, h, l, y, x, status_obj, port_id):
-#
-# super(SinglePortPanel, self).__init__(h, l, y, x, "Port {0}".format(port_id), status_obj)
-#
-# self.port_id = port_id
-#
-# def draw (self):
-# y = 3
-#
-# self.clear()
-#
-# if not self.port_id in self.status_obj.owned_ports_list:
-# self.getwin().addstr(y, 2, "Port {0} is not owned by you, please acquire the port for more info".format(self.port_id))
-# return
-#
-# # streams
-# 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.owned_ports[str(self.port_id)]:
-# stream_info = self.status_obj.owned_ports[str(self.port_id)]['streams']
-#
-# for stream_id, stream in sorted(stream_info.iteritems(), key=operator.itemgetter(0)):
-# self.getwin().addstr(y, 2, "{:^15} {:^15} {:^15} {:^15} {:^15} {:^15} {:^15}".format(
-# stream_id,
-# ("True" if stream['enabled'] else "False"),
-# stream['mode']['type'],
-# ("True" if stream['self_start'] else "False"),
-# stream['isg'],
-# (stream['next_stream_id'] if stream['next_stream_id'] != -1 else "None"),
-# ("{0} instr.".format(len(stream['vm'])) if stream['vm'] else "None")))
-#
-# y += 1
-#
-# # new section - traffic
-# y += 2
-#
-# self.getwin().addstr(y, 2, "Traffic:", curses.A_UNDERLINE)
-# y += 2
-#
-#
-#
-# # table header
-# self.getwin().addstr(y, 2, "{:^15} {:^30} {:^30} {:^30}".format(
-# "Port ID", "Tx Rate [bps/pps]", "Rx Rate [bps/pps]", "Total Bytes [tx/rx]"))
-#
-#
-# y += 2
-#
-# port_stats = self.status_obj.stats.get_port_stats(self.port_id)
-#
-# if port_stats:
-# self.getwin().addstr(y, 2, "{:^15} {:^30} {:^30} {:^30}".format(
-# "{0} ({1})".format(str(self.port_id), self.status_obj.server_sys_info["ports"][self.port_id]["speed"]),
-# "{0} / {1}".format(port_stats.get("m_total_tx_bps", format = True, suffix = "bps"),
-# port_stats.get("m_total_tx_pps", format = True, suffix = "pps")),
-#
-# "{0} / {1}".format(port_stats.get("m_total_rx_bps", format = True, suffix = "bps"),
-# port_stats.get("m_total_rx_pps", format = True, suffix = "pps")),
-# "{0} / {1}".format(port_stats.get_rel("obytes", format = True, suffix = "B"),
-# port_stats.get_rel("ibytes", format = True, suffix = "B"))))
-#
-# else:
-# self.getwin().addstr(y, 2, "{:^15} {:^30} {:^30} {:^30}".format(
-# "{0} ({1})".format(str(self.port_id), self.status_obj.server_sys_info["ports"][self.port_id]["speed"]),
-# "N/A",
-# "N/A",
-# "N/A",
-# "N/A"))
-#
-#
-#################### main objects #################
-#
-## status log
-#class TrexStatusLog():
-# def __init__ (self):
-# self.log = []
-#
-# def add_event (self, msg):
-# self.log.append("[{0}] {1}".format(str(datetime.datetime.now().time()), msg))
-#
-# def draw (self, window, x, y, max_lines = 4):
-# index = y
-#
-# cut = len(self.log) - max_lines
-# if cut < 0:
-# cut = 0
-#
-# for msg in self.log[cut:]:
-# window.addstr(index, x, msg)
-# index += 1
-#
-## status commands
-#class TrexStatusCommands():
-# def __init__ (self, status_object):
-#
-# self.status_object = status_object
-#
-# self.stateless_client = status_object.stateless_client
-# self.log = self.status_object.log
-#
-# self.actions = {}
-# self.actions[ord('q')] = self._quit
-# self.actions[ord('p')] = self._ping
-# self.actions[ord('f')] = self._freeze
-#
-# self.actions[ord('g')] = self._show_ports_stats
-#
-# # register all the available ports shortcuts
-# for port_id in xrange(0, self.stateless_client.get_port_count()):
-# self.actions[ord('0') + port_id] = self._show_port_generator(port_id)
-#
-#
-# # handle a key pressed
-# def handle (self, ch):
-# if ch in self.actions:
-# return self.actions[ch]()
-# else:
-# self.log.add_event("Unknown key pressed, please see legend")
-# return True
-#
-# # show all ports
-# def _show_ports_stats (self):
-# self.log.add_event("Switching to all ports view")
-# self.status_object.stats_panel = self.status_object.ports_stats_panel
-#
-# return True
-#
-#
-# # function generator for different ports requests
-# def _show_port_generator (self, port_id):
-# def _show_port():
-# self.log.add_event("Switching panel to port {0}".format(port_id))
-# self.status_object.stats_panel = self.status_object.ports_panels[port_id]
-#
-# return True
-#
-# return _show_port
-#
-# def _freeze (self):
-# self.status_object.update_active = not self.status_object.update_active
-# self.log.add_event("Update continued" if self.status_object.update_active else "Update stopped")
-#
-# return True
-#
-# def _quit(self):
-# return False
-#
-# def _ping (self):
-# self.log.add_event("Pinging RPC server")
-#
-# rc, msg = self.stateless_client.ping()
-# if rc:
-# self.log.add_event("Server replied: '{0}'".format(msg))
-# else:
-# self.log.add_event("Failed to get reply")
-#
-# return True
-#
-## status object
-##
-##
-##
-#class CTRexStatus():
-# def __init__ (self, stdscr, stateless_client):
-# self.stdscr = stdscr
-#
-# self.stateless_client = stateless_client
-#
-# self.log = TrexStatusLog()
-# self.cmds = TrexStatusCommands(self)
-#
-# self.stats = stateless_client.get_stats_async()
-# self.general_stats = stateless_client.get_stats_async().get_general_stats()
-#
-# # fetch server info
-# self.server_sys_info = self.stateless_client.get_system_info()
-#
-# self.server_version = self.stateless_client.get_server_version()
-#
-# # list of owned ports
-# self.owned_ports_list = self.stateless_client.get_acquired_ports()
-#
-# # data per port
-# self.owned_ports = {}
-#
-# for port_id in self.owned_ports_list:
-# self.owned_ports[str(port_id)] = {}
-# self.owned_ports[str(port_id)]['streams'] = {}
-#
-# stream_list = self.stateless_client.get_all_streams(port_id)
-#
-# self.owned_ports[str(port_id)] = stream_list
-#
-#
-# try:
-# curses.curs_set(0)
-# except:
-# pass
-#
-# curses.use_default_colors()
-# self.stdscr.nodelay(1)
-# curses.nonl()
-# curses.noecho()
-#
-# self.generate_layout()
-#
-#
-# def generate_layout (self):
-# self.max_y = self.stdscr.getmaxyx()[0]
-# self.max_x = self.stdscr.getmaxyx()[1]
-#
-# self.server_info_panel = ServerInfoPanel(int(self.max_y * 0.3), self.max_x / 2, int(self.max_y * 0.5), self.max_x /2, self)
-# self.general_info_panel = GeneralInfoPanel(int(self.max_y * 0.5), self.max_x / 2, 0, self.max_x /2, self)
-# self.control_panel = ControlPanel(int(self.max_y * 0.2), self.max_x , int(self.max_y * 0.8), 0, self)
-#
-# # those can be switched on the same place
-# self.ports_stats_panel = PortsStatsPanel(int(self.max_y * 0.8), self.max_x / 2, 0, 0, self)
-#
-# self.ports_panels = {}
-# for i in xrange(0, self.stateless_client.get_port_count()):
-# self.ports_panels[i] = SinglePortPanel(int(self.max_y * 0.8), self.max_x / 2, 0, 0, self, i)
-#
-# # at start time we point to the main one
-# self.stats_panel = self.ports_stats_panel
-# self.stats_panel.panel.top()
-#
-# panel.update_panels(); self.stdscr.refresh()
-# return
-#
-#
-# def wait_for_key_input (self):
-# ch = self.stdscr.getch()
-#
-# # no key , continue
-# if ch == curses.ERR:
-# return True
-#
-# return self.cmds.handle(ch)
-#
-# # main run entry point
-# def run (self):
-#
-# # list of owned ports
-# self.owned_ports_list = self.stateless_client.get_acquired_ports()
-#
-# # data per port
-# self.owned_ports = {}
-#
-# for port_id in self.owned_ports_list:
-# self.owned_ports[str(port_id)] = {}
-# self.owned_ports[str(port_id)]['streams'] = {}
-#
-# stream_list = self.stateless_client.get_all_streams(port_id)
-#
-# self.owned_ports[str(port_id)] = stream_list
-#
-# self.update_active = True
-# while (True):
-#
-# rc = self.wait_for_key_input()
-# if not rc:
-# break
-#
-# self.server_info_panel.draw()
-# self.general_info_panel.draw()
-# self.control_panel.draw()
-#
-# # can be different kinds of panels
-# self.stats_panel.panel.top()
-# self.stats_panel.draw()
-#
-# panel.update_panels()
-# self.stdscr.refresh()
-# sleep(0.01)
-#
-#
-## global container
-#trex_status = None
-#
-#def show_trex_status_internal (stdscr, stateless_client):
-# global trex_status
-#
-# if trex_status == None:
-# trex_status = CTRexStatus(stdscr, stateless_client)
-#
-# trex_status.run()
-#
-#def show_trex_status (stateless_client):
-#
-# try:
-# curses.wrapper(show_trex_status_internal, stateless_client)
-# except KeyboardInterrupt:
-# curses.endwin()
-#
-#def cleanup ():
-# try:
-# curses.endwin()
-# except:
-# pass
-#