From 5cf93a39dc59f1040a5118bdc74a00cb3eb3163a Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Thu, 22 Dec 2011 19:54:03 -0500 Subject: Fixes LP bug #907898. Update DB api so that fixed_ip_disassociate_all_by_timeout uses two separate commands (a query then an update). Fixes LP bug #907898. Change-Id: I60d7e7ba6bb3d3542ccf5b595d0c0de944e499a3 --- nova/db/sqlalchemy/api.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 2163ba8ca..c1e003b18 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -777,12 +777,12 @@ def fixed_ip_disassociate_all_by_timeout(context, host, time): session = get_session() # NOTE(vish): only update fixed ips that "belong" to this # host; i.e. the network host or the instance - # host matches. Inner queries necessary because + # host matches. Two queries necessary because # join with update doesn't work. host_filter = or_(and_(models.Instance.host == host, models.Network.multi_host == True), models.Network.host == host) - subq = model_query(context, models.FixedIp.id, session=session, + fixed_ips = model_query(context, models.FixedIp.id, session=session, read_deleted="yes").\ filter(models.FixedIp.updated_at < time).\ filter(models.FixedIp.instance_id != None).\ @@ -790,10 +790,10 @@ def fixed_ip_disassociate_all_by_timeout(context, host, time): join(models.FixedIp.instance).\ join(models.FixedIp.network).\ filter(host_filter).\ - subquery() + all() result = model_query(context, models.FixedIp, session=session, read_deleted="yes").\ - filter(models.FixedIp.id.in_(subq)).\ + filter(models.FixedIp.id.in_(fixed_ips)).\ update({'instance_id': None, 'leased': False, 'updated_at': utils.utcnow()}, -- cgit