From 03f0526cfbd8e6c380d27080cc6f163077c955b2 Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Tue, 28 Apr 2015 18:18:24 -0300 Subject: [PATCH 1/2] Use ceph-public-address instead of private-address when relating to mon --- hooks/hooks.py | 8 +++----- unit_tests/test_hooks.py | 9 +++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/hooks/hooks.py b/hooks/hooks.py index 9b3699ac..fbb1952c 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -199,11 +199,9 @@ def get_mon_hosts(): hosts = [] for relid in relation_ids('mon'): for unit in related_units(relid): - hosts.append( - '{}:6789'.format(get_host_ip( - relation_get('private-address', - unit, relid))) - ) + host_ip = get_host_ip(relation_get('ceph-public-address', + unit, relid)) + hosts.append('{}:6789'.format(host_ip)) hosts.sort() return hosts diff --git a/unit_tests/test_hooks.py b/unit_tests/test_hooks.py index f494ab74..46279486 100644 --- a/unit_tests/test_hooks.py +++ b/unit_tests/test_hooks.py @@ -213,8 +213,13 @@ class CephRadosGWTests(CharmTestCase): def test_get_mon_hosts(self): self.relation_ids.return_value = ['monrelid'] self.related_units.return_value = ['monunit'] - self.relation_get.return_value = '10.0.0.1' - self.get_host_ip.return_value = '10.0.0.1' + + def rel_get(k, *args): + return {'private-address': '127.0.0.1', + 'ceph-public-address': '10.0.0.1'}[k] + + self.relation_get.side_effect = rel_get + self.get_host_ip.side_effect = lambda x: x self.assertEquals(ceph_hooks.get_mon_hosts(), ['10.0.0.1:6789']) def test_get_conf(self): From f69ef407ba5da3cb1a7d85394e112923b77d75e1 Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Tue, 28 Apr 2015 18:20:22 -0300 Subject: [PATCH 2/2] Fix lint warning --- unit_tests/test_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit_tests/test_utils.py b/unit_tests/test_utils.py index bd257485..060fba97 100644 --- a/unit_tests/test_utils.py +++ b/unit_tests/test_utils.py @@ -25,7 +25,7 @@ def load_config(): if not config: logging.error('Could not find config.yaml in any parent directory ' - 'of %s. ' % file) + 'of %s. ' % f) raise Exception return yaml.safe_load(open(config).read())['options']