diff options
author | Nauman Ahad <nauman.ahad@xflowresearch.com> | 2016-06-28 09:28:14 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@172.30.200.206> | 2016-06-28 09:28:14 +0000 |
commit | 18d526d8e13ef7698a13e08a9f915d59d5d563a3 (patch) | |
tree | 5220f29aa83bd862dbf23d542ffff8c8be047512 /func/env_setup.py | |
parent | 94da6bec4d24c1b889e04c13db6b13d944e34644 (diff) | |
parent | 0537cab223ae76d501591e6a1e83aa3ea4fdec0e (diff) |
Merge "Run the test only when ping ok and try ping 20 times."
Diffstat (limited to 'func/env_setup.py')
-rw-r--r-- | func/env_setup.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/func/env_setup.py b/func/env_setup.py index 487d7af3..c1e2a003 100644 --- a/func/env_setup.py +++ b/func/env_setup.py @@ -13,7 +13,6 @@ from collections import defaultdict import yaml import time import paramiko - class Env_setup(): roles_ip_list = [] # ROLE and its corresponding IP address list ip_pw_list = [] # IP and password, this will be used to ssh @@ -90,18 +89,23 @@ class Env_setup(): print 'Retrying SSH' def pingtest(self, lister): - pingFlag = 0 + result = True for k, v in lister.iteritems(): time.sleep(10) for val in v: ipvar = val ping_cmd = 'ping -D -c1 {0}'.format(ipvar) - while os.system(ping_cmd) != 0: + while (os.system(ping_cmd) != 0) &(pingFlag <=20): print '\nWaiting for machine\n' time.sleep(10) - pingFlag = 0 - print ('\n\n %s is UP \n\n ' % ipvar) + pingFlag = pingFlag+1 + if pingFlag <= 2: + print ('\n\n %s is UP \n\n ' % ipvar) + else: + result = False + return result + def GetHostMachineinfo(self, Hosttag): |