VIRL VPP PID fix 98/7198/2
authorJan Gelety <jgelety@cisco.com>
Tue, 20 Jun 2017 07:53:56 +0000 (09:53 +0200)
committerJan Gelety <jgelety@cisco.com>
Tue, 20 Jun 2017 13:06:23 +0000 (13:06 +0000)
- use three tries to get PID of VPP process

Change-Id: If72784dfc2c5600aae703dff9170c4f491a3b685
Signed-off-by: Jan Gelety <jgelety@cisco.com>
resources/libraries/python/DUTSetup.py

index 4834ba6..efc5887 100644 (file)
@@ -113,30 +113,31 @@ class DUTSetup(object):
 
         ssh = SSH()
         ssh.connect(node)
 
         ssh = SSH()
         ssh.connect(node)
-        ret_code, stdout, stderr = ssh.exec_command('pidof vpp')
 
 
-        logger.trace(stdout)
-        logger.trace(stderr)
-
-        if int(ret_code) != 0:
-            logger.debug('Not possible to get PID of VPP process on node: '
-                         '{0}\n {1}'.format(node['host'], stdout + stderr))
-            raise RuntimeError('Not possible to get PID of VPP process on node:'
-                               ' {}'.format(node['host']))
-
-        if len(stdout.splitlines()) == 1:
-            return int(stdout)
-        elif len(stdout.splitlines()) == 0:
-            logger.debug("No VPP PID found on node {0}".
-                         format(node['host']))
-            return None
-        else:
-            logger.debug("More then one VPP PID found on node {0}".
-                         format(node['host']))
-            ret_list = ()
-            for line in stdout.splitlines():
-                ret_list.append(int(line))
-            return ret_list
+        for i in range(3):
+            logger.trace('Try {}: Get VPP PID'.format(i))
+            ret_code, stdout, stderr = ssh.exec_command('pidof vpp')
+
+            if int(ret_code) != 0:
+                raise RuntimeError('Not possible to get PID of VPP process '
+                                   'on node: {0}\n {1}'.
+                                   format(node['host'], stdout + stderr))
+
+            if len(stdout.splitlines()) == 1:
+                return int(stdout)
+            elif len(stdout.splitlines()) == 0:
+                logger.debug("No VPP PID found on node {0}".
+                             format(node['host']))
+                continue
+            else:
+                logger.debug("More then one VPP PID found on node {0}".
+                             format(node['host']))
+                ret_list = ()
+                for line in stdout.splitlines():
+                    ret_list.append(int(line))
+                return ret_list
+
+        return None
 
     @staticmethod
     def get_vpp_pids(nodes):
 
     @staticmethod
     def get_vpp_pids(nodes):

©2016 FD.io a Linux Foundation Collaborative Project. All Rights Reserved.
Linux Foundation is a registered trademark of The Linux Foundation. Linux is a registered trademark of Linus Torvalds.
Please see our privacy policy and terms of use.