From 2320efdf793de0cea35fcedd531096e051e970a2 Mon Sep 17 00:00:00 2001 From: "Erlon R. Cruz" Date: Fri, 20 Oct 2023 17:40:16 -0300 Subject: [PATCH] Set service_user_id from keystone relation This is necessary so we can avoid ambiguities (by using the id vs name) when we want to use the service user. (cherry picked from commit f7e65d27b1f93fe00bca13ed3ce741dce3eb9101) --- charmhelpers/contrib/openstack/context.py | 3 ++- tests/contrib/openstack/test_os_contexts.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/charmhelpers/contrib/openstack/context.py b/charmhelpers/contrib/openstack/context.py index 42f15032a..1e667fb03 100644 --- a/charmhelpers/contrib/openstack/context.py +++ b/charmhelpers/contrib/openstack/context.py @@ -545,7 +545,7 @@ def _resolve(key): 'internal_auth_url': internal_auth_url, }) - # we keep all veriables in ctxt for compatibility and + # we keep all variables in ctxt for compatibility and # add nested dictionary for keystone_authtoken generic # templating if keystonemiddleware_os_release: @@ -557,6 +557,7 @@ def _resolve(key): # NOTE(jamespage) this is required for >= icehouse # so a missing value just indicates keystone needs # upgrading + ctxt['admin_user_id'] = _resolve('service_user_id') ctxt['admin_tenant_id'] = _resolve('service_tenant_id') ctxt['admin_domain_id'] = _resolve('service_domain_id') return ctxt diff --git a/tests/contrib/openstack/test_os_contexts.py b/tests/contrib/openstack/test_os_contexts.py index e9ae3adf7..8b7a56d9f 100644 --- a/tests/contrib/openstack/test_os_contexts.py +++ b/tests/contrib/openstack/test_os_contexts.py @@ -1072,6 +1072,7 @@ def test_identity_service_context_with_data(self, *args): 'admin_tenant_id': None, 'admin_domain_id': None, 'admin_user': 'adam', + 'admin_user_id': None, 'auth_host': 'keystone-host.local', 'auth_port': '35357', 'auth_protocol': 'http', @@ -1129,6 +1130,7 @@ def test_identity_service_context_with_altname(self, *args): 'admin_tenant_id': None, 'admin_domain_id': None, 'admin_user': 'adam', + 'admin_user_id': None, 'auth_host': 'keystone-host.local', 'auth_port': '35357', 'auth_protocol': 'http', @@ -1161,6 +1163,7 @@ def test_identity_service_context_with_cache(self, *args): 'admin_tenant_id': None, 'admin_domain_id': None, 'admin_user': 'adam', + 'admin_user_id': None, 'auth_host': 'keystone-host.local', 'auth_port': '35357', 'auth_protocol': 'http', @@ -1192,6 +1195,7 @@ def test_identity_service_context_with_data_http(self, *args): 'admin_tenant_id': '123456', 'admin_domain_id': None, 'admin_user': 'adam', + 'admin_user_id': None, 'auth_host': 'keystone-host.local', 'auth_port': '35357', 'auth_protocol': 'http', @@ -1222,6 +1226,7 @@ def test_identity_service_context_with_data_https(self, *args): 'admin_tenant_id': None, 'admin_domain_id': None, 'admin_user': 'adam', + 'admin_user_id': None, 'auth_host': 'keystone-host.local', 'auth_port': '35357', 'auth_protocol': 'https', @@ -1256,6 +1261,7 @@ def test_identity_service_app_context_with_data_http(self, *args): 'service_project_id': 'svc-proj-id', 'service_domain_id': 'svc-dom-id', 'admin_user': 'svc-user-name', + 'admin_user_id': 'svc-user-id', 'auth_host': 'keystoneadmin.local', 'auth_port': '5000', 'auth_protocol': 'http', @@ -1298,6 +1304,7 @@ def test_identity_service_app_context_with_app_data_nones(self, *args): 'service_project_id': 'svc-proj-id', 'service_domain_id': 'svc-dom-id', 'admin_user': 'adam', # comes from the relation data + 'admin_user_id': 'svc-user-id', 'auth_host': 'keystoneadmin.local', 'auth_port': '5000', 'auth_protocol': 'http', @@ -1334,6 +1341,7 @@ def test_identity_service_context_with_data_versioned(self, *args): 'service_project_id': 'svc-proj-id', 'service_domain_id': 'svc-dom-id', 'admin_user': 'adam', + 'admin_user_id': None, 'auth_host': 'keystone-host.local', 'auth_port': '35357', 'auth_protocol': 'https', @@ -1365,6 +1373,7 @@ def test_identity_service_context_with_admin_role(self, *args): 'admin_tenant_id': None, 'admin_domain_id': None, 'admin_user': 'adam', + 'admin_user_id': None, 'auth_host': 'keystone-host.local', 'auth_port': '35357', 'auth_protocol': 'https', @@ -1421,6 +1430,7 @@ def test_identity_service_context_with_ipv6(self, format_ipv6_addr, *args): 'admin_tenant_id': '123456', 'admin_domain_id': None, 'admin_user': 'adam', + 'admin_user_id': None, 'auth_host': '[2001:db8:1::1]', 'auth_port': '35357', 'auth_protocol': 'http',