diff --git a/tools/marvin/marvin/TestCaseExecuteEngine.py b/tools/marvin/marvin/TestCaseExecuteEngine.py index 94ba8168624..996a7e9f4b1 100644 --- a/tools/marvin/marvin/TestCaseExecuteEngine.py +++ b/tools/marvin/marvin/TestCaseExecuteEngine.py @@ -10,15 +10,12 @@ # limitations under the License. # # Automatically generated by addcopyright.py at 04/03/2012 -try: - import unittest2 as unittest -except ImportError: - import unittest -from functools import partial +import unittest import os import sys import logging +from functools import partial def testCaseLogger(message, logger=None): if logger is not None: diff --git a/tools/marvin/marvin/cloudstackTestCase.py b/tools/marvin/marvin/cloudstackTestCase.py index cf822adc39e..e4ff2d19339 100644 --- a/tools/marvin/marvin/cloudstackTestCase.py +++ b/tools/marvin/marvin/cloudstackTestCase.py @@ -11,10 +11,7 @@ # # Automatically generated by addcopyright.py at 04/03/2012 from cloudstackAPI import * -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import cloudstackTestClient #class UserName(object): diff --git a/tools/marvin/marvin/remoteSSHClient.py b/tools/marvin/marvin/remoteSSHClient.py index 99d298be5ae..8836844dc9f 100644 --- a/tools/marvin/marvin/remoteSSHClient.py +++ b/tools/marvin/marvin/remoteSSHClient.py @@ -11,19 +11,31 @@ # # Automatically generated by addcopyright.py at 04/03/2012 import paramiko +import time import cloudstackException + class remoteSSHClient(object): - def __init__(self, host, port, user, passwd): + def __init__(self, host, port, user, passwd, retries = 10): self.host = host self.port = port self.user = user self.passwd = passwd self.ssh = paramiko.SSHClient() self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - try: - self.ssh.connect(str(host),int(port), user, passwd) - except paramiko.SSHException, sshex: - raise cloudstackException.InvalidParameterException(repr(sshex)) + + retry_count = retries + while True: + try: + self.ssh.connect(str(host),int(port), user, passwd) + except paramiko.SSHException, sshex: + if retry_count == 0: + raise cloudstackException.InvalidParameterException(repr(sshex)) + retry_count = retry_count - 1 + time.sleep(5) + except paramiko.AuthenticationException, authEx: + raise cloudstackException.InvalidParameterException("Invalid credentials to login to %s on port %s"%(str(host), port)) + else: + return def execute(self, command): stdin, stdout, stderr = self.ssh.exec_command(command)