Ask Your Question
2

how to upload image to glance(grizzly) from local disk through rest api in python.

asked 2014-03-13 14:55:50 -0500

Ukesh gravatar image

how to upload image to glance(grizzly) from local disk through rest api in python.

tried with httplib2, and open file and assign to body, not worked can anyone help with an example.

fs=open("/root/filename.qcow2", "rb") h = httplib2.http() h.request with body=fs and headers

thanks

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
0

answered 2014-03-14 03:10:16 -0500

unmesh-gurjar gravatar image

Ensure the header Content-Type is 'application/octet-stream' & Transfer-Encoding is 'chunked'. Also, ensure the data is transmitted in chunks! Refer _http_request method in https://github.com/openstack/python-glanceclient/blob/0.12.0/glanceclient/common/http.py. Do post the error if you are stuck.

edit flag offensive delete link more
0

answered 2014-03-14 15:03:27 -0500

dmitrymex gravatar image

Glance, like all other OpenStack services has a python client: https://github.com/openstack/python-g...

Using clients from python is generally much easier than sending http requests via httplib2 or requests libs. You can find an example on how to use glance and other python clients in the following article: http://www.ibm.com/developerworks/clo...

edit flag offensive delete link more
0

answered 2014-03-21 00:15:44 -0500

Ukesh gravatar image

I used python glance client (version: 0.12.0). it is working fine.

image = glance.images.create(name=self['name'], disk_format="vmdk", container_format="bare", location=self['localImagePath'])

with open(self['localImagePath'], "rb") as fimage: glance.images.upload(image.id, fimage)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2014-03-13 14:55:50 -0500

Seen: 691 times

Last updated: Mar 21 '14