Selects IPv4 preferentially for internal_ip
Hadoop doesn't support IPv6. Selects IPv4 preferentially for internal_ip/management_ip when private network has IPv4/IPv6 dual subnets. Change-Id: Ibc808d5467ea6db081cdc98655c7eb7faffa6ec3 Closes-Bug: #1489433
This commit is contained in:
parent
742023fd13
commit
1622710e2b
@ -42,8 +42,9 @@ def init_instances_ips(instance):
|
||||
management_ip = None
|
||||
internal_ip = None
|
||||
|
||||
for network_label, addresses in six.iteritems(server.addresses):
|
||||
for address in addresses:
|
||||
for addresses in six.itervalues(server.addresses):
|
||||
# selects IPv4 preferentially
|
||||
for address in sorted(addresses, key=lambda addr: addr['version']):
|
||||
if address['OS-EXT-IPS:type'] == 'fixed':
|
||||
internal_ip = internal_ip or address['addr']
|
||||
else:
|
||||
|
@ -138,3 +138,27 @@ class TestNetworks(base.SaharaTestCase):
|
||||
neutron.return_value = neutron_client
|
||||
|
||||
self.assertEqual('10.2.2.2', networks.init_instances_ips(mock.Mock()))
|
||||
|
||||
@mock.patch('sahara.service.networks.conductor.instance_update')
|
||||
@mock.patch('sahara.utils.openstack.nova.get_instance_info')
|
||||
def test_init_instances_ips_with_ipv6_subnet(self, nova, upd):
|
||||
self.override_config('use_floating_ips', False)
|
||||
instance = mock.Mock()
|
||||
server = mock.Mock()
|
||||
server.addresses = {
|
||||
'network': [
|
||||
{
|
||||
'version': 6,
|
||||
'OS-EXT-IPS:type': 'fixed',
|
||||
'addr': 'fe80::1234:5678:9abc:def0'
|
||||
},
|
||||
{
|
||||
'version': 4,
|
||||
'OS-EXT-IPS:type': 'fixed',
|
||||
'addr': '10.2.2.2'
|
||||
}
|
||||
]
|
||||
}
|
||||
nova.return_value = server
|
||||
|
||||
self.assertEqual('10.2.2.2', networks.init_instances_ips(instance))
|
||||
|
Loading…
Reference in New Issue
Block a user