Catch some of the exceptions that can happen when failing to connect to target host.
This commit is contained in:
parent
e090c4465d
commit
d8deaaf456
@ -5,8 +5,14 @@ from tqdm import tqdm
|
|||||||
|
|
||||||
from fabric2 import ThreadingGroup, SerialGroup, Config, Connection
|
from fabric2 import ThreadingGroup, SerialGroup, Config, Connection
|
||||||
|
|
||||||
|
import paramiko
|
||||||
|
|
||||||
|
|
||||||
def thread_run(connection, command, result_lock, result_queue):
|
def thread_run(connection, command, result_lock, result_queue):
|
||||||
res = connection.run(command, warn=True, hide=True)
|
try:
|
||||||
|
res = connection.run(command, warn=True, hide=True)
|
||||||
|
except (paramiko.ssh_exception.NoValidConnectionsError, paramiko.ssh_exception.SSHException) as inst:
|
||||||
|
res = f"Could not connect to host: {inst}"
|
||||||
with result_lock:
|
with result_lock:
|
||||||
result_queue.append((connection, res))
|
result_queue.append((connection, res))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user