mirror of https://github.com/apache/cloudstack.git
Automation: Fix SSH connection test
And increase default retry to 10 times, each 30 seconds.
This commit is contained in:
parent
7acb023aad
commit
fda055388e
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue