Commit 1fbe4d09 authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

snf-burnin: Retry when SSHException

Retry when `SSHException: Error reading SSH protocol banner'.
parent faaf1c17
......@@ -356,18 +356,19 @@ class CycladesTests(BurninTests):
d_image = self.clients.cyclades.get_image_details(image['id'])
return d_image['metadata']['osfamily'].lower().find(osfamily) >= 0
# Method could be a function. pylint: disable-msg=R0201
def _ssh_execute(self, hostip, username, password, command):
"""Execute a command via ssh"""
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect(hostip, username=username, password=password)
except socket.error as err:
self.fail(err)
try:
_, stdout, _ = ssh.exec_command(command)
except paramiko.SSHException as err:
self.fail(err)
except paramiko.SSHException as excpt:
if excpt.code == 104: # Error reading SSH protocol banner
raise Retry()
else:
raise
_, stdout, _ = ssh.exec_command(command)
status = stdout.channel.recv_exit_status()
output = stdout.readlines()
ssh.close()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment