From da360462a54501178753571cdfec800e899f38ae Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Wed, 11 Jul 2012 19:34:28 -0700 Subject: Wrap image data in iterator This is establishing the API for a future optimization. We want to be able to offer true socket-level caching, but can't do that with httplib2 right now. For now, we will just fake the optimization by returning an iterator over the image body, which happens to already be fully loaded into a string. Change-Id: I2d36e3cdd45b26d7c7c27ba050bf6a4b5765df6c --- glanceclient/v1/images.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'glanceclient/v1/images.py') diff --git a/glanceclient/v1/images.py b/glanceclient/v1/images.py index 5bee359..4263baf 100644 --- a/glanceclient/v1/images.py +++ b/glanceclient/v1/images.py @@ -159,8 +159,9 @@ class ImageManager(base.Manager): if copy_from is not None: hdrs['x-glance-api-copy-from'] = copy_from - resp, body = self.api.raw_request( + resp, body_iter = self.api.raw_request( 'POST', '/v1/images', headers=hdrs, body=image_data) + body = ''.join([c for c in body_iter]) return Image(self, json.loads(body)['image']) def update(self, image, **kwargs): @@ -199,6 +200,7 @@ class ImageManager(base.Manager): hdrs['x-glance-api-copy-from'] = copy_from url = '/v1/images/%s' % base.getid(image) - resp, body = self.api.raw_request( + resp, body_iter = self.api.raw_request( 'PUT', url, headers=hdrs, body=image_data) + body = ''.join([c for c in body_iter]) return Image(self, json.loads(body)['image']) -- cgit v1.2.1