mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 18:21:12 +03:00
AC-630 Expose cloud_credentials field for job template and job.
This commit is contained in:
parent
2c4062e58b
commit
17899eed3a
@ -852,8 +852,9 @@ class JobTemplateSerializer(BaseSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = JobTemplate
|
model = JobTemplate
|
||||||
fields = BASE_FIELDS + ('job_type', 'inventory', 'project', 'playbook',
|
fields = BASE_FIELDS + ('job_type', 'inventory', 'project', 'playbook',
|
||||||
'credential', 'forks', 'limit', 'verbosity',
|
'credential', 'cloud_credential', 'forks',
|
||||||
'extra_vars', 'job_tags', 'host_config_key')
|
'limit', 'verbosity', 'extra_vars', 'job_tags',
|
||||||
|
'host_config_key')
|
||||||
|
|
||||||
def get_related(self, obj):
|
def get_related(self, obj):
|
||||||
if obj is None:
|
if obj is None:
|
||||||
@ -866,6 +867,9 @@ class JobTemplateSerializer(BaseSerializer):
|
|||||||
))
|
))
|
||||||
if obj.credential:
|
if obj.credential:
|
||||||
res['credential'] = reverse('api:credential_detail', args=(obj.credential.pk,))
|
res['credential'] = reverse('api:credential_detail', args=(obj.credential.pk,))
|
||||||
|
if obj.cloud_credential:
|
||||||
|
res['cloud_credential'] = reverse('api:credential_detail',
|
||||||
|
args=(obj.cloud_credential.pk,))
|
||||||
if obj.host_config_key:
|
if obj.host_config_key:
|
||||||
res['callback'] = reverse('api:job_template_callback', args=(obj.pk,))
|
res['callback'] = reverse('api:job_template_callback', args=(obj.pk,))
|
||||||
return res
|
return res
|
||||||
@ -885,7 +889,7 @@ class JobSerializer(BaseSerializer):
|
|||||||
model = Job
|
model = Job
|
||||||
fields = ('id', 'url', 'related', 'summary_fields', 'created',
|
fields = ('id', 'url', 'related', 'summary_fields', 'created',
|
||||||
'modified', 'job_template', 'job_type', 'inventory',
|
'modified', 'job_template', 'job_type', 'inventory',
|
||||||
'project', 'playbook', 'credential',
|
'project', 'playbook', 'credential', 'cloud_credential',
|
||||||
'forks', 'limit', 'verbosity', 'extra_vars',
|
'forks', 'limit', 'verbosity', 'extra_vars',
|
||||||
'job_tags', 'launch_type', 'status', 'failed',
|
'job_tags', 'launch_type', 'status', 'failed',
|
||||||
'result_stdout', 'result_traceback',
|
'result_stdout', 'result_traceback',
|
||||||
@ -905,6 +909,9 @@ class JobSerializer(BaseSerializer):
|
|||||||
))
|
))
|
||||||
if obj.job_template:
|
if obj.job_template:
|
||||||
res['job_template'] = reverse('api:job_template_detail', args=(obj.job_template.pk,))
|
res['job_template'] = reverse('api:job_template_detail', args=(obj.job_template.pk,))
|
||||||
|
if obj.cloud_credential:
|
||||||
|
res['cloud_credential'] = reverse('api:credential_detail',
|
||||||
|
args=(obj.cloud_credential.pk,))
|
||||||
if obj.can_start or True:
|
if obj.can_start or True:
|
||||||
res['start'] = reverse('api:job_start', args=(obj.pk,))
|
res['start'] = reverse('api:job_start', args=(obj.pk,))
|
||||||
if obj.can_cancel or True:
|
if obj.can_cancel or True:
|
||||||
@ -927,6 +934,8 @@ class JobSerializer(BaseSerializer):
|
|||||||
data.setdefault('playbook', job_template.playbook)
|
data.setdefault('playbook', job_template.playbook)
|
||||||
if job_template.credential:
|
if job_template.credential:
|
||||||
data.setdefault('credential', job_template.credential.pk)
|
data.setdefault('credential', job_template.credential.pk)
|
||||||
|
if job_template.cloud_credential:
|
||||||
|
data.setdefault('cloud_credential', job_template.cloud_credential.pk)
|
||||||
data.setdefault('forks', job_template.forks)
|
data.setdefault('forks', job_template.forks)
|
||||||
data.setdefault('limit', job_template.limit)
|
data.setdefault('limit', job_template.limit)
|
||||||
data.setdefault('verbosity', job_template.verbosity)
|
data.setdefault('verbosity', job_template.verbosity)
|
||||||
|
@ -432,8 +432,8 @@ class JobTemplateTest(BaseJobTestMixin, django.test.TestCase):
|
|||||||
JOB_TEMPLATE_FIELDS = ('id', 'url', 'related', 'summary_fields', 'created',
|
JOB_TEMPLATE_FIELDS = ('id', 'url', 'related', 'summary_fields', 'created',
|
||||||
'modified', 'name', 'description', 'job_type',
|
'modified', 'name', 'description', 'job_type',
|
||||||
'inventory', 'project', 'playbook', 'credential',
|
'inventory', 'project', 'playbook', 'credential',
|
||||||
'forks', 'limit', 'verbosity', 'extra_vars',
|
'cloud_credential', 'forks', 'limit', 'verbosity',
|
||||||
'job_tags', 'host_config_key',)
|
'extra_vars', 'job_tags', 'host_config_key',)
|
||||||
|
|
||||||
def test_get_job_template_list(self):
|
def test_get_job_template_list(self):
|
||||||
url = reverse('api:job_template_list')
|
url = reverse('api:job_template_list')
|
||||||
@ -541,6 +541,7 @@ class JobTemplateTest(BaseJobTestMixin, django.test.TestCase):
|
|||||||
self.head(url)
|
self.head(url)
|
||||||
response = self.get(url)
|
response = self.get(url)
|
||||||
self.assertEqual(response['url'], url)
|
self.assertEqual(response['url'], url)
|
||||||
|
self.assertEqual(response['cloud_credential'], None)
|
||||||
|
|
||||||
# FIXME: Check other credentials and optional fields.
|
# FIXME: Check other credentials and optional fields.
|
||||||
|
|
||||||
@ -663,6 +664,7 @@ class JobTest(BaseJobTestMixin, django.test.TestCase):
|
|||||||
self.head(url)
|
self.head(url)
|
||||||
response = self.get(url)
|
response = self.get(url)
|
||||||
self.assertEqual(response['url'], url)
|
self.assertEqual(response['url'], url)
|
||||||
|
self.assertEqual(response['cloud_credential'], None)
|
||||||
|
|
||||||
# FIXME: Check with other credentials and optional fields.
|
# FIXME: Check with other credentials and optional fields.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user