From bbdfeb48283b46bd6915c7fcc0a95af7db69acaf Mon Sep 17 00:00:00 2001 From: James Page Date: Wed, 6 Oct 2021 09:39:09 +0100 Subject: [PATCH] Add support for CMR Although not a typical deployment scenario the ceph-mon charm will support cross model relations. To use this feature the local unit name must be exposed on the relation so that the ceph-mon charm can target broker responses back to individual units. Juju obfuscates this to a remote-UUID label so the normal use of the hookenv set remote unit does not work correctly. Change-Id: I67142f782008f891f7dccba3a37e9616c3060af9 --- interface_ceph_client/ceph_client.py | 8 ++++++-- unit_tests/test_interface_ceph_client.py | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/interface_ceph_client/ceph_client.py b/interface_ceph_client/ceph_client.py index 74efdb7..13c3fed 100755 --- a/interface_ceph_client/ceph_client.py +++ b/interface_ceph_client/ceph_client.py @@ -56,8 +56,12 @@ class CephClientRequires(Object): self.previous_requests = self.get_previous_requests_from_relations() def on_joined(self, event): - relation = self.model.relations[self.relation_name] - if relation: + relations = self.model.relations[self.relation_name] + if relations: + # Setup unit-name for CMR on the relation + for relation in relations: + relation.data[self.this_unit]["unit-name"] = \ + self.this_unit.name logging.info("emiting broker_available") self._stored.broker_available = True self.on.broker_available.emit() diff --git a/unit_tests/test_interface_ceph_client.py b/unit_tests/test_interface_ceph_client.py index 2515c42..1c0764d 100644 --- a/unit_tests/test_interface_ceph_client.py +++ b/unit_tests/test_interface_ceph_client.py @@ -83,6 +83,7 @@ class TestCephClientRequires(unittest.TestCase): 'client/0': { 'remote_unit_data': { 'ingress-address': '192.0.2.4', + 'unit-name': 'client/0', 'broker_req': ( '{"api-version": 1, ' '"ops": [{"op": "create-pool", "name": "tmbtil", '