"""Allocate IP addresses according to the configured fixed_ips."""
ips = []
for fixed in fixed_ips:
+ subnet = self._get_subnet(context, fixed['subnet_id'])
+ is_auto_addr = ipv6_utils.is_auto_address_subnet(subnet)
if 'ip_address' in fixed:
- # Remove the IP address from the allocation pool
- NeutronDbPluginV2._allocate_specific_ip(
- context, fixed['subnet_id'], fixed['ip_address'])
+ if not is_auto_addr:
+ # Remove the IP address from the allocation pool
+ NeutronDbPluginV2._allocate_specific_ip(
+ context, fixed['subnet_id'], fixed['ip_address'])
ips.append({'ip_address': fixed['ip_address'],
'subnet_id': fixed['subnet_id']})
# Only subnet ID is specified => need to generate IP
# from subnet
else:
- subnet = self._get_subnet(context, fixed['subnet_id'])
- if (subnet['ip_version'] == 6 and
- ipv6_utils.is_auto_address_subnet(subnet)):
+ if is_auto_addr:
prefix = subnet['cidr']
ip_address = ipv6_utils.get_ipv6_addr_by_EUI64(
prefix, mac_address)
self.assertEqual(res.status_int,
webob.exc.HTTPClientError.code)
- def test_requested_fixed_ip_address_v6_slaac_router_iface(self):
+ @mock.patch.object(db_base_plugin_v2.NeutronDbPluginV2,
+ '_allocate_specific_ip')
+ def test_requested_fixed_ip_address_v6_slaac_router_iface(
+ self, alloc_specific_ip):
with self.subnet(gateway_ip='fe80::1',
cidr='fe80::/64',
ip_version=6,
self.assertEqual(len(port['port']['fixed_ips']), 1)
self.assertEqual(port['port']['fixed_ips'][0]['ip_address'],
'fe80::1')
+ self.assertFalse(alloc_specific_ip.called)
def test_requested_subnet_id_v6_slaac(self):
with self.subnet(gateway_ip='fe80::1',