mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-15 07:48:38 -05:00
Merge branch 'devel' of github.com:ansible/ansible-tower into merge-devel
This commit is contained in:
@@ -40,6 +40,7 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique, ResourceMixin):
|
||||
('gce', _('Google Compute Engine')),
|
||||
('azure', _('Microsoft Azure')),
|
||||
('openstack', _('OpenStack')),
|
||||
('openstack_v3', _('OpenStack V3')),
|
||||
]
|
||||
|
||||
BECOME_METHOD_CHOICES = [
|
||||
@@ -119,6 +120,13 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique, ResourceMixin):
|
||||
verbose_name=_('Project'),
|
||||
help_text=_('The identifier for the project.'),
|
||||
)
|
||||
domain = models.CharField(
|
||||
blank=True,
|
||||
default='',
|
||||
max_length=100,
|
||||
verbose_name=_('Domain'),
|
||||
help_text=_('The identifier for the domain.'),
|
||||
)
|
||||
ssh_key_data = models.TextField(
|
||||
blank=True,
|
||||
default='',
|
||||
@@ -229,10 +237,19 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique, ResourceMixin):
|
||||
host = self.host or ''
|
||||
if not host and self.kind == 'vmware':
|
||||
raise ValidationError('Host required for VMware credential.')
|
||||
if not host and self.kind == 'openstack':
|
||||
if not host and self.kind in ('openstack', 'openstack_v3'):
|
||||
raise ValidationError('Host required for OpenStack credential.')
|
||||
return host
|
||||
|
||||
def clean_domain(self):
|
||||
"""For case of Keystone v3 identity service that requires a
|
||||
`domain`, that a domain is provided.
|
||||
"""
|
||||
domain = self.domain or ''
|
||||
if not domain and self.kind == 'openstack_v3':
|
||||
raise ValidationError('Domain required for OpenStack with Keystone v3.')
|
||||
return domain
|
||||
|
||||
def clean_username(self):
|
||||
username = self.username or ''
|
||||
if not username and self.kind == 'aws':
|
||||
@@ -242,7 +259,7 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique, ResourceMixin):
|
||||
'credential.')
|
||||
if not username and self.kind == 'vmware':
|
||||
raise ValidationError('Username required for VMware credential.')
|
||||
if not username and self.kind == 'openstack':
|
||||
if not username and self.kind in ('openstack', 'openstack_v3'):
|
||||
raise ValidationError('Username required for OpenStack credential.')
|
||||
return username
|
||||
|
||||
@@ -254,13 +271,13 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique, ResourceMixin):
|
||||
raise ValidationError('API key required for Rackspace credential.')
|
||||
if not password and self.kind == 'vmware':
|
||||
raise ValidationError('Password required for VMware credential.')
|
||||
if not password and self.kind == 'openstack':
|
||||
if not password and self.kind in ('openstack', 'openstack_v3'):
|
||||
raise ValidationError('Password or API key required for OpenStack credential.')
|
||||
return password
|
||||
|
||||
def clean_project(self):
|
||||
project = self.project or ''
|
||||
if self.kind == 'openstack' and not project:
|
||||
if self.kind in ('openstack', 'openstack_v3') and not project:
|
||||
raise ValidationError('Project name required for OpenStack credential.')
|
||||
return project
|
||||
|
||||
|
||||
Reference in New Issue
Block a user