From c8ad7f7c406b4684391bfd5aa0b309b4d9dafe70 Mon Sep 17 00:00:00 2001 From: Jason Kölker Date: Tue, 13 Mar 2012 14:14:36 -0500 Subject: Use a FixedIp subquery to find networks by host * Fixes LP954341 * The FK removals missed this FK reference. Updated function to use a subquery in the filter Change-Id: Ia61d6536deb78e1aa16c5a94956bf919aa3356ba --- nova/db/sqlalchemy/api.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 2136dbd6d..3544023eb 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -2067,11 +2067,15 @@ def network_get_all_by_instance(context, instance_id): @require_admin_context def network_get_all_by_host(context, host): + session = get_session() + fixed_ip_query = model_query(context, models.FixedIp.network_id, + session=session).\ + filter(models.FixedIp.host == host) # NOTE(vish): return networks that have host set # or that have a fixed ip with host set host_filter = or_(models.Network.host == host, - models.FixedIp.host == host) - return _network_get_query(context).\ + models.Network.id.in_(fixed_ip_query.subquery())) + return _network_get_query(context, session=session).\ filter(host_filter).\ all() -- cgit