diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2011-01-09 23:53:51 -0800 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2011-01-09 23:53:51 -0800 |
| commit | c8566628d4c15bcaf16baf8fca2a31528e7eac13 (patch) | |
| tree | c5002b9ac6929993935f6591d93fab6ea7d7318d /nova/api | |
| parent | 6d05c3e5d9112aead1db23e942f24605a3301af9 (diff) | |
| download | nova-c8566628d4c15bcaf16baf8fca2a31528e7eac13.tar.gz nova-c8566628d4c15bcaf16baf8fca2a31528e7eac13.tar.xz nova-c8566628d4c15bcaf16baf8fca2a31528e7eac13.zip | |
optimize to call get if instance_id is specified since most of the time people will just be requesting one id
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index fd3141a97..9166301c7 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -613,11 +613,12 @@ class CloudController(object): def _format_instances(self, context, instance_id=None, **kwargs): reservations = {} - instances = self.compute_api.get_all(context, **kwargs) # NOTE(vish): instance_id is an optional list of ids to filter by if instance_id: instance_id = [ec2_id_to_id(x) for x in instance_id] - instances = [x for x in instances if x['id'] in instance_id] + instances = [self.compute_api.get(context, x) for x in instance_id] + else: + instances = self.compute_api.get_all(context, **kwargs) for instance in instances: if not context.user.is_admin(): if instance['image_id'] == FLAGS.vpn_image_id: |
