From 093f112f386c4415f73560c5eea686af1245d8d6 Mon Sep 17 00:00:00 2001 From: Rodrigo Barbieri Date: Tue, 22 Aug 2023 09:10:56 -0300 Subject: [PATCH] Add name parameter to send_application_name This way, multiple nova-compute applications can share the same ceph key, as nova can invoke send_application_name('nova-compute'). (cherry picked from commit 6a19a0a7090ea552118a7d220a49ab4c66ed6fb9) (cherry picked from commit c29362d5086b86485a349fb08daf5e252dac58ff) --- charmhelpers/contrib/storage/linux/ceph.py | 8 ++++++-- tests/contrib/storage/test_linux_ceph.py | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/charmhelpers/contrib/storage/linux/ceph.py b/charmhelpers/contrib/storage/linux/ceph.py index 1b20b8fe7..2ff7a8885 100644 --- a/charmhelpers/contrib/storage/linux/ceph.py +++ b/charmhelpers/contrib/storage/linux/ceph.py @@ -159,15 +159,19 @@ def get_osd_settings(relation_name): return _order_dict_by_key(osd_settings) -def send_application_name(relid=None): +def send_application_name(relid=None, app_name=None): """Send the application name down the relation. :param relid: Relation id to set application name in. :type relid: str + :param app_name: Application name to send in the relation. + :type app_name: str """ + if app_name is None: + app_name = application_name() relation_set( relation_id=relid, - relation_settings={'application-name': application_name()}) + relation_settings={'application-name': app_name}) def send_osd_settings(): diff --git a/tests/contrib/storage/test_linux_ceph.py b/tests/contrib/storage/test_linux_ceph.py index 2d9433670..51c4863ab 100644 --- a/tests/contrib/storage/test_linux_ceph.py +++ b/tests/contrib/storage/test_linux_ceph.py @@ -285,6 +285,11 @@ def test_send_application_name(self, application_name): self.relation_set.assert_called_once_with( relation_settings={'application-name': 'client'}, relation_id='rid:1') + self.relation_set.reset_mock() + ceph_utils.send_application_name(relid='rid:1', app_name='foo') + self.relation_set.assert_called_once_with( + relation_settings={'application-name': 'foo'}, + relation_id='rid:1') @patch.object(ceph_utils, 'get_osd_settings') def test_send_osd_settings(self, _get_osd_settings):