mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
runtime inventory compatibility with blank, and resolve issue #1453
This commit is contained in:
@@ -2140,7 +2140,12 @@ class JobLaunchSerializer(BaseSerializer):
|
|||||||
obj = self.context.get('obj')
|
obj = self.context.get('obj')
|
||||||
data = self.context.get('data')
|
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:
|
if not credential:
|
||||||
errors['credential'] = 'Credential not provided'
|
errors['credential'] = 'Credential not provided'
|
||||||
|
|
||||||
@@ -2174,7 +2179,7 @@ class JobLaunchSerializer(BaseSerializer):
|
|||||||
|
|
||||||
if obj.job_type != PERM_INVENTORY_SCAN and (obj.project is None):
|
if obj.job_type != PERM_INVENTORY_SCAN and (obj.project is None):
|
||||||
errors['project'] = 'Job Template Project is missing or undefined'
|
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'
|
errors['inventory'] = 'Job Template Inventory is missing or undefined'
|
||||||
|
|
||||||
if errors:
|
if errors:
|
||||||
|
|||||||
@@ -265,7 +265,9 @@ class JobTemplate(UnifiedJobTemplate, JobOptions, ResourceMixin):
|
|||||||
Return whether job template can be used to start a new job without
|
Return whether job template can be used to start a new job without
|
||||||
requiring any user input.
|
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
|
@property
|
||||||
def variables_needed_to_start(self):
|
def variables_needed_to_start(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user