diff --git a/hooks/ceph_hooks.py b/hooks/ceph_hooks.py index a637ff6..53568cd 100755 --- a/hooks/ceph_hooks.py +++ b/hooks/ceph_hooks.py @@ -146,7 +146,8 @@ def notify_radosgws(): def notify_client(): for relid in relation_ids('client'): - client_relation_joined(relid) + for unit in related_units(relid): + client_relation_joined(relid=relid, unit=unit) @hooks.hook('radosgw-relation-changed') @@ -195,7 +196,8 @@ def client_relation_joined(relid=None, unit=None): units = related_units(relid) if len(units) > 0: service_name = units[0].split('/')[0] - + if unit is None: + unit = units[0] if service_name is not None: ceph_addrs = config('monitor-hosts') data = {'key': ceph.get_named_key(service_name), diff --git a/unit_tests/test_ceph_hooks.py b/unit_tests/test_ceph_hooks.py index e6b4f08..63dccdb 100644 --- a/unit_tests/test_ceph_hooks.py +++ b/unit_tests/test_ceph_hooks.py @@ -87,7 +87,9 @@ class TestHooks(test_utils.CharmTestCase): def c(k): x = {'radosgw': ['rados:1'], 'client': ['client:1'], - 'rados:1': ['rados/1']} + 'rados:1': ['rados/1'], + 'client:1': ['client/1'], + } return x[k] self.relation_ids.side_effect = c @@ -124,7 +126,7 @@ class TestHooks(test_utils.CharmTestCase): context, owner='ceph-user', perms=0o600) mock_rgw_rel.assert_called_with(relid='rados:1', unit='rados/1') - mock_client_rel.assert_called_with('client:1') + mock_client_rel.assert_called_with(relid='client:1', unit='client/1') @mock.patch.object(hooks.ceph, 'ceph_user') @mock.patch('subprocess.check_output')