diff options
author | Brian Waldon <bcwaldon@gmail.com> | 2012-07-11 19:34:28 -0700 |
---|---|---|
committer | Brian Waldon <bcwaldon@gmail.com> | 2012-07-11 19:55:02 -0700 |
commit | da360462a54501178753571cdfec800e899f38ae (patch) | |
tree | afb6cc0c42ae3169003db24eceb83e166a760d6a /glanceclient/v1/images.py | |
parent | a814c154652312e6c5f40674933275a0a6d2c647 (diff) | |
download | python-glanceclient-da360462a54501178753571cdfec800e899f38ae.tar.gz |
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
Diffstat (limited to 'glanceclient/v1/images.py')
-rw-r--r-- | glanceclient/v1/images.py | 6 |
1 files changed, 4 insertions, 2 deletions
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']) |