Add parameter attempts in ping_test() 43/17943/1
authorwu.zhihui <wu.zhihui1@zte.com.cn>
Wed, 3 Aug 2016 02:20:57 +0000 (10:20 +0800)
committerwu.zhihui <wu.zhihui1@zte.com.cn>
Wed, 3 Aug 2016 02:33:41 +0000 (10:33 +0800)
According to
https://build.opnfv.org/ci/job/qtip-fuel-zte-pod1-daily-master/55/consoleText,
it need to add attempts for ping test. The default value is 30.

Change-Id: Ia6c2628bd88c963374d00ed2c02346c8d7f40c39
Signed-off-by: wu.zhihui <wu.zhihui1@zte.com.cn>
func/env_setup.py

index 9c0dadb..f59883a 100644 (file)
@@ -98,16 +98,18 @@ class Env_setup:
                         print 'Retrying SSH %s' % infinity
 
     @staticmethod
-    def ping_test(lister):
-
+    def ping_test(lister, attempts=30):
         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:
-                    print '\nWaiting for machine\n'
-                    time.sleep(10)
+                for i in range(attempts):
+                    if os.system(ping_cmd) != 0:
+                        print '\nWaiting for machine\n'
+                        time.sleep(10)
+                    else:
+                        break
                 print ('\n\n %s is UP \n\n ' % ipvar)
 
     def get_host_machine_info(self, host_tag):