From 60cfebc31b101cfaf794a78dda74ef644179bd43 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 31 Jan 2013 16:20:08 -0800 Subject: [PATCH] Quote image ids before passing them to glance If the image id contains a space it needs to be quoted or else it will construct an improper header. Fixes bug 1111948 Change-Id: I4db2e74401b57de9666d40b38151182b2a76cd1b --- glanceclient/v1/images.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/glanceclient/v1/images.py b/glanceclient/v1/images.py index 16ee5f01..0cb81bce 100644 --- a/glanceclient/v1/images.py +++ b/glanceclient/v1/images.py @@ -91,13 +91,16 @@ class ImageManager(base.Manager): pass return meta - def get(self, image_id): + def get(self, image): """Get the metadata for a specific image. :param image: image object or id to look up :rtype: :class:`Image` """ - resp, body = self.api.raw_request('HEAD', '/v1/images/%s' % image_id) + + image_id = base.getid(image) + resp, body = self.api.raw_request('HEAD', '/v1/images/%s' + % urllib.quote(image_id)) meta = self._image_meta_from_headers(dict(resp.getheaders())) return Image(self, meta) @@ -109,7 +112,8 @@ class ImageManager(base.Manager): :rtype: iterable containing image data """ image_id = base.getid(image) - resp, body = self.api.raw_request('GET', '/v1/images/%s' % image_id) + resp, body = self.api.raw_request('GET', '/v1/images/%s' + % urllib.quote(image_id)) checksum = resp.getheader('x-image-meta-checksum', None) if do_checksum and checksum is not None: return utils.integrity_iter(body, checksum)