Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

python failed image upload

I have the following code:

    print "Uploading image from {0}".format(img_file)
    with open(img_file,'rb') as handle:
        try:
            self.dst_gl.images.create(data=handle,name=img_name,disk_format=self.src_img.disk_format,container_format=self.src_img.container_format)
        except Exception as e:
            print e

That throws the following error:

    Unable to set 'data' to '<open file '/tmp/matdaivd-migration-test_rootvol.raw', mode 'rb' at        0x7fb0c44856f0>'. Reason: <open file '/tmp/matdaivd-migration-test_rootvol.raw', mode 'rb' at       0x7fb0c44856f0> is not of type u'string'

    Failed validating u'type' in schema[u'additionalProperties']:
        {u'type': u'string'}

"self.dst_gl.images" is an object of type glanceclient.v2.images.ImageManager. From what I understand OS is basically saying that the object type for the image data is incorrect, but i've followed the example almost exactly. Can anyone provide any insight as to how I might get around this error?