diff options
| author | Brian Waldon <bcwaldon@gmail.com> | 2012-01-28 21:47:06 -0800 |
|---|---|---|
| committer | Brian Waldon <bcwaldon@gmail.com> | 2012-01-28 22:19:21 -0800 |
| commit | 755f660b7ca129f869da07db0cc4433106f47ff9 (patch) | |
| tree | 93dd09af3ac71ceb3005c4e1e9659d51939781ce /nova/image | |
| parent | 6a239cb7a2ea05a9382ed71469ca770afbb12212 (diff) | |
Use name filter in GlanceImageService show_by_name
Fixes bug 883289
Change-Id: Ie2e62aea55e6541dc4ad1a725130fbf0259362fb
Diffstat (limited to 'nova/image')
| -rw-r--r-- | nova/image/glance.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/nova/image/glance.py b/nova/image/glance.py index 2a24d534e..092dd832a 100644 --- a/nova/image/glance.py +++ b/nova/image/glance.py @@ -227,13 +227,11 @@ class GlanceImageService(object): def show_by_name(self, context, name): """Returns a dict containing image data for the given name.""" - # TODO(vish): replace this with more efficient call when glance - # supports it. - image_metas = self.detail(context) - for image_meta in image_metas: - if name == image_meta.get('name'): - return image_meta - raise exception.ImageNotFound(image_id=name) + image_metas = self.detail(context, filters={'name': name}) + try: + return image_metas[0] + except (IndexError, TypeError): + raise exception.ImageNotFound(image_id=name) def get(self, context, image_id, data): """Calls out to Glance for metadata and data and writes data.""" |
