#NEWLINE# def _connect( self , host , results , raise_on_any_error = False ) : #NEWLINE# #INDENT# ( hostname , port ) = self . _get_host_port_info ( host ) #NEWLINE# extra = { #NEWLINE# #INDENT# 'host' : host , #NEWLINE# 'port' : port , #NEWLINE# 'user' : self . _ssh_user , #NEWLINE# #UNINDENT# } #NEWLINE# if self . _ssh_password : #NEWLINE# #INDENT# extra [ 'password' ] = '<redacted>' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . _ssh_key_file : #NEWLINE# #INDENT# extra [ 'key_file_path' ] = self . _ssh_key_file #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# extra [ 'private_key' ] = '<redacted>' #NEWLINE# #UNINDENT# #UNINDENT# LOG . debug ( 'Connecting to host.' , extra = extra ) #NEWLINE# client = ParamikoSSHClient ( hostname , username = self . _ssh_user , password = self . _ssh_password , key = self . _ssh_key_file , key_material = self . _ssh_key_material , passphrase = self . _passphrase , port = port ) #NEWLINE# try : #NEWLINE# #INDENT# client . connect ( ) #NEWLINE# #UNINDENT# except Exception as ex : #NEWLINE# #INDENT# error = ( 'Failed connecting to host %s.' % hostname ) #NEWLINE# LOG . exception ( error ) #NEWLINE# if raise_on_any_error : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# error = ' ' . join ( [ host . CONNECT_ERROR , str ( ex ) ] ) #NEWLINE# error_dict = self . _generate_error_result ( exc = ex , message = error ) #NEWLINE# self . _bad_hosts [ hostname ] = error_dict #NEWLINE# results [ hostname ] = error_dict #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _successful_connects += 1 #NEWLINE# self . _hosts_client [ hostname ] = client #NEWLINE# results [ hostname ] = { #NEWLINE# #INDENT# 'message' : 'Connected to host.' , #NEWLINE# #UNINDENT# }