From 5bf41646a86d48e674588e16041bcdf34c3808cb Mon Sep 17 00:00:00 2001 From: Rodrigo Barbieri Date: Fri, 1 Dec 2023 12:00:03 -0300 Subject: [PATCH] Add config option to override hardcoded service username 'manila' username is hardcoded and cannot be overridden. At the moment the main purpose of this is to allow operator to configure an username that can match manila charm's service credential, which may be "manila", "manila_manilav2" or "-manila". Related-bug: #2043588 Change-Id: I7bcdcd361b633481bd401209a1df614132d34139 (cherry picked from commit ed1b52eaf18e9ff1199a11b60b8dc82dbc88301d) (cherry picked from commit 537992c8b0a8e58f215f3ea6c0997ade2d68aeac) (cherry picked from commit 35aa4668252ce584b991cafbf0a35a9f4901167b) (cherry picked from commit 46be288e3da56eb814d61d5795cf9d3bee843f1b) --- src/config.yaml | 4 ++++ src/reactive/manila_ganesha.py | 17 +++++++++++++---- unit_tests/test_manila_ganesha_handlers.py | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/config.yaml b/src/config.yaml index c7249ad..e0b3214 100644 --- a/src/config.yaml +++ b/src/config.yaml @@ -14,6 +14,10 @@ options: Note that updating this setting to a source that is known to provide a later version of OpenStack will trigger a software upgrade. + service-user: + default: manila + type: string + description: Username used for keystone's service credential. rabbit-user: default: manila type: string diff --git a/src/reactive/manila_ganesha.py b/src/reactive/manila_ganesha.py index 7563043..4e95bc9 100644 --- a/src/reactive/manila_ganesha.py +++ b/src/reactive/manila_ganesha.py @@ -7,7 +7,10 @@ import charms.reactive.relations as relations import charmhelpers.core as ch_core -from charmhelpers.core.hookenv import log +from charmhelpers.core.hookenv import ( + log, + config, +) charms_openstack.bus.discover() @@ -42,12 +45,18 @@ def setup_manila(): } +@reactive.when('config.changed.service-user') +@reactive.when('identity-service.connected') +def update_ident_username(keystone): + """Updates the user to the Identity Service""" + configure_ident_username(keystone) + + @reactive.when_not('identity-service.available') @reactive.when('identity-service.connected') def configure_ident_username(keystone): - """Requests a user to the Identity Service - """ - username = 'manila' + """Requests a user to the Identity Service""" + username = config().get('service-user') keystone.request_credentials(username) diff --git a/unit_tests/test_manila_ganesha_handlers.py b/unit_tests/test_manila_ganesha_handlers.py index 02a449e..c41b858 100644 --- a/unit_tests/test_manila_ganesha_handlers.py +++ b/unit_tests/test_manila_ganesha_handlers.py @@ -49,6 +49,8 @@ def test_hooks(self): 'enable_services_in_non_ha': ('config.rendered', 'ganesha-pool-configured',), 'disable_services': ('cluster.connected',), + 'update_ident_username': ('config.changed.service-user', + 'identity-service.connected',), }, 'when_not': { 'ceph_connected': ('ganesha-pool-configured',),