aboutsummaryrefslogtreecommitdiffstats
path: root/tools/pkt_gen/trex/trex_client.py
diff options
context:
space:
mode:
authorSridhar K. N. Rao <sridhar.rao@spirent.com>2021-09-01 11:26:28 +0530
committerSridhar K. N. Rao <sridhar.rao@spirent.com>2021-09-07 10:29:55 +0530
commit17e20bfa70d1a9ce5e6ee6687245e3e22f3633a8 (patch)
tree76240b45f7bc1ef5de20a60866908b0a3c33b7a8 /tools/pkt_gen/trex/trex_client.py
parent8f4fd575ae70079d2bff9f9af4b251a3961b7428 (diff)
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 <sridhar.rao@spirent.com> Change-Id: Id227a4b787c4c7e4dd97f28009946ac6a8a802d3
Diffstat (limited to 'tools/pkt_gen/trex/trex_client.py')
-rw-r--r--tools/pkt_gen/trex/trex_client.py34
1 files changed, 27 insertions, 7 deletions
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])