mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 23:17:32 -02:30
Merge pull request #10322 from jbradberry/show-ee-resolver
Expose the EE resolver to the API SUMMARY This change exposes the output of .resolve_execution_environment() for job templates as a new summary field in the API. Note that this is only exposed for the detail views, not the list views. Also, there is the caveat for job templates that may be run under workflows that the workflow EE might override the results of this value. related #10210 ISSUE TYPE Feature Pull Request COMPONENT NAME API AWX VERSION Reviewed-by: Shane McDonald <me@shanemcd.com> Reviewed-by: Christian Adams <rooftopcellist@gmail.com> Reviewed-by: Chris Meyers <None> Reviewed-by: Jeff Bradberry <None>
This commit is contained in:
@@ -724,6 +724,19 @@ class UnifiedJobTemplateSerializer(BaseSerializer):
|
||||
else:
|
||||
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):
|
||||
show_capabilities = ['start', 'delete']
|
||||
|
||||
@@ -478,11 +478,11 @@ class ExecutionEnvironmentMixin(models.Model):
|
||||
if wf_template and wf_template.execution_environment is not None:
|
||||
return wf_template.execution_environment
|
||||
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
|
||||
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
|
||||
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:
|
||||
return self.inventory.organization.default_environment
|
||||
|
||||
|
||||
Reference in New Issue
Block a user