diff options
author | Monty Taylor <mordred@inaugust.com> | 2016-01-23 13:03:55 -0500 |
---|---|---|
committer | David Shrewsbury <shrewsbury.dave@gmail.com> | 2016-01-25 14:56:08 -0500 |
commit | 42727a5e182eade19f4007195ee9058e56ba27bc (patch) | |
tree | a804aff1cb843ee45c1e3f2e7ab9ee989184dc42 | |
parent | a2db877b41fad494fe9daa09b5c77914638ac605 (diff) | |
download | os-client-config-42727a5e182eade19f4007195ee9058e56ba27bc.tar.gz |
Stop ignoring v2password plugin
We have no codepaths that currently set v2password plugin by default.
However, there are some cases, such as old clouds, where a user needs
to explicitly set v2password as the auth_type to avoid version discovery
because their cloud is old enough to not support it. If the user
sets v2password, keep it and align the auth parameters the other
direction to set tenant_name and tenant_id.
Co-Authored-By: David Shrewsbury <shrewsbury.dave@gmail.com>
Change-Id: Ib9eb3ae163b79b67737d01868868187b6dee1756
-rw-r--r-- | os_client_config/config.py | 21 | ||||
-rw-r--r-- | os_client_config/tests/test_config.py | 40 |
2 files changed, 54 insertions, 7 deletions
diff --git a/os_client_config/config.py b/os_client_config/config.py index 0444316..1c47ed7 100644 --- a/os_client_config/config.py +++ b/os_client_config/config.py @@ -474,8 +474,8 @@ class OpenStackConfig(object): name)) def _fix_backwards_madness(self, cloud): - cloud = self._fix_backwards_project(cloud) cloud = self._fix_backwards_auth_plugin(cloud) + cloud = self._fix_backwards_project(cloud) cloud = self._fix_backwards_interface(cloud) cloud = self._handle_domain_id(cloud) return cloud @@ -507,10 +507,6 @@ class OpenStackConfig(object): # Also handle moving domain names into auth so that domain mapping # is easier mappings = { - 'project_id': ('tenant_id', 'tenant-id', - 'project_id', 'project-id'), - 'project_name': ('tenant_name', 'tenant-name', - 'project_name', 'project-name'), 'domain_id': ('domain_id', 'domain-id'), 'domain_name': ('domain_name', 'domain-name'), 'user_domain_id': ('user_domain_id', 'user-domain-id'), @@ -520,6 +516,19 @@ class OpenStackConfig(object): 'project_domain_name', 'project-domain-name'), 'token': ('auth-token', 'auth_token', 'token'), } + if cloud.get('auth_type', None) == 'v2password': + # If v2password is explcitly requested, this is to deal with old + # clouds. That's fine - we need to map settings in the opposite + # direction + mappings['tenant_id'] = ( + 'project_id', 'project-id', 'tenant_id', 'tenant-id') + mappings['tenant_name'] = ( + 'project_name', 'project-name', 'tenant_name', 'tenant-name') + else: + mappings['project_id'] = ( + 'tenant_id', 'tenant-id', 'project_id', 'project-id') + mappings['project_name'] = ( + 'tenant_name', 'tenant-name', 'project_name', 'project-name') for target_key, possible_values in mappings.items(): target = None for key in possible_values: @@ -549,8 +558,6 @@ class OpenStackConfig(object): # use of the auth plugin that can do auto-selection and dealing # with that based on auth parameters. v2password is basically # completely broken - if cloud['auth_type'] == 'v2password': - cloud['auth_type'] = 'password' return cloud def register_argparse_arguments(self, parser, argv, service_keys=[]): diff --git a/os_client_config/tests/test_config.py b/os_client_config/tests/test_config.py index 73be114..10a3d7b 100644 --- a/os_client_config/tests/test_config.py +++ b/os_client_config/tests/test_config.py @@ -713,3 +713,43 @@ class TestBackwardsCompatibility(base.TestCase): 'auth_type': 'v3password', } self.assertDictEqual(expected, result) + + def test_project_v2password(self): + c = config.OpenStackConfig(config_files=[self.cloud_yaml], + vendor_files=[self.vendor_yaml]) + cloud = { + 'auth_type': 'v2password', + 'auth': { + 'project-name': 'my_project_name', + 'project-id': 'my_project_id' + } + } + result = c._fix_backwards_project(cloud) + expected = { + 'auth_type': 'v2password', + 'auth': { + 'tenant_name': 'my_project_name', + 'tenant_id': 'my_project_id' + } + } + self.assertEqual(expected, result) + + def test_project_password(self): + c = config.OpenStackConfig(config_files=[self.cloud_yaml], + vendor_files=[self.vendor_yaml]) + cloud = { + 'auth_type': 'password', + 'auth': { + 'project-name': 'my_project_name', + 'project-id': 'my_project_id' + } + } + result = c._fix_backwards_project(cloud) + expected = { + 'auth_type': 'password', + 'auth': { + 'project_name': 'my_project_name', + 'project_id': 'my_project_id' + } + } + self.assertEqual(expected, result) |