diff --git a/spug_api/apps/host/views.py b/spug_api/apps/host/views.py index e7e36d3..83291fc 100644 --- a/spug_api/apps/host/views.py +++ b/spug_api/apps/host/views.py @@ -33,6 +33,8 @@ class HostView(View): Argument('password', required=False), ).parse(request.body) if error is None: + if Host.objects.filter(name=form.name, deleted_by_id__isnull=True).exists(): + return json_response(error=f'已存在的主机名称【{form.name}】') if valid_ssh(form.hostname, form.port, form.username, form.pop('password')) is False: return json_response('auth fail')