do not raise exception on ip address recycle operation
Currenty a exception will raise on ip address recycle operation if the ip address doesn't belong to any allocation pool which will make user unable to update port, even worse it will make user unable to create new port. So do not raise exception if the ip address to be recycled doesn't belong to any allocation, just delete it from the ip allocation table. fixes bug 1201692 Change-Id: Icfbded5158f1f4043f69bb1463fd4c830c9714a9
This commit is contained in:
parent
58424dd616
commit
d6cddd430c
@ -362,9 +362,9 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
|
||||
pool_id = allocation_pool['id']
|
||||
break
|
||||
if not pool_id:
|
||||
error_message = _("No allocation pool found for "
|
||||
"ip address:%s") % ip_address
|
||||
raise q_exc.InvalidInput(error_message=error_message)
|
||||
NeutronDbPluginV2._delete_ip_allocation(
|
||||
context, network_id, subnet_id, ip_address)
|
||||
return
|
||||
# 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
|
||||
# will be to see if an entry ends with ip_address -1 (r2).
|
||||
|
@ -1707,6 +1707,28 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
||||
|
||||
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):
|
||||
plugin = NeutronManager.get_plugin()
|
||||
with self.subnet() as subnet:
|
||||
|
Loading…
Reference in New Issue
Block a user