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/compute/api.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/api.py b/nova/compute/api.py index 57e0d9edd..8b5005e78 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -917,7 +917,11 @@ class API(base.Base): instance = self.db.instance_get_by_uuid(context, uuid) else: instance = self.db.instance_get(context, instance_id) - return dict(instance.iteritems()) + + inst = dict(instance.iteritems()) + # NOTE(comstud): Doesn't get returned with iteritems + inst['name'] = instance['name'] + return inst @scheduler_api.reroute_compute("get") def routing_get(self, context, instance_id): @@ -986,7 +990,15 @@ class API(base.Base): local_zone_only = search_opts.get('local_zone_only', False) - instances = self._get_instances_by_filters(context, filters) + inst_models = self._get_instances_by_filters(context, filters) + + # Convert the models to dictionaries + instances = [] + for inst_model in inst_models: + instance = dict(inst_model.iteritems()) + # NOTE(comstud): Doesn't get returned by iteritems + instance['name'] = inst_model['name'] + instances.append(instance) if local_zone_only: return instances -- cgit