X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FDUTSetup.py;h=efc588783a2a27425be31ae9aee1794ec1b314d4;hp=dabdfceef201252352172e6daeda55233f747dd2;hb=665b506d4f3b229e05d14eda9def5e46c56518e9;hpb=4e421686933355ddc6ce0780efd15041c60de7e3 diff --git a/resources/libraries/python/DUTSetup.py b/resources/libraries/python/DUTSetup.py index dabdfceef2..efc588783a 100644 --- a/resources/libraries/python/DUTSetup.py +++ b/resources/libraries/python/DUTSetup.py @@ -113,25 +113,31 @@ class DUTSetup(object): 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: - raise RuntimeError("No VPP PID found on node {0}". - format(node['host'])) - else: - raise RuntimeError("More then one VPP PID found on node {0}". - format(node['host'])) + 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):