From 0ff10f440a4c14cc32bc8eb450d5026ba0f1e3e1 Mon Sep 17 00:00:00 2001 From: James Page Date: Wed, 25 Jan 2017 10:29:36 +0000 Subject: [PATCH] Fix network space support for database relation Drop provision of hostname for database configuration; the latest interface versions correctly use Juju 2.0 network space bindings for the relation, or fallback to using the units private-address on older Juju version. Change-Id: I378eef2a7c4acf4225ba73e4c7261bc057f42a24 --- src/reactive/aodh_handlers.py | 3 +-- unit_tests/test_aodh_handlers.py | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/reactive/aodh_handlers.py b/src/reactive/aodh_handlers.py index f6e8e7a..712ff81 100644 --- a/src/reactive/aodh_handlers.py +++ b/src/reactive/aodh_handlers.py @@ -13,7 +13,6 @@ # limitations under the License. import charms.reactive as reactive -import charmhelpers.core.hookenv as hookenv # This charm's library contains all of the handler code associated with # aodh @@ -51,7 +50,7 @@ def setup_database(database): """On receiving database credentials, configure the database on the interface. """ - database.configure('aodh', 'aodh', hookenv.unit_private_ip()) + database.configure('aodh', 'aodh') aodh.assess_status() diff --git a/unit_tests/test_aodh_handlers.py b/unit_tests/test_aodh_handlers.py index 2a1bd3e..df31771 100644 --- a/unit_tests/test_aodh_handlers.py +++ b/unit_tests/test_aodh_handlers.py @@ -88,11 +88,12 @@ class TestAodhHandlers(unittest.TestCase): self._patches = None self._patches_start = None - def patch(self, obj, attr, return_value=None): + def patch(self, obj, attr, return_value=None, side_effect=None): mocked = mock.patch.object(obj, attr) self._patches[attr] = mocked started = mocked.start() started.return_value = return_value + started.side_effect = side_effect self._patches_start[attr] = started setattr(self, attr, started) @@ -152,11 +153,9 @@ class TestAodhHandlers(unittest.TestCase): def test_database(self): database = mock.MagicMock() - self.patch(handlers.hookenv, 'unit_private_ip', 'private_ip') self.patch(handlers.aodh, 'assess_status') handlers.setup_database(database) - database.configure.assert_called_once_with( - 'aodh', 'aodh', 'private_ip') + database.configure.assert_called_once_with('aodh', 'aodh') def test_setup_endpoint(self): self.patch(handlers.aodh, 'setup_endpoint')