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
This commit is contained in:
parent
a2db877b41
commit
42727a5e18
@ -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=[]):
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user