mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-11 20:29:40 +00:00
feat: 批量命令api
This commit is contained in:
@@ -5,11 +5,12 @@ from rest_framework.response import Response
|
||||
from ops.models import Job, JobExecution
|
||||
from ops.serializers.job import JobSerializer, JobExecutionSerializer
|
||||
|
||||
__all__ = ['JobViewSet', 'JobExecutionViewSet', 'JobRunVariableHelpAPIView', 'JobAssetDetail', ]
|
||||
__all__ = ['JobViewSet', 'JobExecutionViewSet', 'JobRunVariableHelpAPIView', 'JobAssetDetail', 'JobExecutionTaskDetail']
|
||||
|
||||
from ops.tasks import run_ops_job_execution
|
||||
from ops.variables import JMS_JOB_VARIABLE_HELP
|
||||
from orgs.mixins.api import OrgBulkModelViewSet
|
||||
from orgs.utils import tmp_to_org, get_current_org_id, get_current_org
|
||||
|
||||
|
||||
def set_task_to_serializer_data(serializer, task):
|
||||
@@ -93,3 +94,20 @@ class JobAssetDetail(APIView):
|
||||
if execution_id:
|
||||
execution = get_object_or_404(JobExecution, id=execution_id)
|
||||
return Response(data=execution.assent_result_detail)
|
||||
|
||||
|
||||
class JobExecutionTaskDetail(APIView):
|
||||
rbac_perms = ()
|
||||
permission_classes = ()
|
||||
|
||||
def get(self, request, **kwargs):
|
||||
org = get_current_org()
|
||||
task_id = request.query_params.get('task_id')
|
||||
if task_id:
|
||||
with tmp_to_org(org):
|
||||
execution = get_object_or_404(JobExecution, task_id=task_id)
|
||||
return Response(data={
|
||||
'is_finished': execution.is_finished,
|
||||
'is_success': execution.is_success,
|
||||
'time_cost': execution.time_cost,
|
||||
})
|
||||
|
Reference in New Issue
Block a user