From fa92b2e851304dc0f71d7feb66ddc84e65bcf606 Mon Sep 17 00:00:00 2001
From: AlanCoding
Date: Mon, 28 Mar 2016 15:02:56 -0400
Subject: [PATCH] back out openstack_v3 options but retain v3 functionality
---
awx/main/constants.py | 2 +-
awx/main/models/base.py | 2 +-
awx/main/models/credential.py | 17 ++++--------
awx/main/models/inventory.py | 6 ----
awx/main/tasks.py | 13 +++------
awx/main/tests/old/inventory.py | 32 +++-------------------
awx/ui/client/src/forms/Credentials.js | 17 ++++--------
awx/ui/client/src/forms/Source.js | 3 +-
awx/ui/client/src/helpers/Credentials.js | 22 +++------------
awx/ui/client/src/helpers/Groups.js | 12 +++-----
awx/ui/client/src/lists/HomeGroups.js | 5 +---
awx/ui/client/src/lists/InventoryGroups.js | 5 +---
12 files changed, 32 insertions(+), 104 deletions(-)
diff --git a/awx/main/constants.py b/awx/main/constants.py
index a6bdafdf5a..64f6265569 100644
--- a/awx/main/constants.py
+++ b/awx/main/constants.py
@@ -1,5 +1,5 @@
# Copyright (c) 2015 Ansible, Inc.
# All Rights Reserved.
-CLOUD_PROVIDERS = ('azure', 'ec2', 'gce', 'rax', 'vmware', 'openstack', 'openstack_v3')
+CLOUD_PROVIDERS = ('azure', 'ec2', 'gce', 'rax', 'vmware', 'openstack')
SCHEDULEABLE_PROVIDERS = CLOUD_PROVIDERS + ('custom',)
diff --git a/awx/main/models/base.py b/awx/main/models/base.py
index c1ddb3600e..0db4f37f38 100644
--- a/awx/main/models/base.py
+++ b/awx/main/models/base.py
@@ -61,7 +61,7 @@ PERMISSION_TYPE_CHOICES = [
(PERM_JOBTEMPLATE_CREATE, _('Create a Job Template')),
]
-CLOUD_INVENTORY_SOURCES = ['ec2', 'rax', 'vmware', 'gce', 'azure', 'openstack', 'openstack_v3', 'custom']
+CLOUD_INVENTORY_SOURCES = ['ec2', 'rax', 'vmware', 'gce', 'azure', 'openstack', 'custom']
VERBOSITY_CHOICES = [
(0, '0 (Normal)'),
diff --git a/awx/main/models/credential.py b/awx/main/models/credential.py
index 0293d18e00..2d40ce6856 100644
--- a/awx/main/models/credential.py
+++ b/awx/main/models/credential.py
@@ -34,7 +34,6 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique):
('gce', _('Google Compute Engine')),
('azure', _('Microsoft Azure')),
('openstack', _('OpenStack')),
- ('openstack_v3', _('OpenStack V3')),
]
BECOME_METHOD_CHOICES = [
@@ -211,18 +210,12 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique):
host = self.host or ''
if not host and self.kind == 'vmware':
raise ValidationError('Host required for VMware credential.')
- if not host and self.kind in ('openstack', 'openstack_v3'):
+ if not host and self.kind == 'openstack':
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
+ return self.domain or ''
def clean_username(self):
username = self.username or ''
@@ -233,7 +226,7 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique):
'credential.')
if not username and self.kind == 'vmware':
raise ValidationError('Username required for VMware credential.')
- if not username and self.kind in ('openstack', 'openstack_v3'):
+ if not username and self.kind == 'openstack':
raise ValidationError('Username required for OpenStack credential.')
return username
@@ -245,13 +238,13 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique):
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 in ('openstack', 'openstack_v3'):
+ if not password and self.kind == 'openstack':
raise ValidationError('Password or API key required for OpenStack credential.')
return password
def clean_project(self):
project = self.project or ''
- if self.kind in ('openstack', 'openstack_v3') and not project:
+ if self.kind == 'openstack' and not project:
raise ValidationError('Project name required for OpenStack credential.')
return project
diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py
index e1dd36e64d..c95c8488bd 100644
--- a/awx/main/models/inventory.py
+++ b/awx/main/models/inventory.py
@@ -748,7 +748,6 @@ class InventorySourceOptions(BaseModel):
('azure', _('Microsoft Azure')),
('vmware', _('VMware vCenter')),
('openstack', _('OpenStack')),
- ('openstack_v3', _('OpenStack V3')),
('custom', _('Custom Script')),
]
@@ -977,11 +976,6 @@ class InventorySourceOptions(BaseModel):
"""I don't think openstack has regions"""
return [('all', 'All')]
- @classmethod
- def get_openstack_v3_region_choices(self):
- """Defer to the behavior of openstack"""
- return self.get_openstack_region_choices()
-
def clean_credential(self):
if not self.source:
return None
diff --git a/awx/main/tasks.py b/awx/main/tasks.py
index 387193b06b..559b6cb4f5 100644
--- a/awx/main/tasks.py
+++ b/awx/main/tasks.py
@@ -710,7 +710,7 @@ class RunJob(BaseTask):
if credential.ssh_key_data not in (None, ''):
private_data[cred_name] = decrypt_field(credential, 'ssh_key_data') or ''
- if job.cloud_credential and job.cloud_credential.kind in ('openstack', 'openstack_v3'):
+ if job.cloud_credential and job.cloud_credential.kind == 'openstack':
credential = job.cloud_credential
openstack_auth = dict(auth_url=credential.host,
username=credential.username,
@@ -802,7 +802,7 @@ class RunJob(BaseTask):
env['VMWARE_USER'] = cloud_cred.username
env['VMWARE_PASSWORD'] = decrypt_field(cloud_cred, 'password')
env['VMWARE_HOST'] = cloud_cred.host
- elif cloud_cred and cloud_cred.kind in ('openstack', 'openstack_v3'):
+ elif cloud_cred and cloud_cred.kind == 'openstack':
env['OS_CLIENT_CONFIG_FILE'] = kwargs.get('private_data_files', {}).get('cloud_credential', '')
# Set environment variables related to scan jobs
@@ -1151,7 +1151,7 @@ class RunInventoryUpdate(BaseTask):
credential = inventory_update.credential
return dict(cloud_credential=decrypt_field(credential, 'ssh_key_data'))
- if inventory_update.source in ('openstack', 'openstack_v3'):
+ if inventory_update.source == 'openstack':
credential = inventory_update.credential
openstack_auth = dict(auth_url=credential.host,
username=credential.username,
@@ -1306,7 +1306,7 @@ class RunInventoryUpdate(BaseTask):
env['GCE_PROJECT'] = passwords.get('source_project', '')
env['GCE_PEM_FILE_PATH'] = cloud_credential
env['GCE_ZONE'] = inventory_update.source_regions
- elif inventory_update.source in ('openstack', 'openstack_v3'):
+ elif inventory_update.source == 'openstack':
env['OS_CLIENT_CONFIG_FILE'] = cloud_credential
elif inventory_update.source == 'file':
# FIXME: Parse source_env to dict, update env.
@@ -1349,11 +1349,6 @@ class RunInventoryUpdate(BaseTask):
# to a shorter variable. :)
src = inventory_update.source
- # OpenStack V3 has everything in common with OpenStack aside
- # from one extra parameter, so share these resources between them.
- if src == 'openstack_v3':
- src = 'openstack'
-
# Get the path to the inventory plugin, and append it to our
# arguments.
plugin_path = self.get_path_to('..', 'plugins', 'inventory',
diff --git a/awx/main/tests/old/inventory.py b/awx/main/tests/old/inventory.py
index 3ac2310160..f4d27ac222 100644
--- a/awx/main/tests/old/inventory.py
+++ b/awx/main/tests/old/inventory.py
@@ -2068,7 +2068,7 @@ class InventoryUpdatesTest(BaseTransactionTest):
self.check_inventory_source(inventory_source)
self.assertFalse(self.group.all_hosts.filter(instance_id='').exists())
- def test_update_from_openstack_v3(self):
+ def test_update_from_openstack_with_domain(self):
# Check that update works with Keystone v3 identity service
api_url = getattr(settings, 'TEST_OPENSTACK_HOST_V3', '')
api_user = getattr(settings, 'TEST_OPENSTACK_USER', '')
@@ -2076,15 +2076,15 @@ class InventoryUpdatesTest(BaseTransactionTest):
api_project = getattr(settings, 'TEST_OPENSTACK_PROJECT', '')
api_domain = getattr(settings, 'TEST_OPENSTACK_DOMAIN', '')
if not all([api_url, api_user, api_password, api_project, api_domain]):
- self.skipTest("No test openstack v3 credentials defined")
+ self.skipTest("No test openstack credentials defined with a domain")
self.create_test_license_file()
- credential = Credential.objects.create(kind='openstack_v3',
+ credential = Credential.objects.create(kind='openstack',
host=api_url,
username=api_user,
password=api_password,
project=api_project,
domain=api_domain)
- inventory_source = self.update_inventory_source(self.group, source='openstack_v3', credential=credential)
+ inventory_source = self.update_inventory_source(self.group, source='openstack', credential=credential)
self.check_inventory_source(inventory_source)
self.assertFalse(self.group.all_hosts.filter(instance_id='').exists())
@@ -2132,27 +2132,3 @@ class InventoryCredentialTest(BaseTest):
self.assertIn('password', response)
self.assertIn('host', response)
self.assertIn('project', response)
-
- def test_openstack_v3_create_ok(self):
- data = {
- 'kind': 'openstack_v3',
- 'name': 'Best credential ever',
- 'username': 'some_user',
- 'password': 'some_password',
- 'project': 'some_project',
- 'host': 'some_host',
- 'domain': 'some_domain',
- }
- self.post(self.url, data=data, expect=201, auth=self.get_super_credentials())
-
- def test_openstack_v3_create_fail_required_fields(self):
- data = {
- 'kind': 'openstack_v3',
- 'name': 'Best credential ever',
- }
- response = self.post(self.url, data=data, expect=400, auth=self.get_super_credentials())
- self.assertIn('username', response)
- self.assertIn('password', response)
- self.assertIn('host', response)
- self.assertIn('project', response)
- self.assertIn('domain', response)
diff --git a/awx/ui/client/src/forms/Credentials.js b/awx/ui/client/src/forms/Credentials.js
index 84aaf804e8..b60906c8e7 100644
--- a/awx/ui/client/src/forms/Credentials.js
+++ b/awx/ui/client/src/forms/Credentials.js
@@ -169,7 +169,7 @@ export default
"host": {
labelBind: 'hostLabel',
type: 'text',
- ngShow: "kind.value == 'vmware' || kind.value == 'openstack' || kind.value === 'openstack_v3'",
+ ngShow: "kind.value == 'vmware' || kind.value == 'openstack'",
awPopOverWatch: "hostPopOver",
awPopOver: "set in helpers/credentials",
dataTitle: 'Host',
@@ -243,7 +243,7 @@ export default
"password": {
labelBind: 'passwordLabel',
type: 'sensitive',
- ngShow: "kind.value == 'scm' || kind.value == 'vmware' || kind.value == 'openstack' || kind.value == 'openstack_v3'",
+ ngShow: "kind.value == 'scm' || kind.value == 'vmware' || kind.value == 'openstack'",
addRequired: false,
editRequired: false,
ask: false,
@@ -338,7 +338,7 @@ export default
"project": {
labelBind: 'projectLabel',
type: 'text',
- ngShow: "kind.value == 'gce' || kind.value == 'openstack' || kind.value == 'openstack_v3'",
+ ngShow: "kind.value == 'gce' || kind.value == 'openstack'",
awPopOverWatch: "projectPopOver",
awPopOver: "set in helpers/credentials",
dataTitle: 'Project ID',
@@ -355,18 +355,13 @@ export default
"domain": {
labelBind: 'domainLabel',
type: 'text',
- ngShow: "kind.value == 'openstack_v3'",
- awPopOverWatch: "domainPopOver",
- awPopOver: "set in helpers/credentials",
- dataTitle: 'Domain Name',
+ ngShow: "kind.value == 'openstack'",
+ awPopOver: "Domain used for Keystone v3
identity service.
",
+ dataTitle: 'Domain Name (optional)',
dataPlacement: 'right',
dataContainer: "body",
addRequired: false,
editRequired: false,
- awRequiredWhen: {
- variable: 'domain_required',
- init: false
- },
subForm: 'credentialSubForm'
},
"vault_password": {
diff --git a/awx/ui/client/src/forms/Source.js b/awx/ui/client/src/forms/Source.js
index 86e6db5477..1eee07b344 100644
--- a/awx/ui/client/src/forms/Source.js
+++ b/awx/ui/client/src/forms/Source.js
@@ -169,8 +169,7 @@ export default
label: 'Source Variables', //"{{vars_label}}" ,
ngShow: "source && (source.value == 'vmware' || " +
- "source.value == 'openstack' || " +
- "source.value == 'openstack_v3')",
+ "source.value == 'openstack')",
type: 'textarea',
addRequired: false,
class: 'Form-textAreaLabel',
diff --git a/awx/ui/client/src/helpers/Credentials.js b/awx/ui/client/src/helpers/Credentials.js
index f1af37a011..f33c724a76 100644
--- a/awx/ui/client/src/helpers/Credentials.js
+++ b/awx/ui/client/src/helpers/Credentials.js
@@ -74,7 +74,8 @@ angular.module('CredentialsHelper', ['Utilities'])
scope.project_required = false;
scope.passwordLabel = 'Password (API Key)';
scope.projectPopOver = "The project value
";
- scope.domainPopOver = "The domain name
";
+ scope.domainPopOver = "Domain used for Keystone v3 " +
+ "
identity service.
";
scope.hostPopOver = "The host value
";
if (!Empty(scope.kind)) {
@@ -126,7 +127,8 @@ angular.module('CredentialsHelper', ['Utilities'])
break;
case 'openstack':
scope.hostLabel = "Host (Authentication URL)";
- scope.projectLabel = "Project (Tenet Name/ID)";
+ scope.projectLabel = "Project (Tenant Name/ID)";
+ scope.domainLabel = "Domain Name (optional)";
scope.password_required = true;
scope.project_required = true;
scope.host_required = true;
@@ -136,22 +138,6 @@ angular.module('CredentialsHelper', ['Utilities'])
" as the username.
";
scope.hostPopOver = "The host to authenticate with." +
"
For example, https://openstack.business.com/v2.0/";
- case 'openstack_v3':
- scope.hostLabel = "Host (Authentication URL)";
- scope.projectLabel = "Project (Tenet Name/ID)";
- scope.domainLabel = "Domain Name";
- scope.password_required = true;
- scope.project_required = true;
- scope.domain_required = true;
- scope.host_required = true;
- scope.username_required = true;
- scope.projectPopOver = "
This is the tenant name " +
- "or tenant id. This value is usually the same " +
- " as the username.
";
- scope.hostPopOver = "The host to authenticate with." +
- "
For example, https://openstack.business.com/v3
";
- scope.domainPopOver = "Domain used for Keystone v3 " +
- "
identity service.
";
break;
}
}
diff --git a/awx/ui/client/src/helpers/Groups.js b/awx/ui/client/src/helpers/Groups.js
index 4e95d96857..eeebb9d8bf 100644
--- a/awx/ui/client/src/helpers/Groups.js
+++ b/awx/ui/client/src/helpers/Groups.js
@@ -305,8 +305,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
field_id: 'source_extra_vars', onReady: callback });
}
if(scope.source.value==="vmware" ||
- scope.source.value==="openstack" ||
- scope.source.value==="openstack_v3"){
+ scope.source.value==="openstack"){
scope.inventory_variables = (Empty(scope.source_vars)) ? "---" : scope.source_vars;
ParseTypeChange({ scope: scope, variable: 'inventory_variables', parse_variable: form.fields.inventory_variables.parseTypeName,
field_id: 'source_inventory_variables', onReady: callback });
@@ -316,8 +315,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
scope.source.value==='gce' ||
scope.source.value === 'azure' ||
scope.source.value === 'vmware' ||
- scope.source.value === 'openstack' ||
- scope.source.value === 'openstack_v3') {
+ scope.source.value === 'openstack') {
if (scope.source.value === 'ec2') {
kind = 'aws';
} else {
@@ -926,8 +924,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
ParseTypeChange({ scope: sources_scope, variable: 'source_vars', parse_variable: SourceForm.fields.source_vars.parseTypeName,
field_id: 'source_source_vars', onReady: waitStop });
} else if (sources_scope.source && (sources_scope.source.value === 'vmware' ||
- sources_scope.source.value === 'openstack' ||
- sources_scope.source.value === 'openstack_v3')) {
+ sources_scope.source.value === 'openstack')) {
Wait('start');
ParseTypeChange({ scope: sources_scope, variable: 'inventory_variables', parse_variable: SourceForm.fields.inventory_variables.parseTypeName,
field_id: 'source_inventory_variables', onReady: waitStop });
@@ -1306,8 +1303,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
}
if (sources_scope.source && (sources_scope.source.value === 'vmware' ||
- sources_scope.source.value === 'openstack' ||
- sources_scope.source.value === 'openstack_v3')) {
+ sources_scope.source.value === 'openstack')) {
data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.inventory_variables, true);
}
diff --git a/awx/ui/client/src/lists/HomeGroups.js b/awx/ui/client/src/lists/HomeGroups.js
index 1c21fb6268..ad7180dff0 100644
--- a/awx/ui/client/src/lists/HomeGroups.js
+++ b/awx/ui/client/src/lists/HomeGroups.js
@@ -76,9 +76,6 @@ export default
},{
name: "OpenStack",
value: "openstack"
- },{
- name: "OpenStack V3",
- value: "openstack_v3"
}],
sourceModel: 'inventory_source',
sourceField: 'source',
@@ -87,7 +84,7 @@ export default
has_external_source: {
label: 'Has external source?',
searchType: 'in',
- searchValue: 'ec2,rax,vmware,azure,gce,openstack,openstack_v3',
+ searchValue: 'ec2,rax,vmware,azure,gce,openstack',
searchOnly: true,
sourceModel: 'inventory_source',
sourceField: 'source'
diff --git a/awx/ui/client/src/lists/InventoryGroups.js b/awx/ui/client/src/lists/InventoryGroups.js
index 3b221e54e0..53881f3d7c 100644
--- a/awx/ui/client/src/lists/InventoryGroups.js
+++ b/awx/ui/client/src/lists/InventoryGroups.js
@@ -51,9 +51,6 @@ export default
},{
name: "OpenStack",
value: "openstack"
- },{
- name: "OpenStack V3",
- value: "openstack_v3"
}],
sourceModel: 'inventory_source',
sourceField: 'source',
@@ -62,7 +59,7 @@ export default
has_external_source: {
label: 'Has external source?',
searchType: 'in',
- searchValue: 'ec2,rax,vmware,azure,gce,openstack,openstack_v3',
+ searchValue: 'ec2,rax,vmware,azure,gce,openstack',
searchOnly: true,
sourceModel: 'inventory_source',
sourceField: 'source'