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:
Chris Church
2013-11-19 02:32:40 -05:00
parent 735da6bff6
commit 11d2f76546
9 changed files with 237 additions and 127 deletions
+15
View File
@@ -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,