Creating image records
POST /v2/images
Create an image record. You need to provide a name and specify container_format
and disk_format
.
Next, upload an image file to the record, according to Uploading image data.
Source: https://docs.openstack.org/api-ref/image/v2/index.html?expanded=create-image-detail#create-image
Request
Parameters
Name | In | Type | Description |
---|---|---|---|
container_format (Optional) |
body | enum |
Format of the image container. Values may vary based on the configuration available in a particular OpenStack cloud. Example formats are: The value might be |
disk_format (Optional) |
body | enum |
The format of the disk. Values may vary based on the configuration available in a particular OpenStack cloud. See the Image Schema response from the cloud itself for the valid values available. Example formats are: The value might be |
id (Optional) |
body | string |
A unique, user-defined image UUID, in the format: nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn Where n is a hexadecimal digit from 0 to f, or F. For example: b2173dd3-7ad6-4362-baa6-a68bce3565cb If you omit this value, the API generates a UUID for the image. If you
specify a value that has already been assigned, the request fails with
a |
min_disk (Optional) |
body | integer | Amount of disk space in GB that is required to boot the image. |
min_ram (Optional) |
body | integer | Amount of RAM in MB that is required to boot the image. |
name (Optional) |
body | string | The name of the image. |
protected (Optional) |
body | boolean | Image protection for deletion. Valid value is true or false .
Default is false . |
tags (Optional) |
body | array | List of tags for this image. Each tag is a string of at most 255 chars. The maximum number of tags allowed on an image is set by the operator. |
visibility (Optional) |
body | string |
Visibility for this image. Valid value is one of: Since the Image API v2.5, the default value is |
Example
# curl -ks -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' -d ' { "container_format": "bare", "disk_format": "qcow2", "name": "cirros3" }' https://<node_IP_addr>:9292/v2/images
Response
Parameters
Name | In | Type | Description |
---|---|---|---|
Location
|
header | string | The URL to access the image file from the external store. |
OpenStack-image-import-methods (Optional) |
header | string |
A comma separated list of import method identifiers. Included only if image import is enabled in your cloud. New in version 2.6 |
OpenStack-image-store-ids (Optional) |
header | string | A comma separated list of available store identifiers. If this header is missing the cloud does not support multiple backend stores. |
checksum
|
body | string | Hash that is used over the image data. The Image
service uses this value for verification. The value might be
null (JSON null data type). |
container_format
|
body | enum |
Format of the image container. Values may vary based on the configuration available in a particular OpenStack cloud. Example formats are: The value might be |
created_at
|
body | string |
The date and time when the resource was created. The date and time stamp format is ISO 8601: CCYY-MM-DDThh:mm:ss±hh:mm For example, The |
disk_format
|
body | enum |
The format of the disk. Values may vary based on the configuration available in a particular OpenStack cloud. See the Image Schema response from the cloud itself for the valid values available. Example formats are: The value might be |
file
|
body | string | The URL for the virtual machine image file. |
id
|
body | string |
A unique, user-defined image UUID, in the format: nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn Where n is a hexadecimal digit from 0 to f, or F. For example: b2173dd3-7ad6-4362-baa6-a68bce3565cb If you omit this value, the API generates a UUID for the image. |
min_disk
|
body | integer | Amount of disk space in GB that is required to boot the image.
The value might be null (JSON null data type). |
min_ram
|
body | integer | Amount of RAM in MB that is required to boot the image.
The value might be null (JSON null data type). |
name
|
body | string | The name of the image. Value might be null (JSON null data type). |
os_hash_algo
|
body | string |
The algorithm used to compute a secure hash of the image data for this
image. The result of the computation is displayed as the value of the
New in version 2.7 |
os_hash_value
|
body | string |
The hexdigest of the secure hash of the image data computed using the
algorithm whose name is the value of the New in version 2.7 |
os_hidden
|
body | boolean |
This field controls whether an image is displayed in the default image-list response. A “hidden” image is out of date somehow (for example, it may not have the latest updates applied) and hence should not be a user’s first choice, but it’s not deleted because it may be needed for server rebuilds. By hiding it from the default image list, it’s easier for end users to find and use a more up-to-date version of this image. New in version 2.7 |
owner
|
body | string | An identifier for the owner of the image, usually the project (also
called the “tenant”) ID.
The value might be null (JSON null data type). |
protected
|
body | boolean | A boolean value that must be false or the image cannot be deleted. |
schema
|
body | string | The URL for the schema describing a virtual machine image. |
self
|
body | string | The URL for the virtual machine image. |
size
|
body | integer | The size of the image data, in bytes. The value
might be null (JSON null data type). |
status
|
body | string | The image status. |
tags
|
body | array | List of tags for this image, possibly an empty list. |
updated_at
|
body | string |
The date and time when the resource was updated. If the resource has
not been updated, this field will be The date and time stamp format is ISO 8601: CCYY-MM-DDThh:mm:ss±hh:mm For example, The |
virtual_size
|
body | integer | The virtual size of the image. The value might
be null (JSON null data type). |
visibility
|
body | string | Image visibility, that is, the access permission for the image. |
direct_url (Optional) |
body | string |
The URL to access the image file kept in external store. It is present
only if the As it presents a security risk, this option is disabled by default. |
locations (Optional) |
body | array |
A list of objects, each of which describes an image location. Each object
contains a As it presents a security risk, this option is disabled by default. |
Status codes
Success
Code | Reason |
---|---|
201 - Created
|
Resource was created and is ready to use. |
Error
Code | Reason |
---|---|
400 - Bad Request
|
Some content in the request was invalid. |
401 - Unauthorized
|
User must authenticate before making a request. |
403 - Forbidden
|
Policy does not allow current user to do this operation. |
409 - Conflict
|
This operation conflicted with another operation on this resource. |
413 - Request Entity Too Large
|
The request is larger than the server is willing or able to process. |
415 - Unsupported Media Type
|
The request entity has a media type which the server or resource does not support. |
Example
{ "container_format": "bare", "min_ram": 0, "updated_at": "2020-02-11T12:05:52Z", "file": "/v2/images/c7c31840-ff42-4ef1-b489-48af638fdf7f/file", "owner": "f5d834d636c642c7bfe8af86139c6f26", "id": "c7c31840-ff42-4ef1-b489-48af638fdf7f", "size": null, "self": "/v2/images/c7c31840-ff42-4ef1-b489-48af638fdf7f", "disk_format": "qcow2", "os_hash_algo": null, "schema": "/v2/schemas/image", "status": "queued", "tags": [], "visibility": "shared", "min_disk": 0, "virtual_size": null, "name": "cirros3", "checksum": null, "created_at": "2020-02-11T12:05:52Z", "os_hidden": false, "protected": false, "os_hash_value": null }