mirror of https://github.com/jumpserver/jumpserver
perf: 修复发布机安装应用的报错
parent
e5bfa29c7b
commit
68c4cd5928
|
@ -1,3 +1,5 @@
|
||||||
|
import uuid
|
||||||
|
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
|
@ -80,8 +82,12 @@ class AppletHostDeploymentViewSet(viewsets.ModelViewSet):
|
||||||
objs = [model(host=host) for host in hosts_qs]
|
objs = [model(host=host) for host in hosts_qs]
|
||||||
applet_host_deployments = model.objects.bulk_create(objs)
|
applet_host_deployments = model.objects.bulk_create(objs)
|
||||||
applet_host_deployment_ids = [str(obj.id) for obj in applet_host_deployments]
|
applet_host_deployment_ids = [str(obj.id) for obj in applet_host_deployments]
|
||||||
|
task_id = str(uuid.uuid4())
|
||||||
task = run_applet_host_deployment_install_applet.delay(applet_host_deployment_ids, applet_id)
|
|
||||||
task_id = str(task.id)
|
|
||||||
model.objects.filter(id__in=applet_host_deployment_ids).update(task=task_id)
|
model.objects.filter(id__in=applet_host_deployment_ids).update(task=task_id)
|
||||||
|
transaction.on_commit(lambda: self.start_install_applet(applet_host_deployment_ids, applet_id, task_id))
|
||||||
return Response({'task': task_id}, status=201)
|
return Response({'task': task_id}, status=201)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def start_install_applet(applet_host_deployment_ids, applet_id, task_id):
|
||||||
|
run_applet_host_deployment_install_applet.apply_async((applet_host_deployment_ids, applet_id),
|
||||||
|
task_id=str(task_id))
|
||||||
|
|
Loading…
Reference in New Issue