From 3f9118b2ae025cd707642b179fe58459dd39dbc3 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Sun, 12 Sep 2010 18:06:59 -0700 Subject: set leased = 0 as well on disassociate update --- nova/db/sqlalchemy/api.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index ca5e12f95..b4b68fa02 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -252,16 +252,17 @@ def fixed_ip_disassociate_all_by_timeout(_context, host, time): # table. It would be great if we can coax sqlalchemy into # generating this update for us without having to update # each fixed_ip individually. - result = session.execute('UPDATE fixed_ips SET instance_id = NULL ' + result = session.execute('UPDATE fixed_ips SET instance_id = NULL, ' + 'leased = 0 ' 'WHERE id IN (SELECT x.id FROM ' - '(SELECT fixed_ips.id FROM fixed_ips ' - 'INNER JOIN networks ' - 'ON fixed_ips.network_id = ' - 'networks.id ' - 'WHERE networks.host = :host ' - 'AND fixed_ip.updated_at < :time ' - 'AND fixed_ip.instance_id IS NOT NULL' - 'AND fixed_ip.allocated = 0) as x) ', + '(SELECT fixed_ips.id FROM fixed_ips ' + 'INNER JOIN networks ' + 'ON fixed_ips.network_id = ' + 'networks.id ' + 'WHERE networks.host = :host ' + 'AND fixed_ip.updated_at < :time ' + 'AND fixed_ip.instance_id IS NOT NULL' + 'AND fixed_ip.allocated = 0) as x) ', {'host': host, 'time': time.isoformat()}) return result.rowcount -- cgit