Uploads a volume to glance

Overview

Uploads a volume on cinder to glance.

Classification

  • Upload

API Operation Object

  • action

Synchronous / Asynchronous

  • asynchronous

Request

HTTP Request Method

  • POST

HTTP Request Path

{api_endpoint}/v2/{tenant_id}/volumes/{volume_id}/action

HTTP Request Header

Format

Accept-Encoding: gzip, deflate, compress(optional)
Accept: application/json
X-Auth-Token: <token_id>
Content-Type: application/json

HTTP Request Body

Format

{
    "os-volume_upload_image": {
        "container_format": "<container_format>",
        "disk_format": "<disk_format>",
        "force": <force>,
        "image_name": "<image_name>"
    }
}

Request Parameter

Request Parameters

name

style

format

description

required/optional

default value

action for invalid parameter

response code for invalid parameter

tenant_id

URL

UUID(3)

tenant ID

required

-

Terminate

400, 404

volume_id

URL

UUID

Volume ID that will be uploaded

required

-

Terminate

404

token_id

Header

String(token_id)

Keystone administration token

required

-

Terminate

401

container_format

Body

String

Select one of the following("bare", "ovf", "ami", "aki", "ari")

optional

"bare"

Terminate

400

disk_format

Body

String

Select one of the following("raw", "vmdk", "vdi", "qcow2")*

optional

"raw"

Terminate

400

force

Body

boolean

other string means False

Whether to upload a volume of attached state.

When the state of volume is available, the value of force option does not affect the operation.

optional

false

Terminate

400

image_name

Body

String(1-255characters)

The name of the image to be registered in the Glance

required

-

Terminate

400

  • * If disk_format is set to "iso" the request is accepted, but the uploaded image is not created.

Response

HTTP Response Header

Format

HTTP/1.1 <response code> <message>       (ex. 202 Accepted)
  • <response_code>: see "HTTP Responses" section

  • <message>: message based on the response code

    • skip auto insert field such as "X-Compute-Request-Id" and "X-Openstack-Request-Id", "Content-Length", "Date"

Response Code

Response Codes

response code

condition

202

normal end

400

There is no HTTP request body. Or, there is no "os-volume_upload_image" element in the body.

-

There is no image_name parameter. Or, its parameter is null, 0, etc.

-

specify 256 or more characters in the image_name

-

value of force key is not boolean.

-

The volume status specified in URL is not "available", or "in-use".

-

The volume status specified in URL is "in-use", but force parameter is not True.

-

invalid input for tenant ID

401

unauthorized (including Keystone down)

403

The user who requests is not allowed to do get_operation.

-

The user who requests is not allowed to do copy_volume_to_image_operation.

404

The volume specified in URL does not exist.

-

tenant_id is empty

500

Information about end point of Glance is incorrect.

-

Failed to communicate with glance-api.

HTTP Response Body

Format

{
    "os-volume_upload_image": {
        "container_format": "<container_format>",
        "disk_format": "<disk_format>",
        "display_description": null,
        "id": "<volume_id>",
        "image_id": "<image_id>",
        "image_name": "<image_name>",
        "size": <volume_size>,
        "status": "<status>",
        "updated_at": "<updated_at>",
        "volume_type": "<volume_type>"
    }
}

Response Parameter

Response Parameters

item

format

description

container_format

String

choose one from "bare", "ovf", "ami", "aki", "ari".

disk_format

String

choose one from "raw", "vmdk", "vdi", "qcow2".

volume_id

UUID

Volume ID

image_id

UUID

Glance image ID

image_name

String(0-255characters)

Glance image name

volume_size

Integer

Size of source volume(GB)

status

String

The volume status.

updated_at

time/date

format: "yyyy-mm-ddThh:mm:ss.ssssss"

volume_type

String(0-255characters) or null

Type of the source volume

Sample API Request and Response

Sample API Request

Request URI

https://example.com/v2/{tenant_id}/volumes/{volume_id}/action

Request Header

Accept-Encoding: gzip, deflate, compress(optional)
Accept: application/json
X-Auth-Token: ajk3adjiown02
Content-Type: application/json

Request Body

{
    "os-volume_upload_image": {
        "container_format": "<container_format>",
        "disk_format": "<disk_format>",
        "force": <force>,
        "image_name": "<image_name>"
    }
}

Sample API Response

Response Header

HTTP/1.1 202 Accepted
  • <response_code>: see "HTTP Responses" section

  • <message>: message based on the response code

    • skip auto insert field such as "X-Compute-Request-Id" and "X-Openstack-Request-Id", "Content-Length", "Date"

Response Body

{
    "os-volume_upload_image": {
        "container_format": "<container_format>",
        "disk_format": "<disk_format>",
        "display_description": null,
        "id": "<volume_id>",
        "image_id": "<image_id>",
        "image_name": "<image_name>",
        "size": <volume_size>,
        "status": "<status>",
        "updated_at": "<updated_at>",
        "volume_type": "<volume_type>"
    }
}

Execution Example

HTTP Request

POST /v2/88b6f916fc8a4b81b055aa26993bd68e/volumes/f2f02802-00ff-4690-9eb2-3f9fa43d2244/action HTTP/1.1
Host: 192.168.11.67:8776
X-Auth-Project-Id: demo
Accept-Encoding: gzip, deflate, compress
Content-Length: 128
Accept: application/json
User-Agent: python-cinderclient
X-Auth-Token: 42f80c103a7a403396bed90711b24378
Content-Type: application/json

{"os-volume_upload_image": {"container_format": "bare", "force": false, "image_name": "testupdateimage", "disk_format": "raw"}}

HTTP Response

HTTP/1.1 202 Accepted
X-Compute-Request-Id: req-db239bb1-a131-4dfb-86cb-e0d657a2f505
Content-Type: application/json
Content-Length: 338
X-Openstack-Request-Id: req-db239bb1-a131-4dfb-86cb-e0d657a2f505
Date: Tue, 27 May 2014 12:32:32 GMT

{"os-volume_upload_image": {"status": "uploading", "image_id": "f43d5555-1ac9-4c12-9485-8a72cbc5ba5a", "image_name": "testupdateimage", "volume_type": null, "container_format": "bare", "size": 1, "disk_format": "raw", "id": "f2f02802-00ff-4690-9eb2-3f9fa43d2244", "display_description": null, "updated_at": "2014-05-27T12:26:11.000000"}}

Error Execution Example

HTTP Request

POST /v2/cb8aa2a2c7244af5aab1fa7881ba7f4/volumes/ec48eb1f-f32e-43ee-97ab-9a6c453bc3b2/action HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.56.250:8776
X-Auth-Token: 517486dbd39a44088fdc5b3dfcfdb831
Content-type: application/json
Accept: application/json
Content-Length: 127

{"os-volume_upload_image": {"container_format": "bare", "force": false, "image_name": "testupdateimage", "disk_format": "raw"}}

HTTP Response

HTTP/1.1 400 Bad Request
Content-Length: 65
Content-Type: application/json; charset=UTF-8
X-Compute-Request-Id: req-c3e47bf1-e8ec-43fc-bf4f-48c9ef8962cc
X-Openstack-Request-Id: req-c3e47bf1-e8ec-43fc-bf4f-48c9ef8962cc
Date: Thu, 15 Oct 2015 12:19:51 GMT

{"badRequest": {"message": "Malformed request url", "code": 400}}