mirror of
https://github.com/ansible/awx.git
synced 2026-02-04 11:08:13 -03:30
Initial Scan Job Template type implementation
This commit is contained in:
@@ -1304,11 +1304,19 @@ class JobOptionsSerializer(BaseSerializer):
|
||||
ret['cloud_credential'] = None
|
||||
return ret
|
||||
|
||||
def validate_project(self, attrs, source):
|
||||
project = attrs.get('project', None)
|
||||
if not project and attrs.get('job_type') != PERM_INVENTORY_SCAN:
|
||||
raise serializers.ValidationError("This field is required")
|
||||
return attrs
|
||||
|
||||
def validate_playbook(self, attrs, source):
|
||||
project = attrs.get('project', None)
|
||||
playbook = attrs.get('playbook', '')
|
||||
if project and playbook and smart_str(playbook) not in project.playbooks:
|
||||
raise serializers.ValidationError('Playbook not found for project')
|
||||
if project and not playbook:
|
||||
raise serializers.ValidationError('Must select playbook for project')
|
||||
return attrs
|
||||
|
||||
|
||||
@@ -1470,14 +1478,12 @@ class SystemJobSerializer(UnifiedJobSerializer):
|
||||
args=(obj.system_job_template.pk,))
|
||||
return res
|
||||
|
||||
|
||||
class JobListSerializer(JobSerializer, UnifiedJobListSerializer):
|
||||
pass
|
||||
|
||||
class SystemJobListSerializer(SystemJobSerializer, UnifiedJobListSerializer):
|
||||
pass
|
||||
|
||||
|
||||
class JobHostSummarySerializer(BaseSerializer):
|
||||
|
||||
class Meta:
|
||||
|
||||
@@ -1451,7 +1451,7 @@ class JobTemplateLaunch(GenericAPIView):
|
||||
status=status.HTTP_400_BAD_REQUEST)
|
||||
if obj.credential is None and ('credential' not in request.DATA and 'credential_id' not in request.DATA):
|
||||
return Response(dict(errors="Credential not provided"), status=status.HTTP_400_BAD_REQUEST)
|
||||
if obj.project is None or not obj.project.active:
|
||||
if obj.job_type != PERM_INVENTORY_SCAN and (obj.project is None or not obj.project.active):
|
||||
return Response(dict(errors="Job Template Project is missing or undefined"), status=status.HTTP_400_BAD_REQUEST)
|
||||
if obj.inventory is None or not obj.inventory.active:
|
||||
return Response(dict(errors="Job Template Inventory is missing or undefined"), status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
Reference in New Issue
Block a user