硬盘相关接口
创建数据硬盘(CreateDataVolume)
创建硬盘
API请求
URLs
POST zstack/v1/volumes/dataHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "test-volume",
"description": "test-data-volume",
"diskOfferingUuid": "d88594833a393e119c6fc5a8aa2ad08f",
"diskSize": 0,
"primaryStorageUuid": "5fe18eef72483c9cbde984a3176fab78",
"resourceUuid": "52f6075e4d6839fc8a40f569fb7d991e"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X POST -d '{"params":{"name":"test-volume","description":"test-data-volume","diskOfferingUuid":"d88594833a393e119c6fc5a8aa2ad08f","diskSize":0,"primaryStorageUuid":"5fe18eef72483c9cbde984a3176fab78","resourceUuid":"52f6075e4d6839fc8a40f569fb7d991e"}}' http://localhost:8080/zstack/v1/volumes/data参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
硬盘名称 | 0.6 | |
| description (可选) | String | body(包含在params结构中) |
硬盘的描述 | 0.6 | |
| diskOfferingUuid (可选) | String | body(包含在params结构中) |
硬盘规格UUID | 0.6 | |
| primaryStorageUuid (可选) | String | body(包含在params结构中) |
数据存储UUID | 0.6 | |
| encrypted (可选) | Boolean | body(包含在params结构中) |
是否创建加密硬盘 | 5.1.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源的Uuid | 0.6 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 3.4 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 | |
| diskSize (可选) | long | body(包含在params结构中) |
3.4.0 |
API返回
返回示例
{
"inventory": {
"uuid": "35f063bd547030299a4547127a7b676c",
"name": "test-volume",
"primaryStorageUuid": "52ddf3a573b23b52812d3f77840d0d83",
"vmInstanceUuid": "71be0e4c7bd03cda819b12f2b11b7996",
"diskOfferingUuid": "78d0cde715c5332cabe53e1c934795da",
"rootImageUuid": "5029547b43e8348aa2efde1ce7d0707d",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-35f063bd547030299a4547127a7b676c/35f063bd547030299a4547127a7b676c.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | VolumeInventory | 详情参考inventory | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| primaryStorageUuid | String | 数据存储UUID | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| diskOfferingUuid | String | 硬盘规格UUID | 3.17.13 |
| rootImageUuid | String | 3.17.13 | |
| installPath | String | 3.17.13 | |
| type | String | 3.17.13 | |
| format | String | 3.17.13 | |
| size | Long | 3.17.13 | |
| actualSize | Long | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| state | String | 3.17.13 | |
| status | String | 3.17.13 | |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| isShareable | Boolean | 3.17.13 | |
| volumeQos | String | 3.17.13 | |
| lastDetachDate | Timestamp | 3.17.13 | |
| lastVmInstanceUuid | String | 3.17.13 | |
| encrypted | Boolean | 5.1.0 |
SDK示例
Java SDK
CreateDataVolumeAction action = new CreateDataVolumeAction();
action.name = "test-volume";
action.description = "test-data-volume";
action.diskOfferingUuid = "d88594833a393e119c6fc5a8aa2ad08f";
action.diskSize = 0;
action.primaryStorageUuid = "5fe18eef72483c9cbde984a3176fab78";
action.resourceUuid = "52f6075e4d6839fc8a40f569fb7d991e";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateDataVolumeAction.Result res = action.call();Python SDK
action = CreateDataVolumeAction()
action.name = "test-volume"
action.description = "test-data-volume"
action.diskOfferingUuid = "d88594833a393e119c6fc5a8aa2ad08f"
action.diskSize = 0
action.primaryStorageUuid = "5fe18eef72483c9cbde984a3176fab78"
action.resourceUuid = "52f6075e4d6839fc8a40f569fb7d991e"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()从镜像创建硬盘(CreateDataVolumeFromVolumeTemplate)
从镜像创建硬盘
API请求
URLs
POST zstack/v1/volumes/data/from/data-volume-templates/{imageUuid}Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "data-volume-1",
"description": "dataVolume-from-volume-template",
"primaryStorageUuid": "849de664b4db321f8eeef65a1aa757c7",
"hostUuid": "0de619ae30373e97acc7bb4b42ca87a1"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X POST -d '{"params":{"name":"data-volume-1","description":"dataVolume-from-volume-template","primaryStorageUuid":"849de664b4db321f8eeef65a1aa757c7","hostUuid":"0de619ae30373e97acc7bb4b42ca87a1"}}' http://localhost:8080/zstack/v1/volumes/data/from/data-volume-templates/285f4a49e7403d2dad9545b42c33b837参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| imageUuid | String | url | 镜像UUID | 0.6 | |
| name | String | body(包含在params结构中) |
硬盘名称 | 0.6 | |
| description (可选) | String | body(包含在params结构中) |
硬盘的详细描述 | 0.6 | |
| primaryStorageUuid | String | body(包含在params结构中) |
数据存储UUID | 0.6 | |
| hostUuid (可选) | String | body(包含在params结构中) |
主机UUID | 0.6 | |
| encrypted (可选) | Boolean | body(包含在params结构中) |
是否创建加密硬盘 | 5.1.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
0.6 | ||
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 3.4.0 |
API返回
返回示例
{
"inventory": {
"uuid": "c6c15e12c30a3188bc7873da94372eff",
"name": "test-volume",
"primaryStorageUuid": "7914e620b7f7392eb9fa0a4d23a4736e",
"vmInstanceUuid": "a2b18465275139b8b97958bd358e7c6d",
"diskOfferingUuid": "2bbe96e1a633351ba7b201bd6ccd8184",
"rootImageUuid": "1360f952d152344088f85f7005985832",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-c6c15e12c30a3188bc7873da94372eff/c6c15e12c30a3188bc7873da94372eff.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | VolumeInventory | 详情参考inventory | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| primaryStorageUuid | String | 数据存储UUID | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| diskOfferingUuid | String | 硬盘规格UUID | 3.17.13 |
| rootImageUuid | String | 3.17.13 | |
| installPath | String | 3.17.13 | |
| type | String | 3.17.13 | |
| format | String | 3.17.13 | |
| size | Long | 3.17.13 | |
| actualSize | Long | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| state | String | 3.17.13 | |
| status | String | 3.17.13 | |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| isShareable | Boolean | 3.17.13 | |
| volumeQos | String | 3.17.13 | |
| lastDetachDate | Timestamp | 3.17.13 | |
| lastVmInstanceUuid | String | 3.17.13 | |
| encrypted | Boolean | 5.1.0 |
SDK示例
Java SDK
CreateDataVolumeFromVolumeTemplateAction action = new CreateDataVolumeFromVolumeTemplateAction();
action.imageUuid = "285f4a49e7403d2dad9545b42c33b837";
action.name = "data-volume-1";
action.description = "dataVolume-from-volume-template";
action.primaryStorageUuid = "849de664b4db321f8eeef65a1aa757c7";
action.hostUuid = "0de619ae30373e97acc7bb4b42ca87a1";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateDataVolumeFromVolumeTemplateAction.Result res = action.call();Python SDK
action = CreateDataVolumeFromVolumeTemplateAction()
action.imageUuid = "285f4a49e7403d2dad9545b42c33b837"
action.name = "data-volume-1"
action.description = "dataVolume-from-volume-template"
action.primaryStorageUuid = "849de664b4db321f8eeef65a1aa757c7"
action.hostUuid = "0de619ae30373e97acc7bb4b42ca87a1"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()从硬盘快照创建数据硬盘(CreateDataVolumeFromVolumeSnapshot)
从快照创建一个硬盘
API请求
URLs
POST zstack/v1/volumes/data/from/volume-snapshots/{volumeSnapshotUuid}Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "DataVolume-1",
"description": "dataVolume-from-snapshot",
"primaryStorageUuid": "b2237f228a343d0cb8b20b5b64663314"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X POST -d '{"params":{"name":"DataVolume-1","description":"dataVolume-from-snapshot","primaryStorageUuid":"b2237f228a343d0cb8b20b5b64663314"}}' http://localhost:8080/zstack/v1/volumes/data/from/volume-snapshots/192da9c7d6493a5d9a35d2df2dcc82b0参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
硬盘名称 | 0.6 | |
| description (可选) | String | body(包含在params结构中) |
硬盘的详细描述 | 0.6 | |
| volumeSnapshotUuid | String | url | 硬盘快照UUID | 0.6 | |
| primaryStorageUuid (可选) | String | body(包含在params结构中) |
数据存储UUID | 0.6 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源的Uuid | 0.6 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 3.4.0 |
API返回
返回示例
{
"inventory": {
"uuid": "b4a0e804aa593dc4acb6e88b4924d2a7",
"name": "test-volume",
"primaryStorageUuid": "f3bf7c425e7e39d28425b180e162518f",
"vmInstanceUuid": "b5d31d42533a3a67964b7a09a8a3d0a3",
"diskOfferingUuid": "200eb910246b32dd854fd76de1a60de8",
"rootImageUuid": "b09688d2265e381a9362a02d0fab5f61",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-b4a0e804aa593dc4acb6e88b4924d2a7/b4a0e804aa593dc4acb6e88b4924d2a7.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | VolumeInventory | 详情参考inventory | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| primaryStorageUuid | String | 数据存储UUID | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| diskOfferingUuid | String | 硬盘规格UUID | 3.17.13 |
| rootImageUuid | String | 3.17.13 | |
| installPath | String | 3.17.13 | |
| type | String | 3.17.13 | |
| format | String | 3.17.13 | |
| size | Long | 3.17.13 | |
| actualSize | Long | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| state | String | 3.17.13 | |
| status | String | 3.17.13 | |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| isShareable | Boolean | 3.17.13 | |
| volumeQos | String | 3.17.13 | |
| lastDetachDate | Timestamp | 3.17.13 | |
| lastVmInstanceUuid | String | 3.17.13 | |
| encrypted | Boolean | 5.1.0 |
SDK示例
Java SDK
CreateDataVolumeFromVolumeSnapshotAction action = new CreateDataVolumeFromVolumeSnapshotAction();
action.name = "DataVolume-1";
action.description = "dataVolume-from-snapshot";
action.volumeSnapshotUuid = "192da9c7d6493a5d9a35d2df2dcc82b0";
action.primaryStorageUuid = "b2237f228a343d0cb8b20b5b64663314";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateDataVolumeFromVolumeSnapshotAction.Result res = action.call();Python SDK
action = CreateDataVolumeFromVolumeSnapshotAction()
action.name = "DataVolume-1"
action.description = "dataVolume-from-snapshot"
action.volumeSnapshotUuid = "192da9c7d6493a5d9a35d2df2dcc82b0"
action.primaryStorageUuid = "b2237f228a343d0cb8b20b5b64663314"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()加载数据硬盘到虚拟机(AttachDataVolumeToVm)
挂载硬盘到虚拟机上
API请求
URLs
POST zstack/v1/volumes/{volumeUuid}/vm-instances/{vmInstanceUuid}Headers
Authorization: OAuth the-session-uuidBody
{
"params": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X POST -d '{"params":{}}' http://localhost:8080/zstack/v1/volumes/6fdcff5868fe376a98359eba8b3d0efe/vm-instances/f6abc3b26ffe337ba61dd7298fb0b9df参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| vmInstanceUuid | String | url | 虚拟机UUID | 0.6 | |
| volumeUuid | String | url | 硬盘UUID | 0.6 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
API返回
返回示例
{
"inventory": {
"uuid": "8476e080a92e3c6f84627c6a86bfae08",
"name": "test-volume",
"primaryStorageUuid": "1c25ebdcdb6a3b7e8f891f9f9ba8e740",
"vmInstanceUuid": "8de5cd9e5a2139f8b0ee5b6ca697f630",
"diskOfferingUuid": "ebd55ac451fc364483efded09c72d348",
"rootImageUuid": "ae2ecb59af10319494b77e142bf009b3",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-8476e080a92e3c6f84627c6a86bfae08/8476e080a92e3c6f84627c6a86bfae08.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | VolumeInventory | 详情参考inventory | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| primaryStorageUuid | String | 数据存储UUID | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| diskOfferingUuid | String | 硬盘规格UUID | 3.17.13 |
| rootImageUuid | String | 3.17.13 | |
| installPath | String | 3.17.13 | |
| type | String | 3.17.13 | |
| format | String | 3.17.13 | |
| size | Long | 3.17.13 | |
| actualSize | Long | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| state | String | 3.17.13 | |
| status | String | 3.17.13 | |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| isShareable | Boolean | 3.17.13 | |
| volumeQos | String | 3.17.13 | |
| lastDetachDate | Timestamp | 3.17.13 | |
| lastVmInstanceUuid | String | 3.17.13 | |
| encrypted | Boolean | 5.1.0 |
SDK示例
Java SDK
AttachDataVolumeToVmAction action = new AttachDataVolumeToVmAction();
action.vmInstanceUuid = "f6abc3b26ffe337ba61dd7298fb0b9df";
action.volumeUuid = "6fdcff5868fe376a98359eba8b3d0efe";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AttachDataVolumeToVmAction.Result res = action.call();Python SDK
action = AttachDataVolumeToVmAction()
action.vmInstanceUuid = "f6abc3b26ffe337ba61dd7298fb0b9df"
action.volumeUuid = "6fdcff5868fe376a98359eba8b3d0efe"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()从虚拟机卸载数据硬盘(DetachDataVolumeFromVm)
从虚拟机上卸载硬盘
API请求
URLs
DELETE zstack/v1/volumes/{uuid}/vm-instancesHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X DELETE http://localhost:8080/zstack/v1/volumes/f86fef130e1632a0873f6d3db1ca2b91/vm-instances?vmUuid=88d866d0c5ec303cb55cf4d4077f1987参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 硬盘的UUID,唯一标示该资源 | 0.6 | |
| vmUuid (可选) | String | query | 虚拟机的UUID | 0.6 | |
| systemTags (可选) | List | query | 0.6 | ||
| userTags (可选) | List | query | 用户标签 | 0.6 |
API返回
返回示例
{
"inventory": {
"uuid": "13c852f93e893c0ebaee534f765d8020",
"name": "test-volume",
"primaryStorageUuid": "4ecbb189079030f7bd0c4540a12131e0",
"vmInstanceUuid": "852244e0057032f9a4e4773062117ff5",
"diskOfferingUuid": "c91ad931a7893e3088e45d5343a394ef",
"rootImageUuid": "f8d3536a850e3f8b939dc8381c6a1692",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-13c852f93e893c0ebaee534f765d8020/13c852f93e893c0ebaee534f765d8020.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | VolumeInventory | 详情参考inventory | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| primaryStorageUuid | String | 数据存储UUID | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| diskOfferingUuid | String | 硬盘规格UUID | 3.17.13 |
| rootImageUuid | String | 3.17.13 | |
| installPath | String | 3.17.13 | |
| type | String | 3.17.13 | |
| format | String | 3.17.13 | |
| size | Long | 3.17.13 | |
| actualSize | Long | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| state | String | 3.17.13 | |
| status | String | 3.17.13 | |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| isShareable | Boolean | 3.17.13 | |
| volumeQos | String | 3.17.13 | |
| lastDetachDate | Timestamp | 3.17.13 | |
| lastVmInstanceUuid | String | 3.17.13 | |
| encrypted | Boolean | 5.1.0 |
SDK示例
Java SDK
DetachDataVolumeFromVmAction action = new DetachDataVolumeFromVmAction();
action.uuid = "f86fef130e1632a0873f6d3db1ca2b91";
action.vmUuid = "88d866d0c5ec303cb55cf4d4077f1987";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DetachDataVolumeFromVmAction.Result res = action.call();Python SDK
action = DetachDataVolumeFromVmAction()
action.uuid = "f86fef130e1632a0873f6d3db1ca2b91"
action.vmUuid = "88d866d0c5ec303cb55cf4d4077f1987"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()更改硬盘状态(ChangeVolumeState)
开启或关闭硬盘
API请求
URLs
PUT zstack/v1/volumes/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"changeVolumeState": {
"stateEvent": "enable"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"changeVolumeState":{"stateEvent":"enable"}}' http://localhost:8080/zstack/v1/volumes/97fa26ec14d9328c9cfada75e3c0307b/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 硬盘资源Uuid | 0.6 | |
| stateEvent | String | body(包含在changeVolumeState结构中) |
开启或关闭 |
|
0.6 |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
API返回
返回示例
{
"inventory": {
"uuid": "2abdbbf661253f9e9438f5af185b0ad0",
"name": "test-volume",
"primaryStorageUuid": "e7a19eb3078b3de289cd2a5aa9cfbdfc",
"vmInstanceUuid": "2df5db71b12b3d7b9df3b3c900db964f",
"diskOfferingUuid": "894513d30e093ca18e61e9d6c864552c",
"rootImageUuid": "98046b09102e302eaa7345c233065cd1",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-2abdbbf661253f9e9438f5af185b0ad0/2abdbbf661253f9e9438f5af185b0ad0.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | VolumeInventory | 详情参考inventory | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| primaryStorageUuid | String | 数据存储UUID | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| diskOfferingUuid | String | 硬盘规格UUID | 3.17.13 |
| rootImageUuid | String | 3.17.13 | |
| installPath | String | 3.17.13 | |
| type | String | 3.17.13 | |
| format | String | 3.17.13 | |
| size | Long | 3.17.13 | |
| actualSize | Long | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| state | String | 3.17.13 | |
| status | String | 3.17.13 | |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| isShareable | Boolean | 3.17.13 | |
| volumeQos | String | 3.17.13 | |
| lastDetachDate | Timestamp | 3.17.13 | |
| lastVmInstanceUuid | String | 3.17.13 | |
| encrypted | Boolean | 5.1.0 |
SDK示例
Java SDK
ChangeVolumeStateAction action = new ChangeVolumeStateAction();
action.uuid = "97fa26ec14d9328c9cfada75e3c0307b";
action.stateEvent = "enable";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeVolumeStateAction.Result res = action.call();Python SDK
action = ChangeVolumeStateAction()
action.uuid = "97fa26ec14d9328c9cfada75e3c0307b"
action.stateEvent = "enable"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()修改硬盘属性(UpdateVolume)
修改硬盘属性
API请求
URLs
PUT zstack/v1/volumes/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateVolume": {
"name": "volume-1",
"description": "data-volume"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"updateVolume":{"name":"volume-1","description":"data-volume"}}' http://localhost:8080/zstack/v1/volumes/f1eddfdb19ad3a0881b0be863901ff09/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 硬盘的UUID,唯一标示该资源 | 0.6 | |
| name (可选) | String | body(包含在updateVolume结构中) |
硬盘名称 | 0.6 | |
| description (可选) | String | body(包含在updateVolume结构中) |
硬盘的详细描述 | 0.6 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
API返回
返回示例
{
"inventory": {
"uuid": "9ad8111dec96322d813cc2783408392f",
"name": "test-volume",
"primaryStorageUuid": "a5825e8187f03a318572c11b2b9b046d",
"vmInstanceUuid": "4f35f03f5be0317bb9c682fcafedec9e",
"diskOfferingUuid": "b0b42031ee1833778744ef67283338e9",
"rootImageUuid": "6bfe2461fb333ca8b0d76385652343af",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-9ad8111dec96322d813cc2783408392f/9ad8111dec96322d813cc2783408392f.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | VolumeInventory | 详情参考inventory | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| primaryStorageUuid | String | 数据存储UUID | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| diskOfferingUuid | String | 硬盘规格UUID | 3.17.13 |
| rootImageUuid | String | 3.17.13 | |
| installPath | String | 3.17.13 | |
| type | String | 3.17.13 | |
| format | String | 3.17.13 | |
| size | Long | 3.17.13 | |
| actualSize | Long | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| state | String | 3.17.13 | |
| status | String | 3.17.13 | |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| isShareable | Boolean | 3.17.13 | |
| volumeQos | String | 3.17.13 | |
| lastDetachDate | Timestamp | 3.17.13 | |
| lastVmInstanceUuid | String | 3.17.13 | |
| encrypted | Boolean | 5.1.0 |
SDK示例
Java SDK
UpdateVolumeAction action = new UpdateVolumeAction();
action.uuid = "f1eddfdb19ad3a0881b0be863901ff09";
action.name = "volume-1";
action.description = "data-volume";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateVolumeAction.Result res = action.call();Python SDK
action = UpdateVolumeAction()
action.uuid = "f1eddfdb19ad3a0881b0be863901ff09"
action.name = "volume-1"
action.description = "data-volume"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()获取硬盘清单(QueryVolume)
获取硬盘清单
API请求
URLs
GET zstack/v1/volumes
GET zstack/v1/volumes/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X GET http://localhost:8080/zstack/v1/volumes?curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X GET http://localhost:8080/zstack/v1/volumes/734f1106137b37e3b5876e9b836e9774可查询字段
运行CLI命令行工具,输入QueryVolume并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "a66cd4f1ac2b3fa0855b8b5e91798178",
"name": "test-volume",
"primaryStorageUuid": "9ef9f24c513e367285a7119c42561a53",
"vmInstanceUuid": "b2b98398b49e3fbfa59d24c0b6a9a947",
"diskOfferingUuid": "c9ff1c6960323e3a930842b1aa4f4212",
"rootImageUuid": "c8b688328aa335d0bb5f11f6eb6dd6bc",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-a66cd4f1ac2b3fa0855b8b5e91798178/a66cd4f1ac2b3fa0855b8b5e91798178.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventories | List | 详情参考inventories | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| primaryStorageUuid | String | 数据存储UUID | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| diskOfferingUuid | String | 硬盘规格UUID | 3.17.13 |
| rootImageUuid | String | 3.17.13 | |
| installPath | String | 3.17.13 | |
| type | String | 3.17.13 | |
| format | String | 3.17.13 | |
| size | Long | 3.17.13 | |
| actualSize | Long | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| state | String | 3.17.13 | |
| status | String | 3.17.13 | |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| isShareable | Boolean | 3.17.13 | |
| volumeQos | String | 3.17.13 | |
| lastDetachDate | Timestamp | 3.17.13 | |
| lastVmInstanceUuid | String | 3.17.13 | |
| encrypted | Boolean | 5.1.0 |
SDK示例
Java SDK
QueryVolumeAction action = new QueryVolumeAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryVolumeAction.Result res = action.call();Python SDK
action = QueryVolumeAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()扩容数据硬盘(ResizeDataVolume)
扩展数据硬盘
API请求
URLs
PUT zstack/v1/volumes/data/resize/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"resizeDataVolume": {
"size": 10000000
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"resizeDataVolume":{"size":10000000}}' http://localhost:8080/zstack/v1/volumes/data/resize/6c2a13e8d7fa3ef99091bc6a445d4e9c/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 2.2 | |
| size | long | body(包含在resizeDataVolume结构中) |
扩展后大小 | 2.2 | |
| systemTags (可选) | List | body | 系统标签 | 2.2 | |
| userTags (可选) | List | body | 用户标签 | 2.2 |
API返回
返回示例
{
"inventory": {
"uuid": "f17a01d17e4d39bdb17d227a1df97e3a",
"name": "test-volume",
"primaryStorageUuid": "83245aa16d02322785f84450d1a05441",
"vmInstanceUuid": "14ca01538ffa3ab49aad3dd60c4c41b4",
"diskOfferingUuid": "9dd65df23d453f25855a2c2b2f9f778b",
"rootImageUuid": "825ca3ebcb053abf843ed8b2731ec4b9",
"installPath": "/zstack_ps/dataVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-f17a01d17e4d39bdb17d227a1df97e3a/f17a01d17e4d39bdb17d227a1df97e3a.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | VolumeInventory | 详情参考inventory | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| primaryStorageUuid | String | 数据存储UUID | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| diskOfferingUuid | String | 硬盘规格UUID | 3.17.13 |
| rootImageUuid | String | 3.17.13 | |
| installPath | String | 3.17.13 | |
| type | String | 3.17.13 | |
| format | String | 3.17.13 | |
| size | Long | 3.17.13 | |
| actualSize | Long | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| state | String | 3.17.13 | |
| status | String | 3.17.13 | |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| isShareable | Boolean | 3.17.13 | |
| volumeQos | String | 3.17.13 | |
| lastDetachDate | Timestamp | 3.17.13 | |
| lastVmInstanceUuid | String | 3.17.13 | |
| encrypted | Boolean | 5.1.0 |
SDK示例
Java SDK
ResizeDataVolumeAction action = new ResizeDataVolumeAction();
action.uuid = "6c2a13e8d7fa3ef99091bc6a445d4e9c";
action.size = 10000000;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ResizeDataVolumeAction.Result res = action.call();Python SDK
action = ResizeDataVolumeAction()
action.uuid = "6c2a13e8d7fa3ef99091bc6a445d4e9c"
action.size = 10000000
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()扩容根硬盘(ResizeRootVolume)
扩展根硬盘
API请求
URLs
PUT zstack/v1/volumes/resize/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"resizeRootVolume": {
"size": 10000000
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"resizeRootVolume":{"size":10000000}}' http://localhost:8080/zstack/v1/volumes/resize/16a052d270983392bd2824c06a44253f/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid (可选) | String | url | 资源的UUID,唯一标示该资源 | 0.6 | |
| size | long | body(包含在resizeRootVolume结构中) |
扩展后大小 | 0.6 | |
| systemTags (可选) | List | body | 0.6 | ||
| userTags (可选) | List | body | 0.6 | ||
| vmInstanceUuid (可选) | String | body(包含在resizeRootVolume结构中) |
虚拟机UUID | 0.6 |
API返回
返回示例
{
"inventory": {
"uuid": "fc005064ec293934bfb3f0263189de68",
"name": "test-volume",
"primaryStorageUuid": "f9c7c967f9fb38839b9f115283fdfbd2",
"vmInstanceUuid": "927c1d13b9e8382cb8f548571a416c21",
"diskOfferingUuid": "250ba8e5379930daab16bcd8bf44d04b",
"rootImageUuid": "ffcedb51196c370dac87dce89cd78e94",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-fc005064ec293934bfb3f0263189de68/fc005064ec293934bfb3f0263189de68.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | VolumeInventory | 详情参考inventory | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| primaryStorageUuid | String | 数据存储UUID | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| diskOfferingUuid | String | 硬盘规格UUID | 3.17.13 |
| rootImageUuid | String | 3.17.13 | |
| installPath | String | 3.17.13 | |
| type | String | 3.17.13 | |
| format | String | 3.17.13 | |
| size | Long | 3.17.13 | |
| actualSize | Long | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| state | String | 3.17.13 | |
| status | String | 3.17.13 | |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| isShareable | Boolean | 3.17.13 | |
| volumeQos | String | 3.17.13 | |
| lastDetachDate | Timestamp | 3.17.13 | |
| lastVmInstanceUuid | String | 3.17.13 | |
| encrypted | Boolean | 5.1.0 |
SDK示例
Java SDK
ResizeRootVolumeAction action = new ResizeRootVolumeAction();
action.uuid = "16a052d270983392bd2824c06a44253f";
action.size = 10000000;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ResizeRootVolumeAction.Result res = action.call();Python SDK
action = ResizeRootVolumeAction()
action.uuid = "16a052d270983392bd2824c06a44253f"
action.size = 10000000
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()设置硬盘QoS(SetVolumeQos)
设置硬盘限速
API请求
URLs
PUT zstack/v1/volumes/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"setVolumeQos": {
"totalBandwidth": 10000,
"totalIOPS": 1000
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"setVolumeQos":{"totalBandwidth":10000,"totalIOPS":1000}}' http://localhost:8080/zstack/v1/volumes/384f99ce0b7a307685856b23f75c5167/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 硬盘的UUID | 3.1.0 | |
| volumeBandwidth (可选) | Long | body(包含在setVolumeQos结构中) |
硬盘限速带宽 | 3.1.0 | |
| systemTags (可选) | List | body | 3.1.0 | ||
| userTags (可选) | List | body | 3.1.0 | ||
| mode (可选) | String | body(包含在setVolumeQos结构中) |
|
3.1.0 | |
| readBandwidth (可选) | Long | body(包含在setVolumeQos结构中) |
3.14.0 | ||
| writeBandwidth (可选) | Long | body(包含在setVolumeQos结构中) |
3.14.0 | ||
| totalBandwidth (可选) | Long | body(包含在setVolumeQos结构中) |
3.14.0 | ||
| readIOPS (可选) | Long | body(包含在setVolumeQos结构中) |
3.14.0 | ||
| writeIOPS (可选) | Long | body(包含在setVolumeQos结构中) |
3.14.0 | ||
| totalIOPS (可选) | Long | body(包含在setVolumeQos结构中) |
3.14.0 |
API返回
返回示例
{
"inventory": {
"uuid": "6e9ee53ebad936da8a8d5d2741108a75",
"name": "volume",
"primaryStorageUuid": "630a2901d3083328a04333ca9e1330c0",
"vmInstanceUuid": "042bfcd0830731d78f35598541b8de48",
"diskOfferingUuid": "31294bcbedf53971bd71c2f247e0f9fc",
"rootImageUuid": "0bc2f95ef0fb3785936d02ea58fd2e02",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/inventory-6e9ee53ebad936da8a8d5d2741108a75/6e9ee53ebad936da8a8d5d2741108a75.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM",
"volumeQos": "total\u003d20971520"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 3.1.0 | |
| inventory | VolumeInventory | 详情参考inventory | 3.1.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.1.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| primaryStorageUuid | String | 数据存储UUID | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| diskOfferingUuid | String | 硬盘规格UUID | 3.17.13 |
| rootImageUuid | String | 3.17.13 | |
| installPath | String | 3.17.13 | |
| type | String | 3.17.13 | |
| format | String | 3.17.13 | |
| size | Long | 3.17.13 | |
| actualSize | Long | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| state | String | 3.17.13 | |
| status | String | 3.17.13 | |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| isShareable | Boolean | 3.17.13 | |
| volumeQos | String | 3.17.13 | |
| lastDetachDate | Timestamp | 3.17.13 | |
| lastVmInstanceUuid | String | 3.17.13 | |
| encrypted | Boolean | 5.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java SDK
SetVolumeQosAction action = new SetVolumeQosAction();
action.uuid = "384f99ce0b7a307685856b23f75c5167";
action.totalBandwidth = 10000;
action.totalIOPS = 1000;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SetVolumeQosAction.Result res = action.call();Python SDK
action = SetVolumeQosAction()
action.uuid = "384f99ce0b7a307685856b23f75c5167"
action.totalBandwidth = 10000
action.totalIOPS = 1000
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()同步硬盘大小(SyncVolumeSize)
同步硬盘大小
API请求
URLs
PUT zstack/v1/volumes/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"syncVolumeSize": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"syncVolumeSize":{}}' http://localhost:8080/zstack/v1/volumes/017a6c821b3433c594285712cd7e69f4/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 硬盘的UUID,唯一标示该资源 | 0.6 | |
| systemTags (可选) | List | body | 0.6 | ||
| userTags (可选) | List | body | 用户标签 | 0.6 |
API返回
返回示例
{
"inventory": {
"uuid": "0de2e5ea43b539479b6e9add80b4a993",
"name": "test-volume",
"primaryStorageUuid": "61676be9b012303686d8565dce039e01",
"vmInstanceUuid": "e9603db499f6357d9de6c03af2017b3d",
"diskOfferingUuid": "6b5132d5bf01385e8888c3d98b2139c9",
"rootImageUuid": "5086350485c532218fa1e1c32b88827d",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-0de2e5ea43b539479b6e9add80b4a993/0de2e5ea43b539479b6e9add80b4a993.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | VolumeInventory | 详情参考inventory | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| primaryStorageUuid | String | 数据存储UUID | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| diskOfferingUuid | String | 硬盘规格UUID | 3.17.13 |
| rootImageUuid | String | 3.17.13 | |
| installPath | String | 3.17.13 | |
| type | String | 3.17.13 | |
| format | String | 3.17.13 | |
| size | Long | 3.17.13 | |
| actualSize | Long | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| state | String | 3.17.13 | |
| status | String | 3.17.13 | |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| isShareable | Boolean | 3.17.13 | |
| volumeQos | String | 3.17.13 | |
| lastDetachDate | Timestamp | 3.17.13 | |
| lastVmInstanceUuid | String | 3.17.13 | |
| encrypted | Boolean | 5.1.0 |
SDK示例
Java SDK
SyncVolumeSizeAction action = new SyncVolumeSizeAction();
action.uuid = "017a6c821b3433c594285712cd7e69f4";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SyncVolumeSizeAction.Result res = action.call();Python SDK
action = SyncVolumeSizeAction()
action.uuid = "017a6c821b3433c594285712cd7e69f4"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()恢复硬盘(RecoverDataVolume)
恢复硬盘
API请求
URLs
PUT zstack/v1/volumes/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"recoverDataVolume": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"recoverDataVolume":{}}' http://localhost:8080/zstack/v1/volumes/9f5090fc93ff33e283e0ff3c99fad1e2/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 硬盘的UUID,唯一标示该资源 | 0.6 | |
| systemTags (可选) | List | body | 0.6 | ||
| userTags (可选) | List | body | 用户标签 | 0.6 |
API返回
返回示例
{
"inventory": {
"uuid": "81408dab76543096930e9ac798f20c8a",
"name": "test-volume",
"primaryStorageUuid": "a513990b7a4036b78a1ef7b943ccfdbd",
"vmInstanceUuid": "9454b675de203c0a8a3148dd8b8e8ce0",
"diskOfferingUuid": "39b3b8963ec1304ba9b173995867b016",
"rootImageUuid": "515d16fefeb5322580f46521aade4551",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-81408dab76543096930e9ac798f20c8a/81408dab76543096930e9ac798f20c8a.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | VolumeInventory | 详情参考inventory | 0.6 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| primaryStorageUuid | String | 数据存储UUID | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| diskOfferingUuid | String | 硬盘规格UUID | 3.17.13 |
| rootImageUuid | String | 3.17.13 | |
| installPath | String | 3.17.13 | |
| type | String | 3.17.13 | |
| format | String | 3.17.13 | |
| size | Long | 3.17.13 | |
| actualSize | Long | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| state | String | 3.17.13 | |
| status | String | 3.17.13 | |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| isShareable | Boolean | 3.17.13 | |
| volumeQos | String | 3.17.13 | |
| lastDetachDate | Timestamp | 3.17.13 | |
| lastVmInstanceUuid | String | 3.17.13 | |
| encrypted | Boolean | 5.1.0 |
SDK示例
Java SDK
RecoverDataVolumeAction action = new RecoverDataVolumeAction();
action.uuid = "9f5090fc93ff33e283e0ff3c99fad1e2";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RecoverDataVolumeAction.Result res = action.call();Python SDK
action = RecoverDataVolumeAction()
action.uuid = "9f5090fc93ff33e283e0ff3c99fad1e2"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()扁平化硬盘(FlattenVolume)
扁平合并硬盘
API请求
URLs
PUT zstack/v1/volumes/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"flattenVolume": {
"dryRun": false
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"flattenVolume":{"dryRun":false}}' http://localhost:8080/zstack/v1/volumes/df7876b9124d3fcb92528cf774fa6de1/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.17.0 | |
| dryRun (可选) | boolean | body(包含在flattenVolume结构中) |
试运行,可用于预测数据用量 | 3.17.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.17.0 | |
| userTags (可选) | List | body | 用户标签 | 3.17.0 |
API返回
返回示例
{
"inventory": {
"uuid": "13ff90c5fcd43587915817a65cc87af3",
"name": "test-volume",
"primaryStorageUuid": "55db0399efaf35479125967b5bd6e8c7",
"vmInstanceUuid": "c3f9c1907206307a896db9a94a35c29d",
"diskOfferingUuid": "d4d9b3afe4993bfbba991b4414295a65",
"rootImageUuid": "7bcdd79e0ed1347f9a2d4ea043bb9f37",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-13ff90c5fcd43587915817a65cc87af3/13ff90c5fcd43587915817a65cc87af3.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 请求是否成功 | 3.17.0 |
| inventory | VolumeInventory | 详情参考inventory | 3.17.0 |
| error | ErrorCode | 详情参考error | 3.17.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| primaryStorageUuid | String | 数据存储UUID | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| diskOfferingUuid | String | 硬盘规格UUID | 3.17.13 |
| rootImageUuid | String | 3.17.13 | |
| installPath | String | 3.17.13 | |
| type | String | 3.17.13 | |
| format | String | 3.17.13 | |
| size | Long | 3.17.13 | |
| actualSize | Long | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| state | String | 3.17.13 | |
| status | String | 3.17.13 | |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| isShareable | Boolean | 3.17.13 | |
| volumeQos | String | 3.17.13 | |
| lastDetachDate | Timestamp | 3.17.13 | |
| lastVmInstanceUuid | String | 3.17.13 | |
| encrypted | Boolean | 5.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java SDK
FlattenVolumeAction action = new FlattenVolumeAction();
action.uuid = "df7876b9124d3fcb92528cf774fa6de1";
action.dryRun = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
FlattenVolumeAction.Result res = action.call();Python SDK
action = FlattenVolumeAction()
action.uuid = "df7876b9124d3fcb92528cf774fa6de1"
action.dryRun = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()转换硬盘加密属性(ChangeVolumeEncryption)
转换硬盘加密属性
API请求
URLs
PUT zstack/v1/volumes/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"changeVolumeEncryption": {
"encrypted": true
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"changeVolumeEncryption":{"encrypted":true}}' http://localhost:8080/zstack/v1/volumes/46afde2b3d9838c888ebfa821e5c3e43/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 5.1.0 | |
| encrypted | boolean | body(包含在changeVolumeEncryption结构中) |
5.1.0 | ||
| systemTags (可选) | List | body | 系统标签 | 5.1.0 | |
| userTags (可选) | List | body | 用户标签 | 5.1.0 |
API返回
返回示例
{
"inventory": {
"uuid": "ff0eb5a723e9316bb1053ed7e4bb3100",
"name": "test-volume",
"primaryStorageUuid": "ff0359abb8443d2f8077cc368afa7c00",
"vmInstanceUuid": "ff01ec80fd11327cba7519b66119d900",
"diskOfferingUuid": "ff08f99cf0213becb76cb9cbd4e7d900",
"rootImageUuid": "ff0d8d59fa8b3afeaae58282fe49fa00",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-ff0eb5a723e9316bb1053ed7e4bb3100/ff0eb5a723e9316bb1053ed7e4bb3100.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM",
"encrypted": true
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 5.1.0 | |
| inventory | VolumeInventory | 详情参考inventory | 5.1.0 |
| error | ErrorCode | 详情参考error | 5.1.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| primaryStorageUuid | String | 数据存储UUID | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| diskOfferingUuid | String | 硬盘规格UUID | 3.17.13 |
| rootImageUuid | String | 3.17.13 | |
| installPath | String | 3.17.13 | |
| type | String | 3.17.13 | |
| format | String | 3.17.13 | |
| size | Long | 3.17.13 | |
| actualSize | Long | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| state | String | 3.17.13 | |
| status | String | 3.17.13 | |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| isShareable | Boolean | 3.17.13 | |
| volumeQos | String | 3.17.13 | |
| lastDetachDate | Timestamp | 3.17.13 | |
| lastVmInstanceUuid | String | 3.17.13 | |
| encrypted | Boolean | 5.1.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
SDK示例
Java SDK
ChangeVolumeEncryptionAction action = new ChangeVolumeEncryptionAction();
action.uuid = "46afde2b3d9838c888ebfa821e5c3e43";
action.encrypted = true;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ChangeVolumeEncryptionAction.Result res = action.call();Python SDK
action = ChangeVolumeEncryptionAction()
action.uuid = "46afde2b3d9838c888ebfa821e5c3e43"
action.encrypted = true
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()