1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Merge pull request #24 from matburt/make_credential_required

Make credential required when using a cloud inventory source
This commit is contained in:
Matthew Jones 2015-01-20 09:58:39 -05:00
commit 3beab0a22e

View File

@ -1024,6 +1024,13 @@ class InventorySourceOptionsSerializer(BaseSerializer):
# FIXME # FIXME
return attrs return attrs
def validate_credential(self, attrs, source):
src = attrs.get('source', '')
if src in CLOUD_PROVIDERS:
if attrs.get(source, None) is None:
raise serializers.ValidationError("Credential is required for Cloud source types")
return attrs
def validate_source_script(self, attrs, source): def validate_source_script(self, attrs, source):
src = attrs.get(source, None) src = attrs.get(source, None)
if 'source' in attrs and attrs.get('source', '') == 'custom': if 'source' in attrs and attrs.get('source', '') == 'custom':