Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Openstack REST API - "Block Device Mapping is Invalid: Some fields are invalid" error while creating a new server

Dear all,

I'm writting a piece of code to create instances in OpenStack Icehouse using the REST API and JSON. I'm using the POST "/v2/{tenant_id}/servers" OpenStack API Ref.

My goal is to create the server and the volume in a single operation, I mean, create the instance, create the volume and attach the volume to the instance, similarly to the "Boot from image (creates a new volume)" option in Horizon dashboard. The JSON request message I'm using is:

        "availability_zone": "nova",
        "name": "instance_name",
        "imageRef": "9ba032af-f6dd-49dc-83b1-eea9bd3a45ea",
        "flavorRef": "2",
        "max_count": "1",
        "min_count": "1",
        "key_name": "default",
        "networks": [ { "uuid": "78749f43-bbf6-453c-9f04-e3fc3f851c31" } ],
        "security_groups": [ { "name": "default" } ],
                "device_name": "\/dev\/vga1",
                "uuid": "instance_name",
                "source_type": "image",
                "destination_type": "volume",
                "size": "20",
                "delete_on_termination": "False",
                "boot_index": "-1"

The availability zone name, imageRef ID, flavorRef, key name, network ID and security group ID are taken from previous GET requests to corresponding endpoints, so they should be correct.

My main concerns are with the block_device_mapping_v2 element. I tried to fill this element according the reference API, but it does not work.

What am I doing wrong?

Thanks, Lluis