trex: Improve error handling 85/50485/4
authorMartin Klozik <martinx.klozik@intel.com>
Fri, 12 Jan 2018 10:25:15 +0000 (10:25 +0000)
committerMartin Klozik <martinx.klozik@intel.com>
Thu, 18 Jan 2018 16:07:34 +0000 (16:07 +0000)
Print an error message in case, that vsperf is not able
to connect to the T-Rex server. User is instructed
to check if T-Rex server is up and running.

Change-Id: I70c6d27fa8331921d43e25c5eaa3638ded6c015b
Signed-off-by: Martin Klozik <martinx.klozik@intel.com>
Reviewed-by: Jose Lausuch <jalausuch@suse.com>
Reviewed-by: Al Morton <acmorton@att.com>
Reviewed-by: Christian Trautman <ctrautma@redhat.com>
Reviewed-by: Sridhar Rao <sridhar.rao@spirent.com>
Reviewed-by: Trevor Cooper <trevor.cooper@intel.com>
docs/testing/user/configguide/trafficgen.rst
tools/pkt_gen/trex/trex.py

index 029247f..3382448 100644 (file)
@@ -791,6 +791,10 @@ It is neccesary for proper connection between Trex server and VSPERF.
    cd trex-core/scripts/
    ./t-rex-64 -i
 
+**NOTE:** Please check your firewall settings at both DUT and T-Rex server.
+Firewall must allow a connection from DUT (VSPERF) to the T-Rex server running
+at TCP port 4501.
+
 For additional information about Trex stateless mode see Trex stateless documentation:
 
 https://trex-tgn.cisco.com/trex/doc/trex_stateless.html
index 5ce87b1..cfe54b7 100644 (file)
@@ -126,9 +126,14 @@ class Trex(ITrafficGenerator):
                 'T-Rex: Cannot locate Trex program at %s within %s' \
                 % (self._trex_host_ip_addr, self._trex_base_dir))
 
-        self._stlclient = STLClient(username=self._trex_user, server=self._trex_host_ip_addr,
-                                    verbose_level=0)
-        self._stlclient.connect()
+        try:
+            self._stlclient = STLClient(username=self._trex_user, server=self._trex_host_ip_addr,
+                                        verbose_level=0)
+            self._stlclient.connect()
+        except STLError:
+            raise RuntimeError('T-Rex: Cannot connect to T-Rex server. Please check if it is '
+                               'running and that firewall allows connection to TCP port 4501.')
+
         self._logger.info("T-Rex: Trex host successfully found...")
 
     def disconnect(self):