From 5e87b8763d77d6a40fee8f2e0c5174764e16b4a8 Mon Sep 17 00:00:00 2001 From: vapao Date: Wed, 29 Mar 2023 18:35:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=BB=E6=9C=BA=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spug_api/apps/host/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spug_api/apps/host/views.py b/spug_api/apps/host/views.py index 377da26..db5036e 100644 --- a/spug_api/apps/host/views.py +++ b/spug_api/apps/host/views.py @@ -9,6 +9,7 @@ from apps.setting.utils import AppSetting from apps.account.utils import get_host_perms from apps.host.models import Host, Group from apps.host.utils import batch_sync_host, _sync_host_extend +from apps.exec.models import ExecTemplate from apps.app.models import Deploy from apps.schedule.models import Task from apps.monitor.models import Detection @@ -117,6 +118,9 @@ class HostView(View): detection = Detection.objects.filter(type__in=('3', '4'), targets__regex=regex).first() if detection: return json_response(error=f'监控中心的任务【{detection.name}】关联了该主机,请解除关联后再尝试删除该主机') + tpl = ExecTemplate.objects.filter(host_ids__regex=regex).first() + if tpl: + return json_response(error=f'执行模板【{tpl.name}】关联了该主机,请解除关联后再尝试删除该主机') Host.objects.filter(id__in=host_ids).delete() return json_response(error=error)