Skip to content

Commit

Permalink
Merge pull request juju#481 from gnuoy/bug/1780712
Browse files Browse the repository at this point in the history
Add helper to send application name to ceph-mons
  • Loading branch information
javacruft authored Sep 28, 2020
2 parents 77f119a + 02656fa commit 84fd5aa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions charmhelpers/contrib/storage/linux/ceph.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
)
from charmhelpers import deprecate
from charmhelpers.core.hookenv import (
application_name,
config,
service_name,
local_unit,
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions tests/contrib/storage/test_linux_ceph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit 84fd5aa

Please sign in to comment.