mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 20:00:43 -03:30
Provide linkage from spawned job back to wfj.
This commit is contained in:
parent
16c0bc29a5
commit
54f99749eb
@ -566,7 +566,7 @@ class UnifiedJobSerializer(BaseSerializer):
|
||||
fields = ('*', 'unified_job_template', 'launch_type', 'status',
|
||||
'failed', 'started', 'finished', 'elapsed', 'job_args',
|
||||
'job_cwd', 'job_env', 'job_explanation', 'result_stdout',
|
||||
'execution_node', 'result_traceback')
|
||||
'execution_node', 'result_traceback', 'source_workflow_job')
|
||||
extra_kwargs = {
|
||||
'unified_job_template': {
|
||||
'source': 'unified_job_template_id',
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('main', '0052_v310_inventory_name_non_unique'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='unifiedjob',
|
||||
name='source_workflow_job',
|
||||
field=models.ForeignKey(related_name='spawned_jobs', on_delete=django.db.models.deletion.SET_NULL, default=None, editable=False, to='main.WorkflowJob', null=True),
|
||||
),
|
||||
]
|
||||
@ -528,7 +528,14 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
||||
blank=True,
|
||||
related_name='%(class)s_labels'
|
||||
)
|
||||
|
||||
source_workflow_job = models.ForeignKey(
|
||||
'WorkflowJob',
|
||||
null=True,
|
||||
default=None,
|
||||
editable=False,
|
||||
related_name='spawned_jobs',
|
||||
on_delete=models.SET_NULL,
|
||||
)
|
||||
|
||||
def get_absolute_url(self):
|
||||
real_instance = self.get_real_instance()
|
||||
|
||||
@ -116,6 +116,11 @@ class TaskManager():
|
||||
for spawn_node in spawn_nodes:
|
||||
kv = spawn_node.get_job_kwargs()
|
||||
job = spawn_node.unified_job_template.create_unified_job(**kv)
|
||||
# source_workflow_job is a job-specific field rather than a field copied from job
|
||||
# template, therefore does not fit into the copy routine and should be put outside
|
||||
# of create_unified_job.
|
||||
job.source_workflow_job = workflow_job
|
||||
job.save()
|
||||
spawn_node.job = job
|
||||
spawn_node.save()
|
||||
can_start = job.signal_start(**kv)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user