Fix support for shared-db network spaces

Newer versions of the mysql-shared interface automatically configure
the hostname data item based on either the network space binding for
the relation (for Juju 2.0 and later), or using the units private-address
on older Juju versions.

Change-Id: I8b3e351b0cb475c9859181db03e63fd6365c844e
This commit is contained in:
James Page 2017-01-26 11:54:39 +00:00
parent fdd1e1a70f
commit 93bd2065f7
2 changed files with 5 additions and 8 deletions

View File

@ -20,8 +20,6 @@ from __future__ import absolute_import
import re
import subprocess
import charmhelpers.core.hookenv as hookenv
import charms_openstack.charm
import charms_openstack.adapters
import charms_openstack.ip as os_ip
@ -208,8 +206,7 @@ class ManilaCharm(charms_openstack.charm.HAOpenStackCharm):
return [
dict(
database=self.options.database,
username=self.options.database_user,
hostname=hookenv.unit_private_ip(), )
username=self.options.database_user, )
]
def register_endpoints(self, keystone):

View File

@ -17,6 +17,8 @@ from __future__ import print_function
import mock
import charmhelpers
import charm.openstack.manila as manila
import charms_openstack.test_utils as test_utils
@ -84,7 +86,7 @@ class TestManilaCharmConfigProperties(Helper):
class TestManilaCharm(Helper):
def _patch_config_and_charm(self, config):
self.patch_object(manila.hookenv, 'config')
self.patch_object(charmhelpers.core.hookenv, 'config')
def cf(key=None):
if key is not None:
@ -162,11 +164,9 @@ class TestManilaCharm(Helper):
'database-user': 'user1'
}
c = self._patch_config_and_charm(config)
self.patch_object(manila.hookenv, 'unit_private_ip')
self.unit_private_ip.return_value = 'ip1'
self.assertEqual(
c.get_database_setup(),
[dict(database='db1', username='user1', hostname='ip1')])
[dict(database='db1', username='user1')])
def test_register_endpoints(self):
# note that this also tests _custom_register_endpoints() indirectly,