mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-14 15:58:38 -05:00
AC-537 Add remaining API/field validation for credentials and other objects using credentials.
AC-630 Added validation of cloud_credential kind on job template and job, set environment variables based on cloud credential. AC-610 Require a credential for a cloud inventory source. AC-457 Do not set password when using hg over ssh.
This commit is contained in:
@@ -561,6 +561,21 @@ class InventorySource(PrimordialModel):
|
||||
editable=False,
|
||||
)
|
||||
|
||||
def clean_credential(self):
|
||||
if not self.source:
|
||||
return None
|
||||
cred = self.credential
|
||||
if cred:
|
||||
if self.source == 'ec2' and cred.kind != 'aws':
|
||||
raise ValidationError('Credential kind must be "aws" for an '
|
||||
'"ec2" source')
|
||||
if self.source == 'rax' and cred.kind != 'rax':
|
||||
raise ValidationError('Credential kind must be "rax" for a '
|
||||
'"rax" source')
|
||||
elif self.source in ('ec2', 'rax'):
|
||||
raise ValidationError('Credential is required for a cloud source')
|
||||
return cred
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
new_instance = not bool(self.pk)
|
||||
# If update_fields has been specified, add our field names to it,
|
||||
|
||||
Reference in New Issue
Block a user