Network space aware address for cluster relation
Use the get_relation_ip function for selecting addresses for the cluster relationship. Including overrides for the admin, internal, and public config settings or extra bindings. Partial-Bug: #1687439 Change-Id: Ib554aa390a4bad04e8ad689effb8ab1739e84e26
This commit is contained in:
parent
124b5ab5a0
commit
bbe300f5ca
|
@ -100,10 +100,8 @@ from charmhelpers.payload.execd import (
|
|||
execd_preinstall
|
||||
)
|
||||
from charmhelpers.contrib.network.ip import (
|
||||
get_address_in_network,
|
||||
get_netmask_for_address,
|
||||
get_iface_for_address,
|
||||
get_ipv6_addr,
|
||||
is_ipv6,
|
||||
get_relation_ip,
|
||||
)
|
||||
|
@ -420,19 +418,18 @@ def config_changed():
|
|||
|
||||
@hooks.hook('cluster-relation-joined')
|
||||
def cluster_joined(relation_id=None):
|
||||
settings = {}
|
||||
|
||||
for addr_type in ADDRESS_TYPES:
|
||||
address = get_address_in_network(
|
||||
config('os-{}-network'.format(addr_type))
|
||||
)
|
||||
address = get_relation_ip(
|
||||
addr_type,
|
||||
cidr_network=config('os-{}-network'.format(addr_type)))
|
||||
if address:
|
||||
relation_set(
|
||||
relation_id=relation_id,
|
||||
relation_settings={'{}-address'.format(addr_type): address}
|
||||
)
|
||||
if config('prefer-ipv6'):
|
||||
private_addr = get_ipv6_addr(exc_list=[config('vip')])[0]
|
||||
relation_set(relation_id=relation_id,
|
||||
relation_settings={'private-address': private_addr})
|
||||
settings['{}-address'.format(addr_type)] = address
|
||||
|
||||
settings['private-address'] = get_relation_ip('cluster')
|
||||
|
||||
relation_set(relation_id=relation_id, relation_settings=settings)
|
||||
|
||||
|
||||
@hooks.hook('cluster-relation-changed')
|
||||
|
|
|
@ -95,7 +95,6 @@ TO_PATCH = [
|
|||
'get_hacluster_config',
|
||||
'get_netmask_for_address',
|
||||
'get_iface_for_address',
|
||||
'get_ipv6_addr',
|
||||
'sync_db_with_multi_ipv6_addresses',
|
||||
'delete_keyring',
|
||||
'get_relation_ip',
|
||||
|
@ -691,7 +690,7 @@ class GlanceRelationTests(CharmTestCase):
|
|||
configs.complete_contexts = MagicMock()
|
||||
configs.complete_contexts.return_value = ['cluster']
|
||||
configs.write = MagicMock()
|
||||
self.get_ipv6_addr.return_value = '2001:db8:1::1'
|
||||
self.get_relation_ip.return_value = '2001:db8:1::1'
|
||||
self.relation_ids.return_value = ['cluster:0']
|
||||
relations.cluster_changed()
|
||||
self.assertEquals([call('/etc/glance/glance-api.conf'),
|
||||
|
|
Loading…
Reference in New Issue