diff --git a/hooks/neutron_api_hooks.py b/hooks/neutron_api_hooks.py index 3b00e028..e5fe66f3 100755 --- a/hooks/neutron_api_hooks.py +++ b/hooks/neutron_api_hooks.py @@ -118,8 +118,6 @@ from charmhelpers.contrib.openstack.neutron import ( from charmhelpers.contrib.network.ip import ( get_iface_for_address, get_netmask_for_address, - get_address_in_network, - get_ipv6_addr, is_ipv6, get_relation_ip, ) @@ -514,19 +512,18 @@ def neutron_plugin_api_relation_joined(rid=None): @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', diff --git a/unit_tests/test_neutron_api_hooks.py b/unit_tests/test_neutron_api_hooks.py index 04ba7d52..51361439 100644 --- a/unit_tests/test_neutron_api_hooks.py +++ b/unit_tests/test_neutron_api_hooks.py @@ -82,7 +82,6 @@ TO_PATCH = [ 'unit_get', 'get_iface_for_address', 'get_netmask_for_address', - 'get_address_in_network', 'update_nrpe_config', 'service_reload', 'neutron_plugin_attribute',