diff options
| author | Jason Kölker <jason@koelker.net> | 2012-03-13 14:14:36 -0500 |
|---|---|---|
| committer | Jason Kölker <jason@koelker.net> | 2012-03-13 14:14:36 -0500 |
| commit | c8ad7f7c406b4684391bfd5aa0b309b4d9dafe70 (patch) | |
| tree | 70ebc258c139e1869842fa4c8fc88b02c4621977 | |
| parent | 8bec631791eba835cc9a698da68260a6b49072e0 (diff) | |
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
| -rw-r--r-- | nova/db/sqlalchemy/api.py | 8 |
1 files 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() |
