From 17e20bfa70d1a9ce5e6ee6687245e3e22f3633a8 Mon Sep 17 00:00:00 2001 From: "Sridhar K. N. Rao" Date: Wed, 1 Sep 2021 11:26:28 +0530 Subject: Clean Output Option. This patch adds support for clean output - displaying only final results. User has to run with --verbosity and level as error or critical. --verbosity is an existing option. Remove unnecessary spaces Signed-off-by: Sridhar K. N. Rao Change-Id: Id227a4b787c4c7e4dd97f28009946ac6a8a802d3 --- tools/pkt_gen/trex/trex_client.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'tools/pkt_gen') diff --git a/tools/pkt_gen/trex/trex_client.py b/tools/pkt_gen/trex/trex_client.py index ff9d5c79..680497ec 100644 --- a/tools/pkt_gen/trex/trex_client.py +++ b/tools/pkt_gen/trex/trex_client.py @@ -136,7 +136,15 @@ class Trex(ITrafficGenerator): else: raise RuntimeError('T-Rex: Trex host not defined') - ping = subprocess.Popen(cmd_ping, shell=True, stderr=subprocess.PIPE) + if settings.getValue('CLEAN_OUTPUT'): + ping = subprocess.Popen(cmd_ping, + shell=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.PIPE) + else: + ping = subprocess.Popen(cmd_ping, + shell=True, + stderr=subprocess.PIPE) output, error = ping.communicate() if ping.returncode: @@ -152,9 +160,16 @@ class Trex(ITrafficGenerator): self._trex_base_dir + "t-rex-64" - find_trex = subprocess.Popen(cmd_find_trex, - shell=True, - stderr=subprocess.PIPE) + if settings.getValue('CLEAN_OUTPUT'): + find_trex = subprocess.Popen(cmd_find_trex, + shell=True, + stdout=subprocess.DEVNULL, + stderr=subprocess.PIPE) + else: + find_trex = subprocess.Popen(cmd_find_trex, + shell=True, + stderr=subprocess.PIPE) + output, error = find_trex.communicate() if find_trex.returncode: @@ -165,8 +180,12 @@ class Trex(ITrafficGenerator): % (self._trex_host_ip_addr, self._trex_base_dir)) try: - self._stlclient = STLClient(username=self._trex_user, server=self._trex_host_ip_addr, - verbose_level='info') + if settings.getValue('CLEAN_OUTPUT'): + self._stlclient = STLClient(username=self._trex_user, server=self._trex_host_ip_addr, + verbose_level='error') + else: + self._stlclient = STLClient(username=self._trex_user, server=self._trex_host_ip_addr, + verbose_level='info') self._stlclient.connect() except STLError: raise RuntimeError('T-Rex: Cannot connect to T-Rex server. Please check if it is ' @@ -392,7 +411,8 @@ class Trex(ITrafficGenerator): self._stlclient.set_port_attr(my_ports, promiscuous=True) packet_1, packet_2 = self.create_packets(traffic, ports_info) - self.show_packet_info(packet_1, packet_2) + if not settings.getValue('CLEAN_OUTPUT'): + self.show_packet_info(packet_1, packet_2) stream_1, stream_2, stream_1_lat, stream_2_lat = Trex.create_streams(packet_1, packet_2, traffic) self._stlclient.add_streams(stream_1, ports=[0]) self._stlclient.add_streams(stream_2, ports=[1]) -- cgit 1.2.3-korg