Create image¶
Overview¶
Creates a new image. Specify the createImage action in the request body.
Classification¶
- Create
API Operation Object¶
- action
Synchronous / Asynchronous¶
- asynchronous
Request¶
HTTP Request Method¶
- POST
HTTP Request Path¶
{api_endpoint}/v2/{project_id}/servers/{server_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¶
{
"createImage": {
"metadata": {
"<metadata_key>": "<metadata_value>",
<<repeat>>
},
"name": "<name>"
}
}
- * Since the disk format can not be specified, it will be all qcow2.
Request Parameter¶
name | style | format | description | required/optional | default value | action for invalid parameter | response code for invalid parameter |
---|---|---|---|---|---|---|---|
project_id | URL | UUID(3) | Project id | required | - | Terminate | 400, 404 |
server_id | URL | UUID String | instance id | required | - | Terminate | 404 |
token_id | Header | authentication token string | keystone authentication token | required | - | Terminate | 401 |
name | Body | String(1-255 characters) or number(1-255digits) | name | required | - | Terminate | 400 |
metadata_key | Body | String (1-255 characters) or number(1-255digits) | metadata key | optional | - | Terminate | 400 |
metadata_value | Body | text (2^16 - 1 bytes) | metadata value | optional | - | - | - |
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 "Content-Length", "Date"
Response Code¶
response code | condition |
---|---|
202 | normal end |
400 | not found createImage entity in body |
- | not found the image name in body |
- | metadata key cannnot be blank in body |
- | invalid project_id |
- | snapshots is disable in config file |
401 | unauthorized |
403 | metadata items > Quota(metadata_items) |
404 | not found a specified instance |
- | not found a specified project |
409 | vm_state isn't ACTIVE, STOPPED, PAUSED, SUSPENDED |
Sample API Request and Response¶
Sample API Request¶
Request URI¶
https://example.com/v2/{project_id}/servers/{server_id}/action
Request Header¶
Accept-Encoding: gzip, deflate, compress (optional)
Accept: application/json
X-Auth-Token: ajk3adjiown02
Content-Type: application/json
Request Body¶
{
"createImage": {
"metadata": {
"<metadata_key>": "<metadata_value>",
<<repeat>>
},
"name": "<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 "Content-Length", "Date"
Response Body¶
- none
Execution Example¶
HTTP Request¶
POST /v2/b7a7b63e92174a95a999c95da856f143/servers/da5834e0-31d2-40f9-b271-6592f9f68370/action HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.150.51:8774
Accept-Encoding: gzip, deflate, compress
Accept: application/json
X-Auth-Token: e5b9d3e8160747b3b7bdd9d4833d0b08
Content-Type: application/json
Content-Length: 76
{ "createImage" : { "name": "test-image", "metadata": { "myvar": "test" } }}
HTTP Response¶
HTTP/1.1 202 Accepted
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Location: http://192.168.150.51:8774/v2/b7a7b63e92174a95a999c95da856f143/images/248df7a9-e0c3-4f31-be6b-71e3108498f2
X-Compute-Request-Id: req-2e200807-2295-4fd5-aaf1-0c144f402210
Date: Wed, 20 Aug 2014 05:47:00 GMT
Error Execution Example¶
HTTP Request¶
POST /v2/f66f8e846a65484a9a6740077e72e3dd/servers/cbb50b7d-0326-4dd4-83d3-59179e244492/action HTTP/1.1
User-Agent: curl/7.35.0
Host: 192.168.56.250:8774
X-Auth-Token: dbccc0180c0c42feb6feea5295f48882
Accept: application/json
Content-Length: 57
Content-Type: application/x-www-form-urlencoded
HTTP Response¶
HTTP/1.1 400 Bad Request
Content-Length: 73
Content-Type: application/json; charset=UTF-8
X-Compute-Request-Id: req-7c60dc31-060c-47e0-8e34-6fc6d85fc084
Date: Wed, 07 Oct 2015 07:38:30 GMT
{"badRequest": {"message": "There is no such action: None", "code": 400}}