Skip to content

Commit

Permalink
Add helper to send application name to ceph-mons
Browse files Browse the repository at this point in the history
Add helper to send application name to ceph-mons. When clients
are connecting to the ceph-mons via a cross-model relation the
ceph-mons have no way to derive the remote application name so
they need to send it via relation data. The corresponding
ceph-mon change is here https://review.opendev.org/736709
  • Loading branch information
Liam Young committed Sep 25, 2020
1 parent 47c0a41 commit cdd9631
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 cdd9631

Please sign in to comment.