• Native OpenStack API

noa
  1. Help Center
  2. Native OpenStack API
  3. API Reference
  4. Glance
  5. Images
  6. Update Image

Update Image

Function Description

This interface is used to update image information.

Interface Format

Method

URI

Description

PATCH

/v2/images/{image_id}

Updates the image information.

Restrictions

N/A

Expanded Interface

N/A

Request Parameter

Glance has two methods of updating image information. The method is specified by Content-Type in the HTTP header. application/openstack-images-v2.0-json-patch and application/openstack-images-v2.1-json-patch are supported. Content types differ only in the format of the request message body.

Table 1 Interface v2.0 request parameters

Parameter

Type

Mandatory

Description

replace

String

Select one of the following: replaceadd, and remove.

If key is set to replace, indicating that the attribute of the image needs to be replaced. You need to set value to the attribute name to be replaced and add a backslash (/) before the name.

add

String

If key is set to add, indicating that the attribute of the image is required to be added. You need to set value to the attribute name to be added and add a backslash (/) before the name.

remove

String

If key is set to remove, indicating that the attribute of the image is required to be removed. You need to set value to the attribute name to be removed and add a backslash (/) before the name.

value

Mixed

If key is set to replace or add, you need to specify the parameter. If key is set to remove, you are not required to specify the parameter.

Specifies the value of the attribute to be updated or added.

Table 2 Interface v2.1 request parameters

Parameter

Type

Mandatory

Description

op

String

Yes

Specifies the update operation type. The value can be replaceadd, or remove.

path

String

Yes

Specifies the name of the attribute to be updated. If op is set to replace or remove, the path value must be the existing attribute of the image. If op is set to add, the path value is the attribute that the image does not have. You need to add a backslash (/) before the attribute name.

value

Mixed

If op is set to replace or add, you need to specify the parameter value. If op is set to remove, you are not required to specify the parameter value.

Specifies the value of the attribute to be updated or added.

Response Parameter

Table 3 Response parameters

Parameter

Type

Mandatory

Description

visibility

String

Yes

Specifies whether the image can be viewed by other tenants. The value can be public or private.

name

String

No

Specifies the image name, a string of up to 256 characters.

protected

Bool

Yes

Specifies whether the image is protected. The protected image cannot be deleted.

container_format

String

No

Specifies the container format. The value can be amiariakibare, or ovf.

disk_format

String

No

Specifies the disk format. The value can be amiariakivhdvmdkrawqcow2vdi, or iso.

tags

List(String)

Yes

Specifies the image tag, a string of up to 256 characters.

min_ram

Int

Yes

Specifies the minimum size of the memory (MB) that the running image belongs to. The value is less than 2,147,483,648.

min_disk

Int

Yes

Specifies the minimum size of the disk (GB) that the running image belongs to. The value is less than 2,147,483,648.

status

String

Yes

Specifies the image status.

created_at

Datetime

Yes

Specifies the date and time when the image was created.

updated_at

Datetime

Yes

Specifies the date and time when the image was updated.

self

String

Yes

Specifies the URL for the image.

id

String

Yes

Specifies the image ID.

file

String

Yes

Specifies the URL for the image file that you can upload or download.

schema

String

Yes

Specifies the URL for the schema.

size

Int

Yes

Specifies the image size. This parameter is valid after the image is uploaded.

checksum

String

Yes

Specifies the image checksum. This parameter is valid after the image is uploaded.

virtual_size

Int

Yes

Specifies the virtual size of the image.

Attribute name of a customized image

String

No

Specifies the image attribute. You can specify multiple attribute key pairs, for example, 'a'='b'.

'c'='d'

Request Example

PATCH /V2/IMAGES/4CA46BF1-5C61-48FF-B4F3-0AD4E5E3BA90
"Content-Type:application/openstack-images-v2.0-json-patch"
[
    {
        "replace": "/name",
        "value": "test01"
    },
    {
        "add": "/usage",
        "value": "test"
    },
    {
        "remove": "/image_test"
    }
]

PATCH /V2/IMAGES/4CA46BF1-5C61-48FF-B4F3-0AD4E5E3BA90
"Content-Type:application/openstack-images-v2.1-json-patch"
[
    {
        "op": "replace",
        "path": "/tags",
        "value": ["cirros"]
    },
    {
        "op": "add",
        "path": "/properties",
        "value": "test"
    },
    {
        "op": "remove",
        "path": "/usage"
    }
]

Response Example

{
    "status": "queued",
    "properties": "test",
    "name": "test01",
    "tags": [
        "cirros"
    ],
    "container_format": "bare","created_at": "2014-12-16T01:22:05Z",
    "size": null,
    "disk_format": "raw",
    "updated_at": "2014-12-16T22:21:15Z",
    "visibility": "private",
    "id": "4ca46bf1-5c61-48ff-b4f3-0ad4e5e3ba90",
    "self": "/v2/images/4ca46bf1-5c61-48ff-b4f3-0ad4e5e3ba90",
    "min_disk": 1,
    "protected": false,"file": "/v2/images/4ca46bf1-5c61-48ff-b4f3-0ad4e5e3ba90/file",
    "checksum": null,
    "owner": "aed2c611711548a4a9c16fb8fe166af4",
    "min_ram": 1024,
    "schema": "/v2/schemas/image",
    "virtual_size": null
}    

Error Code

N/A