mirror of https://github.com/jumpserver/jumpserver
perf: 删除job-execution/asset-detail接口
parent
80a506e99f
commit
90d4914280
|
@ -23,8 +23,7 @@ from ops.models import Job, JobExecution
|
||||||
from ops.serializers.job import JobSerializer, JobExecutionSerializer, FileSerializer, JobTaskStopSerializer
|
from ops.serializers.job import JobSerializer, JobExecutionSerializer, FileSerializer, JobTaskStopSerializer
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'JobViewSet', 'JobExecutionViewSet', 'JobRunVariableHelpAPIView',
|
'JobViewSet', 'JobExecutionViewSet', 'JobRunVariableHelpAPIView', 'JobExecutionTaskDetail', 'UsernameHintsAPI'
|
||||||
'JobAssetDetail', 'JobExecutionTaskDetail', 'UsernameHintsAPI'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
from ops.tasks import run_ops_job_execution
|
from ops.tasks import run_ops_job_execution
|
||||||
|
@ -226,17 +225,6 @@ class JobExecutionViewSet(OrgBulkModelViewSet):
|
||||||
return Response({'task_id': task_id}, status=200)
|
return Response({'task_id': task_id}, status=200)
|
||||||
|
|
||||||
|
|
||||||
class JobAssetDetail(APIView):
|
|
||||||
rbac_perms = {
|
|
||||||
'get': ['ops.view_jobexecution'],
|
|
||||||
}
|
|
||||||
|
|
||||||
def get(self, request, **kwargs):
|
|
||||||
execution_id = request.query_params.get('execution_id', '')
|
|
||||||
execution = get_object_or_404(JobExecution, id=execution_id, creator=request.user)
|
|
||||||
return Response(data=execution.assent_result_detail)
|
|
||||||
|
|
||||||
|
|
||||||
class JobExecutionTaskDetail(APIView):
|
class JobExecutionTaskDetail(APIView):
|
||||||
rbac_perms = {
|
rbac_perms = {
|
||||||
'GET': ['ops.view_jobexecution'],
|
'GET': ['ops.view_jobexecution'],
|
||||||
|
|
|
@ -254,45 +254,6 @@ class JobExecution(JMSOrgBaseModel):
|
||||||
return self.job.get_history(self.job_version)
|
return self.job.get_history(self.job_version)
|
||||||
return self.job
|
return self.job
|
||||||
|
|
||||||
@property
|
|
||||||
def assent_result_detail(self):
|
|
||||||
if not self.is_finished or self.summary.get('error'):
|
|
||||||
return None
|
|
||||||
result = {
|
|
||||||
"summary": self.summary,
|
|
||||||
"detail": [],
|
|
||||||
}
|
|
||||||
for asset in self.current_job.assets.all():
|
|
||||||
asset_detail = {
|
|
||||||
"name": asset.name,
|
|
||||||
"status": "ok",
|
|
||||||
"tasks": [],
|
|
||||||
}
|
|
||||||
if self.summary.get("excludes", None) and self.summary["excludes"].get(asset.name, None):
|
|
||||||
asset_detail.update({"status": "excludes"})
|
|
||||||
result["detail"].append(asset_detail)
|
|
||||||
break
|
|
||||||
if self.result["dark"].get(asset.name, None):
|
|
||||||
asset_detail.update({"status": "failed"})
|
|
||||||
for key, task in self.result["dark"][asset.name].items():
|
|
||||||
task_detail = {"name": key,
|
|
||||||
"output": "{}{}".format(task.get("stdout", ""), task.get("stderr", ""))}
|
|
||||||
asset_detail["tasks"].append(task_detail)
|
|
||||||
if self.result["failures"].get(asset.name, None):
|
|
||||||
asset_detail.update({"status": "failed"})
|
|
||||||
for key, task in self.result["failures"][asset.name].items():
|
|
||||||
task_detail = {"name": key,
|
|
||||||
"output": "{}{}".format(task.get("stdout", ""), task.get("stderr", ""))}
|
|
||||||
asset_detail["tasks"].append(task_detail)
|
|
||||||
|
|
||||||
if self.result["ok"].get(asset.name, None):
|
|
||||||
for key, task in self.result["ok"][asset.name].items():
|
|
||||||
task_detail = {"name": key,
|
|
||||||
"output": "{}{}".format(task.get("stdout", ""), task.get("stderr", ""))}
|
|
||||||
asset_detail["tasks"].append(task_detail)
|
|
||||||
result["detail"].append(asset_detail)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def compile_shell(self):
|
def compile_shell(self):
|
||||||
if self.current_job.type != 'adhoc':
|
if self.current_job.type != 'adhoc':
|
||||||
return
|
return
|
||||||
|
|
|
@ -25,7 +25,6 @@ router.register(r'task-executions', api.CeleryTaskExecutionViewSet, 'task-execut
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('playbook/<uuid:pk>/file/', api.PlaybookFileBrowserAPIView.as_view(), name='playbook-file'),
|
path('playbook/<uuid:pk>/file/', api.PlaybookFileBrowserAPIView.as_view(), name='playbook-file'),
|
||||||
path('variables/help/', api.JobRunVariableHelpAPIView.as_view(), name='variable-help'),
|
path('variables/help/', api.JobRunVariableHelpAPIView.as_view(), name='variable-help'),
|
||||||
path('job-execution/asset-detail/', api.JobAssetDetail.as_view(), name='asset-detail'),
|
|
||||||
path('job-execution/task-detail/<uuid:task_id>/', api.JobExecutionTaskDetail.as_view(), name='task-detail'),
|
path('job-execution/task-detail/<uuid:task_id>/', api.JobExecutionTaskDetail.as_view(), name='task-detail'),
|
||||||
path('username-hints/', api.UsernameHintsAPI.as_view(), name='username-hints'),
|
path('username-hints/', api.UsernameHintsAPI.as_view(), name='username-hints'),
|
||||||
path('ansible/job-execution/<uuid:pk>/log/', api.AnsibleTaskLogApi.as_view(), name='job-execution-log'),
|
path('ansible/job-execution/<uuid:pk>/log/', api.AnsibleTaskLogApi.as_view(), name='job-execution-log'),
|
||||||
|
|
Loading…
Reference in New Issue