Merge pull request #9519 from jumpserver/pr@dev@perf_test_node_conn

perf: 优化测试节点可连接性
pull/9527/head
老广 2023-02-13 18:24:23 +08:00 committed by GitHub
commit 0666b1e747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 10 deletions

View File

@ -1,24 +1,24 @@
# ~*~ coding: utf-8 ~*~
from functools import partial
from collections import namedtuple, defaultdict
from functools import partial
from django.db.models.signals import m2m_changed
from django.utils.translation import ugettext_lazy as _
from rest_framework import status
from rest_framework.response import Response
from rest_framework.decorators import action
from rest_framework.generics import get_object_or_404
from rest_framework.response import Response
from rest_framework.serializers import ValidationError
from assets.models import Asset
from common.const.http import POST
from common.utils import get_logger
from common.api import SuggestionMixin
from common.exceptions import SomeoneIsDoingThis
from common.const.http import POST
from common.const.signals import PRE_REMOVE, POST_REMOVE
from common.exceptions import SomeoneIsDoingThis
from common.utils import get_logger
from orgs.mixins import generics
from orgs.utils import current_org
from orgs.mixins.api import OrgBulkModelViewSet
from orgs.utils import current_org
from .. import serializers
from ..models import Node
from ..tasks import (
@ -210,7 +210,7 @@ class NodeTaskCreateApi(generics.CreateAPIView):
return
if action == "refresh":
task = update_node_assets_hardware_info_manual.delay(node.id)
task = update_node_assets_hardware_info_manual(node.id)
else:
task = test_node_assets_connectivity_manual.delay(node.id)
task = test_node_assets_connectivity_manual(node.id)
self.set_serializer_data(serializer, task)

View File

@ -40,4 +40,4 @@ def test_node_assets_connectivity_manual(node_id):
node = Node.objects.get(id=node_id)
task_name = gettext_noop("Test if the assets under the node are connectable ")
assets = node.get_all_assets()
return test_assets_connectivity_task.delay(*assets, task_name)
return test_assets_connectivity_task.delay(assets, task_name)

View File

@ -117,7 +117,10 @@ class JMSInventory:
if host['jms_account'] and asset.platform.type == 'oracle':
host['jms_account']['mode'] = 'sysdba' if account.privileged else None
ansible_config = dict(automation.ansible_config)
try:
ansible_config = dict(automation.ansible_config)
except Exception as e:
ansible_config = {}
ansible_connection = ansible_config.get('ansible_connection', 'ssh')
host.update(ansible_config)