Chuyển tới nội dung chính

Cập nhật image

PATCH/v2/images/{image_id}

Thay đổi tên image, phân phối OS, dung lượng disk tối thiểu, placement và trạng thái shared của image theo ID được chỉ định.

Request​

Content-Typestringbắt buộc

Media type của request body. Dùng application/openstack-images-v2.1-json-patch.

Tham số path​

image_idstringbắt buộc

UUID của image.

Request mẫu​

Dùng curl​

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": "alpine-api"
},
{
"op": "add",
"path": "/os_distro",
"value": "genericlinux"
},
{
"op": "replace",
"path": "/min_disk",
"value": 5
}
]'
https://api.vietnix.cloud:9292/v2/images/c92d820c-50dc-4fd1-a0bc-2f1071487b67

HTTP request​

PATCH https://api.vietnix.cloud:9292/v2/images/{image_id}
Content-Type: application/openstack-images-v2.1-json-patch
X-Auth-Token: <token>

[ JSON Patch body ]

Ghi chú: các giá trị os_distro​

Tham số os_distro có thể nhận một trong các giá trị sau.

Các bản phân phối Linux:

  • genericlinux — Linux chung
  • centos8, centos7, centos6
  • rhel9, rhel8, rhel7
  • ubuntu22.04, ubuntu20.04, ubuntu18.04, ubuntu16.04
  • debian10, debian9
  • rockylinux9, rockylinux8
  • almalinux9, almalinux8

Response​

Tham số​

checksumstringbắt buộc

Hash dùng cho dữ liệu image. Có thể là null.

container_formatenumbắt buộc

Định dạng container của image (ví dụ bare, ami, ovf). Có thể là null.

created_atstringbắt buộc

Ngày giờ tạo tài nguyên (ISO 8601).

disk_formatenumbắt buộc

Định dạng disk (ví dụ qcow2, raw, vmdk). Có thể là null.

filestringbắt buộc

URL của file image máy ảo (đường dẫn tương đối).

idstringbắt buộc

UUID của image.

min_diskintegerbắt buộc

Dung lượng disk tối thiểu (GB) cần để boot image. Có thể là null.

min_ramintegerbắt buộc

Dung lượng RAM tối thiểu (MB) cần để boot image. Có thể là null.

namestringbắt buộc

Tên image. Có thể là null.

os_hash_algostringbắt buộc

Thuật toán tính hash bảo mật cho image (mới trong 2.7). Có thể là null.

os_hash_valuestringbắt buộc

Hexdigest của hash bảo mật, tính bằng os_hash_algo (mới trong 2.7). Có thể là null.

os_hiddenbooleanbắt buộc

Nếu true, image bị ẩn khỏi danh sách image mặc định (mới trong 2.7).

ownerstringbắt buộc

ID của chủ sở hữu (project/tenant ID). Có thể là null.

protectedbooleanbắt buộc

Nếu true, image không thể bị xoá.

schemastringbắt buộc

URL của schema image.

selfstringbắt buộc

URL của image máy ảo.

sizeintegerbắt buộc

Kích thước dữ liệu image, tính bằng byte. Có thể là null.

statusstringbắt buộc

Trạng thái image (ví dụ active).

tagsarraybắt buộc

Danh sách tag của image, có thể rỗng.

updated_atstringbắt buộc

Ngày giờ cập nhật tài nguyên (ISO 8601) hoặc null.

virtual_sizeintegerbắt buộc

Kích thước ảo của image. Có thể là null.

visibilitystringbắt buộc

Mức hiển thị của image (ví dụ public, private, shared).

direct_urlstring

URL trực tiếp tới file image trong external store. Chỉ có khi show_image_direct_url được bật trên Image service.

locationsarray

Mảng object vị trí (mỗi object có url và metadata) khi show_multiple_locations được bật trên Image service.

Mã trạng thái​

Thành công​

MãMô tả
200 - OKRequest thành công.

Lỗi​

MãMô tả
400 - Bad RequestNội dung request không hợp lệ.
401 - UnauthorizedCần xác thực trước khi gửi request.
403 - ForbiddenPolicy không cho phép user hiện tại thực hiện thao tác này.
404 - Not FoundKhông tìm thấy tài nguyên.
409 - ConflictThao tác xung đột với một thao tác khác trên tài nguyên.
413 - Request Entity Too LargeRequest lớn hơn mức server có thể xử lý.
415 - Unsupported Media TypeMedia type của request không được server hỗ trợ.

Response mẫu​

Response body
{
"image_validated": "yes",
"os_distro": "genericlinux",
"name": "alpine-api",
"disk_format": "qcow2",
"container_format": "bare",
"visibility": "shared",
"size": 120061952,
"virtual_size": 127926272,
"status": "active",
"checksum": "7625f1f6a355d3a042a1f39b79ab3513",
"protected": false,
"min_ram": 0,
"min_disk": 5,
"owner": "f33507157a634f1cac71e06a70fb558e",
"os_hidden": false,
"os_hash_algo": "sha512",
"os_hash_value": "d0eec0ffc7c1c60dd1c3f42a653086825b3e4ddcf07f49475c31e35da53c5e3c0df7e962c6d570591c3d5e2f8587aef54e1b40a016d944bca3cbaedec8f7f213",
"id": "9775d86a-8bf8-4200-a4b5-d892e931e8f6",
"created_at": "2025-10-22T08:40:44Z",
"updated_at": "2025-10-22T10:18:38Z",
"direct_url": "file:///mnt/vstorage/vols/datastores/glance/9775d86a-8bf8-4200-a4b5-d892e931e8f6",
"tags": [],
"self": "/v2/images/9775d86a-8bf8-4200-a4b5-d892e931e8f6",
"file": "/v2/images/9775d86a-8bf8-4200-a4b5-d892e931e8f6/file",
"schema": "/v2/schemas/image"
}