OpenStack SDK - How to create image with Kernel id and Ramdisk parameters?

asked 2016-09-09 13:55:15 -0500

Vini.g.fer gravatar image

I've been trying to create an OpenStack image informing the Kernel Id and Ramdisk Id, using the OpenStack Unified SDK( (, but without success. I know this is possible, because the OpenStack CLI have this parameters, as shown on this page ( (, where the CLI have the "--kernel-id" and "--ramdisk-id" parameters. I've used this parameter in the terminal and confirmed they work, but I need to use them in python.

I'm trying to use the upload_method, as described here ( but I can't get the attrs parameter right. Documentation only say it is suposed to be a dictionary. Here is the code I'm using

    atrib = {
        'properties': {
            'kernel_id': 'd84e1f2b-8d8c-4a4a-8858-77a8d5a93cb1',
            'ramdisk_id': 'cfef18e0-006e-477a-a098-593d43435a1e'
    with open(file) as fimage:
    image = image_service.upload_image(

And here is the error I'm getting:

  File "", line 121, in main
  File "/usr/lib/python2.7/site-packages/openstack/image/v2/", line 51, in upload_image
  File "/usr/lib/python2.7/site-packages/openstack/", line 193, in _create
    return res.create(self.session)
  File "/usr/lib/python2.7/site-packages/openstack/", line 570, in create
    json=request.body, headers=request.headers)
  File "/usr/lib/python2.7/site-packages/keystoneauth1/", line 675, in post
    return self.request(url, 'POST', **kwargs)
  File "/usr/lib/python2.7/site-packages/openstack/", line 52, in map_exceptions_wrapper
    http_status=e.http_status, cause=e)
openstack.exceptions.HttpException: HttpException: Bad Request, 400 Bad Request

Provided object does not match schema 'image': {u'kernel_id': u'd84e1f2b-8d8c-4a4a-8858-77a8d5a93cb1', u'ramdisk_id': u'cfef18e0-006e-477a-a098-593d43435a1e'} is not of type 'string'  Failed validating 'type' in schema['additionalProperties']:     {'type': 'string'}  On instance[u'properties']:     {u'kernel_id': u'd84e1f2b-8d8c-4a4a-8858-77a8d5a93cb1',      u'ramdisk_id': u'cfef18e0-006e-477a-a098-593d43435a1e'}

Already tried to use the update_image method, but without success, passing kernel id and ramdisk id as a strings creates the instance, but it does not boot. Does anyone knows how to solve this?

edit retag flag offensive close merge delete