Skip to content

Commit

Permalink
Add config option to override hardcoded service username
Browse files Browse the repository at this point in the history
'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
"<prefix>-manila".

Related-bug: #2043588
Change-Id: I7bcdcd361b633481bd401209a1df614132d34139
(cherry picked from commit ed1b52e)
(cherry picked from commit 537992c)
(cherry picked from commit 35aa466)
(cherry picked from commit 46be288)
  • Loading branch information
rodrigogansobarbieri committed Jan 31, 2024
1 parent dbfcc4e commit 5bf4164
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 13 additions & 4 deletions src/reactive/manila_ganesha.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)


Expand Down
2 changes: 2 additions & 0 deletions unit_tests/test_manila_ganesha_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',),
Expand Down

0 comments on commit 5bf4164

Please sign in to comment.