Merge "Revert "IPv6 SLAAC subnet create should update ports on net""
This commit is contained in:
commit
3deccfe189
|
@ -472,9 +472,9 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
|
||||||
# from subnet
|
# from subnet
|
||||||
else:
|
else:
|
||||||
if is_auto_addr:
|
if is_auto_addr:
|
||||||
ip_address = self._calculate_ipv6_eui64_addr(context,
|
prefix = subnet['cidr']
|
||||||
subnet,
|
ip_address = ipv6_utils.get_ipv6_addr_by_EUI64(
|
||||||
mac_address)
|
prefix, mac_address)
|
||||||
ips.append({'ip_address': ip_address.format(),
|
ips.append({'ip_address': ip_address.format(),
|
||||||
'subnet_id': subnet['id']})
|
'subnet_id': subnet['id']})
|
||||||
else:
|
else:
|
||||||
|
@ -531,17 +531,6 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
|
||||||
ips = self._allocate_fixed_ips(context, to_add, mac_address)
|
ips = self._allocate_fixed_ips(context, to_add, mac_address)
|
||||||
return ips, prev_ips
|
return ips, prev_ips
|
||||||
|
|
||||||
def _calculate_ipv6_eui64_addr(self, context, subnet, mac_addr):
|
|
||||||
prefix = subnet['cidr']
|
|
||||||
network_id = subnet['network_id']
|
|
||||||
ip_address = ipv6_utils.get_ipv6_addr_by_EUI64(
|
|
||||||
prefix, mac_addr).format()
|
|
||||||
if not self._check_unique_ip(context, network_id,
|
|
||||||
subnet['id'], ip_address):
|
|
||||||
raise n_exc.IpAddressInUse(net_id=network_id,
|
|
||||||
ip_address=ip_address)
|
|
||||||
return ip_address
|
|
||||||
|
|
||||||
def _allocate_ips_for_port(self, context, port):
|
def _allocate_ips_for_port(self, context, port):
|
||||||
"""Allocate IP addresses for the port.
|
"""Allocate IP addresses for the port.
|
||||||
|
|
||||||
|
@ -596,8 +585,13 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
|
||||||
for subnet in v6_stateless:
|
for subnet in v6_stateless:
|
||||||
# IP addresses for IPv6 SLAAC and DHCPv6-stateless subnets
|
# IP addresses for IPv6 SLAAC and DHCPv6-stateless subnets
|
||||||
# are implicitly included.
|
# are implicitly included.
|
||||||
ip_address = self._calculate_ipv6_eui64_addr(context, subnet,
|
prefix = subnet['cidr']
|
||||||
p['mac_address'])
|
ip_address = ipv6_utils.get_ipv6_addr_by_EUI64(prefix,
|
||||||
|
p['mac_address'])
|
||||||
|
if not self._check_unique_ip(context, p['network_id'],
|
||||||
|
subnet['id'], ip_address.format()):
|
||||||
|
raise n_exc.IpAddressInUse(net_id=p['network_id'],
|
||||||
|
ip_address=ip_address.format())
|
||||||
ips.append({'ip_address': ip_address.format(),
|
ips.append({'ip_address': ip_address.format(),
|
||||||
'subnet_id': subnet['id']})
|
'subnet_id': subnet['id']})
|
||||||
|
|
||||||
|
@ -1260,9 +1254,6 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
|
||||||
s['dns_nameservers'],
|
s['dns_nameservers'],
|
||||||
s['host_routes'],
|
s['host_routes'],
|
||||||
s['allocation_pools'])
|
s['allocation_pools'])
|
||||||
# If this subnet supports auto-addressing, then update any
|
|
||||||
# internal ports on the network with addresses for this subnet.
|
|
||||||
self._add_auto_addrs_on_network_ports(context, subnet)
|
|
||||||
if network.external:
|
if network.external:
|
||||||
self._update_router_gw_ports(context,
|
self._update_router_gw_ports(context,
|
||||||
subnet['id'],
|
subnet['id'],
|
||||||
|
@ -1289,9 +1280,6 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
|
||||||
s['dns_nameservers'],
|
s['dns_nameservers'],
|
||||||
s['host_routes'],
|
s['host_routes'],
|
||||||
s['allocation_pools'])
|
s['allocation_pools'])
|
||||||
# If this subnet supports auto-addressing, then update any
|
|
||||||
# internal ports on the network with addresses for this subnet.
|
|
||||||
self._add_auto_addrs_on_network_ports(context, subnet)
|
|
||||||
if network.external:
|
if network.external:
|
||||||
self._update_router_gw_ports(context,
|
self._update_router_gw_ports(context,
|
||||||
subnet['id'],
|
subnet['id'],
|
||||||
|
@ -1358,25 +1346,6 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
|
||||||
return self._create_subnet_from_implicit_pool(context, subnet)
|
return self._create_subnet_from_implicit_pool(context, subnet)
|
||||||
return self._create_subnet_from_pool(context, subnet, subnetpool_id)
|
return self._create_subnet_from_pool(context, subnet, subnetpool_id)
|
||||||
|
|
||||||
def _add_auto_addrs_on_network_ports(self, context, subnet):
|
|
||||||
"""If subnet uses auto-addressing, add addrs for ports on the net."""
|
|
||||||
if ipv6_utils.is_auto_address_subnet(subnet):
|
|
||||||
network_id = subnet['network_id']
|
|
||||||
port_qry = context.session.query(models_v2.Port)
|
|
||||||
for port in port_qry.filter(
|
|
||||||
and_(models_v2.Port.network_id == network_id,
|
|
||||||
models_v2.Port.device_owner !=
|
|
||||||
constants.DEVICE_OWNER_ROUTER_SNAT,
|
|
||||||
~models_v2.Port.device_owner.in_(
|
|
||||||
constants.ROUTER_INTERFACE_OWNERS))):
|
|
||||||
ip_address = self._calculate_ipv6_eui64_addr(
|
|
||||||
context, subnet, port['mac_address'])
|
|
||||||
allocated = models_v2.IPAllocation(network_id=network_id,
|
|
||||||
port_id=port['id'],
|
|
||||||
ip_address=ip_address,
|
|
||||||
subnet_id=subnet['id'])
|
|
||||||
context.session.add(allocated)
|
|
||||||
|
|
||||||
def _update_subnet_dns_nameservers(self, context, id, s):
|
def _update_subnet_dns_nameservers(self, context, id, s):
|
||||||
old_dns_list = self._get_dns_by_subnet(context, id)
|
old_dns_list = self._get_dns_by_subnet(context, id)
|
||||||
new_dns_addr_set = set(s["dns_nameservers"])
|
new_dns_addr_set = set(s["dns_nameservers"])
|
||||||
|
|
|
@ -3811,62 +3811,6 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
||||||
self.assertEqual(ctx_manager.exception.code,
|
self.assertEqual(ctx_manager.exception.code,
|
||||||
webob.exc.HTTPClientError.code)
|
webob.exc.HTTPClientError.code)
|
||||||
|
|
||||||
def _test_create_subnet_ipv6_auto_addr_with_port_on_network(
|
|
||||||
self, addr_mode, device_owner=DEVICE_OWNER_COMPUTE):
|
|
||||||
# Create a network with one IPv4 subnet and one port
|
|
||||||
with self.network() as network:
|
|
||||||
with self.subnet(network=network) as v4_subnet:
|
|
||||||
with self.port(subnet=v4_subnet,
|
|
||||||
device_owner=device_owner) as port:
|
|
||||||
# Add an IPv6 auto-address subnet to the network
|
|
||||||
with self.subnet(network=network, cidr='fe80::/64',
|
|
||||||
ip_version=6, ipv6_ra_mode=addr_mode,
|
|
||||||
ipv6_address_mode=addr_mode
|
|
||||||
) as v6_subnet:
|
|
||||||
if (device_owner == constants.DEVICE_OWNER_ROUTER_SNAT
|
|
||||||
or device_owner in
|
|
||||||
constants.ROUTER_INTERFACE_OWNERS):
|
|
||||||
# DVR SNAT and router interfaces should not have
|
|
||||||
# been updated with addresses from the new
|
|
||||||
# auto-address subnet
|
|
||||||
self.assertEqual(1,
|
|
||||||
len(port['port']['fixed_ips']))
|
|
||||||
else:
|
|
||||||
# Confirm that the port has been updated with an
|
|
||||||
# address from the new auto-address subnet
|
|
||||||
req = self.new_show_request(
|
|
||||||
'ports', port['port']['id'], self.fmt)
|
|
||||||
sport = self.deserialize(
|
|
||||||
self.fmt, req.get_response(self.api))
|
|
||||||
fixed_ips = sport['port']['fixed_ips']
|
|
||||||
self.assertEqual(2, len(fixed_ips))
|
|
||||||
self.assertIn(v6_subnet['subnet']['id'],
|
|
||||||
[fixed_ip['subnet_id'] for fixed_ip
|
|
||||||
in fixed_ips])
|
|
||||||
|
|
||||||
def test_create_subnet_ipv6_slaac_with_port_on_network(self):
|
|
||||||
self._test_create_subnet_ipv6_auto_addr_with_port_on_network(
|
|
||||||
constants.IPV6_SLAAC)
|
|
||||||
|
|
||||||
def test_create_subnet_dhcpv6_stateless_with_port_on_network(self):
|
|
||||||
self._test_create_subnet_ipv6_auto_addr_with_port_on_network(
|
|
||||||
constants.DHCPV6_STATELESS)
|
|
||||||
|
|
||||||
def test_create_subnet_ipv6_slaac_with_dhcp_port_on_network(self):
|
|
||||||
self._test_create_subnet_ipv6_auto_addr_with_port_on_network(
|
|
||||||
constants.DHCPV6_STATELESS,
|
|
||||||
device_owner=constants.DEVICE_OWNER_DHCP)
|
|
||||||
|
|
||||||
def test_create_subnet_ipv6_slaac_with_router_intf_on_network(self):
|
|
||||||
self._test_create_subnet_ipv6_auto_addr_with_port_on_network(
|
|
||||||
constants.DHCPV6_STATELESS,
|
|
||||||
device_owner=constants.DEVICE_OWNER_ROUTER_INTF)
|
|
||||||
|
|
||||||
def test_create_subnet_ipv6_slaac_with_snat_intf_on_network(self):
|
|
||||||
self._test_create_subnet_ipv6_auto_addr_with_port_on_network(
|
|
||||||
constants.DHCPV6_STATELESS,
|
|
||||||
device_owner=constants.DEVICE_OWNER_ROUTER_SNAT)
|
|
||||||
|
|
||||||
def test_update_subnet_no_gateway(self):
|
def test_update_subnet_no_gateway(self):
|
||||||
with self.subnet() as subnet:
|
with self.subnet() as subnet:
|
||||||
data = {'subnet': {'gateway_ip': '10.0.0.1'}}
|
data = {'subnet': {'gateway_ip': '10.0.0.1'}}
|
||||||
|
@ -5386,7 +5330,6 @@ class TestNeutronDbPluginV2(base.BaseTestCase):
|
||||||
'enable_dhcp': True,
|
'enable_dhcp': True,
|
||||||
'gateway_ip': u'2001:100::1',
|
'gateway_ip': u'2001:100::1',
|
||||||
'id': u'd1a28edd-bd83-480a-bd40-93d036c89f13',
|
'id': u'd1a28edd-bd83-480a-bd40-93d036c89f13',
|
||||||
'network_id': 'fbb9b578-95eb-4b79-a116-78e5c4927176',
|
|
||||||
'ip_version': 6,
|
'ip_version': 6,
|
||||||
'ipv6_address_mode': None,
|
'ipv6_address_mode': None,
|
||||||
'ipv6_ra_mode': u'slaac'},
|
'ipv6_ra_mode': u'slaac'},
|
||||||
|
@ -5395,7 +5338,6 @@ class TestNeutronDbPluginV2(base.BaseTestCase):
|
||||||
'enable_dhcp': True,
|
'enable_dhcp': True,
|
||||||
'gateway_ip': u'2001:200::1',
|
'gateway_ip': u'2001:200::1',
|
||||||
'id': u'dc813d3d-ed66-4184-8570-7325c8195e28',
|
'id': u'dc813d3d-ed66-4184-8570-7325c8195e28',
|
||||||
'network_id': 'fbb9b578-95eb-4b79-a116-78e5c4927176',
|
|
||||||
'ip_version': 6,
|
'ip_version': 6,
|
||||||
'ipv6_address_mode': None,
|
'ipv6_address_mode': None,
|
||||||
'ipv6_ra_mode': u'slaac'}]
|
'ipv6_ra_mode': u'slaac'}]
|
||||||
|
|
Loading…
Reference in New Issue