|
|
@ -9,7 +9,7 @@ import yaml
|
|
|
|
from django.conf import settings
|
|
|
|
from django.conf import settings
|
|
|
|
from django.utils import timezone
|
|
|
|
from django.utils import timezone
|
|
|
|
from django.utils.translation import gettext as _
|
|
|
|
from django.utils.translation import gettext as _
|
|
|
|
from sshtunnel import SSHTunnelForwarder, BaseSSHTunnelForwarderError
|
|
|
|
from sshtunnel import SSHTunnelForwarder
|
|
|
|
|
|
|
|
|
|
|
|
from assets.automations.methods import platform_automation_methods
|
|
|
|
from assets.automations.methods import platform_automation_methods
|
|
|
|
from common.utils import get_logger, lazyproperty, is_openssh_format_key, ssh_pubkey_gen
|
|
|
|
from common.utils import get_logger, lazyproperty, is_openssh_format_key, ssh_pubkey_gen
|
|
|
@ -265,7 +265,7 @@ class BasePlaybookManager:
|
|
|
|
jms_asset, jms_gateway = host.get('jms_asset'), host.get('gateway')
|
|
|
|
jms_asset, jms_gateway = host.get('jms_asset'), host.get('gateway')
|
|
|
|
if not jms_gateway:
|
|
|
|
if not jms_gateway:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
try:
|
|
|
|
server = SSHTunnelForwarder(
|
|
|
|
server = SSHTunnelForwarder(
|
|
|
|
(jms_gateway['address'], jms_gateway['port']),
|
|
|
|
(jms_gateway['address'], jms_gateway['port']),
|
|
|
|
ssh_username=jms_gateway['username'],
|
|
|
|
ssh_username=jms_gateway['username'],
|
|
|
@ -273,11 +273,10 @@ class BasePlaybookManager:
|
|
|
|
ssh_pkey=jms_gateway['private_key_path'],
|
|
|
|
ssh_pkey=jms_gateway['private_key_path'],
|
|
|
|
remote_bind_address=(jms_asset['address'], jms_asset['port'])
|
|
|
|
remote_bind_address=(jms_asset['address'], jms_asset['port'])
|
|
|
|
)
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
|
|
|
|
server.start()
|
|
|
|
server.start()
|
|
|
|
except BaseSSHTunnelForwarderError:
|
|
|
|
except Exception as e:
|
|
|
|
err_msg = 'Gateway is not active: %s' % jms_asset.get('name', '')
|
|
|
|
err_msg = 'Gateway is not active: %s' % jms_asset.get('name', '')
|
|
|
|
print('\033[31m %s \033[0m\n' % err_msg)
|
|
|
|
print(f'\033[31m {err_msg} 原因: {e} \033[0m\n')
|
|
|
|
not_valid.append(k)
|
|
|
|
not_valid.append(k)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
host['ansible_host'] = jms_asset['address'] = '127.0.0.1'
|
|
|
|
host['ansible_host'] = jms_asset['address'] = '127.0.0.1'
|
|
|
|