As the error said, you need to see the disk_format and container_format. I haven't digged the code, but I think you should try to set the container_format and disk_format when you create the image like this:
image = self.glance.images.create(name="myNewImage", container_format='bare', disk_format='raw',) On 03/08/16 13:27, kris...@itri.org.tw wrote: > > > > refer to: glance client Python API v2 > > http://docs.openstack.org/developer/python-glanceclient/ref/v2/images.html > > > > *add_location*(/image_id/, /url/, /metadata/) > > Add a new location entry to an image’s list of locations. > > It is an error to add a URL that is already present in the list of > locations. > > *Parameters:* > > > > · *image_id* –ID of image to which the location is to be added. > > · *url* –URL of the location to add. > > · *metadata* –Metadata associated with the location. > > *Returns:* > > > > The updated image > > ------------------------------------------------------------------------------------------------------------------- > > #--source code-- > > from glanceclient.v2.client import Client > > …… > > url = 'http://xxxx/ubuntu1604.qcow2' > > image = self.glance.images.create(name="myNewImage") > > self.glance.images.add_location(image.id, url, {}) > > #--end > > ------------------------------------------------------------------------------------------------------------------- > > > > I am sure the images.create is work. > > I got image .id ‘be416e4a-f266-4ad5-a62f-979242d23633’. > > I don’t Know which data should be assign to metadata. > > Then I got : > > > > self.glance.images.add_location(image.id, url, {}) > > File "/usr/lib/python2.7/dist-packages/glanceclient/v2/images.py", > line 311, in add_location > > self._send_image_update_request(image_id, add_patch) > > File "/usr/lib/python2.7/dist-packages/glanceclient/v2/images.py", > line 296, in _send_image_update_request > > self.http_client.patch(url, headers=hdrs, data=json.dumps(patch_body)) > > File "/usr/lib/python2.7/dist-packages/glanceclient/common/http.py", > line 284, in patch > > return self._request('PATCH', url, **kwargs) > > File "/usr/lib/python2.7/dist-packages/glanceclient/common/http.py", > line 267, in _request > > resp, body_iter = self._handle_response(resp) > > File "/usr/lib/python2.7/dist-packages/glanceclient/common/http.py", > line 83, in _handle_response > > raise exc.from_response(resp, resp.content) > > HTTPBadRequest: 400 Bad Request: Properties disk_format, > container_format must be set prior to saving data. (HTTP 400) > > > > Best Regards, > > Kristen > > > > > > -- > 本信件可能包含工研院機密資訊,非指定之收件者,請勿使用或揭露本信件內 > 容,並請銷毀此信件。 This email may contain confidential information. > Please do not use or disclose it in any way and delete it if you are > not the intended recipient. > > > __________________________________________________________________________ > OpenStack Development Mailing List (not for usage questions) > Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev -- Cheers & Best regards, Fei Long Wang (王飞龙) -------------------------------------------------------------------------- Senior Cloud Software Engineer Tel: +64-48032246 Email: flw...@catalyst.net.nz Catalyst IT Limited Level 6, Catalyst House, 150 Willis Street, Wellington --------------------------------------------------------------------------
__________________________________________________________________________ OpenStack Development Mailing List (not for usage questions) Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev