From 61e5b8e7da3b36db9a09f80d62ebf2e276bbe88b Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Fri, 21 Oct 2011 00:29:54 -0700 Subject: Revert how APIs get IP address info for instances Fixes bug 862839 listing instances with IPs is extremely inefficient after changes were made to query the network manager for IP information for each instance. I tried adding a network manager call that said 'give me IP information for 'x' instances', but that was also too slow. We need a solution that caches IP info from the network manager before we can fully untie things. So, this reverts APIs to use instance['fixed_ips'] which hasn't been untied in the DB yet. Change-Id: I37d21105d6306f0a812c5eb0f0717a5094cd17b9 --- nova/db/sqlalchemy/api.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'nova/db') diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index f6a147e89..983c48145 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1217,12 +1217,13 @@ def _build_instance_get(context, session=None): session = get_session() partial = session.query(models.Instance).\ - options(joinedload_all('fixed_ips.floating_ips')).\ - options(joinedload_all('fixed_ips.network')).\ - options(joinedload_all('security_groups.rules')).\ - options(joinedload('volumes')).\ - options(joinedload('metadata')).\ - options(joinedload('instance_type')) + options(joinedload_all('fixed_ips.floating_ips')).\ + options(joinedload_all('fixed_ips.network')).\ + options(joinedload_all('fixed_ips.virtual_interface')).\ + options(joinedload_all('security_groups.rules')).\ + options(joinedload('volumes')).\ + options(joinedload('metadata')).\ + options(joinedload('instance_type')) if is_admin_context(context): partial = partial.filter_by(deleted=can_read_deleted(context)) @@ -1287,10 +1288,13 @@ def instance_get_all_by_filters(context, filters): session = get_session() query_prefix = session.query(models.Instance).\ - options(joinedload('security_groups')).\ - options(joinedload('metadata')).\ - options(joinedload('instance_type')).\ - order_by(desc(models.Instance.created_at)) + options(joinedload_all('fixed_ips.floating_ips')).\ + options(joinedload_all('fixed_ips.network')).\ + options(joinedload_all('fixed_ips.virtual_interface')).\ + options(joinedload('security_groups')).\ + options(joinedload('metadata')).\ + options(joinedload('instance_type')).\ + order_by(desc(models.Instance.created_at)) # Make a copy of the filters dictionary to use going forward, as we'll # be modifying it and we shouldn't affect the caller's use of it. -- cgit