diff --git a/apps/assets/api/node.py b/apps/assets/api/node.py index bb81a3b45..e690b8ebf 100644 --- a/apps/assets/api/node.py +++ b/apps/assets/api/node.py @@ -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) diff --git a/apps/assets/tasks/ping.py b/apps/assets/tasks/ping.py index 882f5e5ef..973085db3 100644 --- a/apps/assets/tasks/ping.py +++ b/apps/assets/tasks/ping.py @@ -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) diff --git a/apps/ops/ansible/inventory.py b/apps/ops/ansible/inventory.py index e83f50c41..da9e8b599 100644 --- a/apps/ops/ansible/inventory.py +++ b/apps/ops/ansible/inventory.py @@ -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)