Add support for ipv6 nameservers
Update interfaces.template to support ipv6 based dns servers. Make sure we validate the version of the ip addresses before we fill them in. Closes-Bug: #1355777 Change-Id: I7229656bfa5ff5a29c63befc3b9ce91c46e04723
This commit is contained in:
parent
9a1a1fb3e8
commit
3d4e421204
|
@ -17,6 +17,7 @@ import netaddr
|
|||
|
||||
from nova import ipv6
|
||||
from nova import objects
|
||||
from nova import utils
|
||||
|
||||
|
||||
def get_ipam_lib(net_man):
|
||||
|
@ -49,11 +50,8 @@ class NeutronNovaIPAMLib(object):
|
|||
'broadcast': n.broadcast,
|
||||
'netmask': n.netmask,
|
||||
'version': 4,
|
||||
'dns1': n.dns1,
|
||||
'dns2': n.dns2}
|
||||
# TODO(tr3buchet): I'm noticing we've assumed here that all dns is v4.
|
||||
# this is probably bad as there is no way to add v6
|
||||
# dns to nova
|
||||
'dns1': n.dns1 if utils.is_valid_ipv4(n.dns1) else None,
|
||||
'dns2': n.dns2 if utils.is_valid_ipv4(n.dns2) else None}
|
||||
subnet_v6 = {
|
||||
'network_id': n.uuid,
|
||||
'cidr': n.cidr_v6,
|
||||
|
@ -62,8 +60,8 @@ class NeutronNovaIPAMLib(object):
|
|||
'broadcast': None,
|
||||
'netmask': n.netmask_v6,
|
||||
'version': 6,
|
||||
'dns1': None,
|
||||
'dns2': None}
|
||||
'dns1': n.dns1 if utils.is_valid_ipv6(n.dns1) else None,
|
||||
'dns2': n.dns2 if utils.is_valid_ipv6(n.dns2) else None}
|
||||
|
||||
def ips_to_strs(net):
|
||||
for key, value in net.items():
|
||||
|
|
|
@ -535,6 +535,10 @@ class NetworkInfoTests(test.NoDBTestCase):
|
|||
ipv6_subnet_dict = dict(
|
||||
cidr='1234:567::/48',
|
||||
gateway=gateway_ip,
|
||||
dns=[fake_network_cache_model.new_ip(
|
||||
dict(address='2001:4860:4860::8888')),
|
||||
fake_network_cache_model.new_ip(
|
||||
dict(address='2001:4860:4860::8844'))],
|
||||
ips=[ip])
|
||||
if not gateway:
|
||||
ipv6_subnet_dict['gateway'] = None
|
||||
|
@ -643,6 +647,7 @@ iface eth0 inet6 static
|
|||
address 1234:567::2
|
||||
netmask 48
|
||||
gateway 1234:567::1
|
||||
dns-nameservers 2001:4860:4860::8888 2001:4860:4860::8844
|
||||
"""
|
||||
template = self._setup_injected_network_scenario(use_ipv6=True)
|
||||
self.assertEqual(expected, template)
|
||||
|
@ -667,6 +672,7 @@ iface eth0 inet static
|
|||
iface eth0 inet6 static
|
||||
address 1234:567::2
|
||||
netmask 48
|
||||
dns-nameservers 2001:4860:4860::8888 2001:4860:4860::8844
|
||||
"""
|
||||
template = self._setup_injected_network_scenario(use_ipv6=True,
|
||||
gateway=False)
|
||||
|
@ -699,6 +705,7 @@ iface eth0 inet6 static
|
|||
address 1234:567::2
|
||||
netmask 48
|
||||
gateway 1234:567::1
|
||||
dns-nameservers 2001:4860:4860::8888 2001:4860:4860::8844
|
||||
|
||||
auto eth1
|
||||
iface eth1 inet static
|
||||
|
@ -711,6 +718,7 @@ iface eth1 inet6 static
|
|||
address 1234:567::2
|
||||
netmask 48
|
||||
gateway 1234:567::1
|
||||
dns-nameservers 2001:4860:4860::8888 2001:4860:4860::8844
|
||||
"""
|
||||
template = self._setup_injected_network_scenario(use_ipv6=True,
|
||||
two_interfaces=True)
|
||||
|
|
|
@ -34,6 +34,9 @@ iface {{ ifc.name }} inet6 static
|
|||
{% if ifc.gateway_v6 %}
|
||||
gateway {{ ifc.gateway_v6 }}
|
||||
{% endif %}
|
||||
{% if ifc.dns_v6 %}
|
||||
dns-nameservers {{ ifc.dns_v6 }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
|
|
@ -128,6 +128,7 @@ def get_injected_network_template(network_info, use_ipv6=None, template=None,
|
|||
address_v6 = None
|
||||
gateway_v6 = ''
|
||||
netmask_v6 = None
|
||||
dns_v6 = None
|
||||
have_ipv6 = (use_ipv6 and subnet_v6)
|
||||
if have_ipv6:
|
||||
if subnet_v6.get_meta('dhcp_server') is not None:
|
||||
|
@ -140,6 +141,7 @@ def get_injected_network_template(network_info, use_ipv6=None, template=None,
|
|||
netmask_v6 = model.get_netmask(ip_v6, subnet_v6)
|
||||
if subnet_v6['gateway']:
|
||||
gateway_v6 = subnet_v6['gateway']['address']
|
||||
dns_v6 = ' '.join([i['address'] for i in subnet_v6['dns']])
|
||||
|
||||
net_info = {'name': 'eth%d' % ifc_num,
|
||||
'address': address,
|
||||
|
@ -150,6 +152,7 @@ def get_injected_network_template(network_info, use_ipv6=None, template=None,
|
|||
'address_v6': address_v6,
|
||||
'gateway_v6': gateway_v6,
|
||||
'netmask_v6': netmask_v6,
|
||||
'dns_v6': dns_v6,
|
||||
}
|
||||
nets.append(net_info)
|
||||
|
||||
|
|
Loading…
Reference in New Issue