diff --git a/scripts/automation/trex_control_plane/interactive/trex/astf/trex_astf_client.py b/scripts/automation/trex_control_plane/interactive/trex/astf/trex_astf_client.py index 99435823f4..2a6f63ea38 100644 --- a/scripts/automation/trex_control_plane/interactive/trex/astf/trex_astf_client.py +++ b/scripts/automation/trex_control_plane/interactive/trex/astf/trex_astf_client.py @@ -54,6 +54,7 @@ def __init__(self, server = "localhost", sync_port = 4501, async_port = 4500, + max_ports = 4, verbose_level = "error", logger = None, sync_timeout = None, @@ -75,6 +76,9 @@ def __init__(self, async_port : int the ASYNC port (subscriber port) + max_ports : int + maximum amount of ports to show + verbose_level: str one of "none", "critical", "error", "info", "debug" @@ -99,6 +103,7 @@ def __init__(self, server, sync_port, async_port, + max_ports, verbose_level, logger, sync_timeout, diff --git a/scripts/automation/trex_control_plane/interactive/trex/common/trex_client.py b/scripts/automation/trex_control_plane/interactive/trex/common/trex_client.py index 6b2aeb786f..522290b3fc 100644 --- a/scripts/automation/trex_control_plane/interactive/trex/common/trex_client.py +++ b/scripts/automation/trex_control_plane/interactive/trex/common/trex_client.py @@ -94,6 +94,7 @@ def __init__(self, server = "localhost", sync_port = 4501, async_port = 4500, + max_ports = 4, verbose_level = "error", logger = None, sync_timeout = None, @@ -133,6 +134,8 @@ def __init__(self, # server version check for dynamic port addition self.is_dynamic = False + self.max_ports = max_ports + def get_mode (self): """ @@ -3622,7 +3625,10 @@ def _show_port_stats (self, ports, buffer = sys.stdout): self.logger.warning(format_text('Empty set of ports\n', 'bold')) return - port_stats = [self.ports[port_id].get_port_stats() for port_id in ports[:4]] + if self.max_ports < 1: + port_stats = [self.ports[port_id].get_port_stats() for port_id in ports] + else: + port_stats = [self.ports[port_id].get_port_stats() for port_id in ports[:self.max_ports]] # update in a batch StatsBatch.update(port_stats, self.conn.rpc) @@ -3649,7 +3655,11 @@ def _show_port_xstats (self, ports, include_zero_lines): self.logger.warning(format_text('Empty set of ports\n', 'bold')) return - port_xstats = [self.ports[port_id].get_port_xstats() for port_id in ports[:4]] + if self.max_ports < 1: + port_xstats = [self.ports[port_id].get_port_xstats() for port_id in ports] + else: + port_xstats = [self.ports[port_id].get_port_xstats() for port_id in ports[:self.max_ports]] + # update in a batch StatsBatch.update(port_xstats, self.conn.rpc) diff --git a/scripts/automation/trex_control_plane/interactive/trex/console/trex_console.py b/scripts/automation/trex_control_plane/interactive/trex/console/trex_console.py index 6fe9c4d5fb..f4a8b3a50f 100644 --- a/scripts/automation/trex_control_plane/interactive/trex/console/trex_console.py +++ b/scripts/automation/trex_control_plane/interactive/trex/console/trex_console.py @@ -183,7 +183,7 @@ def completenames(self, text, *ignored): class TRexConsole(TRexGeneralCmd): """Trex Console""" - def __init__(self, client, verbose = False, dummy_client = False): + def __init__(self, client, verbose = False, dummy_client = False, max_ports = 4): # cmd lock is used to make sure background job # of the console is not done while the user excutes commands @@ -202,7 +202,7 @@ def __init__(self, client, verbose = False, dummy_client = False): self.terminal = None - self.tui = trex_tui.TrexTUI(self) + self.tui = trex_tui.TrexTUI(self, max_ports) self.cap_mngr = CaptureManager(client, self.cmd_lock) self.load_client_console_functions() self.postcmd(False, "") @@ -852,6 +852,8 @@ def setParserOptions(): action="store_true", help="Starts with all outputs suppressed", default = False) + parser.add_argument("-m", "--max-ports", default=4, help="Set maximum amount of ports to show, any value below 1 is unlimited", type=int) + return parser # a simple info printed on log on @@ -896,6 +898,7 @@ def probe_server_mode (options): server = options.server, sync_port = options.port, async_port = options.pub, + max_ports = options.max_ports, logger = ConsoleLogger(), verbose_level = 'error') @@ -912,7 +915,7 @@ def run_console(client, logger, options): if not cont: return - console = TRexConsole(client = client, verbose = options.verbose, dummy_client = options.emu_only_server is not None) + console = TRexConsole(client = client, verbose = options.verbose, dummy_client = options.emu_only_server is not None, max_ports = options.max_ports) console.server = options.server # set server in console so plugins can use it # run emu if needed @@ -992,6 +995,7 @@ def main(): server = options.server, sync_port = options.port, async_port = options.pub, + max_ports = options.max_ports, logger = logger, verbose_level = verbose_level, sync_timeout = sync_timeout, @@ -1005,6 +1009,7 @@ def main(): server = options.server, sync_port = options.port, async_port = options.pub, + max_ports = options.max_ports, logger = logger, verbose_level = verbose_level, sync_timeout = sync_timeout, diff --git a/scripts/automation/trex_control_plane/interactive/trex/console/trex_tui.py b/scripts/automation/trex_control_plane/interactive/trex/console/trex_tui.py index 90901bffdb..ccbc7bf159 100644 --- a/scripts/automation/trex_control_plane/interactive/trex/console/trex_tui.py +++ b/scripts/automation/trex_control_plane/interactive/trex/console/trex_tui.py @@ -707,7 +707,10 @@ def __init__ (self, cols, rows): super(TrexTUI.ScreenSizeException, self).__init__(msg) - def __init__ (self, console): + def __init__ (self, console, max_ports = 4): + if max_ports > 2: + # Showing one port takes about 20 columns + TrexTUI.MIN_COLS += 20 * (max_ports - 4) self.console = console self.client = console.client diff --git a/scripts/automation/trex_control_plane/interactive/trex/stl/trex_stl_client.py b/scripts/automation/trex_control_plane/interactive/trex/stl/trex_stl_client.py index 60a351a652..5c841cf71a 100644 --- a/scripts/automation/trex_control_plane/interactive/trex/stl/trex_stl_client.py +++ b/scripts/automation/trex_control_plane/interactive/trex/stl/trex_stl_client.py @@ -126,6 +126,7 @@ def __init__(self, server = "localhost", sync_port = 4501, async_port = 4500, + max_ports = 4, verbose_level = "error", logger = None, sync_timeout = None, @@ -147,6 +148,9 @@ def __init__(self, async_port : int the ASYNC port (subscriber port) + max_ports : int + maximum number of ports to show + verbose_level: str one of "none", "critical", "error", "info", "debug" @@ -172,6 +176,7 @@ def __init__(self, server, sync_port, async_port, + max_ports, verbose_level, logger, sync_timeout,