Merge "Use network space binding for shared-db relation"
This commit is contained in:
commit
980c2c5cdf
@ -124,9 +124,11 @@ This charm supports the use of Juju Network Spaces, allowing the charm to be bou
|
||||
|
||||
API endpoints can be bound to distinct network spaces supporting the network separation of public, internal and admin endpoints.
|
||||
|
||||
Access to the underlying MySQL instance can also be bound to a specific space using the shared-db relation.
|
||||
|
||||
To use this feature, use the --bind option when deploying the charm:
|
||||
|
||||
juju deploy neutron-api --bind "public=public-space internal=internal-space admin=admin-space"
|
||||
juju deploy neutron-api --bind "public=public-space internal=internal-space admin=admin-space shared-db=internal-space"
|
||||
|
||||
alternatively these can also be provided as part of a juju native bundle configuration:
|
||||
|
||||
@ -137,6 +139,7 @@ alternatively these can also be provided as part of a juju native bundle configu
|
||||
public: public-space
|
||||
admin: admin-space
|
||||
internal: internal-space
|
||||
shared-db: internal-space
|
||||
|
||||
NOTE: Spaces must be configured in the underlying provider prior to attempting to use them.
|
||||
|
||||
|
@ -22,6 +22,7 @@ from charmhelpers.core.hookenv import (
|
||||
status_set,
|
||||
open_port,
|
||||
unit_get,
|
||||
network_get_primary_address,
|
||||
)
|
||||
|
||||
from charmhelpers.core.host import (
|
||||
@ -330,7 +331,14 @@ def db_joined():
|
||||
sync_db_with_multi_ipv6_addresses(config('database'),
|
||||
config('database-user'))
|
||||
else:
|
||||
host = unit_get('private-address')
|
||||
host = None
|
||||
try:
|
||||
# NOTE: try to use network spaces
|
||||
host = network_get_primary_address('shared-db')
|
||||
except NotImplementedError:
|
||||
# NOTE: fallback to private-address
|
||||
host = unit_get('private-address')
|
||||
|
||||
relation_set(database=config('database'),
|
||||
username=config('database-user'),
|
||||
hostname=host)
|
||||
|
@ -74,6 +74,7 @@ TO_PATCH = [
|
||||
'IdentityServiceContext',
|
||||
'force_etcd_restart',
|
||||
'status_set',
|
||||
'network_get_primary_address',
|
||||
]
|
||||
NEUTRON_CONF_DIR = "/etc/neutron"
|
||||
|
||||
@ -117,6 +118,7 @@ class NeutronAPIHooksTests(CharmTestCase):
|
||||
self.test_config.set('openstack-origin', 'distro')
|
||||
self.test_config.set('neutron-plugin', 'ovs')
|
||||
self.neutron_plugin_attribute.side_effect = _mock_nuage_npa
|
||||
self.network_get_primary_address.side_effect = NotImplementedError
|
||||
|
||||
def _fake_relids(self, rel_name):
|
||||
return [randrange(100) for _count in range(2)]
|
||||
@ -341,6 +343,18 @@ class NeutronAPIHooksTests(CharmTestCase):
|
||||
hostname='myhostname',
|
||||
)
|
||||
|
||||
def test_db_joined_spaces(self):
|
||||
self.network_get_primary_address.side_effect = None
|
||||
self.network_get_primary_address.return_value = '192.168.20.1'
|
||||
self.is_relation_made.return_value = False
|
||||
self.unit_get.return_value = 'myhostname'
|
||||
self._call_hook('shared-db-relation-joined')
|
||||
self.relation_set.assert_called_with(
|
||||
username='neutron',
|
||||
database='neutron',
|
||||
hostname='192.168.20.1',
|
||||
)
|
||||
|
||||
def test_db_joined_with_postgresql(self):
|
||||
self.is_relation_made.return_value = True
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user