Skip to content

Commit

Permalink
Set service_user_id from keystone relation
Browse files Browse the repository at this point in the history
This is necessary so we can avoid ambiguities (by using the id vs
name) when we want to use the service user.
  • Loading branch information
sombrafam authored and rodrigogansobarbieri committed Jan 11, 2024
1 parent 57a5c1a commit f7e65d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion charmhelpers/contrib/openstack/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tests/contrib/openstack/test_os_contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit f7e65d2

Please sign in to comment.