Skip to content

Commit

Permalink
Add execution_environment and pull to the fields for UJs and UJTs
Browse files Browse the repository at this point in the history
  • Loading branch information
jbradberry committed Jul 6, 2020
1 parent e8f8c4e commit b524a95
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion awx/api/serializers.py
Expand Up @@ -108,6 +108,7 @@
'host': DEFAULT_SUMMARY_FIELDS,
'group': DEFAULT_SUMMARY_FIELDS,
'default_environment': ('id', 'organization_id', 'image', 'description'),
'execution_environment': ('id', 'organization_id', 'image', 'description'),
'project': DEFAULT_SUMMARY_FIELDS + ('status', 'scm_type'),
'source_project': DEFAULT_SUMMARY_FIELDS + ('status', 'scm_type'),
'project_update': DEFAULT_SUMMARY_FIELDS + ('status', 'failed',),
Expand Down Expand Up @@ -651,7 +652,7 @@ class UnifiedJobTemplateSerializer(BaseSerializer):
class Meta:
model = UnifiedJobTemplate
fields = ('*', 'last_job_run', 'last_job_failed',
'next_job_run', 'status')
'next_job_run', 'status', 'execution_environment', 'pull')

def get_related(self, obj):
res = super(UnifiedJobTemplateSerializer, self).get_related(obj)
Expand All @@ -661,6 +662,9 @@ def get_related(self, obj):
res['last_job'] = obj.last_job.get_absolute_url(request=self.context.get('request'))
if obj.next_schedule:
res['next_schedule'] = obj.next_schedule.get_absolute_url(request=self.context.get('request'))
if obj.execution_environment_id:
res['execution_environment'] = self.reverse('api:execution_environment_detail',
kwargs={'pk': obj.execution_environment_id})
return res

def get_types(self):
Expand Down Expand Up @@ -715,6 +719,7 @@ class UnifiedJobSerializer(BaseSerializer):
class Meta:
model = UnifiedJob
fields = ('*', 'unified_job_template', 'launch_type', 'status',
'execution_environment', 'pull',
'failed', 'started', 'finished', 'canceled_on', 'elapsed', 'job_args',
'job_cwd', 'job_env', 'job_explanation',
'execution_node', 'controller_node',
Expand Down Expand Up @@ -752,6 +757,9 @@ def get_related(self, obj):
res['stdout'] = self.reverse('api:ad_hoc_command_stdout', kwargs={'pk': obj.pk})
if obj.workflow_job_id:
res['source_workflow_job'] = self.reverse('api:workflow_job_detail', kwargs={'pk': obj.workflow_job_id})
if obj.execution_environment_id:
res['execution_environment'] = self.reverse('api:execution_environment_detail',
kwargs={'pk': obj.execution_environment_id})
return res

def get_summary_fields(self, obj):
Expand Down
Expand Up @@ -40,7 +40,7 @@ def project_update(mocker):
@pytest.fixture
def job(mocker, job_template, project_update):
return mocker.MagicMock(pk=5, job_template=job_template, project_update=project_update,
workflow_job_id=None)
workflow_job_id=None, execution_environment_id=None)


@pytest.fixture
Expand Down

0 comments on commit b524a95

Please sign in to comment.