Allow to disable printing expected runtime errors in SSHAuth
When users on a node are not prepared yet, it is expected to get wrong authorization exception like this: ssh_client.py:147 -- Connection using stored authentication info failed! Traceback (most recent call last): ... BadAuthenticationType: ('Bad authentication type', [u'publickey']) (allowed_types=[u'publickey']) - new parameter to SSHClient 'verbose' allows to disable printing such errors during waiting for ssh access. Change-Id: I665d5dca3c064e5445863870bfb97d12cf2a4905
This commit is contained in:
parent
69e893e581
commit
dba9bd0b15
|
@ -243,7 +243,7 @@ class _MemorizedSSH(type):
|
|||
cls,
|
||||
host, port=22,
|
||||
username=None, password=None, private_keys=None,
|
||||
auth=None
|
||||
auth=None, verbose=True
|
||||
):
|
||||
"""Main memorize method: check for cached instance and return it
|
||||
|
||||
|
@ -280,7 +280,7 @@ class _MemorizedSSH(type):
|
|||
_MemorizedSSH, cls).__call__(
|
||||
host=host, port=port,
|
||||
username=username, password=password, private_keys=private_keys,
|
||||
auth=auth)
|
||||
auth=auth, verbose=verbose)
|
||||
|
||||
@classmethod
|
||||
def record(mcs, ssh):
|
||||
|
@ -323,7 +323,7 @@ class _MemorizedSSH(type):
|
|||
class SSHClient(six.with_metaclass(_MemorizedSSH, object)):
|
||||
__slots__ = [
|
||||
'__hostname', '__port', '__auth', '__ssh', '__sftp', 'sudo_mode',
|
||||
'__lock'
|
||||
'__lock', '__verbose'
|
||||
]
|
||||
|
||||
class __get_sudo(object):
|
||||
|
@ -367,7 +367,7 @@ class SSHClient(six.with_metaclass(_MemorizedSSH, object)):
|
|||
self,
|
||||
host, port=22,
|
||||
username=None, password=None, private_keys=None,
|
||||
auth=None
|
||||
auth=None, verbose=True
|
||||
):
|
||||
"""SSHClient helper
|
||||
|
||||
|
@ -377,6 +377,7 @@ class SSHClient(six.with_metaclass(_MemorizedSSH, object)):
|
|||
:type password: str
|
||||
:type private_keys: list
|
||||
:type auth: SSHAuth
|
||||
:type verbose: bool, show additional error/warning messages
|
||||
"""
|
||||
self.__lock = threading.RLock()
|
||||
|
||||
|
@ -389,6 +390,7 @@ class SSHClient(six.with_metaclass(_MemorizedSSH, object)):
|
|||
self.__sftp = None
|
||||
|
||||
self.__auth = auth if auth is None else auth.copy()
|
||||
self.__verbose = verbose
|
||||
|
||||
if auth is None:
|
||||
msg = (
|
||||
|
@ -501,7 +503,7 @@ class SSHClient(six.with_metaclass(_MemorizedSSH, object)):
|
|||
self.auth.connect(
|
||||
client=self.__ssh,
|
||||
hostname=self.hostname, port=self.port,
|
||||
log=True)
|
||||
log=self.__verbose)
|
||||
|
||||
def __connect_sftp(self):
|
||||
"""SFTP connection opener"""
|
||||
|
|
Loading…
Reference in New Issue