Create volume

Overview

Creates a volume.

Classification

  • Create

API Operation Object

  • os-volumes

Synchronous / Asynchronous

  • -

Request

HTTP Request Method

  • POST

HTTP Request Path

{api_endpoint}/v2/{tenant_id}/os-volumes

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

{
    "volume": {
        "display_name": "<display_name>",
        "display_description": "<display_description>",
        "size": <size>,
        "volume_type": "<volume_type>",
        "metadata": {
            "contents": "<contents>"
        },
        "availability_zone": "<availability_zone>"
    }
}

Request Parameter

Request Parameters
name style format description required/optional
tenant_id URI String The unique identifier of the tenant or account. required
display_name plain String The volume name. optional
display_description plain String The volume description. optional
size plain String The size of the volume, in gigabytes (GB). required
volume_type plain String The unique identifier for a volume type. optional
metadata plain String One or more metadata key and value pairs to associate with the volume. optional
availability_zone plain String The availability zone. optional
snapshot_id plain String The unique identifier for a snapshot. required

Response

HTTP Response Header

Format

HTTP/1.1 <response_code> <message>       (ex. 200 OK)
  • <response_code>: see "HTTP Responses" section

  • <message>: message based on the response code

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

Response Code

Response Codes
response code condition
200 normal end
400 badRequest
401 unauthorized
403 forbidden
404 itemNotFound
405 badMethod
413 overLimit
503 serviceUnavailable

HTTP Response Body

Format

{
    "volume": {
        "id": "<id>",
        "display_name": "<display_name>",
        "display_description": "<display_description>",
        "status": "<status>",
        "size": <size>,
        "volume_type": "<volume_type>",
        "metadata": {
            "contents": "<contents>"
        },
        "availability_zone": "<availability_zone>",
        "snapshot_id": <snapshot_id>,
        "attachments": [],
        "created_at": "<created_at>"
    }
}

Response Parameter

Response Parameters
item format description
id UUID The volume ID.
display_name String The volume name.
display_description String The volume description.
status String The volume status.
size String The size of the volume, in gigabytes (GB).
volume_type String The unique identifier for a volume type.
contents String One or more metadata key and value pairs to associate with the volume.
availability_zone String The availability zone.
snapshot_id String The unique identifier for a snapshot.
attachments list One or more instance attachments.
created_at time/date Date and time when the volume was created.

Sample API Request and Response

Sample API Request

Request URI

https://example.com/v2/{tenant_id}/os-volumes

Request Header

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

Request Body

{
    "volume": {
        "display_name": "vol-001",
        "display_description": "Another volume.",
        "size": 15,
        "volume_type": "289da7f8-6440-407c-9fb4-7db01ec49164",
        "metadata": {
            "contents": "junk"
        },
        "availability_zone": "us-east1"
    }
}

Sample API Response

Response Header

HTTP/1.1 200 OK
  • <response_code>: see "HTTP Responses" section

  • <message>: message based on the response code

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

Response Body

{
    "volume": {
        "id": "521752a6-acf6-4b2d-bc7a-119f9148cd8c",
        "display_name": "vol-001",
        "display_description": "Another volume.",
        "status": "active",
        "size": 15,
        "volume_type": "289da7f8-6440-407c-9fb4-7db01ec49164",
        "metadata": {
            "contents": "junk"
        },
        "availability_zone": "us-east1",
        "snapshot_id": null,
        "attachments": [],
        "created_at": "2012-02-14T20:53:07Z"
    }
}

Execution Example

HTTP Request

POST /v2/ad355aa6ed3e4cf5ae0fa0df652bc291/os-volumes HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.56.250:8774
X-Auth-Token: ebbd28fada8b4d23be04d60b912d8144
Content-type: application/json
Accept: application/json
Content-Length: 352

HTTP Response

HTTP/1.1 200 OK
Location: http://192.168.56.250:8774/v2/ad355aa6ed3e4cf5ae0fa0df652bc291/os-volumes/8cecdc1f-b724-4a78-affa-1a24dd2ecebc
Content-Type: application/json
Content-Length: 328
X-Compute-Request-Id: req-1236d6f1-f175-457a-90ab-8758d8e91853
Date: Thu, 15 Oct 2015 05:18:06 GMT

{"volume": {"status": "creating", "displayDescription": null, "availabilityZone": "nova", "displayName": null, "attachments": [{}], "volumeType": "lvmdriver-1", "snapshotId": null, "metadata": {"key2": "val2", "key1": "val1"}, "id": "8cecdc1f-b724-4a78-affa-1a24dd2ecebc", "createdAt": "2015-10-15T05:18:06.721850", "size": 15}}

Error Execution Example

HTTP Request

POST /v2/ad355aa6ed3e4cf5ae0fa0df652bc290/os-volumes HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.56.250:8774
X-Auth-Token: ebbd28fada8b4d23be04d60b912d8144
Content-type: application/json
Accept: application/json
Content-Length: 352

HTTP Response

HTTP/1.1 400 Bad Request
Content-Length: 188
Content-Type: application/json; charset=UTF-8
X-Compute-Request-Id: req-c4370309-12b1-4b29-bbc6-f2f418976fb8
Date: Thu, 15 Oct 2015 05:20:18 GMT

{"badRequest": {"message": "Malformed request URL: URL's project_id 'ad355aa6ed3e4cf5ae0fa0df652bc290' doesn't match Context's project_id 'ad355aa6ed3e4cf5ae0fa0df652bc291'", "code": 400}}