mirror of https://github.com/openspug/spug
fix issue
parent
0bb559ceb2
commit
033d9fc6ce
|
@ -211,7 +211,7 @@ def fetch_host_extend(ssh):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def batch_sync_host(token, hosts, password, ):
|
def batch_sync_host(token, hosts, password):
|
||||||
private_key, public_key = AppSetting.get_ssh_key()
|
private_key, public_key = AppSetting.get_ssh_key()
|
||||||
threads, latest_exception, rds = [], None, get_redis_connection()
|
threads, latest_exception, rds = [], None, get_redis_connection()
|
||||||
max_workers = max(10, os.cpu_count() * 5)
|
max_workers = max(10, os.cpu_count() * 5)
|
||||||
|
@ -251,15 +251,12 @@ def _sync_host_extend(host, private_key=None, public_key=None, password=None, ss
|
||||||
|
|
||||||
def _get_ssh(kwargs, pkey=None, private_key=None, public_key=None, password=None):
|
def _get_ssh(kwargs, pkey=None, private_key=None, public_key=None, password=None):
|
||||||
try:
|
try:
|
||||||
if pkey:
|
ssh = SSH(pkey=pkey or private_key, **kwargs)
|
||||||
ssh = SSH(pkey=pkey, **kwargs)
|
ssh.ping()
|
||||||
ssh.ping()
|
return ssh
|
||||||
return ssh
|
except AuthenticationException as e:
|
||||||
else:
|
if password:
|
||||||
ssh = SSH(password=str(password), **kwargs)
|
ssh = SSH(password=str(password), **kwargs)
|
||||||
ssh.add_public_key(public_key)
|
ssh.add_public_key(public_key)
|
||||||
return _get_ssh(kwargs, private_key)
|
return _get_ssh(kwargs, private_key)
|
||||||
except AuthenticationException as e:
|
|
||||||
if password:
|
|
||||||
return _get_ssh(kwargs, None, public_key, public_key, password)
|
|
||||||
raise e
|
raise e
|
||||||
|
|
Loading…
Reference in New Issue