Ask Your Question

hyphon81's profile - activity

2017-03-09 20:05:35 -0500 commented answer Why does openstack image create of cirros result in size 0

Yes, you are right. I thought the file object was inserted to data. However, "pass" is simpler and better.

2017-02-21 07:34:37 -0500 received badge  Teacher (source)
2017-02-09 02:31:33 -0500 received badge  Enthusiast
2017-02-05 17:56:16 -0500 answered a question Why does openstack image create of cirros result in size 0

Same one. The size 0 image was created in my environment with no error.

Eventually, I found it to happen when glanceclient is sending PUT message. I modified glanceclient code and I could create images correctly.

I'm trying to construct OpenStack Newton with source build and I referred from http://docs.openstack.org/newton/install-guide-ubuntu/index.html.

The python "requests" package version 2.13.0 needs to receive the "file-like" object. (http://docs.python-requests.org/en/master/api/) However, the glanceclient version 2.5.0 was sending generator object.

For the moment, I patched this code to glanceclient and I got image has right image size.

diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py
index 352ba10..e49442f 100644
--- a/glanceclient/common/http.py
+++ b/glanceclient/common/http.py
@@ -84,7 +84,12 @@ class _BaseHTTPClient(object):
# Here we assume it's
# a file-like object
# and we'll chunk it
- data = self._chunk_body(data)
+ #data = self._chunk_body(data)
+
+ # WORKAROUND
+ # The chunked generator object
+ # caused creating size 0 image
+ data = data

headers['Content-Type'] = content_type
kwargs['stream'] = content_type == 'application/octet-stream'