diff --git a/tools/marvin/marvin/integration/lib/utils.py b/tools/marvin/marvin/integration/lib/utils.py index 2da9272c7aa..6d101327121 100644 --- a/tools/marvin/marvin/integration/lib/utils.py +++ b/tools/marvin/marvin/integration/lib/utils.py @@ -109,7 +109,7 @@ def cleanup_resources(api_client, resources): obj.delete(api_client) -def is_server_ssh_ready(ipaddress, port, username, password, retries=5, timeout=30, keyPairFileLocation=None): +def is_server_ssh_ready(ipaddress, port, username, password, retries=10, timeout=30, keyPairFileLocation=None): """Return ssh handle else wait till sshd is running""" try: ssh = remoteSSHClient( diff --git a/tools/marvin/marvin/remoteSSHClient.py b/tools/marvin/marvin/remoteSSHClient.py index e0ead9315a9..fea9b125d19 100644 --- a/tools/marvin/marvin/remoteSSHClient.py +++ b/tools/marvin/marvin/remoteSSHClient.py @@ -17,7 +17,6 @@ import paramiko import time -import socket import cloudstackException import contextlib import logging @@ -25,7 +24,7 @@ from contextlib import closing class remoteSSHClient(object): - def __init__(self, host, port, user, passwd, retries=5, delay=30, + def __init__(self, host, port, user, passwd, retries=10, delay=30, log_lvl=logging.INFO, keyPairFileLocation=None): self.host = host self.port = port @@ -40,7 +39,7 @@ class remoteSSHClient(object): self.logger.addHandler(ch) retry_count = retries - while True: + while retry_count >= 0: try: if keyPairFileLocation is None: self.ssh.connect(str(host), int(port), user, passwd) @@ -58,17 +57,20 @@ class remoteSSHClient(object): (str(host), user, keyPairFileLocation)) self.logger.debug("SSH connect: %s@%s with passwd %s" % (user, str(host), passwd)) - except (paramiko.SSHException, paramiko.ChannelException, socket.error) as se: + #except paramiko.AuthenticationException, authEx: + # raise cloudstackException. \ + # InvalidParameterException("Invalid credentials to " + # + "login to %s on port %s" % + # (str(host), port)) + except Exception as se: if retry_count == 0: raise cloudstackException. \ InvalidParameterException(repr(se)) - retry_count = retry_count - 1 - time.sleep(delay) - except paramiko.AuthenticationException, authEx: - raise cloudstackException. \ - InvalidParameterException("Invalid credentials to " - + "login to %s on port %s" % - (str(host), port)) + else: + return + + retry_count = retry_count - 1 + time.sleep(delay) def execute(self, command): stdin, stdout, stderr = self.ssh.exec_command(command)