diff --git a/src/config.yaml b/src/config.yaml index 6f1b7da..7662a87 100644 --- a/src/config.yaml +++ b/src/config.yaml @@ -30,6 +30,10 @@ options: description: | A comma-separated list of nagios servicegroups. If left empty, the nagios_context will be used as the servicegroup. + 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 2020ab7..b022aa2 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() @@ -41,12 +44,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 a3d8aaf..72bc6e3 100644 --- a/unit_tests/test_manila_ganesha_handlers.py +++ b/unit_tests/test_manila_ganesha_handlers.py @@ -50,6 +50,8 @@ def test_hooks(self): 'ganesha-pool-configured',), 'disable_services': ('cluster.connected',), 'configure_nrpe': ('nrpe-external-master.available',), + 'update_ident_username': ('config.changed.service-user', + 'identity-service.connected',), }, 'when_not': { 'ceph_connected': ('ganesha-pool-configured',),