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

View File

@@ -255,6 +255,22 @@ class Credential(CommonModelNameNotUnique):
def get_absolute_url(self):
return reverse('api:credential_detail', args=(self.pk,))
def clean_username(self):
username = self.username or ''
if not username and self.kind == 'aws':
raise ValidationError('Access key required for "aws" credential')
if not username and self.kind == 'rax':
raise ValidationError('Username required for "rax" credential')
return username
def clean_password(self):
password = self.password or ''
if not password and self.kind == 'aws':
raise ValidationError('Secret key required for "aws" credential')
if not password and self.kind == 'rax':
raise ValidationError('API key required for "rax" credential')
return password
def clean_ssh_key_unlock(self):
if self.pk:
ssh_key_data = decrypt_field(self, 'ssh_key_data')