Update network metadata type field for IPv6
Currently it is not possible to decide from looking at the network metadata whether an IPv6 subnet is using slaac, dhcpv6-stateless or dhcpv6-stateful. So we add ipv6_address_mode information into the subnet metadata when it is available and use that to construct the subnet type. As a result, the type for a subnet with mode SLAAC will be "ipv6_slaac" instead of "ipv6_dhcp" and similarly for the other available modes. Change-Id: I751200a354ec9be2bfd5f94d3e4bbf53dab2c8bb Partial-Bug: 1676363
This commit is contained in:
@@ -2259,6 +2259,8 @@ class API(base_api.NetworkAPI):
|
|||||||
address=subnet['gateway_ip'],
|
address=subnet['gateway_ip'],
|
||||||
type='gateway'),
|
type='gateway'),
|
||||||
}
|
}
|
||||||
|
if subnet.get('ipv6_address_mode'):
|
||||||
|
subnet_dict['ipv6_address_mode'] = subnet['ipv6_address_mode']
|
||||||
|
|
||||||
# attempt to populate DHCP server field
|
# attempt to populate DHCP server field
|
||||||
search_opts = {'network_id': subnet['network_id'],
|
search_opts = {'network_id': subnet['network_id'],
|
||||||
|
|||||||
@@ -963,6 +963,46 @@ class TestNetworkMetadata(test.NoDBTestCase):
|
|||||||
},
|
},
|
||||||
net_metadata['networks'][1])
|
net_metadata['networks'][1])
|
||||||
|
|
||||||
|
def _test_get_network_metadata_json_ipv6_addr_mode(self, mode):
|
||||||
|
ipv6_subnet = fake_network_cache_model.new_subnet(
|
||||||
|
subnet_dict=dict(dhcp_server='1234:567::',
|
||||||
|
ipv6_address_mode=mode), version=6)
|
||||||
|
|
||||||
|
self.netinfo[0]['network']['subnets'][1] = ipv6_subnet
|
||||||
|
net_metadata = netutils.get_network_metadata(self.netinfo)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
{
|
||||||
|
'id': 'network1',
|
||||||
|
'link': 'interface0',
|
||||||
|
'ip_address': 'fd00::2',
|
||||||
|
'netmask': 'ffff:ffff:ffff::',
|
||||||
|
'routes': [
|
||||||
|
{
|
||||||
|
'network': '::',
|
||||||
|
'netmask': '::',
|
||||||
|
'gateway': 'fd00::1'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'network': '::',
|
||||||
|
'netmask': 'ffff:ffff:ffff::',
|
||||||
|
'gateway': 'fd00::1:1'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'type': 'ipv6_%s' % mode,
|
||||||
|
'network_id': 1
|
||||||
|
},
|
||||||
|
net_metadata['networks'][1])
|
||||||
|
|
||||||
|
def test_get_network_metadata_json_ipv6_addr_mode_slaac(self):
|
||||||
|
self._test_get_network_metadata_json_ipv6_addr_mode('slaac')
|
||||||
|
|
||||||
|
def test_get_network_metadata_json_ipv6_addr_mode_stateful(self):
|
||||||
|
self._test_get_network_metadata_json_ipv6_addr_mode('dhcpv6-stateful')
|
||||||
|
|
||||||
|
def test_get_network_metadata_json_ipv6_addr_mode_stateless(self):
|
||||||
|
self._test_get_network_metadata_json_ipv6_addr_mode('dhcpv6-stateless')
|
||||||
|
|
||||||
def test__get_nets(self):
|
def test__get_nets(self):
|
||||||
expected_net = {
|
expected_net = {
|
||||||
'id': 'network0',
|
'id': 'network0',
|
||||||
|
|||||||
@@ -261,7 +261,10 @@ def _get_nets(vif, subnet, version, net_num, link_id):
|
|||||||
:param link_id: Arbitrary identifier for the link the networks are
|
:param link_id: Arbitrary identifier for the link the networks are
|
||||||
attached to
|
attached to
|
||||||
"""
|
"""
|
||||||
if subnet.get_meta('dhcp_server') is not None:
|
net_type = ''
|
||||||
|
if subnet.get_meta('ipv6_address_mode') is not None:
|
||||||
|
net_type = '_%s' % subnet.get_meta('ipv6_address_mode')
|
||||||
|
elif subnet.get_meta('dhcp_server') is not None:
|
||||||
net_info = {
|
net_info = {
|
||||||
'id': 'network%d' % net_num,
|
'id': 'network%d' % net_num,
|
||||||
'type': 'ipv%d_dhcp' % version,
|
'type': 'ipv%d_dhcp' % version,
|
||||||
@@ -279,7 +282,7 @@ def _get_nets(vif, subnet, version, net_num, link_id):
|
|||||||
|
|
||||||
net_info = {
|
net_info = {
|
||||||
'id': 'network%d' % net_num,
|
'id': 'network%d' % net_num,
|
||||||
'type': 'ipv%d' % version,
|
'type': 'ipv%d%s' % (version, net_type),
|
||||||
'link': link_id,
|
'link': link_id,
|
||||||
'ip_address': address,
|
'ip_address': address,
|
||||||
'netmask': netmask,
|
'netmask': netmask,
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
The network.json metadata format has been amended for IPv6 networks
|
||||||
|
under Neutron control. The type that is shown has been changed
|
||||||
|
from being always set to ``ipv6_dhcp`` to correctly reflecting the
|
||||||
|
``ipv6_address_mode`` option in Neutron, so the type now will be
|
||||||
|
``ipv6_slaac``, ``ipv6_dhcpv6-stateless`` or ``ipv6_dhcpv6-stateful``.
|
||||||
|
upgrade:
|
||||||
|
- |
|
||||||
|
The information in the network.json metadata has been amended,
|
||||||
|
for IPv6 networks under Neutron control, the ``type`` field has been
|
||||||
|
changed from being always set to ``ipv6_dhcp`` to correctly reflecting
|
||||||
|
the ``ipv6_address_mode`` option in Neutron.
|
||||||
Reference in New Issue
Block a user