Cập nhật image
/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
Header
Content-Typestringbắt buộcMedia type của request body. Dùng application/openstack-images-v2.1-json-patch.
Tham số path
image_idstringbắt buộcUUID 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 chungcentos8,centos7,centos6rhel9,rhel8,rhel7ubuntu22.04,ubuntu20.04,ubuntu18.04,ubuntu16.04debian10,debian9rockylinux9,rockylinux8almalinux9,almalinux8
Response
Tham số
checksumstringbắt buộcHash 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ộcNgà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ộcURL của file image máy ảo (đường dẫn tương đối).
idstringbắt buộcUUID của image.
min_diskintegerbắt buộcDung lượng disk tối thiểu (GB) cần để boot image. Có thể là null.
min_ramintegerbắt buộcDung lượng RAM tối thiểu (MB) cần để boot image. Có thể là null.
namestringbắt buộcTên image. Có thể là null.
os_hash_algostringbắt buộcThuậ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ộcHexdigest 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ộcNếu true, image bị ẩn khỏi danh sách image mặc định (mới trong 2.7).
ownerstringbắt buộcID của chủ sở hữu (project/tenant ID). Có thể là null.
protectedbooleanbắt buộcNếu true, image không thể bị xoá.
schemastringbắt buộcURL của schema image.
selfstringbắt buộcURL của image máy ảo.
sizeintegerbắt buộcKích thước dữ liệu image, tính bằng byte. Có thể là null.
statusstringbắt buộcTrạng thái image (ví dụ active).
tagsarraybắt buộcDanh sách tag của image, có thể rỗng.
updated_atstringbắt buộcNgày giờ cập nhật tài nguyên (ISO 8601) hoặc null.
virtual_sizeintegerbắt buộcKích thước ảo của image. Có thể là null.
visibilitystringbắt buộcMức hiển thị của image (ví dụ public, private, shared).
direct_urlstringURL 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.
locationsarrayMả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 - OK | Request thành công. |
Lỗi
| Mã | Mô tả |
|---|---|
| 400 - Bad Request | Nội dung request không hợp lệ. |
| 401 - Unauthorized | Cần xác thực trước khi gửi request. |
| 403 - Forbidden | Policy không cho phép user hiện tại thực hiện thao tác này. |
| 404 - Not Found | Không tìm thấy tài nguyên. |
| 409 - Conflict | Thao tác xung đột với một thao tác khác trên tài nguyên. |
| 413 - Request Entity Too Large | Request lớn hơn mức server có thể xử lý. |
| 415 - Unsupported Media Type | Media 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"
}