mirror of
https://github.com/ansible/awx.git
synced 2026-03-01 16:58:46 -03:30
Expose the EE resolver to the job template detail API endpoints
This commit is contained in:
@@ -724,6 +724,19 @@ class UnifiedJobTemplateSerializer(BaseSerializer):
|
|||||||
else:
|
else:
|
||||||
return super(UnifiedJobTemplateSerializer, self).to_representation(obj)
|
return super(UnifiedJobTemplateSerializer, self).to_representation(obj)
|
||||||
|
|
||||||
|
def get_summary_fields(self, obj):
|
||||||
|
summary_fields = super().get_summary_fields(obj)
|
||||||
|
|
||||||
|
if self.is_detail_view:
|
||||||
|
resolved_ee = obj.resolve_execution_environment()
|
||||||
|
summary_fields['resolved_environment'] = {
|
||||||
|
field: getattr(resolved_ee, field, None)
|
||||||
|
for field in SUMMARIZABLE_FK_FIELDS['execution_environment']
|
||||||
|
if getattr(resolved_ee, field, None) is not None
|
||||||
|
}
|
||||||
|
|
||||||
|
return summary_fields
|
||||||
|
|
||||||
|
|
||||||
class UnifiedJobSerializer(BaseSerializer):
|
class UnifiedJobSerializer(BaseSerializer):
|
||||||
show_capabilities = ['start', 'delete']
|
show_capabilities = ['start', 'delete']
|
||||||
|
|||||||
@@ -477,11 +477,11 @@ class ExecutionEnvironmentMixin(models.Model):
|
|||||||
if wf_template.execution_environment is not None:
|
if wf_template.execution_environment is not None:
|
||||||
return wf_template.execution_environment
|
return wf_template.execution_environment
|
||||||
wf_node = getattr(wf_node.workflow_job, 'unified_job_node', None)
|
wf_node = getattr(wf_node.workflow_job, 'unified_job_node', None)
|
||||||
if getattr(self, 'project', None) and self.project.default_environment is not None:
|
if getattr(self, 'project_id', None) and self.project.default_environment is not None:
|
||||||
return self.project.default_environment
|
return self.project.default_environment
|
||||||
if getattr(self, 'organization', None) and self.organization.default_environment is not None:
|
if getattr(self, 'organization_id', None) and self.organization.default_environment is not None:
|
||||||
return self.organization.default_environment
|
return self.organization.default_environment
|
||||||
if getattr(self, 'inventory', None) and self.inventory.organization is not None:
|
if getattr(self, 'inventory_id', None) and self.inventory.organization is not None:
|
||||||
if self.inventory.organization.default_environment is not None:
|
if self.inventory.organization.default_environment is not None:
|
||||||
return self.inventory.organization.default_environment
|
return self.inventory.organization.default_environment
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user