1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

runtime inventory compatibility with blank, and resolve issue #1453

This commit is contained in:
AlanCoding 2016-04-08 14:49:42 -04:00
parent f471f9b072
commit 86aa0136a2
2 changed files with 10 additions and 3 deletions

View File

@ -2140,7 +2140,12 @@ class JobLaunchSerializer(BaseSerializer):
obj = self.context.get('obj')
data = self.context.get('data')
credential = attrs.get('credential', obj and obj.credential or None)
if obj and obj.credential is not None:
# force job template to override runtime credential, if present
credential = obj.credential
attrs.pop('credential', None)
else:
credential = attrs.get('credential', None)
if not credential:
errors['credential'] = 'Credential not provided'
@ -2174,7 +2179,7 @@ class JobLaunchSerializer(BaseSerializer):
if obj.job_type != PERM_INVENTORY_SCAN and (obj.project is None):
errors['project'] = 'Job Template Project is missing or undefined'
if obj.inventory is None:
if (obj.inventory is None) and not attrs.get('inventory', None):
errors['inventory'] = 'Job Template Inventory is missing or undefined'
if errors:

View File

@ -265,7 +265,9 @@ class JobTemplate(UnifiedJobTemplate, JobOptions, ResourceMixin):
Return whether job template can be used to start a new job without
requiring any user input.
'''
return bool(self.credential and not len(self.passwords_needed_to_start) and not len(self.variables_needed_to_start))
return bool(self.credential and not len(self.passwords_needed_to_start)
and not len(self.variables_needed_to_start)
and self.inventory)
@property
def variables_needed_to_start(self):