Trex client not starting in 4 port baremetal 89/66589/8
authorDanielMartinBuckley <daniel.m.buckley@intel.com>
Wed, 23 Jan 2019 11:11:00 +0000 (11:11 +0000)
committerDaniel Martin Buckley <daniel.m.buckley@intel.com>
Mon, 4 Feb 2019 13:05:29 +0000 (13:05 +0000)
JIRA: YARDSTICK-1589

After calling STLclient.connect() there is no check if
connection was sucessfull or not.

Added a check for success on connect, retry if failure
and disconnect and connect on timeout.

If still connect failed then do not resume .. end with
LOG.critial and exit.

Change-Id: Ifd306b7920d9acbc16681cf79bf952d5af31eb64
Signed-off-by: Daniel Martin Buckley <daniel.m.buckley@intel.com>
yardstick/network_services/vnf_generic/vnf/sample_vnf.py

index 6ae393b..aec0850 100644 (file)
@@ -405,6 +405,10 @@ class ClientResourceHelper(ResourceHelper):
         try:
             self._build_ports()
             self.client = self._connect()
+            if self.client is None:
+                LOG.critical("Failure to Connect ... unable to continue")
+                return
+
             self.client.reset(ports=self.all_ports)
             self.client.remove_all_streams(self.all_ports)  # remove all streams
             traffic_profile.register_generator(self)
@@ -454,16 +458,28 @@ class ClientResourceHelper(ResourceHelper):
                                server=self.vnfd_helper.mgmt_interface["ip"],
                                verbose_level=LoggerApi.VERBOSE_QUIET)
 
-        # try to connect with 5s intervals, 30s max
+        # try to connect with 5s intervals
         for idx in range(6):
             try:
                 client.connect()
-                break
+                for idx2 in range(6):
+                    if client.is_connected():
+                        return client
+                    LOG.info("Waiting to confirm connection %s .. Attempt %s",
+                             idx, idx2)
+                    time.sleep(1)
+                client.disconnect(stop_traffic=True, release_ports=True)
             except STLError:
                 LOG.info("Unable to connect to Trex Server.. Attempt %s", idx)
                 time.sleep(5)
-        return client
 
+        if client.is_connected():
+            return client
+        else:
+            LOG.critical("Connection failure ..TRex username: %s server: %s",
+                         self.vnfd_helper.mgmt_interface["user"],
+                         self.vnfd_helper.mgmt_interface["ip"])
+            return None
 
 class Rfc2544ResourceHelper(object):