Glance does not return image MD5
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Glance |
New
|
Undecided
|
Unassigned | ||
OpenStack SDK |
Invalid
|
Undecided
|
Unassigned |
Bug Description
I'm trying to download an OpenStack image from glance using only the Openstack Python SDK, but I only get this error:
Traceback (most recent call last):
File "/home/
main(
File "/home/
image_
File "/usr/local/
return image.download(
File "/usr/local/
checksum = resp.headers[
File "/usr/local/
return self._store[
KeyError: 'content-md5'
The weird part is that if I run the code using an IDE (PyCharm with remote debug) or as a script (python script.py -i ...) I get the error, but if I run each line using a python interpreter (ipython/python) the error does not happen! Have no idea why.
Here is the code I'm using:
...
image_name = node.name + "_" + time.strftime(
print "Getting data from", node.name
compute_
image = image_service.
image_service.
fileName = "%s.img" % image.name
with open(str(fileName), 'w+') as imgFile:
imgFile.
...
This code ends up calling the API in this file /usr/local/
def download(self, session):
"""Download the data contained in an image"""
# TODO(briancurtin): This method should probably offload the get
# operation into another thread or something of that nature.
url = utils.urljoin(
resp = session.get(url, endpoint_
checksum = resp.headers[
digest = hashlib.
if digest != checksum:
raise exceptions.
return resp.content
The resp.headers variable has no key "Content-MD5". This is the value I found for it:
{'Date': 'Thu, 01 Sep 2016 20:17:01 GMT', 'Transfer-
'Connection': 'keep-alive', 'Content-Type': 'application/
'X-Openstack-
But according to the REST API documentationm the response should return with the key Content-MD5: http://
If I just comment the MD5 check the download works fine, but this is inside the SDK so I can't/shouldn't change it. Anyone have any suggestion on how to achieve this using the OpenStack Python SDK? Is this an SDK bug?
That is interesting that it would work in some ways but not in others. Can you put the following two lines at the top of your script, and then run it and send the sdk.log file to me at <email address hidden>? It seems pretty odd that the response data would be different depending on where it's run.
from openstack import utils logging( debug=True, path="sdk.log")
utils.enable_