6.5. Updating images

PATCH /v2/images/{image_id}

Change image name, OS distribution, minimal disk size, placement, and shared status of an image with the specified ID.

Use the media type application/openstack-images-v2.1-json-patch.

The OS distribution parameter os_distro can be one of the following:

  • Linux distributions:
    • genericlinux, Generic Linux
    • centos8, CentOS 8
    • centos7, CentOS 7
    • centos6, CentOS 6
    • rhel8, Red Hat Enterprise Linux 8
    • rhel7, Red Hat Enterprise Linux 7
    • ubuntu1804, Ubuntu 18.04
    • ubuntu1604, Ubuntu 16.04
    • debian9, Debian 9
  • Windows distributions:
    • genericwindows, Generic Windows
    • win2k19, Windows Server 2019
    • win2k16, Windows Server 2016
    • win2k12r2, Windows Server 2012 R2
    • win2k12, Windows Server 2012
    • win2k8r2, Windows Server 2008 R2
    • win2k8, Windows Server 2008
    • win10, Windows 10
    • win81, Windows 8.1
    • win7, Windows 7

Source: https://docs.openstack.org/api-ref/image/v2/index.html?expanded=#update-image

6.5.1. Request

Name In Type Description
Content-Type header string The media type descriptor for the request body. Use application/openstack-images-v2.1-json-patch. (You can also use application/openstack-images-v2.0-json-patch, but keep in mind that it’s deprecated.)
image_id path string The UUID of the image.

6.5.1.1. Example

# curl -ks -X PATCH -H 'Content-Type: application/openstack-images-v2.1-json-patch' -H 'X-Auth-Token: gAAAAA<...>' -d '
[
    {
        "op": "replace",
        "path": "/name",
        "value": "cirros2"
    },
    {
        "op": "replace",
        "path": "/os_distro",
        "value": "centos8"
    },
    {
        "op": "replace",
        "path": "/min_disk",
        "value": 3
    },
    {
        "op": "replace",
        "path": "/visibility",
        "value": "public"
    },
    {
        "op": "add",
        "path": "/trait:CUSTOM_HCI_122E856B9E9C4D80A0F8C21591B5AFCB",
        "value": "required"
    }
]' https://<node_IP_addr>:9292/v2/images/c92d820c-50dc-4fd1-a0bc-2f1071487b67

6.5.2. Response

Name In Type Description
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: ami, ari, aki, bare, ovf, ova, or docker.

The value might be null (JSON null data type).

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, 2015-08-27T09:49:58-05:00.

The ±hh:mm value, if included, is the time zone as an offset from UTC.

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: ami, ari, aki, vhd, vhdx, vmdk, raw, qcow2, vdi, ploop or iso.

The value might be null (JSON null data type).

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).
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).
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 os_hash_value property. The value might be null (JSON null data type). The algorithm used is chosen by the cloud operator; it may not be configured by end users. (Since Image API v2.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 os_hash_algo property. The value might be null (JSON null data type) if data has not yet been associated with this image, or if the image was created using a version of the Image Service API prior to version 2.7. (Since Image API v2.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. (Since Image API v2.7)
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.

The date and time stamp format is ISO 8601:

CCYY-MM-DDThh:mm:ss±hh:mm

For example, 2015-08-27T09:49:58-05:00.

The ±hh:mm value, if included, is the time zone as an offset from UTC. In the previous example, the offset value is -05:00.

If the updated_at date and time stamp is not set, its value is null.

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 show_image_direct_url option is true in the Image service’s configuration file. Because 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 url key, whose value is a URL specifying a location, and a metadata key, whose value is a dict of key:value pairs containing information appropriate to the use of whatever external store is indicated by the URL. This list appears only if the show_multiple_locations option is set to true in the Image service’s configuration file. Because it presents a security risk, this option is disabled by default.

6.5.2.1. Status codes

6.5.2.1.1. Success

Code Reason
200 - OK Request was successful.

6.5.2.1.2. 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.
404 - Not Found The requested resource could not be found.
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.

6.5.2.2. Example

{
  "image_validated": "yes",
  "container_format": "bare",
  "min_ram": 0,
  "updated_at": "2020-02-11T11:52:02Z",
  "file": "/v2/images/c92d820c-50dc-4fd1-a0bc-2f1071487b67/file",
  "owner": "f5d834d636c642c7bfe8af86139c6f26",
  "id": "c92d820c-50dc-4fd1-a0bc-2f1071487b67",
  "size": 12716032,
  "os_distro": "centos8",
  "self": "/v2/images/c92d820c-50dc-4fd1-a0bc-2f1071487b67",
  "disk_format": "qcow2",
  "os_hash_algo": "sha512",
  "direct_url": "file:///mnt/vstorage/vols/datastores/glance/c92d820c-50dc-4fd1-a0bc-2f1071487b67",
  "hw_disk_bus": "virtio",
  "schema": "/v2/schemas/image",
  "status": "active",
  "tags": [],
  "trait:CUSTOM_HCI_122E856B9E9C4D80A0F8C21591B5AFCB": "required",
  "visibility": "public",
  "min_disk": 3,
  "virtual_size": null,
  "name": "cirros2",
  "checksum": "443b7623e27ecf03dc9e01ee93f67afe",
  "created_at": "2020-01-28T12:58:17Z",
  "os_hidden": false,
  "protected": false,
  "os_hash_value": "6513f21e44aa3da349f248188a<...>",
  "os_type": "linux"
}