mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 19:35:02 -02:30
Merge pull request #1837 from AlanCoding/1826_job_runtime_validation
Protect against special scan job cases in job runtime validation
This commit is contained in:
@@ -2284,6 +2284,15 @@ class JobLaunchSerializer(BaseSerializer):
|
|||||||
if (obj.inventory is None) and not attrs.get('inventory', 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.'
|
||||||
|
|
||||||
|
# Special prohibited cases for scan jobs
|
||||||
|
if 'job_type' in data and obj.ask_job_type_on_launch:
|
||||||
|
if ((obj.job_type==PERM_INVENTORY_SCAN and not data['job_type']==PERM_INVENTORY_SCAN) or
|
||||||
|
(data['job_type']==PERM_INVENTORY_SCAN and not obj['job_type']==PERM_INVENTORY_SCAN)):
|
||||||
|
errors['job_type'] = 'Can not override job_type to or from a scan job.'
|
||||||
|
if (obj.job_type==PERM_INVENTORY_SCAN and ('inventory' in data) and obj.ask_inventory_on_launch and
|
||||||
|
obj.inventory != data['inventory']):
|
||||||
|
errors['inventory'] = 'Inventory can not be changed at runtime for scan jobs.'
|
||||||
|
|
||||||
if errors:
|
if errors:
|
||||||
raise serializers.ValidationError(errors)
|
raise serializers.ValidationError(errors)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user