Commit ed8976a1 authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis

burnin: Catch the SSHException from paramiko

paramiko throws 'SSHException' and not 'socket.error' when it cannot
connect to the remote server (Connection Refused). Catch the
SSHException and retry.
parent 3feaebef
...@@ -22,7 +22,6 @@ had grown too much. ...@@ -22,7 +22,6 @@ had grown too much.
import time import time
import IPy import IPy
import errno
import base64 import base64
import socket import socket
import random import random
...@@ -438,10 +437,8 @@ class CycladesTests(BurninTests): ...@@ -438,10 +437,8 @@ class CycladesTests(BurninTests):
try: try:
ssh.connect(hostip, username=username, password=password) ssh.connect(hostip, username=username, password=password)
except paramiko.SSHException as err: except paramiko.SSHException as err:
if err.args[0] == "Error reading SSH protocol banner": self.warning("%s", err.message)
raise Retry() raise Retry()
else:
raise
_, stdout, _ = ssh.exec_command(command) _, stdout, _ = ssh.exec_command(command)
status = stdout.channel.recv_exit_status() status = stdout.channel.recv_exit_status()
output = stdout.readlines() output = stdout.readlines()
...@@ -484,11 +481,9 @@ class CycladesTests(BurninTests): ...@@ -484,11 +481,9 @@ class CycladesTests(BurninTests):
self.info("Comparing file contents") self.info("Comparing file contents")
remote_content = base64.b64encode(ftmp.read()) remote_content = base64.b64encode(ftmp.read())
self.assertEqual(content, remote_content) self.assertEqual(content, remote_content)
except socket.error as (err_no, err_str): except paramiko.SSHException as err:
if err_no == errno.ECONNREFUSED: self.warning("%s", err.message)
raise Retry() raise Retry()
else:
raise
opmsg = "Fetching file %s from remote server" % remotepath opmsg = "Fetching file %s from remote server" % remotepath
self.info(opmsg) self.info(opmsg)
self._try_until_timeout_expires(opmsg, check_fun) self._try_until_timeout_expires(opmsg, check_fun)
......
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