Remove duplicate while-loop retries during ssh

Signed-off-by: Prasanna Santhanam <tsp@apache.org>
(cherry picked from commit 53feae08de5f4d8072538e9060e5a6e074ebcdde)
This commit is contained in:
Prasanna Santhanam 2013-07-29 14:51:37 +05:30
parent 9c36ad722b
commit ade13bb773
3 changed files with 16 additions and 20 deletions

View File

@ -356,7 +356,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
vpcid=self.vpc.id
)
self.debug("Adding NetwrokACl rules to make NAT rule accessible")
self.debug("Adding NetworkACL rules to make NAT rule accessible")
nwacl_nat = NetworkACL.create(self.apiclient,
networkid=network.id,
services=services,

View File

@ -111,23 +111,19 @@ def cleanup_resources(api_client, resources):
def is_server_ssh_ready(ipaddress, port, username, password, retries=5, timeout=20, keyPairFileLocation=None):
"""Return ssh handle else wait till sshd is running"""
loop_cnt = retries
while True:
try:
ssh = remoteSSHClient(
host=ipaddress,
port=port,
user=username,
passwd=password,
keyPairFileLocation=keyPairFileLocation)
except Exception as e:
if loop_cnt == 0:
raise e
loop_cnt = loop_cnt - 1
time.sleep(timeout)
keyPairFileLocation=keyPairFileLocation,
retries=retries,
delay=timeout)
except Exception, e:
raise Exception("Failed to bring up ssh service in time. Waited %ss. Error is %s" % (retries * timeout, e))
else:
return ssh
raise Exception("Failed to bring up ssh service in time. Waited %ss" % retries*timeout)
def format_volume_to_ext3(ssh_client, device="/dev/sda"):

View File

@ -24,7 +24,7 @@ from contextlib import closing
class remoteSSHClient(object):
def __init__(self, host, port, user, passwd, retries=10,
def __init__(self, host, port, user, passwd, retries=10, delay=5,
log_lvl=logging.INFO, keyPairFileLocation=None):
self.host = host
self.port = port
@ -62,7 +62,7 @@ class remoteSSHClient(object):
raise cloudstackException. \
InvalidParameterException(repr(sshex))
retry_count = retry_count - 1
time.sleep(5)
time.sleep(delay)
except paramiko.AuthenticationException, authEx:
raise cloudstackException. \
InvalidParameterException("Invalid credentials to "