Tạo volume
/v3/{project_id}/volumesĐể tạo volume mới trong project, gửi request POST tới endpoint /v3/{project_id}/volumes của volume service. Request cần token xác thực, gửi kèm trong header.
Request
Tham số
project_idstringbắt buộcpathUUID của project trong cloud multi-tenant.
volumeobjectbắt buộcbodyObject chứa volume.
namestringbắt buộcbodyTuỳ chọn. Tên volume.
sizeintegerbắt buộcbodyDung lượng volume tính bằng GiB.
descriptionstringbắt buộcbodyTuỳ chọn. Mô tả volume.
multiattachbooleanbắt buộcbodyTuỳ chọn. Cho phép gắn vào nhiều server; mặc định false. Khả năng hỗ trợ phụ thuộc volume type.
source_volidstringbắt buộcbodyTuỳ chọn. UUID của volume nguồn; volume mới có cùng dung lượng trừ khi yêu cầu lớn hơn.
snapshot_idstringbắt buộcbodyTuỳ chọn. UUID của snapshot; volume được tạo cùng availability zone và dung lượng với snapshot.
backup_idstringbắt buộcbodyTuỳ chọn. UUID của backup. Mới trong phiên bản 3.47
imageRefstringbắt buộcbodyTuỳ chọn. UUID của image dùng để tạo volume; bắt buộc với volume bootable.
volume_typestringbắt buộcbodyTuỳ chọn. Volume type (tên hoặc ID). Cần thiết với cấu hình nhiều backend; scheduler chọn backend theo type.
metadataobjectbắt buộcbodyTuỳ chọn. Cặp key-value metadata gắn với volume.
consistencygroup_idstringbắt buộcbodyUUID của consistency group.
OS-SCH-HNTobjectbắt buộcbodyTuỳ chọn. Dictionary scheduler hints.
Request mẫu
Dùng curl
curl -ks -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' \
-d '{
"volume": {
"size": 1,
"description": "Volume 2",
"name": "vol2",
"volume_type": "nvmer3"
}
}' https://api.vietnix.cloud:8776/v3/f5d834d636c642c7bfe8af86139c6f26/volumes
HTTP request
POST https://api.vietnix.cloud:8776/v3/f5d834d636c642c7bfe8af86139c6f26/volumes
với body
{
"volume": {
"size": 1,
"description": "Volume 2",
"name": "vol2",
"volume_type": "nvmer3"
}
}
Response
Tham số
volumeobjectbắt buộcObject volume.
migration_statusstringTrạng thái migration của volume. Chỉ admin.
attachmentsarraybắt buộcThông tin gắn instance; gồm server_id, attachment_id, attached_at, host_name, volume_id, device, id. Rỗng nếu chưa gắn.
idstringbắt buộcUUID của volume.
linksarraybắt buộcLiên kết của volume.
namestringbắt buộcTên volume.
sizeintegerbắt buộcDung lượng tính bằng GiB.
bootablestringbắt buộcThuộc tính bootable; instance có thể boot từ volume này.
statusstringbắt buộcTrạng thái volume.
created_atstringbắt buộcThời điểm tạo theo ISO 8601 (CCYY-MM-DDThh:mm±hh).
availability_zonestringbắt buộcTên availability zone; có thể là default hoặc null.
descriptionstringbắt buộcMô tả volume.
multiattachbooleanbắt buộcNếu true, volume có thể gắn vào nhiều instance.
source_volidstringUUID của volume nguồn; volume mới có cùng dung lượng trừ khi yêu cầu lớn hơn.
volume_typestringbắt buộcTên volume type liên kết.
encryptedbooleanbắt buộcNếu true, volume được mã hoá.
updated_atstringbắt buộcThời điểm cập nhật gần nhất theo ISO 8601 hoặc null nếu chưa từng cập nhật.
replication_statusstringbắt buộcTrạng thái replication của volume.
snapshot_idstringUUID của snapshot; volume được tạo cùng AZ và dung lượng với snapshot.
user_idstringbắt buộcUUID của user.
metadataobjectbắt buộcCác cặp key-value metadata gắn với volume.
group_idstringID của group.
consistencygroup_idstringbắt buộcUUID của consistency group.
Mã trạng thái
Thành công
| Mã | Mô tả |
|---|---|
| 202 Accepted | Request đã được chấp nhận để xử lý nhưng chưa hoàn tất. Response có header Location kèm liên kết để kiểm tra tiến độ request. |
Response mẫu
Response body
{
"volume": {
"id": "e767560e-b1b0-4e74-b40f-486127fdb41f",
"status": "creating",
"size": 1,
"availability_zone": "nova",
"created_at": "2025-09-23T04:32:44.133966",
"updated_at": null,
"name": "vol2",
"description": "Volume 2",
"volume_type": "nvmer3",
"snapshot_id": null,
"source_volid": null,
"metadata": {},
"links": [
{
"rel": "self",
"href": "https://api.vietnix.cloud:8776/v3/f33507157a634f1cac71e06a70fb558e/volumes/e767560e-b1b0-4e74-b40f-486127fdb41f"
},
{
"rel": "bookmark",
"href": "https://api.vietnix.cloud:8776/f33507157a634f1cac71e06a70fb558e/volumes/e767560e-b1b0-4e74-b40f-486127fdb41f"
}
],
"user_id": "64166c7effeb4a89b59c073588099640",
"bootable": "false",
"encrypted": false,
"replication_status": null,
"consistencygroup_id": null,
"multiattach": false,
"attachments": []
}
}