Add network space support for HA API endpoints
Switch to using the get_relation_ip helper when resolving internal, public and admin endpoint network configuration, providing compatibility with Juju 2.0 network spaces. Change-Id: Ia6fbf479259b50d938b6798ca17e5dc073c99812
This commit is contained in:
parent
8e78f89c17
commit
fab13633ed
|
@ -259,7 +259,9 @@ class PeerHARelationAdapter(OpenStackRelationAdapter):
|
|||
"""
|
||||
cfg_opt = os_ip.ADDRESS_MAP[os_ip.INTERNAL]['config']
|
||||
int_net = self.config.get(cfg_opt)
|
||||
laddr = ch_ip.get_address_in_network(int_net) or self.local_address
|
||||
laddr = ch_ip.get_relation_ip(
|
||||
os_ip.ADDRESS_MAP[os_ip.INTERNAL]['binding'],
|
||||
int_net)
|
||||
try:
|
||||
hosts = sorted(
|
||||
list(self.cluster_hosts[laddr]['backends'].values()))
|
||||
|
@ -316,7 +318,9 @@ class PeerHARelationAdapter(OpenStackRelationAdapter):
|
|||
_cluster_hosts = {}
|
||||
for addr_type in ADDRESS_TYPES:
|
||||
cfg_opt = os_ip.ADDRESS_MAP[addr_type]['config']
|
||||
laddr = ch_ip.get_address_in_network(config.get(cfg_opt))
|
||||
laddr = ch_ip.get_relation_ip(
|
||||
os_ip.ADDRESS_MAP[addr_type]['binding'],
|
||||
config.get(cfg_opt))
|
||||
if laddr:
|
||||
netmask = ch_ip.get_netmask_for_address(laddr)
|
||||
_cluster_hosts[laddr] = {
|
||||
|
@ -351,7 +355,9 @@ class PeerHARelationAdapter(OpenStackRelationAdapter):
|
|||
"""
|
||||
for addr_type in ADDRESS_TYPES:
|
||||
cfg_opt = os_ip.ADDRESS_MAP[addr_type]['config']
|
||||
laddr = ch_ip.get_address_in_network(self.config.get(cfg_opt))
|
||||
laddr = ch_ip.get_relation_ip(
|
||||
os_ip.ADDRESS_MAP[addr_type]['binding'],
|
||||
self.config.get(cfg_opt))
|
||||
if laddr:
|
||||
self.cluster_hosts[laddr] = \
|
||||
self.local_network_split_addresses()[laddr]
|
||||
|
|
|
@ -724,7 +724,9 @@ class HAOpenStackCharm(OpenStackAPICharm):
|
|||
laddrs = []
|
||||
for addr_type in sorted(os_ip.ADDRESS_MAP.keys()):
|
||||
cidr = self.config.get(os_ip.ADDRESS_MAP[addr_type]['config'])
|
||||
laddr = ch_ip.get_address_in_network(cidr)
|
||||
laddr = ch_ip.get_relation_ip(
|
||||
os_ip.ADDRESS_MAP[addr_type]['binding'],
|
||||
cidr)
|
||||
laddrs.append((addr_type, laddr))
|
||||
with is_data_changed('update_peers.laddrs', laddrs) as changed:
|
||||
if changed:
|
||||
|
|
|
@ -251,8 +251,8 @@ class TestPeerHARelationAdapter(unittest.TestCase):
|
|||
}
|
||||
del expect_local_ns['this_unit_private_addr']
|
||||
# Tests PeerHARelationAdapter with peers
|
||||
with mock.patch.object(adapters.ch_ip, 'get_address_in_network',
|
||||
new=lambda x: test_addresses.get(x)), \
|
||||
with mock.patch.object(adapters.ch_ip, 'get_relation_ip',
|
||||
new=lambda _, x: test_addresses.get(x)), \
|
||||
mock.patch.object(adapters.ch_ip, 'get_netmask_for_address',
|
||||
new=lambda x: test_netmasks.get(x)), \
|
||||
mock.patch.object(adapters, 'APIConfigurationAdapter',
|
||||
|
@ -275,8 +275,8 @@ class TestPeerHARelationAdapter(unittest.TestCase):
|
|||
'this_unit_internal_addr'])
|
||||
|
||||
# Tests PeerHARelationAdapter without peers
|
||||
with mock.patch.object(adapters.ch_ip, 'get_address_in_network',
|
||||
new=lambda x: test_addresses.get(x)), \
|
||||
with mock.patch.object(adapters.ch_ip, 'get_relation_ip',
|
||||
new=lambda _, x: test_addresses.get(x)), \
|
||||
mock.patch.object(adapters.ch_ip, 'get_netmask_for_address',
|
||||
new=lambda x: test_netmasks.get(x)), \
|
||||
mock.patch.object(adapters, 'APIConfigurationAdapter',
|
||||
|
|
Loading…
Reference in New Issue