Merge "Add lock on API layer delete floating IP"

This commit is contained in:
Jenkins 2014-05-13 06:52:18 +00:00 committed by Gerrit Code Review
commit 44cae9cff8

View File

@ -891,12 +891,24 @@ def floating_ip_fixed_ip_associate(context, floating_address,
@require_context @require_context
@_retry_on_deadlock
def floating_ip_deallocate(context, address): def floating_ip_deallocate(context, address):
model_query(context, models.FloatingIp).\ session = get_session()
filter_by(address=address).\
update({'project_id': None, with session.begin():
'host': None, floating_ip_ref = model_query(context, models.FloatingIp,
'auto_assigned': False}) session=session).\
filter_by(address=address).\
filter(models.FloatingIp.project_id != None).\
with_lockmode('update').\
first()
if floating_ip_ref:
floating_ip_ref.update({'project_id': None,
'host': None,
'auto_assigned': False})
return floating_ip_ref
@require_context @require_context