netutils: Ignore 'use_ipv6' for network templates
Nova supports file injection of network templates. Putting these in a config drive is the only way to configure networking without DHCP. At present, setting the 'use_ipv6' config option to False prevents the generation of IPv6 network info, even if there are IPv6 networks available. This was fine when using nova-network, where the same config option is used to control generation of these subnets. However, a mismatch between this nova option and equivalent IPv6 options in neutron would result in IPv6 packets being dropped. Seeing as there is apparent reason for not including IPv6 network info when IPv6 capable networks are present, we can ignore this option. Instead, we include info for all available networks in the template, be they IPv4 or IPv6. Change-Id: I188fc2cd1b26fe7a71804f7e7d66b111d6f15e30 Implements: blueprint centralize-config-options-pike
This commit is contained in:
parent
39cd540917
commit
c0aef97c49
@ -573,7 +573,7 @@ class NetworkInfoTests(test.NoDBTestCase):
|
||||
|
||||
nwinfo = model.NetworkInfo(vifs)
|
||||
return netutils.get_injected_network_template(
|
||||
nwinfo, use_ipv6=use_ipv6, libvirt_virt_type=libvirt_virt_type)
|
||||
nwinfo, libvirt_virt_type=libvirt_virt_type)
|
||||
|
||||
def test_injection_dynamic(self):
|
||||
expected = None
|
||||
@ -869,8 +869,7 @@ class TestNetworkMetadata(test.NoDBTestCase):
|
||||
|
||||
def test_get_network_metadata_json(self):
|
||||
|
||||
net_metadata = netutils.get_network_metadata(self.netinfo,
|
||||
use_ipv6=True)
|
||||
net_metadata = netutils.get_network_metadata(self.netinfo)
|
||||
|
||||
# Physical Ethernet
|
||||
self.assertEqual(
|
||||
@ -938,8 +937,7 @@ class TestNetworkMetadata(test.NoDBTestCase):
|
||||
|
||||
self.netinfo[0]['network']['subnets'][0] = ipv4_subnet
|
||||
self.netinfo[0]['network']['subnets'][1] = ipv6_subnet
|
||||
net_metadata = netutils.get_network_metadata(self.netinfo,
|
||||
use_ipv6=True)
|
||||
net_metadata = netutils.get_network_metadata(self.netinfo)
|
||||
|
||||
# IPv4 Network
|
||||
self.assertEqual(
|
||||
|
@ -56,21 +56,16 @@ def _get_first_network(network, version):
|
||||
pass
|
||||
|
||||
|
||||
def get_injected_network_template(network_info, use_ipv6=None, template=None,
|
||||
def get_injected_network_template(network_info, template=None,
|
||||
libvirt_virt_type=None):
|
||||
"""Returns a rendered network template for the given network_info.
|
||||
|
||||
:param network_info:
|
||||
:py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
|
||||
:param use_ipv6: If False, do not return IPv6 template information
|
||||
even if an IPv6 subnet is present in network_info.
|
||||
:param template: Path to the interfaces template file.
|
||||
:param libvirt_virt_type: The Libvirt `virt_type`, will be `None` for
|
||||
other hypervisors..
|
||||
"""
|
||||
if use_ipv6 is None:
|
||||
use_ipv6 = CONF.use_ipv6
|
||||
|
||||
if not template:
|
||||
template = CONF.injected_network_template
|
||||
|
||||
@ -128,8 +123,7 @@ def get_injected_network_template(network_info, use_ipv6=None, template=None,
|
||||
gateway_v6 = ''
|
||||
netmask_v6 = None
|
||||
dns_v6 = None
|
||||
have_ipv6 = (use_ipv6 and subnet_v6)
|
||||
if have_ipv6:
|
||||
if subnet_v6:
|
||||
if subnet_v6.get_meta('dhcp_server') is not None:
|
||||
continue
|
||||
|
||||
@ -169,7 +163,7 @@ def get_injected_network_template(network_info, use_ipv6=None, template=None,
|
||||
'libvirt_virt_type': libvirt_virt_type})
|
||||
|
||||
|
||||
def get_network_metadata(network_info, use_ipv6=None):
|
||||
def get_network_metadata(network_info):
|
||||
"""Gets a more complete representation of the instance network information.
|
||||
|
||||
This data is exposed as network_data.json in the metadata service and
|
||||
@ -177,16 +171,10 @@ def get_network_metadata(network_info, use_ipv6=None):
|
||||
|
||||
:param network_info: `nova.network.models.NetworkInfo` object describing
|
||||
the network metadata.
|
||||
:param use_ipv6: If False, do not return IPv6 template information
|
||||
even if an IPv6 subnet is present in network_info. Defaults to
|
||||
nova.netconf.use_ipv6.
|
||||
"""
|
||||
if not network_info:
|
||||
return
|
||||
|
||||
if use_ipv6 is None:
|
||||
use_ipv6 = CONF.use_ipv6
|
||||
|
||||
# IPv4 or IPv6 networks
|
||||
nets = []
|
||||
# VIFs, physical NICs, or VLANs. Physical NICs will have type 'phy'.
|
||||
@ -221,7 +209,7 @@ def get_network_metadata(network_info, use_ipv6=None):
|
||||
nets.append(_get_nets(vif, subnet_v4, 4, net_num, link['id']))
|
||||
services += [dns for dns in _get_dns_services(subnet_v4)
|
||||
if dns not in services]
|
||||
if (use_ipv6 and subnet_v6) and subnet_v6.get('ips'):
|
||||
if subnet_v6 and subnet_v6.get('ips'):
|
||||
net_num += 1
|
||||
nets.append(_get_nets(vif, subnet_v6, 6, net_num, link['id']))
|
||||
services += [dns for dns in _get_dns_services(subnet_v6)
|
||||
|
@ -0,0 +1,19 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
Injected network templates will now ignore the ``use_ipv6`` config option.
|
||||
|
||||
Nova supports file injection of network templates. Putting these in a
|
||||
config drive is the only way to configure networking without DHCP.
|
||||
|
||||
Previously, setting the ``use_ipv6`` config option to ``False`` prevented
|
||||
the generation of IPv6 network info, even if there were IPv6 networks
|
||||
available. This was fine when using nova-network, where the same config
|
||||
option is used to control generation of these subnets. However, a mismatch
|
||||
between this nova option and equivalent IPv6 options in neutron would
|
||||
have resulted in IPv6 packets being dropped.
|
||||
|
||||
Seeing as there was no apparent reason for not including IPv6 network info
|
||||
when IPv6 capable networks are present, we now ignore this option.
|
||||
Instead, we include info for all available networks in the template, be
|
||||
they IPv4 or IPv6.
|
Loading…
Reference in New Issue
Block a user