diff --git a/charmhelpers/contrib/storage/linux/ceph.py b/charmhelpers/contrib/storage/linux/ceph.py index 526b95ad2..0a13e5806 100644 --- a/charmhelpers/contrib/storage/linux/ceph.py +++ b/charmhelpers/contrib/storage/linux/ceph.py @@ -41,6 +41,7 @@ ) from charmhelpers import deprecate from charmhelpers.core.hookenv import ( + application_name, config, service_name, local_unit, @@ -162,6 +163,17 @@ def get_osd_settings(relation_name): return _order_dict_by_key(osd_settings) +def send_application_name(relid=None): + """Send the application name down the relation. + + :param relid: Relation id to set application name in. + :type relid: str + """ + relation_set( + relation_id=relid, + relation_settings={'application-name': application_name()}) + + def send_osd_settings(): """Pass on requested OSD settings to osd units.""" try: diff --git a/tests/contrib/storage/test_linux_ceph.py b/tests/contrib/storage/test_linux_ceph.py index a39d5e289..44e6feb0f 100644 --- a/tests/contrib/storage/test_linux_ceph.py +++ b/tests/contrib/storage/test_linux_ceph.py @@ -267,6 +267,19 @@ def test_get_osd_settings_conflicting_options(self): self._get_osd_settings_test_helper, settings) + @patch.object(ceph_utils, 'application_name') + def test_send_application_name(self, application_name): + application_name.return_value = 'client' + ceph_utils.send_application_name() + self.relation_set.assert_called_once_with( + relation_settings={'application-name': 'client'}, + relation_id=None) + self.relation_set.reset_mock() + ceph_utils.send_application_name(relid='rid:1') + self.relation_set.assert_called_once_with( + relation_settings={'application-name': 'client'}, + relation_id='rid:1') + @patch.object(ceph_utils, 'get_osd_settings') def test_send_osd_settings(self, _get_osd_settings): self.relation_ids.return_value = ['client:1', 'client:3']