Add timeout in paramiko ssh command 65/8065/1
authorjose.lausuch <jose.lausuch@ericsson.com>
Tue, 26 Jan 2016 15:16:24 +0000 (16:16 +0100)
committerMorgan Richomme <morgan.richomme@orange.com>
Tue, 26 Jan 2016 17:10:36 +0000 (17:10 +0000)
Change-Id: I7ef30c08a2335400a79b8a7baf91a27e5eea02e1
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
(cherry picked from commit a43fac229e1be8c6af2c72a4be9d9c1c95614d21)

testcases/vPing/CI/libraries/vPing2.py

index 3582235..912627b 100644 (file)
@@ -443,26 +443,26 @@ def main():
             port_id1, port_id2)
         return (EXIT_CODE)
 
-    logger.info("Trying to stablish SSH connection to %s..." % floatip)
+    logger.info("Trying to establish SSH connection to %s..." % floatip)
     username='cirros'
     password='cubswin:)'
     ssh = paramiko.SSHClient()
     ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
 
-    timeout = 50
+    timeout = 20
     while timeout > 0:
         try:
-            ssh.connect(floatip, username=username, password=password)
-            logger.debug("Floating IP '%s' is ssh-able!" % floatip)
+            ssh.connect(floatip, username=username, password=password, timeout=10)
+            logger.debug("SSH connection established to %s." % floatip)
             break
         except Exception, e:
             #print e
             logger.debug("Waiting for %s..." % floatip)
-            time.sleep(6)
+            time.sleep(2)
             timeout -= 1
 
     if timeout == 0: # 300 sec timeout (5 min)
-        logger.error("Cannot ping the floating IP '%s'." % floatip)
+        logger.error("Cannot establish connection to IP '%s'. Aborting" % floatip)
         cleanup(nova_client, neutron_client, image_id, network_dic,
             port_id1, port_id2)
         return (EXIT_CODE)