Merge "do not raise exception on ip address recycle operation"
This commit is contained in:
commit
32ad89fd8a
@ -362,9 +362,9 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
|
|||||||
pool_id = allocation_pool['id']
|
pool_id = allocation_pool['id']
|
||||||
break
|
break
|
||||||
if not pool_id:
|
if not pool_id:
|
||||||
error_message = _("No allocation pool found for "
|
NeutronDbPluginV2._delete_ip_allocation(
|
||||||
"ip address:%s") % ip_address
|
context, network_id, subnet_id, ip_address)
|
||||||
raise q_exc.InvalidInput(error_message=error_message)
|
return
|
||||||
# Two requests will be done on the database. The first will be to
|
# Two requests will be done on the database. The first will be to
|
||||||
# search if an entry starts with ip_address + 1 (r1). The second
|
# search if an entry starts with ip_address + 1 (r1). The second
|
||||||
# will be to see if an entry ends with ip_address -1 (r2).
|
# will be to see if an entry ends with ip_address -1 (r2).
|
||||||
|
@ -1706,6 +1706,28 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||||||
|
|
||||||
self.assertEqual(q.count(), 1)
|
self.assertEqual(q.count(), 1)
|
||||||
|
|
||||||
|
def test_recycle_ip_address_without_allocation_pool(self):
|
||||||
|
plugin = NeutronManager.get_plugin()
|
||||||
|
allocation_pools = [{"start": '10.0.0.10',
|
||||||
|
"end": '10.0.0.50'}]
|
||||||
|
with self.subnet(cidr='10.0.0.0/24',
|
||||||
|
allocation_pools=allocation_pools) as subnet:
|
||||||
|
network_id = subnet['subnet']['network_id']
|
||||||
|
subnet_id = subnet['subnet']['id']
|
||||||
|
fixed_ips = [{"subnet_id": subnet_id,
|
||||||
|
"ip_address": '10.0.0.100'}]
|
||||||
|
with self.port(subnet=subnet, fixed_ips=fixed_ips) as port:
|
||||||
|
update_context = context.Context('', port['port']['tenant_id'])
|
||||||
|
ip_address = port['port']['fixed_ips'][0]['ip_address']
|
||||||
|
plugin._recycle_ip(update_context,
|
||||||
|
network_id,
|
||||||
|
subnet_id,
|
||||||
|
ip_address)
|
||||||
|
|
||||||
|
q = update_context.session.query(models_v2.IPAllocation)
|
||||||
|
q = q.filter_by(subnet_id=subnet_id)
|
||||||
|
self.assertEqual(q.count(), 0)
|
||||||
|
|
||||||
def test_recycle_held_ip_address(self):
|
def test_recycle_held_ip_address(self):
|
||||||
plugin = NeutronManager.get_plugin()
|
plugin = NeutronManager.get_plugin()
|
||||||
with self.subnet() as subnet:
|
with self.subnet() as subnet:
|
||||||
|
Loading…
Reference in New Issue
Block a user