66import sys
77from time import time
88from concurrent .futures import ProcessPoolExecutor , wait
9- from netmiko import ConnectHandler , file_transfer
10- from netmiko .ssh_exception import NetMikoAuthenticationException , NetMikoTimeoutException
11- from paramiko .ssh_exception import AuthenticationException
9+ from netmiko import ConnLogOnly , file_transfer
1210
1311# --- Define the threads
1412MAX_THREADS = 8
@@ -47,9 +45,15 @@ def confirm(prompt=None, resp=False):
4745# --- Upload Netmiko function
4846def upload_nemiko (net_device ):
4947 print ("Upload on:" , HOST )
50- # Create the Netmiko SSH connection
51- try :
52- ssh_conn = ConnectHandler (** net_device )
48+
49+ # Create the Netmiko SSH connection
50+ ssh_conn = ConnLogOnly (** net_device )
51+
52+ # Test access, skip if failed
53+ if ssh_conn is None :
54+ print (HOST + ": Logging in failed... skipping" )
55+ print (40 * "-" )
56+ else :
5357 transfer_dict = {}
5458 transfer_dict = file_transfer (ssh_conn ,
5559 source_file = SOURCE_FILE ,
@@ -60,16 +64,6 @@ def upload_nemiko(net_device):
6064 print ('File exists already: ' ,transfer_dict ['file_exists' ])
6165 print ('File transferred: ' ,transfer_dict ['file_transferred' ])
6266 print ('MD5 verified :' ,transfer_dict ['file_verified' ])
63- except NetMikoTimeoutException :
64- print (80 * "=" )
65- print ('Results for' , HOST + ':' )
66- print ('Skipped: SSH Timed out' )
67- #continue
68- except (AuthenticationException , NetMikoAuthenticationException ):
69- print (80 * "=" )
70- print ('Results for' , HOST + ':' )
71- print ('Skipped: Authentication failed' )
72- #continue
7367
7468# --- Init argparse
7569parser = ArgumentParser ()
0 commit comments