Set service_type on identity relation

Also applies osci.yaml fix for Jammy.

Change-Id: I4cf5d8c0855bb9a3cd6068335fe8100366c0a66d
Related-Bug: #1965967
(cherry picked from commit 08960ba9b7)
(cherry picked from commit 2be04d3ae9)
This commit is contained in:
Edward Hope-Morley 2022-03-26 11:22:58 +00:00
parent 8c8df4f7dc
commit 3c8514d223
2 changed files with 21 additions and 2 deletions

View File

@ -464,6 +464,10 @@ valid_services = {
"type": "workloads",
"desc": "TrilioVault Workload Manager Service",
},
"keystone": {
"type": "identity",
"desc": "Keystone Identity Service",
},
}
# The interface is said to be satisfied if anyone of the interfaces in the
@ -1581,8 +1585,9 @@ def ensure_initial_admin(config):
set_admin_passwd, tenant='admin',
new_roles=[config('admin-role')])
create_service_entry("keystone", "identity",
"Keystone Identity Service")
service_type = valid_services['keystone']['type']
desc = valid_services['keystone']['desc']
create_service_entry("keystone", service_type, desc)
for region in config('region').split():
create_keystone_endpoint(public_ip=resolve_address(PUBLIC),
@ -1881,6 +1886,12 @@ def add_service_to_keystone(relation_id=None, remote_unit=None):
relation_data["api_version"] = get_api_version()
relation_data["admin_domain_id"] = leader_get(
attribute='admin_domain_id')
if 'service' in settings:
svc_name = settings['service'].partition('_')[0]
relation_data['service_type'] = \
valid_services[svc_name]['type']
# Allow the remote service to request creation of any additional
# roles. Currently used by Horizon
for role in requested_roles:
@ -2012,6 +2023,12 @@ def add_service_to_keystone(relation_id=None, remote_unit=None):
get_real_role_names(requested_roles, manager))
}
# get service key
svckey = [k for k in settings if k.endswith('_service')] or ['service']
if svckey[0] in settings:
relation_data['service_type'] = \
valid_services[settings[svckey[0]]]['type']
peer_store_and_set(relation_id=relation_id, **relation_data)
# NOTE(dosaboy): '__null__' settings are for peer relation only so that
# settings can flushed so we filter them out for non-peer relation.

View File

@ -409,6 +409,7 @@ class TestKeystoneUtils(CharmTestCase):
'auth_port': 80,
'auth_protocol': 'https',
'service_port': 81,
'service_type': 'identity',
'internal_host': '10.10.10.10',
'internal_protocol': 'https',
'internal_port': 81,
@ -508,6 +509,7 @@ class TestKeystoneUtils(CharmTestCase):
'service_domain': service_domain,
'service_domain_id': service_domain_id,
'service_tenant': 'tenant',
'service_type': 'identity',
'https_keystone': '__null__',
'ssl_cert': '__null__', 'ssl_key': '__null__',
'ca_cert': '__null__',