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
This commit is contained in:
James Page 2017-01-25 10:29:36 +00:00
parent ac1a668492
commit 0ff10f440a
2 changed files with 4 additions and 6 deletions

View File

@ -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()

View File

@ -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')