mirror of https://github.com/jumpserver/jumpserver
perf: 修改 ops job 约束
parent
7c429163ce
commit
4220c72cd3
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b3c3f8e65468adb0105f2cbcbb8aa3ed50066c9db439a9921932c6e2adcacec3
|
||||
size 119640
|
||||
oid sha256:ee001334775456ab2034f9ac1905f7a9299ff763d3d2c9d394d340b75ceffb6f
|
||||
size 119830
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0c3f5102d732ffe768f0545cf9271bbba45ba4c159f0a348b518b58cbdb5f20c
|
||||
size 105947
|
||||
oid sha256:51dd2a03462cbc3ae08d6257dec51a867b3431bf6b0800c996847a219a11aee0
|
||||
size 106203
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 3.2.14 on 2023-02-03 08:40
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('ops', '0025_auto_20230117_1130'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='jobexecution',
|
||||
name='job',
|
||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='executions', to='ops.job'),
|
||||
),
|
||||
]
|
|
@ -1,4 +1,3 @@
|
|||
import datetime
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
@ -97,7 +96,7 @@ class JobExecution(JMSOrgBaseModel):
|
|||
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
|
||||
task_id = models.UUIDField(null=True)
|
||||
status = models.CharField(max_length=16, verbose_name=_('Status'), default=JobStatus.running)
|
||||
job = models.ForeignKey(Job, on_delete=models.CASCADE, related_name='executions', null=True)
|
||||
job = models.ForeignKey(Job, on_delete=models.SET_NULL, related_name='executions', null=True)
|
||||
job_version = models.IntegerField(default=0)
|
||||
parameters = models.JSONField(default=dict, verbose_name=_('Parameters'))
|
||||
result = models.JSONField(blank=True, null=True, verbose_name=_('Result'))
|
||||
|
@ -122,41 +121,42 @@ class JobExecution(JMSOrgBaseModel):
|
|||
|
||||
@property
|
||||
def assent_result_detail(self):
|
||||
if self.is_finished and not self.summary.get('error', None):
|
||||
result = {
|
||||
"summary": self.count,
|
||||
"detail": [],
|
||||
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": [],
|
||||
}
|
||||
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)
|
||||
if self.summary.get("excludes", None) and self.summary["excludes"].get(asset.name, None):
|
||||
asset_detail.update({"status": "excludes"})
|
||||
result["detail"].append(asset_detail)
|
||||
return result
|
||||
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
|
||||
|
||||
@property
|
||||
def job_type(self):
|
||||
|
|
Loading…
Reference in New Issue