def __connect(hostname, timeout=20, username=None, password=None):
 drac_cred = __opts__.get('drac')
 err_msg = "No drac login credentials found. Please add the 'username' and 'password' fields beneath a 'drac' key in the master configuration file. Or you can pass in a username and password as kwargs at the CLI."
 if (not username):
  if (drac_cred is None):
   log.error(err_msg)
   return False
  username = drac_cred.get('username', None)
 if (not password):
  if (drac_cred is None):
   log.error(err_msg)
   return False
  password = drac_cred.get('password', None)
 client = paramiko.SSHClient()
 client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
 try:
  client.connect(hostname, username=username, password=password, timeout=timeout)
 except Exception as e:
  log.error('Unable to connect to {0}: {1}'.format(hostname, e))
  return False
 return client

def __connect ( hostname , timeout = 20 , username = None , password = None ) : drac_cred = __opts__ . get ( 'drac' ) err_msg = "No drac login credentials found. Please add the 'username' and 'password' fields beneath a 'drac' key in the master configuration file. Or you can pass in a username and password as kwargs at the CLI." if ( not username ) : if ( drac_cred is None ) : log . error ( err_msg ) return False username = drac_cred . get ( 'username' , None ) if ( not password ) : if ( drac_cred is None ) : log . error ( err_msg ) return False password = drac_cred . get ( 'password' , None ) client = paramiko . SSHClient ( ) client . set_missing_host_key_policy ( paramiko . AutoAddPolicy ( ) ) try : client . connect ( hostname , username = username , password = password , timeout = timeout ) except Exception as e : log . error ( 'Unable to connect to {0}: {1}' . format ( hostname , e ) ) return False return client
connect to the drac .