备份管理相关接口
创建虚拟机备份(CreateVmBackup)
创建虚拟机备份
API请求
URLs
POST zstack/v1/volumes/{rootVolumeUuid}/vm-backupsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"backupStorageUuid": "fc50c1ece4753c1981e3e3f65a151e0e",
"name": "backup-1",
"description": "a critical volume backup"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X POST -d '{"params":{"backupStorageUuid":"fc50c1ece4753c1981e3e3f65a151e0e","name":"backup-1","description":"a critical volume backup"}}' http://localhost:8080/zstack/v1/volumes/aa6fad9b71af3785a9fdec200bab3ee8/vm-backups参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| rootVolumeUuid | String | url | 根硬盘UUID | 3.0.0 | |
| backupStorageUuid | String | body(包含在params结构中) |
镜像存储UUID | 3.0.0 | |
| name | String | body(包含在params结构中) |
资源名称 | 3.0.0 | |
| description (可选) | String | body(包含在params结构中) |
资源的详细描述 | 3.0.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
3.0.0 | ||
| systemTags (可选) | List | body | 3.0.0 | ||
| userTags (可选) | List | body | 3.0.0 | ||
| volumeReadBandwidth (可选) | Long | body(包含在params结构中) |
0.6 | ||
| volumeWriteBandwidth (可选) | Long | body(包含在params结构中) |
0.6 | ||
| networkReadBandwidth (可选) | Long | body(包含在params结构中) |
0.6 | ||
| networkWriteBandwidth (可选) | Long | body(包含在params结构中) |
0.6 | ||
| mode (可选) | String | body(包含在params结构中) |
|
0.6 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 3.4.0 |
API返回
返回示例
{
"inventories": [
{
"uuid": "785edb93bb1b3a31857dac1e69cc8392",
"volumeUuid": "2ae6b881bb1239cd907d48993e86a2e8",
"name": "Root-Volume-Backup-1",
"description": "volume backup",
"size": 1073741824,
"groupUuid": "2f7c0a5bb86430e8a5ac48312172d70d",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
},
{
"uuid": "3084eea905f4311b9d484bfe97142bdf",
"volumeUuid": "f6c7d5276c873eba8accddd4a09a1ee6",
"name": "Data-Volume-Backup-1",
"description": "volume backup",
"size": 2147483648,
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
],
"actualExecuteTime": 60
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.0.0 |
| inventories | List | 详情参考inventories | 3.0.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 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 卷备份的UUID,唯一标示该资源 | 2.6 |
| volumeUuid | String | 硬盘UUID | 2.6 |
| name | String | 备份名称 | 2.6 |
| description | String | 备份的详细描述 | 2.6 |
| type | String | 卷的类型 | 2.6 |
| state | String | 卷备份的启用状态 | 2.6 |
| status | String | 卷备份的状态 | 2.6 |
| size | Long | 当前卷备份的大小 | 2.6 |
| metadata | String | 卷备份相关元数据 | 2.6 |
| createDate | Timestamp | 创建时间 | 2.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 2.6 |
| encrypted | Boolean | 备份数据是否加密 | 5.1 |
| keyLastOpDate | Timestamp | 加密备份密钥最后更新时间,非加密备份为空 | 5.1 |
| backupStorageRefs | List | 详情参考backupStorageRefs | 2.6 |
#backupStorageRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| volumeBackupUuid | String | 卷备份的uuid | 2.6 |
| backupStorageUuid | String | 镜像存储UUID | 2.6 |
| installPath | String | 卷备份的数据路径 | 2.6 |
| status | String | 卷备份在镜像存储的状态 | 2.6 |
| createDate | Timestamp | 创建时间 | 2.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 2.6 |
SDK示例
Java SDK
CreateVmBackupAction action = new CreateVmBackupAction();
action.rootVolumeUuid = "aa6fad9b71af3785a9fdec200bab3ee8";
action.backupStorageUuid = "fc50c1ece4753c1981e3e3f65a151e0e";
action.name = "backup-1";
action.description = "a critical volume backup";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVmBackupAction.Result res = action.call();Python SDK
action = CreateVmBackupAction()
action.rootVolumeUuid = "aa6fad9b71af3785a9fdec200bab3ee8"
action.backupStorageUuid = "fc50c1ece4753c1981e3e3f65a151e0e"
action.name = "backup-1"
action.description = "a critical volume backup"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()删除虚拟机备份(DeleteVmBackup)
API请求
URLs
DELETE zstack/v1/vm-backups/{groupUuid}?backupStorageUuids={backupStorageUuids}&deleteMode={deleteMode}Headers
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/vm-backups/92046c016d7c3af7bdd4a5077fb91450?backupStorageUuids=255fc896605f3237a22940fa92d8670b&deleteMode=Permissive参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| groupUuid | String | url | 备份组uuid | 3.0.0 | |
| backupStorageUuids (可选) | List | url | 镜像存储uuid列表 | 3.0.0 | |
| deleteMode (可选) | String | url | 3.0.0 | ||
| systemTags (可选) | List | body | 3.0.0 | ||
| userTags (可选) | List | body | 3.0.0 |
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
DeleteVmBackupAction action = new DeleteVmBackupAction();
action.groupUuid = "92046c016d7c3af7bdd4a5077fb91450";
action.backupStorageUuids = asList("255fc896605f3237a22940fa92d8670b");
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteVmBackupAction.Result res = action.call();Python
SDK
DeleteVmBackupAction action = DeleteVmBackupAction()
action.groupUuid = "92046c016d7c3af7bdd4a5077fb91450"
action.backupStorageUuids = [255fc896605f3237a22940fa92d8670b]
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteVmBackupAction.Result res = action.call()扫描虚拟机备份(SyncVmBackup)
API请求
URLs
PUT zstack/v1/vm-backups/imageStore/{imageStoreUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"syncVmBackup": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"syncVmBackup":{}}' http://localhost:8080/zstack/v1/vm-backups/imageStore/087b41055fbc4875aef622142cbe5ac3/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| imageStoreUuid | String | url | 备份服务器UUID | 3.5.0 | |
| systemTags (可选) | List | body | 3.5.0 | ||
| userTags (可选) | List | body | 3.5.0 |
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
SyncVmBackupAction action = new SyncVmBackupAction();
action.imageStoreUuid = "7c3e52e35de449c9abc1343c83b93cd5";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SyncVmBackupAction.Result res = action.call();Python
SDK
SyncVmBackupAction action = SyncVmBackupAction()
action.imageStoreUuid = "07270eb0ae25428586b224c33e88e485"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
SyncVmBackupAction.Result res = action.call()从虚拟机备份创建虚拟机(CreateVmFromVmBackup)
从虚拟机备份创建虚拟机
API请求
URLs
POST zstack/v1/vm-instances/from/vm-backups/{groupUuid}Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "vm1",
"instanceOfferingUuid": "7d608371542b3ab5960823c1b57bfa0c",
"l3NetworkUuids": [
"6ab4d28582d232708ed2912c1c3eb1ef"
],
"clusterUuid": "84a216b8b0323b87bf9d2b32abc635a3",
"description": "this is a vm",
"diskAOs": [
{
"boot": false,
"primaryStorageUuid": "2b7a5bd210ed3b1ea9d746f714a79eaf",
"size": 0,
"sourceUuid": "b205ac85f069349eafe837afadd173df",
"volumeBackupTemplate": false
}
],
"strategy": "InstantStart"
},
"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":"vm1","instanceOfferingUuid":"7d608371542b3ab5960823c1b57bfa0c","l3NetworkUuids":["6ab4d28582d232708ed2912c1c3eb1ef"],"clusterUuid":"84a216b8b0323b87bf9d2b32abc635a3","description":"this is a vm","diskAOs":[{"boot":false,"primaryStorageUuid":"2b7a5bd210ed3b1ea9d746f714a79eaf","size":0,"sourceUuid":"b205ac85f069349eafe837afadd173df","volumeBackupTemplate":false}],"strategy":"InstantStart"}}' http://localhost:8080/zstack/v1/vm-instances/from/vm-backups/04ac2beae2b03def881dea125299498c参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
资源名称 | 3.0.0 | |
| groupUuid | String | url | 虚拟机备份组UUID | 3.0.0 | |
| backupStorageUuid (可选) | String | body(包含在params结构中) |
镜像存储UUID | 0.6 | |
| instanceOfferingUuid (可选) | String | body(包含在params结构中) |
计算规格UUID | 3.0.0 | |
| l3NetworkUuids (可选) | List | body(包含在params结构中) |
一组分布式端口组的UUID | 3.0.0 | |
| vmNicParams (可选) | String | body(包含在params结构中) |
网卡信息 | 3.17.0 | |
| type (可选) | String | body(包含在params结构中) |
虚拟机类型 |
|
3.0.0 |
| zoneUuid (可选) | String | body(包含在params结构中) |
数据中心UUID | 3.0.0 | |
| clusterUuid (可选) | String | body(包含在params结构中) |
集群UUID | 3.0.0 | |
| hostUuid (可选) | String | body(包含在params结构中) |
主机UUID | 3.0.0 | |
| primaryStorageUuidForRootVolume (可选) | String | body(包含在params结构中) |
根硬盘数据存储UUID | 3.0.0 | |
| primaryStorageUuidForDataVolume (可选) | String | body(包含在params结构中) |
数据盘数据存储UUID | 3.0.0 | |
| description (可选) | String | body(包含在params结构中) |
资源的详细描述 | 3.0.0 | |
| rootVolumeSystemTags (可选) | List | body(包含在params结构中) |
根硬盘系统标签 | 3.0.0 | |
| dataVolumeSystemTags (可选) | List | body(包含在params结构中) |
数据盘系统标签 | 3.0.0 | |
| diskAOs (可选) | List | body(包含在params结构中) |
按硬盘维度传递参数,DiskAO.sourceUuid 与备份对应的原始硬盘UUID (VolumeBackupVO.volumeUuid) 绑定;可为每块硬盘单独指定 primaryStorageUuid、systemTags 等。注意:diskAOs 与 primaryStorageUuidForRootVolume/primaryStorageUuidForDataVolume、rootVolumeSystemTags/dataVolumeSystemTags 互斥,不能同时指定 | 5.0.0 | |
| defaultL3NetworkUuid (可选) | String | body(包含在params结构中) |
默认分布式端口组的UUID | 3.0.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
3.0.0 | ||
| systemTags (可选) | List | body | 系统标签 | 3.0.0 | |
| userTags (可选) | List | body | 用户标签 | 3.0.0 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 3.4.0 | |
| strategy (可选) | String | body(包含在params结构中) |
虚拟机创建策略 |
|
4.10.0 |
| cpuNum (可选) | Integer | body(包含在params结构中) |
zsv 4.3.0 | ||
| memorySize (可选) | Long | body(包含在params结构中) |
zsv 4.3.0 | ||
| reservedMemorySize (可选) | Long | body(包含在params结构中) |
zsv 4.3.0 | ||
| vmEncryption (可选) | Boolean | body(包含在params结构中) |
虚拟机是否加密 | 5.1.0 |
API返回
返回示例
{
"inventory": {
"uuid": "a1c07d683f693f6e9f2d7f9a499c7840",
"name": "Test-VM",
"description": "web server VM",
"zoneUuid": "1e48b41ec4b63660b38a72d271c0164b",
"clusterUuid": "f29498f04b1e3c319bdaeb6b3f8259f3",
"imageUuid": "5c07704333c532e8b402b6b3ddb89315",
"hostUuid": "e18cf66eedb3306686a1d4685bbb63af",
"lastHostUuid": "4834161c409a34b6a84e40d71d85f714",
"instanceOfferingUuid": "f53ad9f147203b499dfbd93ce41b7a8e",
"rootVolumeUuid": "24b9fcb69f123ad6b3ddfffed96d2882",
"platform": "Linux",
"defaultL3NetworkUuid": "d50554f493153be78f6740e18e598046",
"type": "UserVm",
"hypervisorType": "KVM",
"memorySize": 8589934592,
"cpuNum": 1,
"allocatorStrategy": "LastHostPreferredAllocatorStrategy",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM",
"state": "Running",
"vmNics": [
{
"uuid": "9856d36e40783d669b9e4f1de41d1a17",
"vmInstanceUuid": "a1c07d683f693f6e9f2d7f9a499c7840",
"usedIpUuid": "be02105c2a223492a91fb09ba664ecb1",
"l3NetworkUuid": "d50554f493153be78f6740e18e598046",
"ip": "192.168.1.10",
"mac": "00:0c:29:bd:99:fc",
"netmask": "255.255.255.0",
"gateway": "192.168.1.1",
"deviceId": 0,
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
],
"allVolumes": [
{
"uuid": "24b9fcb69f123ad6b3ddfffed96d2882",
"name": "Root-Volume-For-VM-a1c07d683f693f6e9f2d7f9a499c7840",
"primaryStorageUuid": "ae47a25fd7cf3a349035d01060a8a224",
"vmInstanceUuid": "a1c07d683f693f6e9f2d7f9a499c7840",
"rootImageUuid": "5c07704333c532e8b402b6b3ddb89315",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-24b9fcb69f123ad6b3ddfffed96d2882/24b9fcb69f123ad6b3ddfffed96d2882.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 | VmInstanceInventory | 详情参考inventory | 3.0.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 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| name | String | 资源名称 | 0.6 |
| description | String | 资源的详细描述 | 0.6 |
| zoneUuid | String | 数据中心 UUID | 0.6 |
| clusterUuid | String | 集群 UUID | 0.6 |
| imageUuid | String | 镜像 UUID | 0.6 |
| hostUuid | String | 主机 UUID | 0.6 |
| lastHostUuid | String | 上一次启动的主机 UUID | 0.6 |
| instanceOfferingUuid | String | 计算规格 UUID, 已废弃 | 0.6 |
| rootVolumeUuid | String | 根硬盘 UUID | 0.6 |
| platform | String | 虚拟机的平台, 是 Windows / Linux 还是其它 | 0.6 |
| architecture | String | 虚拟机架构, 是 x86_64 / aarch64 还是其它 | 0.6 |
| defaultL3NetworkUuid | String | 默认使用的分布式端口组 UUID | 0.6 |
| type | String | 虚拟机类型, 是用户使用虚拟机还是平台特殊用途的虚拟机 | 0.6 |
| hypervisorType | String | 虚拟机虚拟化类型, 一般为 KVM | 0.6 |
| memorySize | Long | 内存大小 | 0.6 |
| cpuNum | Integer | CPU 数量 | 0.6 |
| cpuSpeed | Long | CPU 速度 | 0.6 |
| allocatorStrategy | String | 虚拟机分配策略 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
| state | String | 虚拟机是否启用的状态 | 0.6 |
| guestOsType | String | 虚拟机宿主操作系统类型 | 3.11.2 |
| vmNics | List | 详情参考vmNics | 0.6 |
| allVolumes | List | 详情参考allVolumes | 0.6 |
| vmCdRoms | List | 详情参考vmCdRoms | 0.6 |
#vmNics
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| l3NetworkUuid | String | 分布式端口组UUID | 3.17.13 |
| ip | String | 3.17.13 | |
| mac | String | 3.17.13 | |
| hypervisorType | String | 3.17.13 | |
| netmask | String | 3.17.13 | |
| gateway | String | 3.17.13 | |
| metaData | String | 3.17.13 | |
| ipVersion | Integer | 3.17.13 | |
| driverType | String | 3.17.13 | |
| internalName | String | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| type | String | 3.17.13 | |
| state | String | 网卡状态 | 3.17.13 |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| usedIps | List | 详情参考usedIps | 3.17.13 |
#usedIps
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.10.0 |
| ipRangeUuid | String | IP段UUID | 4.10.0 |
| l3NetworkUuid | String | 分布式端口组UUID | 4.10.0 |
| ipVersion | Integer | IP协议号 | 4.10.0 |
| ip | String | IP地址 | 4.10.0 |
| netmask | String | 子网掩码 | 4.10.0 |
| gateway | String | 网关地址 | 4.10.0 |
| usedFor | String | 分配原因 | 4.10.0 |
| ipInLong | long | Long存储的IP地址,仅ipv4有效 | 4.10.0 |
| vmNicUuid | String | 虚拟机网卡UUID | 4.10.0 |
| createDate | Timestamp | 创建时间 | 4.10.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.0 |
#allVolumes
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| 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 |
#vmCdRoms
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| deviceId | Integer | 3.17.13 | |
| isoUuid | String | 3.17.13 | |
| isoInstallPath | String | 3.17.13 | |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
SDK示例
Java SDK
CreateVmFromVmBackupAction action = new CreateVmFromVmBackupAction();
action.name = "vm1";
action.groupUuid = "04ac2beae2b03def881dea125299498c";
action.instanceOfferingUuid = "7d608371542b3ab5960823c1b57bfa0c";
action.l3NetworkUuids = asList("6ab4d28582d232708ed2912c1c3eb1ef");
action.clusterUuid = "84a216b8b0323b87bf9d2b32abc635a3";
action.description = "this is a vm";
action.diskAOs = asList([boot:false, primaryStorageUuid:2b7a5bd210ed3b1ea9d746f714a79eaf, size:0, sourceUuid:b205ac85f069349eafe837afadd173df, volumeBackupTemplate:false]);
action.strategy = "InstantStart";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVmFromVmBackupAction.Result res = action.call();Python SDK
action = CreateVmFromVmBackupAction()
action.name = "vm1"
action.groupUuid = "04ac2beae2b03def881dea125299498c"
action.instanceOfferingUuid = "7d608371542b3ab5960823c1b57bfa0c"
action.l3NetworkUuids = [6ab4d28582d232708ed2912c1c3eb1ef]
action.clusterUuid = "84a216b8b0323b87bf9d2b32abc635a3"
action.description = "this is a vm"
action.diskAOs = [[boot:false, primaryStorageUuid:2b7a5bd210ed3b1ea9d746f714a79eaf, size:0, sourceUuid:b205ac85f069349eafe837afadd173df, volumeBackupTemplate:false]]
action.strategy = "InstantStart"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()从备份创建虚拟机(CreateVmFromVolumeBackup)
从备份创建虚拟机
API请求
URLs
POST zstack/v1/vm-instances/from/vm-backup/{backupUuid}Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "vm1",
"instanceOfferingUuid": "31d2057b670d3c32a6970e519b514f12",
"l3NetworkUuids": [
"87b522f02ef83627bcab5e427ba2d5e6"
],
"clusterUuid": "255b14070a533fb5ad9a845d4c50508a",
"description": "this is a vm",
"strategy": "InstantStart"
},
"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":"vm1","instanceOfferingUuid":"31d2057b670d3c32a6970e519b514f12","l3NetworkUuids":["87b522f02ef83627bcab5e427ba2d5e6"],"clusterUuid":"255b14070a533fb5ad9a845d4c50508a","description":"this is a vm","strategy":"InstantStart"}}' http://localhost:8080/zstack/v1/vm-instances/from/vm-backup/b3ecd20a4b523ff0b5a954a8579a1aeb参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
虚拟机名字 | 3.18.0 | |
| backupUuid | String | url | 备份UUID | 3.18.0 | |
| backupStorageUuid (可选) | String | body(包含在params结构中) |
镜像存储UUID | 3.18.0 | |
| instanceOfferingUuid (可选) | String | body(包含在params结构中) |
计算规格UUID | 3.18.0 | |
| cpuNum (可选) | Integer | body(包含在params结构中) |
虚拟机 CPU 核心数 | 4.10.28 | |
| memorySize (可选) | Long | body(包含在params结构中) |
虚拟机内存大小, 单位 byte | 4.10.28 | |
| defaultL3NetworkUuid (可选) | String | body(包含在params结构中) |
默认L3网络UUID | 3.18.0 | |
| l3NetworkUuids | List | body(包含在params结构中) |
一组分布式端口组的UUID | 3.18.0 | |
| type (可选) | String | body(包含在params结构中) |
虚拟机类型 |
|
3.18.0 |
| zoneUuid (可选) | String | body(包含在params结构中) |
数据中心UUID | 3.18.0 | |
| clusterUuid (可选) | String | body(包含在params结构中) |
集群UUID | 3.18.0 | |
| hostUuid (可选) | String | body(包含在params结构中) |
主机UUID | 3.18.0 | |
| primaryStorageUuidForRootVolume (可选) | String | body(包含在params结构中) |
根硬盘数据存储UUID | 3.18.0 | |
| description (可选) | String | body(包含在params结构中) |
资源的详细描述 | 3.18.0 | |
| rootVolumeSystemTags (可选) | List | body(包含在params结构中) |
根硬盘系统标签 | 3.18.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源UUID | 3.18.0 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 3.18.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.18.0 | |
| userTags (可选) | List | body | 用户标签 | 3.18.0 | |
| strategy (可选) | String | body(包含在params结构中) |
虚拟机创建策略 |
|
4.10.0 |
| resetTpm (可选) | Boolean | body(包含在params结构中) |
创建的虚拟机是否重置 TPM 状态 | 5.0.0 |
API返回
返回示例
{
"inventory": {
"uuid": "0a2cbf2edacc399cb9a7e6b2fa14602d",
"name": "Test-VM",
"description": "web server VM",
"zoneUuid": "1086a7491b8c3fb9ab12192dc0fab906",
"clusterUuid": "3e368e7f98913ec6bb20d6cc969cf50a",
"imageUuid": "2ceb7086482d3b42ab56b9daa6fb4d44",
"hostUuid": "d81f8599fd033183ab2d4bcafce233cc",
"lastHostUuid": "2d9fd9b480be3fdd9df46548d9d178d5",
"instanceOfferingUuid": "feba03817e0e326d827ebdb436786bad",
"rootVolumeUuid": "2f368d0d8b4734b7b58e1c5cb2ec27c6",
"platform": "Linux",
"defaultL3NetworkUuid": "ecebe1b81b18351dbdf304622e9ada80",
"type": "UserVm",
"hypervisorType": "KVM",
"memorySize": 8589934592,
"cpuNum": 1,
"allocatorStrategy": "LastHostPreferredAllocatorStrategy",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM",
"state": "Running",
"vmNics": [
{
"uuid": "da1e1002fa2b387bbe389ce3bf10ba92",
"vmInstanceUuid": "0a2cbf2edacc399cb9a7e6b2fa14602d",
"usedIpUuid": "e8c56c6711e83896acb7413183726c1c",
"l3NetworkUuid": "ecebe1b81b18351dbdf304622e9ada80",
"ip": "192.168.1.10",
"mac": "00:0c:29:bd:99:fc",
"netmask": "255.255.255.0",
"gateway": "192.168.1.1",
"deviceId": 0,
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
],
"allVolumes": [
{
"uuid": "2f368d0d8b4734b7b58e1c5cb2ec27c6",
"name": "Root-Volume-For-VM-0a2cbf2edacc399cb9a7e6b2fa14602d",
"primaryStorageUuid": "890196bf1b5a308da1c75eb61ff441a3",
"vmInstanceUuid": "0a2cbf2edacc399cb9a7e6b2fa14602d",
"rootImageUuid": "2ceb7086482d3b42ab56b9daa6fb4d44",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-2f368d0d8b4734b7b58e1c5cb2ec27c6/2f368d0d8b4734b7b58e1c5cb2ec27c6.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.18.0 |
| inventory | VmInstanceInventory | 详情参考inventory | 3.18.0 |
| error | ErrorCode | 详情参考error | 3.18.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| name | String | 资源名称 | 0.6 |
| description | String | 资源的详细描述 | 0.6 |
| zoneUuid | String | 数据中心 UUID | 0.6 |
| clusterUuid | String | 集群 UUID | 0.6 |
| imageUuid | String | 镜像 UUID | 0.6 |
| hostUuid | String | 主机 UUID | 0.6 |
| lastHostUuid | String | 上一次启动的主机 UUID | 0.6 |
| instanceOfferingUuid | String | 计算规格 UUID, 已废弃 | 0.6 |
| rootVolumeUuid | String | 根硬盘 UUID | 0.6 |
| platform | String | 虚拟机的平台, 是 Windows / Linux 还是其它 | 0.6 |
| architecture | String | 虚拟机架构, 是 x86_64 / aarch64 还是其它 | 0.6 |
| defaultL3NetworkUuid | String | 默认使用的分布式端口组 UUID | 0.6 |
| type | String | 虚拟机类型, 是用户使用虚拟机还是平台特殊用途的虚拟机 | 0.6 |
| hypervisorType | String | 虚拟机虚拟化类型, 一般为 KVM | 0.6 |
| memorySize | Long | 内存大小 | 0.6 |
| cpuNum | Integer | CPU 数量 | 0.6 |
| cpuSpeed | Long | CPU 速度 | 0.6 |
| allocatorStrategy | String | 虚拟机分配策略 | 0.6 |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
| state | String | 虚拟机是否启用的状态 | 0.6 |
| guestOsType | String | 虚拟机宿主操作系统类型 | 3.11.2 |
| vmNics | List | 详情参考vmNics | 0.6 |
| allVolumes | List | 详情参考allVolumes | 0.6 |
| vmCdRoms | List | 详情参考vmCdRoms | 0.6 |
#vmNics
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| l3NetworkUuid | String | 分布式端口组UUID | 3.17.13 |
| ip | String | 3.17.13 | |
| mac | String | 3.17.13 | |
| hypervisorType | String | 3.17.13 | |
| netmask | String | 3.17.13 | |
| gateway | String | 3.17.13 | |
| metaData | String | 3.17.13 | |
| ipVersion | Integer | 3.17.13 | |
| driverType | String | 3.17.13 | |
| internalName | String | 3.17.13 | |
| deviceId | Integer | 3.17.13 | |
| type | String | 3.17.13 | |
| state | String | 网卡状态 | 3.17.13 |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
| usedIps | List | 详情参考usedIps | 3.17.13 |
#usedIps
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 4.10.0 |
| ipRangeUuid | String | IP段UUID | 4.10.0 |
| l3NetworkUuid | String | 分布式端口组UUID | 4.10.0 |
| ipVersion | Integer | IP协议号 | 4.10.0 |
| ip | String | IP地址 | 4.10.0 |
| netmask | String | 子网掩码 | 4.10.0 |
| gateway | String | 网关地址 | 4.10.0 |
| usedFor | String | 分配原因 | 4.10.0 |
| ipInLong | long | Long存储的IP地址,仅ipv4有效 | 4.10.0 |
| vmNicUuid | String | 虚拟机网卡UUID | 4.10.0 |
| createDate | Timestamp | 创建时间 | 4.10.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 4.10.0 |
#allVolumes
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| 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 |
#vmCdRoms
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.17.13 |
| vmInstanceUuid | String | 虚拟机UUID | 3.17.13 |
| deviceId | Integer | 3.17.13 | |
| isoUuid | String | 3.17.13 | |
| isoInstallPath | String | 3.17.13 | |
| name | String | 资源名称 | 3.17.13 |
| description | String | 资源的详细描述 | 3.17.13 |
| createDate | Timestamp | 创建时间 | 3.17.13 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.17.13 |
#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
CreateVmFromVolumeBackupAction action = new CreateVmFromVolumeBackupAction();
action.name = "vm1";
action.backupUuid = "b3ecd20a4b523ff0b5a954a8579a1aeb";
action.instanceOfferingUuid = "31d2057b670d3c32a6970e519b514f12";
action.l3NetworkUuids = asList("87b522f02ef83627bcab5e427ba2d5e6");
action.clusterUuid = "255b14070a533fb5ad9a845d4c50508a";
action.description = "this is a vm";
action.strategy = "InstantStart";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVmFromVolumeBackupAction.Result res = action.call();Python SDK
action = CreateVmFromVolumeBackupAction()
action.name = "vm1"
action.backupUuid = "b3ecd20a4b523ff0b5a954a8579a1aeb"
action.instanceOfferingUuid = "31d2057b670d3c32a6970e519b514f12"
action.l3NetworkUuids = [87b522f02ef83627bcab5e427ba2d5e6]
action.clusterUuid = "255b14070a533fb5ad9a845d4c50508a"
action.description = "this is a vm"
action.strategy = "InstantStart"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()从硬盘备份创建数据硬盘(CreateDataVolumeFromVolumeBackup)
从备份创建数据硬盘
API请求
URLs
POST zstack/v1/volumes/data-volume/from/volume-template/{backupUuid}Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "vm1",
"vmInstanceUuid": "df47f06e78bb381eb278f5f6bcc101b2",
"backupStorageUuid": "dd5aec0fdb7c32f3bcfb526dcbe65722",
"primaryStorageUuid": "7fe66ccbc8cc3d19a15ad7188c17374b"
},
"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":"vm1","vmInstanceUuid":"df47f06e78bb381eb278f5f6bcc101b2","backupStorageUuid":"dd5aec0fdb7c32f3bcfb526dcbe65722","primaryStorageUuid":"7fe66ccbc8cc3d19a15ad7188c17374b"}}' http://localhost:8080/zstack/v1/volumes/data-volume/from/volume-template/5ac65bdd607d32a4900fe3f6694ddc95参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) |
数据硬盘名称 | 3.18.0 | |
| vmUuid | String | body(包含在params结构中) |
虚拟机UUID | 3.18.0 | |
| backupUuid | String | url | 备份UUID | 3.18.0 | |
| backupStorageUuid (可选) | String | body(包含在params结构中) |
备份服务器UUID | 3.18.0 | |
| primaryStorageUuid (可选) | String | body(包含在params结构中) |
数据存储UUID | 3.18.0 | |
| description (可选) | String | body(包含在params结构中) |
资源的详细描述 | 3.18.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
资源UUID | 3.18.0 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 3.18.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.18.0 | |
| userTags (可选) | List | body | 用户标签 | 3.18.0 |
API返回
返回示例
{
"inventory": {
"uuid": "4021e9e6f0c535fc9d05e0127189289a",
"name": "data-volume-from-backup",
"primaryStorageUuid": "8f4d8f82dfa335faae5f11683cf7c931",
"vmInstanceUuid": "d2504a8055d73c1eac11ecc7f2f5526d",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-12f3b84e92d03bf7a05b8f585a093329/4021e9e6f0c535fc9d05e0127189289a.qcow2",
"type": "Data",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 1,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 请求是否成功 | 3.18.0 |
| inventory | VolumeInventory | 详情参考inventory | 3.18.0 |
| error | ErrorCode | 详情参考error | 3.18.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
CreateDataVolumeFromVolumeBackupAction action = new CreateDataVolumeFromVolumeBackupAction();
action.name = "vm1";
action.vmInstanceUuid = "df47f06e78bb381eb278f5f6bcc101b2";
action.backupUuid = "5ac65bdd607d32a4900fe3f6694ddc95";
action.backupStorageUuid = "dd5aec0fdb7c32f3bcfb526dcbe65722";
action.primaryStorageUuid = "7fe66ccbc8cc3d19a15ad7188c17374b";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateDataVolumeFromVolumeBackupAction.Result res = action.call();Python SDK
action = CreateDataVolumeFromVolumeBackupAction()
action.name = "vm1"
action.vmInstanceUuid = "df47f06e78bb381eb278f5f6bcc101b2"
action.backupUuid = "5ac65bdd607d32a4900fe3f6694ddc95"
action.backupStorageUuid = "dd5aec0fdb7c32f3bcfb526dcbe65722"
action.primaryStorageUuid = "7fe66ccbc8cc3d19a15ad7188c17374b"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()创建硬盘备份(CreateVolumeBackup)
创建卷备份
API请求
URLs
POST zstack/v1/volumes/{volumeUuid}/volume-backupsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"backupStorageUuid": "eb346a99797a3ad19bae298d2b67be5f",
"name": "backup-1",
"description": "a critical volume backup"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X POST -d '{"params":{"backupStorageUuid":"eb346a99797a3ad19bae298d2b67be5f","name":"backup-1","description":"a critical volume backup"}}' http://localhost:8080/zstack/v1/volumes/deda5c7823b930b198052fd1a7dfae78/volume-backups参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| volumeUuid | String | url | 硬盘UUID | 2.6 | |
| backupStorageUuid | String | body(包含在params结构中) |
镜像存储UUID | 2.6 | |
| name | String | body(包含在params结构中) |
资源名称 | 2.6 | |
| description (可选) | String | body(包含在params结构中) |
资源的详细描述 | 2.6 | |
| resourceUuid (可选) | String | body(包含在params结构中) |
指定资源uuid | 2.6 | |
| systemTags (可选) | List | body | 系统标签 | 2.6 | |
| userTags (可选) | List | body | 用户标签 | 2.6 | |
| volumeReadBandwidth (可选) | Long | body(包含在params结构中) |
0.6 | ||
| volumeWriteBandwidth (可选) | Long | body(包含在params结构中) |
0.6 | ||
| networkReadBandwidth (可选) | Long | body(包含在params结构中) |
0.6 | ||
| networkWriteBandwidth (可选) | Long | body(包含在params结构中) |
0.6 | ||
| mode (可选) | String | body(包含在params结构中) |
|
0.6 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 3.4.0 |
API返回
返回示例
{
"inventory": {
"uuid": "dc64d9ac1b6f30e0aaa398b1f82e10f7",
"volumeUuid": "12a5e7fe96c73fa6812cd4dba80c0df7",
"name": "Backup-1",
"description": "volume backup",
"size": 1073741824,
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
},
"actualExecuteTime": 60
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 2.6 |
| inventory | VolumeBackupInventory | 详情参考inventory | 2.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,唯一标示该资源 | 2.6 |
| volumeUuid | String | 硬盘UUID | 2.6 |
| name | String | 备份名称 | 2.6 |
| description | String | 备份的详细描述 | 2.6 |
| type | String | 卷的类型 | 2.6 |
| state | String | 卷备份的启用状态 | 2.6 |
| status | String | 卷备份的状态 | 2.6 |
| size | Long | 当前卷备份的大小 | 2.6 |
| metadata | String | 卷备份相关元数据 | 2.6 |
| createDate | Timestamp | 创建时间 | 2.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 2.6 |
| encrypted | Boolean | 备份数据是否加密 | 5.1 |
| keyLastOpDate | Timestamp | 加密备份密钥最后更新时间,非加密备份为空 | 5.1 |
| backupStorageRefs | List | 详情参考backupStorageRefs | 2.6 |
#backupStorageRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| volumeBackupUuid | String | 卷备份的uuid | 2.6 |
| backupStorageUuid | String | 镜像存储UUID | 2.6 |
| installPath | String | 卷备份的数据路径 | 2.6 |
| status | String | 卷备份在镜像存储的状态 | 2.6 |
| createDate | Timestamp | 创建时间 | 2.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 2.6 |
SDK示例
Java SDK
CreateVolumeBackupAction action = new CreateVolumeBackupAction();
action.volumeUuid = "deda5c7823b930b198052fd1a7dfae78";
action.backupStorageUuid = "eb346a99797a3ad19bae298d2b67be5f";
action.name = "backup-1";
action.description = "a critical volume backup";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVolumeBackupAction.Result res = action.call();Python SDK
action = CreateVolumeBackupAction()
action.volumeUuid = "deda5c7823b930b198052fd1a7dfae78"
action.backupStorageUuid = "eb346a99797a3ad19bae298d2b67be5f"
action.name = "backup-1"
action.description = "a critical volume backup"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()查询硬盘备份(QueryVolumeBackup)
查询卷备份记录
API请求
URLs
GET zstack/v1/volume-backups
GET zstack/v1/volume-backups/{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/volume-backups?q=uuid=51220c98d9173f97b63be7eb9216f96ecurl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X GET http://localhost:8080/zstack/v1/volume-backups/09de4206bb143d75aad644c88cdbb364可查询字段
运行CLI命令行工具,输入QueryVolumeBackup并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "becd24d9ab613bf2bca69392d168c3d7",
"volumeUuid": "10d2016486e834abb871d1e03b85a45b",
"name": "backup-2",
"description": "my backup",
"size": 1310720,
"encrypted": false
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| success | boolean | 0.6 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 2.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,唯一标示该资源 | 2.6 |
| volumeUuid | String | 硬盘UUID | 2.6 |
| name | String | 备份名称 | 2.6 |
| description | String | 备份的详细描述 | 2.6 |
| type | String | 卷的类型 | 2.6 |
| state | String | 卷备份的启用状态 | 2.6 |
| status | String | 卷备份的状态 | 2.6 |
| size | Long | 当前卷备份的大小 | 2.6 |
| metadata | String | 卷备份相关元数据 | 2.6 |
| createDate | Timestamp | 创建时间 | 2.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 2.6 |
| encrypted | Boolean | 备份数据是否加密 | 5.1 |
| keyLastOpDate | Timestamp | 加密备份密钥最后更新时间,非加密备份为空 | 5.1 |
| backupStorageRefs | List | 详情参考backupStorageRefs | 2.6 |
#backupStorageRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| volumeBackupUuid | String | 卷备份的uuid | 2.6 |
| backupStorageUuid | String | 镜像存储UUID | 2.6 |
| installPath | String | 卷备份的数据路径 | 2.6 |
| status | String | 卷备份在镜像存储的状态 | 2.6 |
| createDate | Timestamp | 创建时间 | 2.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 2.6 |
SDK示例
Java SDK
QueryVolumeBackupAction action = new QueryVolumeBackupAction();
action.conditions = asList("uuid=e4b2249c11a73337828511de527b9f0d");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryVolumeBackupAction.Result res = action.call();Python SDK
action = QueryVolumeBackupAction()
action.conditions = ["uuid=b2b63da2ff5839d8b9b020fcbfe0d045"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()从镜像存储恢复硬盘备份(RecoverBackupFromImageStoreBackupStorage)
从目标镜像服务器恢复卷备份
API请求
URLs
PUT zstack/v1/volume-backups/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"recoverBackupFromImageStoreBackupStorage": {
"srcBackupStorageUuid": "98156e94f6463740908e8b963a64a89f",
"dstBackupStorageUuid": "dbe16164d9cc3ab5a79e6596841f55af"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"recoverBackupFromImageStoreBackupStorage":{"srcBackupStorageUuid":"98156e94f6463740908e8b963a64a89f","dstBackupStorageUuid":"dbe16164d9cc3ab5a79e6596841f55af"}}' http://localhost:8080/zstack/v1/volume-backups/46081ffd1ceb3747be948925bcf6d272/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 卷备份的UUID,唯一标示该资源 | 2.6 | |
| srcBackupStorageUuid | String | body(包含在recoverBackupFromImageStoreBackupStorage结构中) |
接收恢复卷的镜像服务器uuid | 2.6 | |
| dstBackupStorageUuid | String | body(包含在recoverBackupFromImageStoreBackupStorage结构中) |
恢复镜像服务器uuid | 2.6 | |
| systemTags (可选) | List | body | 系统标签 | 2.6 | |
| userTags (可选) | List | body | 系统标签 | 2.6 |
API返回
返回示例
{
"inventory": {
"uuid": "1ca8a996e1583dbf8fdb22eb7c5a7720",
"volumeUuid": "4dcfee4974d7326f8667a26ca4990953",
"name": "Backup-1",
"description": "volume backup",
"size": 1073741824,
"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 | 2.6 |
| inventory | VolumeBackupInventory | 详情参考inventory | 2.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,唯一标示该资源 | 2.6 |
| volumeUuid | String | 硬盘UUID | 2.6 |
| name | String | 备份名称 | 2.6 |
| description | String | 备份的详细描述 | 2.6 |
| type | String | 卷的类型 | 2.6 |
| state | String | 卷备份的启用状态 | 2.6 |
| status | String | 卷备份的状态 | 2.6 |
| size | Long | 当前卷备份的大小 | 2.6 |
| metadata | String | 卷备份相关元数据 | 2.6 |
| createDate | Timestamp | 创建时间 | 2.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 2.6 |
| encrypted | Boolean | 备份数据是否加密 | 5.1 |
| keyLastOpDate | Timestamp | 加密备份密钥最后更新时间,非加密备份为空 | 5.1 |
| backupStorageRefs | List | 详情参考backupStorageRefs | 2.6 |
#backupStorageRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| volumeBackupUuid | String | 卷备份的uuid | 2.6 |
| backupStorageUuid | String | 镜像存储UUID | 2.6 |
| installPath | String | 卷备份的数据路径 | 2.6 |
| status | String | 卷备份在镜像存储的状态 | 2.6 |
| createDate | Timestamp | 创建时间 | 2.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 2.6 |
SDK示例
Java SDK
RecoverBackupFromImageStoreBackupStorageAction action = new RecoverBackupFromImageStoreBackupStorageAction();
action.uuid = "46081ffd1ceb3747be948925bcf6d272";
action.srcBackupStorageUuid = "98156e94f6463740908e8b963a64a89f";
action.dstBackupStorageUuid = "dbe16164d9cc3ab5a79e6596841f55af";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RecoverBackupFromImageStoreBackupStorageAction.Result res = action.call();Python SDK
action = RecoverBackupFromImageStoreBackupStorageAction()
action.uuid = "46081ffd1ceb3747be948925bcf6d272"
action.srcBackupStorageUuid = "98156e94f6463740908e8b963a64a89f"
action.dstBackupStorageUuid = "dbe16164d9cc3ab5a79e6596841f55af"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()从镜像存储同步硬盘备份(SyncBackupFromImageStoreBackupStorage)
将卷备份同步至目标镜像服务器
API请求
URLs
PUT zstack/v1/volume-backups/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"syncBackupFromImageStoreBackupStorage": {
"srcBackupStorageUuid": "4ca933ae060a3c1ba520ba6b20ac3230",
"dstBackupStorageUuid": "738ef8a48f533dafb0b27fc0ba1bc22e"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"syncBackupFromImageStoreBackupStorage":{"srcBackupStorageUuid":"4ca933ae060a3c1ba520ba6b20ac3230","dstBackupStorageUuid":"738ef8a48f533dafb0b27fc0ba1bc22e"}}' http://localhost:8080/zstack/v1/volume-backups/3b77720e739e3f9b87ca0beb6f45f5a5/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 卷备份的UUID,唯一标示该资源 | 2.6 | |
| srcBackupStorageUuid | String | body(包含在syncBackupFromImageStoreBackupStorage结构中) |
源镜像服务器 | 2.6 | |
| dstBackupStorageUuid | String | body(包含在syncBackupFromImageStoreBackupStorage结构中) |
目标镜像服务器 | 2.6 | |
| systemTags (可选) | List | body | 系统标签 | 2.6 | |
| userTags (可选) | List | body | 用户标签 | 2.6 |
API返回
返回示例
{
"inventory": {
"uuid": "3f49e7470a0935a0b0d3088e406b1df7",
"volumeUuid": "43715d2428ce32d48deac117d32fa945",
"name": "Backup-1",
"description": "volume backup",
"size": 1073741824,
"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 | 2.6 |
| inventory | VolumeBackupInventory | 详情参考inventory | 2.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,唯一标示该资源 | 2.6 |
| volumeUuid | String | 硬盘UUID | 2.6 |
| name | String | 备份名称 | 2.6 |
| description | String | 备份的详细描述 | 2.6 |
| type | String | 卷的类型 | 2.6 |
| state | String | 卷备份的启用状态 | 2.6 |
| status | String | 卷备份的状态 | 2.6 |
| size | Long | 当前卷备份的大小 | 2.6 |
| metadata | String | 卷备份相关元数据 | 2.6 |
| createDate | Timestamp | 创建时间 | 2.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 2.6 |
| encrypted | Boolean | 备份数据是否加密 | 5.1 |
| keyLastOpDate | Timestamp | 加密备份密钥最后更新时间,非加密备份为空 | 5.1 |
| backupStorageRefs | List | 详情参考backupStorageRefs | 2.6 |
#backupStorageRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| volumeBackupUuid | String | 卷备份的uuid | 2.6 |
| backupStorageUuid | String | 镜像存储UUID | 2.6 |
| installPath | String | 卷备份的数据路径 | 2.6 |
| status | String | 卷备份在镜像存储的状态 | 2.6 |
| createDate | Timestamp | 创建时间 | 2.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 2.6 |
SDK示例
Java SDK
SyncBackupFromImageStoreBackupStorageAction action = new SyncBackupFromImageStoreBackupStorageAction();
action.uuid = "3b77720e739e3f9b87ca0beb6f45f5a5";
action.srcBackupStorageUuid = "4ca933ae060a3c1ba520ba6b20ac3230";
action.dstBackupStorageUuid = "738ef8a48f533dafb0b27fc0ba1bc22e";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SyncBackupFromImageStoreBackupStorageAction.Result res = action.call();Python SDK
action = SyncBackupFromImageStoreBackupStorageAction()
action.uuid = "3b77720e739e3f9b87ca0beb6f45f5a5"
action.srcBackupStorageUuid = "4ca933ae060a3c1ba520ba6b20ac3230"
action.dstBackupStorageUuid = "738ef8a48f533dafb0b27fc0ba1bc22e"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()从虚拟机备份恢复虚拟机(RevertVmFromVmBackup)
API请求
URLs
PUT zstack/v1/vm-backups/{groupUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"revertVmFromVmBackup": {
"backupStorageUuid": "99afb6149155396c8ac1b6ab62badb9d",
"strategy": "CreateStopped"
},
"systemTags": [],
"userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"revertVmFromVmBackup":{"backupStorageUuid":"99afb6149155396c8ac1b6ab62badb9d","strategy":"CreateStopped"}}' \
http://localhost:8080/zstack/v1/vm-backups/39f4e3c4b7553dbc98b8c0ce0e8f82a1/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| groupUuid | String | url | 备份组uuid | 3.0.0 | |
| backupStorageUuid (可选) | String | body(包含在revertVmFromVmBackup结构中) | 镜像存储UUID | 3.0.0 | |
| strategy (可选) | String | body(包含在revertVmFromVmBackup结构中) |
|
4.3.0 | |
| systemTags (可选) | List | body | 3.0.0 | ||
| userTags (可选) | List | body | 3.0.0 |
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
RevertVmFromVmBackupAction action = new RevertVmFromVmBackupAction();
action.groupUuid = "39f4e3c4b7553dbc98b8c0ce0e8f82a1";
action.backupStorageUuid = "99afb6149155396c8ac1b6ab62badb9d";
action.strategy = "CreateStopped";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RevertVmFromVmBackupAction.Result res = action.call();Python
SDK
RevertVmFromVmBackupAction action = RevertVmFromVmBackupAction()
action.groupUuid = "39f4e3c4b7553dbc98b8c0ce0e8f82a1"
action.backupStorageUuid = "99afb6149155396c8ac1b6ab62badb9d"
action.strategy = "CreateStopped"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RevertVmFromVmBackupAction.Result res = action.call()恢复虚拟机备份(RecoverVmBackupFromImageStoreBackupStorage)
从备份镜像仓库恢复虚拟机备份
API请求
URLs
PUT zstack/v1/vm-backups/{groupUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"recoverVmBackupFromImageStoreBackupStorage": {
"srcBackupStorageUuid": "c63b10a638f6302caeabb7a806d087ad",
"dstBackupStorageUuid": "7c7d653af1c531dfa04dabea3a085de5"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"recoverVmBackupFromImageStoreBackupStorage":{"srcBackupStorageUuid":"c63b10a638f6302caeabb7a806d087ad","dstBackupStorageUuid":"7c7d653af1c531dfa04dabea3a085de5"}}' http://localhost:8080/zstack/v1/vm-backups/7913ce9f37973f4e8339aea4ff61584c/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| groupUuid | String | url | 虚拟机备份组uuid | 3.0.0 | |
| srcBackupStorageUuid | String | body(包含在recoverVmBackupFromImageStoreBackupStorage结构中) |
本地镜像仓库 | 3.0.0 | |
| dstBackupStorageUuid | String | body(包含在recoverVmBackupFromImageStoreBackupStorage结构中) |
备份镜像仓库 | 3.0.0 | |
| systemTags (可选) | List | body | 3.0.0 | ||
| userTags (可选) | List | body | 3.0.0 |
API返回
返回示例
{
"inventories": [
{
"uuid": "5e28a0c27a8e352bbeedff94a0326f9e",
"volumeUuid": "aa5fbdba3ffa352bbefaf913f56949f3",
"name": "Root-Volume-Backup-1",
"description": "volume backup",
"size": 1073741824,
"groupUuid": "0150a8120f9334db8e9abc9d3f5eea08",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
},
{
"uuid": "5924c90ddbcb3784ae6e78b70ede90ce",
"volumeUuid": "12d583f519f03a0593dff7514af65be4",
"name": "Data-Volume-Backup-1",
"description": "volume backup",
"size": 2147483648,
"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 | 3.0.0 |
| inventories | List | 详情参考inventories | 3.0.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 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 卷备份的UUID,唯一标示该资源 | 2.6 |
| volumeUuid | String | 硬盘UUID | 2.6 |
| name | String | 备份名称 | 2.6 |
| description | String | 备份的详细描述 | 2.6 |
| type | String | 卷的类型 | 2.6 |
| state | String | 卷备份的启用状态 | 2.6 |
| status | String | 卷备份的状态 | 2.6 |
| size | Long | 当前卷备份的大小 | 2.6 |
| metadata | String | 卷备份相关元数据 | 2.6 |
| createDate | Timestamp | 创建时间 | 2.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 2.6 |
| encrypted | Boolean | 备份数据是否加密 | 5.1 |
| keyLastOpDate | Timestamp | 加密备份密钥最后更新时间,非加密备份为空 | 5.1 |
| backupStorageRefs | List | 详情参考backupStorageRefs | 2.6 |
#backupStorageRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| volumeBackupUuid | String | 卷备份的uuid | 2.6 |
| backupStorageUuid | String | 镜像存储UUID | 2.6 |
| installPath | String | 卷备份的数据路径 | 2.6 |
| status | String | 卷备份在镜像存储的状态 | 2.6 |
| createDate | Timestamp | 创建时间 | 2.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 2.6 |
SDK示例
Java SDK
RecoverVmBackupFromImageStoreBackupStorageAction action = new RecoverVmBackupFromImageStoreBackupStorageAction();
action.groupUuid = "7913ce9f37973f4e8339aea4ff61584c";
action.srcBackupStorageUuid = "c63b10a638f6302caeabb7a806d087ad";
action.dstBackupStorageUuid = "7c7d653af1c531dfa04dabea3a085de5";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RecoverVmBackupFromImageStoreBackupStorageAction.Result res = action.call();Python SDK
action = RecoverVmBackupFromImageStoreBackupStorageAction()
action.groupUuid = "7913ce9f37973f4e8339aea4ff61584c"
action.srcBackupStorageUuid = "c63b10a638f6302caeabb7a806d087ad"
action.dstBackupStorageUuid = "7c7d653af1c531dfa04dabea3a085de5"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()同步至备份存储(SyncVmBackupFromImageStoreBackupStorage)
同步虚拟机备份至备份镜像服务器
API请求
URLs
PUT zstack/v1/vm-backups/{groupUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"syncVmBackupFromImageStoreBackupStorage": {
"srcBackupStorageUuid": "3428f7d03e493f89b32c57ef80a7e5af",
"dstBackupStorageUuid": "6f8c528537a9347a86da7a96fb7418d4"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"syncVmBackupFromImageStoreBackupStorage":{"srcBackupStorageUuid":"3428f7d03e493f89b32c57ef80a7e5af","dstBackupStorageUuid":"6f8c528537a9347a86da7a96fb7418d4"}}' http://localhost:8080/zstack/v1/vm-backups/14e53ad2aecd3e7ebe1f05cb4f5dd6a5/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| groupUuid | String | url | 备份组uuid | 3.0.0 | |
| srcBackupStorageUuid | String | body(包含在syncVmBackupFromImageStoreBackupStorage结构中) |
本地镜像服务器 | 3.0.0 | |
| dstBackupStorageUuid | String | body(包含在syncVmBackupFromImageStoreBackupStorage结构中) |
备份镜像服务器 | 3.0.0 | |
| systemTags (可选) | List | body | 3.0.0 | ||
| userTags (可选) | List | body | 3.0.0 |
API返回
返回示例
{
"inventories": [
{
"uuid": "cf59b77253e134e483ceda7e21c6bf15",
"volumeUuid": "6be74434a84e3c939830a3987488a499",
"name": "Root-Volume-Backup-1",
"description": "volume backup",
"size": 1073741824,
"groupUuid": "09d5949ca5f233c2adcf4c278f537cef",
"createDate": "Nov 14, 2017 2:20:57 PM",
"lastOpDate": "Nov 14, 2017 2:20:57 PM"
},
{
"uuid": "c546170919a4300e9b3d3e29fc27de7f",
"volumeUuid": "39656103b9e7391e89071517f9d21b91",
"name": "Data-Volume-Backup-1",
"description": "volume backup",
"size": 2147483648,
"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 | 3.0.0 |
| inventories | List | 详情参考inventories | 3.0.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 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 卷备份的UUID,唯一标示该资源 | 2.6 |
| volumeUuid | String | 硬盘UUID | 2.6 |
| name | String | 备份名称 | 2.6 |
| description | String | 备份的详细描述 | 2.6 |
| type | String | 卷的类型 | 2.6 |
| state | String | 卷备份的启用状态 | 2.6 |
| status | String | 卷备份的状态 | 2.6 |
| size | Long | 当前卷备份的大小 | 2.6 |
| metadata | String | 卷备份相关元数据 | 2.6 |
| createDate | Timestamp | 创建时间 | 2.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 2.6 |
| encrypted | Boolean | 备份数据是否加密 | 5.1 |
| keyLastOpDate | Timestamp | 加密备份密钥最后更新时间,非加密备份为空 | 5.1 |
| backupStorageRefs | List | 详情参考backupStorageRefs | 2.6 |
#backupStorageRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| volumeBackupUuid | String | 卷备份的uuid | 2.6 |
| backupStorageUuid | String | 镜像存储UUID | 2.6 |
| installPath | String | 卷备份的数据路径 | 2.6 |
| status | String | 卷备份在镜像存储的状态 | 2.6 |
| createDate | Timestamp | 创建时间 | 2.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 2.6 |
SDK示例
Java SDK
SyncVmBackupFromImageStoreBackupStorageAction action = new SyncVmBackupFromImageStoreBackupStorageAction();
action.groupUuid = "14e53ad2aecd3e7ebe1f05cb4f5dd6a5";
action.srcBackupStorageUuid = "3428f7d03e493f89b32c57ef80a7e5af";
action.dstBackupStorageUuid = "6f8c528537a9347a86da7a96fb7418d4";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SyncVmBackupFromImageStoreBackupStorageAction.Result res = action.call();Python SDK
action = SyncVmBackupFromImageStoreBackupStorageAction()
action.groupUuid = "14e53ad2aecd3e7ebe1f05cb4f5dd6a5"
action.srcBackupStorageUuid = "3428f7d03e493f89b32c57ef80a7e5af"
action.dstBackupStorageUuid = "6f8c528537a9347a86da7a96fb7418d4"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()创建数据库备份(CreateDatabaseBackup)
API请求
URLs
POST zstack/v1/database-backupsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "cloud-db",
"backupStorageUuid": "676c5945223647698fcf4da2fa46d1dd"
},
"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":"cloud-db","backupStorageUuid":"0c0f5fc523d8420a97a9be367f112b4a"}}' http://localhost:8080/zstack/v1/database-backups参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) | 资源名称 | 3.0.0 | |
| description | String | body(包含在params结构中) | 资源的详细描述 | 3.0.0 | |
| backupStorageUuid | String | body(包含在params结构中) | 镜像存储UUID | 3.0.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) | 3.0.0 | ||
| systemTags (可选) | List | body | 3.0.0 | ||
| userTags (可选) | List | body | 3.0.0 |
API返回
返回示例
{
"inventory": {
"uuid": "7decf4a7cb7c41dabc57446df2784476",
"name": "zsdb",
"state": "Enabled",
"size": 1000.0,
"metadata": "{\"version\":\"3.0.0\"}",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.0.0 |
| inventory | DatabaseBackupInventory | 详情参考inventory | 3.0.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.0.0 |
| description | String | 错误的概要描述 | 3.0.0 |
| details | String | 错误的详细信息 | 3.0.0 |
| elaboration | String | 保留字段,默认为null | 3.0.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.0.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.0.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.0.0 |
| name | String | 资源名称 | 3.0.0 |
| description | String | 资源的详细描述 | 3.0.0 |
| state | String | 3.0.0 | |
| status | String | 3.0.0 | |
| size | Long | 3.0.0 | |
| metadata | String | 3.0.0 | |
| createDate | Timestamp | 创建时间 | 3.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.0.0 |
| backupStorageRefs | List | 详情参考backupStorageRefs | 3.0.0 |
#backupStorageRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| databaseBackupUuid | String | 3.0.0 | |
| backupStorageUuid | String | 镜像存储UUID | 3.0.0 |
| installPath | String | 3.0.0 | |
| exportUrl | String | 3.0.0 | |
| status | String | 3.0.0 | |
| createDate | Timestamp | 创建时间 | 3.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.0.0 |
SDK示例
Java
SDK
CreateDatabaseBackupAction action = new CreateDatabaseBackupAction();
action.name = "cloud-db";
action.backupStorageUuid = "35c0d1e417d84bf498be201091f39c49";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateDatabaseBackupAction.Result res = action.call();Python
SDK
CreateDatabaseBackupAction action = CreateDatabaseBackupAction()
action.name = "cloud-db"
action.backupStorageUuid = "476870bf9c4241c8993340bd0703d0bf"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateDatabaseBackupAction.Result res = action.call()删除数据库备份(DeleteDatabaseBackup)
API请求
URLs
DELETE zstack/v1/database-backups/{uuid}?backupStorageUuids={backupStorageUuids}Headers
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/database-backups/9caf0430ce473651ae7033e1a16a0097?backupStorageUuids=0c54ad64cd8d3ca1ba9d98864bb83571参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.0.0 | |
| backupStorageUuids(可选) | List | url | 镜像存储UUID列表 | 3.0.0 | |
| systemTags (可选) | List | body | 3.0.0 | ||
| userTags (可选) | List | body | 3.0.0 |
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
DeleteDatabaseBackupAction action = new DeleteDatabaseBackupAction();
action.uuid = "9caf0430ce473651ae7033e1a16a0097";
action.backupStorageUuids = asList("0c54ad64cd8d3ca1ba9d98864bb83571");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteDatabaseBackupAction.Result res = action.call();Python
SDK
DeleteDatabaseBackupAction action = DeleteDatabaseBackupAction()
action.uuid = "9caf0430ce473651ae7033e1a16a0097"
action.backupStorageUuids = [0c54ad64cd8d3ca1ba9d98864bb83571]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteDatabaseBackupAction.Result res = action.call()查询数据库备份(QueryDatabaseBackup)
API请求
URLs
GET zstack/v1/database-backups
GET zstack/v1/database-backups/{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/database-backups?q=uuid=9f5010336a233d6ebbd82594a6d56e7ccurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/database-backups/296a7da913333dd992d89bf30d9304ed可查询字段
运行CLI命令行工具,输入QueryDatabaseBackup并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "742a7c7d4a4f3a01b206632a40ac414f",
"name": "db-backup",
"description": "db-backup",
"size": 13107.0
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.0.0 |
| inventories | List | 详情参考inventories | 3.0.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.0.0 |
| description | String | 错误的概要描述 | 3.0.0 |
| details | String | 错误的详细信息 | 3.0.0 |
| elaboration | String | 保留字段,默认为null | 3.0.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.0.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.0.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.0.0 |
| name | String | 资源名称 | 3.0.0 |
| description | String | 资源的详细描述 | 3.0.0 |
| state | String | 3.0.0 | |
| status | String | 3.0.0 | |
| size | Long | 3.0.0 | |
| metadata | String | 3.0.0 | |
| createDate | Timestamp | 创建时间 | 3.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.0.0 |
| backupStorageRefs | List | 详情参考backupStorageRefs | 3.0.0 |
#backupStorageRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| databaseBackupUuid | String | 3.0.0 | |
| backupStorageUuid | String | 镜像存储UUID | 3.0.0 |
| installPath | String | 3.0.0 | |
| exportUrl | String | 3.0.0 | |
| status | String | 3.0.0 | |
| createDate | Timestamp | 创建时间 | 3.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.0.0 |
SDK示例
Java
SDK
QueryDatabaseBackupAction action = new QueryDatabaseBackupAction();
action.conditions = asList("uuid=74b420b3e877354e832a900915aab41a");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryDatabaseBackupAction.Result res = action.call();Python
SDK
QueryDatabaseBackupAction action = QueryDatabaseBackupAction()
action.conditions = ["uuid=b11af605703231b4a898bed3fb7d94c0"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryDatabaseBackupAction.Result res = action.call()扫描数据库备份(SyncDatabaseBackup)
API请求
URLs
PUT zstack/v1/database-backups/imageStore/{imageStoreUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"syncDatabaseBackup": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"syncDatabaseBackup":{}}' http://localhost:8080/zstack/v1/database-backups/imageStore/77e7125f5ecf4cbe9129b0e8483a00ae/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| imageStoreUuid | String | url | 备份存储UUID | 3.2.0 | |
| systemTags (可选) | List | body | 3.2.0 | ||
| userTags (可选) | List | body | 3.2.0 |
API返回
返回示例
{
"result": {
"deletedBackupCount": 1.0,
"newBackupCount": 3.0
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| result | SyncBackupResult | 详情参考result | 3.8.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 |
#result
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| deletedBackupCount | int | 已删除的备份数量 | 3.7.0 |
| newBackupCount | int | 新备份数量 | 3.7.0 |
SDK示例
Java
SDK
SyncDatabaseBackupAction action = new SyncDatabaseBackupAction();
action.imageStoreUuid = "e0803f92a12b42688d20f68beef19588";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SyncDatabaseBackupAction.Result res = action.call();Python
SDK
SyncDatabaseBackupAction action = SyncDatabaseBackupAction()
action.imageStoreUuid = "0de54b0b3067493f9461fc74906dfc54"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
SyncDatabaseBackupAction.Result res = action.call()恢复数据库备份(RecoverDatabaseFromBackup)
从备份库恢复数据库备份。
API请求
URLs
PUT zstack/v1/database-backups/actions?uuid={uuid}Headers
Authorization: OAuth the-session-uuidBody
{
"recoverDatabaseFromBackup": {
"backupStorageUrl": "ssh://root:password@localhost:22/Cloud_bs",
"backupInstallPath": "zstore://zsbak/0ed599ec519249489475112a058bb93a",
"mysqlRootPassword": "password"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"recoverDatabaseFromBackup":{"backupStorageUrl":"ssh://root:password@localhost:22/Cloud_bs","backupInstallPath":"zstore://zsbak/0ed599ec519249489475112a058bb93a","mysqlRootPassword":"password"}}' http://localhost:8080/zstack/v1/database-backups/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid (可选) | String | url | 资源的UUID,唯一标示该资源 | 3.0.0 | |
| backupStorageUrl (可选) | String | body(包含在recoverDatabaseFromBackup结构中) | 镜像存储URL | 3.0.0 | |
| backupInstallPath (可选) | String | body(包含在recoverDatabaseFromBackup结构中) | 数据库备份存储路径 | 3.0.0 | |
| mysqlRootPassword | String | body(包含在recoverDatabaseFromBackup结构中) | MYSQL数据库ROOT密码 | 3.0.0 | |
| systemTags (可选) | List | body | 3.0.0 | ||
| userTags (可选) | List | body | 3.0.0 |
API返回
返回示例
{
"logListenPort": 0.0
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| logListenPort | int | 浏览器可以通过此端口号实时打印日志 | 3.0.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.0.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.0.0 |
| description | String | 错误的概要描述 | 3.0.0 |
| details | String | 错误的详细信息 | 3.0.0 |
| elaboration | String | 保留字段,默认为null | 3.0.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.0.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.0.0 |
SDK示例
Java
SDK
RecoverDatabaseFromBackupAction action = new RecoverDatabaseFromBackupAction();
action.backupStorageUrl = "ssh://root:password@localhost:22/Cloud_bs";
action.backupInstallPath = "zstore://zsbak/0ed599ec519249489475112a058bb93a";
action.mysqlRootPassword = "password";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RecoverDatabaseFromBackupAction.Result res = action.call();Python
SDK
RecoverDatabaseFromBackupAction action = RecoverDatabaseFromBackupAction()
action.backupStorageUrl = "ssh://root:password@localhost:22/Cloud_bs"
action.backupInstallPath = "zstore://zsbak/0ed599ec519249489475112a058bb93a"
action.mysqlRootPassword = "password"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RecoverDatabaseFromBackupAction.Result res = action.call()导出数据库备份(ExportDatabaseBackupFromBackupStorage)
从备份存储导出数据库备份。
API请求
URLs
PUT zstack/v1/database-backups/{databaseBackupUuid}/backup-storage/{backupStorageUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"exportDatabaseBackupFromBackupStorage": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"exportDatabaseBackupFromBackupStorage":{}}' http://localhost:8080/zstack/v1/database-backups/6dae84793fc53f5b82034dd9a44c554b/backup-storage/cc9127f6af0e32c888044f49048788a1/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| backupStorageUuid | String | url | 镜像存储UUID | 3.0.0 | |
| databaseBackupUuid | String | url | 数据库备份UUID | 3.0.0 | |
| systemTags (可选) | List | body | 3.0.0 | ||
| userTags (可选) | List | body | 3.0.0 |
API返回
返回示例
{
"databaseBackupUrl": "http://127.0.0.1:8001/path/cloud-db-backup.gz"
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| databaseBackupUrl | String | 被导出备份的访问地址 | 3.0.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.0.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.0.0 |
| description | String | 错误的概要描述 | 3.0.0 |
| details | String | 错误的详细信息 | 3.0.0 |
| elaboration | String | 保留字段,默认为null | 3.0.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.0.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.0.0 |
SDK示例
Java
SDK
ExportDatabaseBackupFromBackupStorageAction action = new ExportDatabaseBackupFromBackupStorageAction();
action.backupStorageUuid = "cc9127f6af0e32c888044f49048788a1";
action.databaseBackupUuid = "6dae84793fc53f5b82034dd9a44c554b";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
ExportDatabaseBackupFromBackupStorageAction.Result res = action.call();Python
SDK
ExportDatabaseBackupFromBackupStorageAction action = ExportDatabaseBackupFromBackupStorageAction()
action.backupStorageUuid = "cc9127f6af0e32c888044f49048788a1"
action.databaseBackupUuid = "6dae84793fc53f5b82034dd9a44c554b"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
ExportDatabaseBackupFromBackupStorageAction.Result res = action.call()获取数据库备份(GetDatabaseBackupFromImageStore)
从备份存储获取导出的数据库备份。
API请求
URLs
GET zstack/v1/database-backups/image-storeHeaders
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/database-backups/image-store?url=ssh://root:password@localhost:22/Cloud_bs®istryPort=8000.0参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| url | String | query | 镜像存储URL | 3.0.0 | |
| registryPort (可选) | int | query | 镜像仓库访问端口 | 3.0.0 | |
| systemTags (可选) | List | query | 3.0.0 | ||
| userTags (可选) | List | query | 3.0.0 |
API返回
返回示例
{
"infos": [
{
"id": "270c67e3699f72ba",
"created": "Nov 14, 2017 10:20:57 PM",
"author": "cloud",
"arch": "amd64",
"size": 7995392.0,
"virtualsize": 1.268224E7,
"name": "78b6afbc9da73932a000fb9a75947962"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.0.0 |
| infos | List | 详情参考infos | 3.0.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.0.0 |
| description | String | 错误的概要描述 | 3.0.0 |
| details | String | 错误的详细信息 | 3.0.0 |
| elaboration | String | 保留字段,默认为null | 3.0.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.0.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.0.0 |
#infos
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| id | String | 镜像仓库中的id | 3.0.0 |
| parent | String | 父镜像名称 | 3.0.0 |
| blobsum | String | 镜像hash码 | 3.0.0 |
| created | Timestamp | 镜像提交时间 | 3.0.0 |
| author | String | 镜像制作者 | 3.0.0 |
| arch | String | 镜像的os结构 | 3.0.0 |
| desc | String | 镜像描述 | 3.0.0 |
| size | Long | 镜像的真实大小 | 3.0.0 |
| virtualsize | Long | 镜像的虚拟大小 | 3.0.0 |
| name | String | 镜像仓库中的镜像名称 | 3.0.0 |
SDK示例
Java
SDK
GetDatabaseBackupFromImageStoreAction action = new GetDatabaseBackupFromImageStoreAction();
action.url = "ssh://root:password@localhost:22/Cloud_bs";
action.registryPort = 8000.0;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetDatabaseBackupFromImageStoreAction.Result res = action.call();Python
SDK
GetDatabaseBackupFromImageStoreAction action = GetDatabaseBackupFromImageStoreAction()
action.url = "ssh://root:password@localhost:22/Cloud_bs"
action.registryPort = 8000.0
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetDatabaseBackupFromImageStoreAction.Result res = action.call()删除数据库备份 (DeleteExportedDatabaseBackupFromBackupStorage)
删除导出的数据库备份。
API请求
URLs
DELETE zstack/v1/exported-database-backup/{databaseBackupUuid}/backup-storage/{backupStorageUuid}Headers
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/exported-database-backup/341a599af82f3ecbab5d680e8dfb0276/backup-storage/737f27cb664c31a594f71080d481dddf?参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| backupStorageUuid | String | url | 镜像存储UUID | 3.0.0 | |
| databaseBackupUuid | String | url | 3.0.0 | ||
| systemTags (可选) | List | body | 3.0.0 | ||
| userTags (可选) | List | body | 3.0.0 |
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
DeleteExportedDatabaseBackupFromBackupStorageAction action = new DeleteExportedDatabaseBackupFromBackupStorageAction();
action.backupStorageUuid = "737f27cb664c31a594f71080d481dddf";
action.databaseBackupUuid = "341a599af82f3ecbab5d680e8dfb0276";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteExportedDatabaseBackupFromBackupStorageAction.Result res = action.call();Python
SDK
DeleteExportedDatabaseBackupFromBackupStorageAction action = DeleteExportedDatabaseBackupFromBackupStorageAction()
action.backupStorageUuid = "737f27cb664c31a594f71080d481dddf"
action.databaseBackupUuid = "341a599af82f3ecbab5d680e8dfb0276"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteExportedDatabaseBackupFromBackupStorageAction.Result res = action.call()同步至DS (SyncDatabaseBackupFromImageStoreBackupStorage)
同步备份至备份存储。
API请求
URLs
PUT zstack/v1/database-backups/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"syncDatabaseBackupFromImageStoreBackupStorage": {
"srcBackupStorageUuid": "72ad4c5419d63f5aaf37faf985c95a65",
"dstBackupStorageUuid": "76b2c6b412a73ef8a4263e659c104fff"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"syncDatabaseBackupFromImageStoreBackupStorage":{"srcBackupStorageUuid":"72ad4c5419d63f5aaf37faf985c95a65","dstBackupStorageUuid":"76b2c6b412a73ef8a4263e659c104fff"}}' http://localhost:8080/zstack/v1/database-backups/4594a949f00e3a55932f5b5e66ec9d67/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.0.0 | |
| srcBackupStorageUuid | String | body(包含在syncDatabaseBackupFromImageStoreBackupStorage结构中) | 3.0.0 | ||
| dstBackupStorageUuid | String | body(包含在syncDatabaseBackupFromImageStoreBackupStorage结构中) | 3.0.0 | ||
| systemTags (可选) | List | body | 3.0.0 | ||
| userTags (可选) | List | body | 3.0.0 |
API返回
返回示例
{
"inventory": {
"uuid": "c04683f1c53039d1bb0b0f0b601b5a5b",
"name": "Backup-1",
"description": "database backup",
"size": 1048576.0,
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.0.0 |
| inventory | DatabaseBackupInventory | 详情参考inventory | 3.0.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.0.0 |
| description | String | 错误的概要描述 | 3.0.0 |
| details | String | 错误的详细信息 | 3.0.0 |
| elaboration | String | 保留字段,默认为null | 3.0.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.0.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.0.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.0.0 |
| name | String | 资源名称 | 3.0.0 |
| description | String | 资源的详细描述 | 3.0.0 |
| state | String | 3.0.0 | |
| status | String | 3.0.0 | |
| size | Long | 3.0.0 | |
| metadata | String | 3.0.0 | |
| createDate | Timestamp | 创建时间 | 3.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.0.0 |
| backupStorageRefs | List | 详情参考backupStorageRefs | 3.0.0 |
#backupStorageRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| databaseBackupUuid | String | 3.0.0 | |
| backupStorageUuid | String | 镜像存储UUID | 3.0.0 |
| installPath | String | 3.0.0 | |
| exportUrl | String | 3.0.0 | |
| status | String | 3.0.0 | |
| createDate | Timestamp | 创建时间 | 3.0.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.0.0 |
SDK示例
Java
SDK
SyncDatabaseBackupFromImageStoreBackupStorageAction action = new SyncDatabaseBackupFromImageStoreBackupStorageAction();
action.uuid = "4594a949f00e3a55932f5b5e66ec9d67";
action.srcBackupStorageUuid = "72ad4c5419d63f5aaf37faf985c95a65";
action.dstBackupStorageUuid = "76b2c6b412a73ef8a4263e659c104fff";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SyncDatabaseBackupFromImageStoreBackupStorageAction.Result res = action.call();Python
SDK
SyncDatabaseBackupFromImageStoreBackupStorageAction action = SyncDatabaseBackupFromImageStoreBackupStorageAction()
action.uuid = "4594a949f00e3a55932f5b5e66ec9d67"
action.srcBackupStorageUuid = "72ad4c5419d63f5aaf37faf985c95a65"
action.dstBackupStorageUuid = "76b2c6b412a73ef8a4263e659c104fff"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
SyncDatabaseBackupFromImageStoreBackupStorageAction.Result res = action.call()定时任务组绑定触发器(AddSchedulerJobGroupToSchedulerTrigger)
API请求
URLs
POST zstack/v1/scheduler/jobgroups/{schedulerJobGroupUuid}/scheduler/triggers/{schedulerTriggerUuid}Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"triggerNow": false
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"triggerNow":false}}' http://localhost:8080/zstack/v1/scheduler/jobgroups/997c126bb3db39f6bbda1ffe90008f51/scheduler/triggers/78341d4e8f683a3291527f4944fa6831参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| schedulerJobGroupUuid | String | url | 定时任务组UUID | 3.4.0 | |
| schedulerTriggerUuid | String | url | 触发器UUID | 3.4.0 | |
| triggerNow (可选) | boolean | body(包含在params结构中) | 是否立即触发 | 3.4.0 | |
| systemTags (可选) | List | body | 系统标签列表 | 3.4.0 | |
| userTags (可选) | List | body | 用户标签列表 | 3.4.0 |
API返回
返回示例
{
"inventory": {
"schedulerJobGroupUuid": "ec8d2952f8f13747bbbf24f93585a63d",
"schedulerTriggerUuid": "4b5bc56b58623324afe0a57951a96064"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.4.0 |
| inventory | SchedulerJobGroupSchedulerTriggerRefInventory | 详情参考inventory | 3.4.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.4.0 |
| description | String | 错误的概要描述 | 3.4.0 |
| details | String | 错误的详细信息 | 3.4.0 |
| elaboration | String | 保留字段,默认为null | 3.4.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.4.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.4.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| schedulerJobGroupUuid | String | 定时任务组UUID | 3.4.0 |
| schedulerTriggerUuid | String | 触发器UUID | 3.4.0 |
| createDate | Timestamp | 创建时间 | 3.4.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.4.0 |
SDK示例
Java
SDK
AddSchedulerJobGroupToSchedulerTriggerAction action = new AddSchedulerJobGroupToSchedulerTriggerAction();
action.schedulerJobGroupUuid = "997c126bb3db39f6bbda1ffe90008f51";
action.schedulerTriggerUuid = "78341d4e8f683a3291527f4944fa6831";
action.triggerNow = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddSchedulerJobGroupToSchedulerTriggerAction.Result res = action.call();Python
SDK
AddSchedulerJobGroupToSchedulerTriggerAction action = AddSchedulerJobGroupToSchedulerTriggerAction()
action.schedulerJobGroupUuid = "997c126bb3db39f6bbda1ffe90008f51"
action.schedulerTriggerUuid = "78341d4e8f683a3291527f4944fa6831"
action.triggerNow = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddSchedulerJobGroupToSchedulerTriggerAction.Result res = action.call()定时任务组解绑触发器(RemoveSchedulerJobGroupFromSchedulerTrigger)
API请求
URLs
DELETE zstack/v1/scheduler/jobgroups/{schedulerJobGroupUuid}/scheduler/triggers/{schedulerTriggerUuid}Headers
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/scheduler/jobgroups/769b8cc2ba343736a919f4a849663fdb/scheduler/triggers/e0f1e497653b39639ff6eac7f6cd2e48?参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| schedulerJobGroupUuid | String | url | 定时任务组UUID | 3.4.0 | |
| schedulerTriggerUuid | String | url | 触发器UUID | 3.4.0 | |
| systemTags (可选) | List | body | 系统标签列表 | 3.4.0 | |
| userTags (可选) | List | body | 用户标签列表 | 3.4.0 |
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
RemoveSchedulerJobGroupFromSchedulerTriggerAction action = new RemoveSchedulerJobGroupFromSchedulerTriggerAction();
action.schedulerJobGroupUuid = "769b8cc2ba343736a919f4a849663fdb";
action.schedulerTriggerUuid = "e0f1e497653b39639ff6eac7f6cd2e48";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RemoveSchedulerJobGroupFromSchedulerTriggerAction.Result res = action.call();Python
SDK
RemoveSchedulerJobGroupFromSchedulerTriggerAction action = RemoveSchedulerJobGroupFromSchedulerTriggerAction()
action.schedulerJobGroupUuid = "769b8cc2ba343736a919f4a849663fdb"
action.schedulerTriggerUuid = "e0f1e497653b39639ff6eac7f6cd2e48"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RemoveSchedulerJobGroupFromSchedulerTriggerAction.Result res = action.call()触发定时器(RunSchedulerTrigger)
API请求
URLs
PUT zstack/v1/scheduler/triggers/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"runSchedulerTrigger": {},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"runSchedulerTrigger":{}}' http://localhost:8080/zstack/v1/scheduler/triggers/2a486c1cd0cd43f3ac40bd60c6dd6fc1/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 定时器UUID | 3.5.0 | |
| jobUuids (可选) | List | body(包含在runSchedulerTrigger结构中) | 可选触发的任务UUID | 3.5.0 | |
| systemTags (可选) | List | body | 3.5.0 | ||
| userTags (可选) | List | body | 3.5.0 |
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
RunSchedulerTriggerAction action = new RunSchedulerTriggerAction();
action.uuid = "61b439ee76004c51bc262324d6eaa332";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RunSchedulerTriggerAction.Result res = action.call();Python
SDK
RunSchedulerTriggerAction action = RunSchedulerTriggerAction()
action.uuid = "8a5ed7d3e0194c2a98d1ecb529b15875"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RunSchedulerTriggerAction.Result res = action.call()创建定时任务组(CreateSchedulerJobGroup)
API请求
URLs
POST zstack/v1/scheduler/jobgroupsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "job",
"description": "description",
"type": "startVm"
},
"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":"job","description":"description","type":"startVm"}}' http://localhost:8080/zstack/v1/scheduler/jobgroups参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name | String | body(包含在params结构中) | 资源名称 | 3.4.0 | |
| description (可选) | String | body(包含在params结构中) | 资源的详细描述 | 3.4.0 | |
| type | String | body(包含在params结构中) | 定时任务的类型 |
|
4.3.0 |
| parameters (可选) | Map | body(包含在params结构中) | 定时任务参数 | 3.4.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) | 资源UUID | 3.4.0 | |
| tagUuids (可选) | List | body(包含在params结构中) | 标签UUID列表 | 3.4.0 | |
| systemTags (可选) | List | body | 系统标签列表 | 3.4.0 | |
| userTags (可选) | List | body | 用户标签列表 | 3.4.0 |
API返回
返回示例
{
"inventory": {
"uuid": "0cd85a37bb88346c8c2d122913d812df",
"targetResourceUuid": "c458e0fb141932d0a87af999b0d0ab81",
"name": "SchedulerJob",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.4.0 |
| inventory | SchedulerJobInventory | 详情参考inventory | 3.4.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.4.0 |
| description | String | 错误的概要描述 | 3.4.0 |
| details | String | 错误的详细信息 | 3.4.0 |
| elaboration | String | 保留字段,默认为null | 3.4.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.4.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.4.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.4.0 |
| targetResourceUuid | String | 3.4.0 | |
| name | String | 资源名称 | 3.4.0 |
| description | String | 资源的详细描述 | 3.4.0 |
| state | String | 3.4.0 | |
| createDate | Timestamp | 创建时间 | 3.4.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.4.0 |
| triggersUuid | List | 3.4.0 |
SDK示例
Java
SDK
CreateSchedulerJobGroupAction action = new CreateSchedulerJobGroupAction();
action.name = "job";
action.description = "description";
action.type = "startVm";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateSchedulerJobGroupAction.Result res = action.call();Python
SDK
CreateSchedulerJobGroupAction action = CreateSchedulerJobGroupAction()
action.name = "job"
action.description = "description"
action.type = "startVm"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateSchedulerJobGroupAction.Result res = action.call()删除定时任务组(DeleteSchedulerJobGroup)
API请求
URLs
DELETE zstack/v1/scheduler/jobgroups/{uuid}Headers
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/scheduler/jobgroups/8bf8b175d6ce337eb24cbe37d9fe9b82参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 定时任务组的UUID,唯一标示该资源 | 3.4.0 | |
| deleteMode (可选) | String | body | 删除模式 | 3.4.0 | |
| systemTags (可选) | List | body | 系统标签列表 | 3.4.0 | |
| userTags (可选) | List | body | 用户标签列表 | 3.4.0 |
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
DeleteSchedulerJobGroupAction action = new DeleteSchedulerJobGroupAction();
action.uuid = "8bf8b175d6ce337eb24cbe37d9fe9b82";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteSchedulerJobGroupAction.Result res = action.call();Python
SDK
DeleteSchedulerJobGroupAction action = DeleteSchedulerJobGroupAction()
action.uuid = "8bf8b175d6ce337eb24cbe37d9fe9b82"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteSchedulerJobGroupAction.Result res = action.call()更新定时任务组(UpdateSchedulerJobGroup)
API请求
URLs
PUT zstack/v1/scheduler/jobgroups/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateSchedulerJobGroup": {
"name": "Test2",
"description": "new test"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateSchedulerJobGroup":{"name":"Test2","description":"new test"}}' http://localhost:8080/zstack/v1/scheduler/jobgroups/4dc1dbf847d733fc98ee2998b5e0eca2/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 定时任务组的UUID,唯一标示该资源 | 3.4.0 | |
| name (可选) | String | body(包含在updateSchedulerJobGroup结构中) | 资源名称 | 3.4.0 | |
| description (可选) | String | body(包含在updateSchedulerJobGroup结构中) | 资源的详细描述 | 3.4.0 | |
| state (可选) | String | body(包含在updateSchedulerJobGroup结构中) | 状态 |
|
3.4.0 |
| parameters (可选) | Map | body(包含在updateSchedulerJobGroup结构中) | 定时任务组参数 | 3.4.0 | |
| systemTags (可选) | List | body | 系统标签列表 | 3.4.0 | |
| userTags (可选) | List | body | 用户标签列表 | 3.4.0 |
API返回
返回示例
{
"inventory": {
"uuid": "e344fd75079735369cbffda253cc173c",
"name": "Test",
"description": "create volume snapshot job",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.4.0 |
| inventory | SchedulerJobGroupInventory | 详情参考inventory | 3.4.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.4.0 |
| description | String | 错误的概要描述 | 3.4.0 |
| details | String | 错误的详细信息 | 3.4.0 |
| elaboration | String | 保留字段,默认为null | 3.4.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.4.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.4.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 定时任务组的UUID,唯一标示该资源 | 3.4.0 |
| name | String | 定时任务组名称 | 3.4.0 |
| description | String | 定时任务组的详细描述 | 3.4.0 |
| state | String | 定时任务组的状态 | 3.4.0 |
| createDate | Timestamp | 创建时间 | 3.4.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.4.0 |
| jobData | String | 任务参数 | 3.4.0 |
| triggersUuid | List | 触发器UUID | 3.4.0 |
SDK示例
Java
SDK
UpdateSchedulerJobGroupAction action = new UpdateSchedulerJobGroupAction();
action.uuid = "4dc1dbf847d733fc98ee2998b5e0eca2";
action.name = "Test2";
action.description = "new test";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateSchedulerJobGroupAction.Result res = action.call();Python
SDK
UpdateSchedulerJobGroupAction action = UpdateSchedulerJobGroupAction()
action.uuid = "4dc1dbf847d733fc98ee2998b5e0eca2"
action.name = "Test2"
action.description = "new test"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateSchedulerJobGroupAction.Result res = action.call()查询定时任务组(QuerySchedulerJobGroup)
API请求
URLs
GET zstack/v1/scheduler/jobgroups
GET zstack/v1/scheduler/jobgroups/{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/scheduler/jobgroups?q=name=TestJobGroup&q=state=Enabledcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/scheduler/jobgroups/c5cb16296a1334d2ac3cd666e1deeca3可查询字段
运行CLI命令行工具,输入QuerySchedulerJobGroup并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "03dd26d45bb43bb094f3fdec29d78829",
"name": "test",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.4.0 |
| inventories | List | 详情参考inventories | 3.4.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.4.0 |
| description | String | 错误的概要描述 | 3.4.0 |
| details | String | 错误的详细信息 | 3.4.0 |
| elaboration | String | 保留字段,默认为null | 3.4.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.4.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.4.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 定时任务组的UUID,唯一标示该资源 | 3.4.0 |
| name | String | 定时任务组名称 | 3.4.0 |
| description | String | 定时任务组的详细描述 | 3.4.0 |
| state | String | 定时任务组的状态 | 3.4.0 |
| createDate | Timestamp | 创建时间 | 3.4.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.4.0 |
| jobData | String | 任务参数 | 3.4.0 |
| triggersUuid | List | 触发器UUID | 3.4.0 |
SDK示例
Java
SDK
QuerySchedulerJobGroupAction action = new QuerySchedulerJobGroupAction();
action.conditions = asList("name=TestJobGroup","state=Enabled");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QuerySchedulerJobGroupAction.Result res = action.call();Python
SDK
QuerySchedulerJobGroupAction action = QuerySchedulerJobGroupAction()
action.conditions = ["name=TestJobGroup","state=Enabled"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QuerySchedulerJobGroupAction.Result res = action.call()任务组添加任务(AddSchedulerJobsToSchedulerJobGroup)
API请求
URLs
POST zstack/v1/scheduler/jobgroups/{schedulerJobGroupUuid}/jobHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"schedulerJobUuids": [
"ed43fba83eb63a1cacb38c113e2bd38a"
]
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"schedulerJobUuids":["ed43fba83eb63a1cacb38c113e2bd38a"]}}' \
http://localhost:8080/zstack/v1/scheduler/jobgroups/280d3a22ab363006b61b4a6c0318056f/job参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| schedulerJobGroupUuid | String | url | 定时任务组UUID | 3.4.0 | |
| schedulerJobUuids | List | body(包含在params结构中) |
定时任务UUID列表 | 3.4.0 | |
| priorities (可选) | Map | body(包含在params结构中) |
定时任务优先级 | 4.3.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.4.0 | |
| userTags (可选) | List | body | 用户标签 | 3.4.0 |
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
AddSchedulerJobsToSchedulerJobGroupAction action = new AddSchedulerJobsToSchedulerJobGroupAction();
action.schedulerJobGroupUuid = "280d3a22ab363006b61b4a6c0318056f";
action.schedulerJobUuids = asList("ed43fba83eb63a1cacb38c113e2bd38a");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddSchedulerJobsToSchedulerJobGroupAction.Result res = action.call();Python
SDK
AddSchedulerJobsToSchedulerJobGroupAction action = AddSchedulerJobsToSchedulerJobGroupAction()
action.schedulerJobGroupUuid = "280d3a22ab363006b61b4a6c0318056f"
action.schedulerJobUuids = [ed43fba83eb63a1cacb38c113e2bd38a]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddSchedulerJobsToSchedulerJobGroupAction.Result res = action.call()定时任务组移除定时任务(RemoveSchedulerJobsFromSchedulerJobGroup)
API请求
URLs
DELETE zstack/v1/scheduler/jobgroups/{schedulerJobGroupUuid}/job/{schedulerJobUuids}Headers
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/scheduler/jobgroups/fa287a3654d330658db1863b8a41a660/job/[24634a04cc45397cb0298258a47ad650]参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| schedulerJobGroupUuid | String | url | 定时任务组UUID | 3.4.0 | |
| schedulerJobUuids | List | url | 定时任务i列表 | 3.4.0 | |
| systemTags (可选) | List | body | 系统标签列表 | 3.4.0 | |
| userTags (可选) | List | body | 用户标签列表 | 3.4.0 |
API返回
该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
RemoveSchedulerJobsFromSchedulerJobGroupAction action = new RemoveSchedulerJobsFromSchedulerJobGroupAction();
action.schedulerJobGroupUuid = "fa287a3654d330658db1863b8a41a660";
action.schedulerJobUuids = asList("24634a04cc45397cb0298258a47ad650");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RemoveSchedulerJobsFromSchedulerJobGroupAction.Result res = action.call();Python
SDK
RemoveSchedulerJobsFromSchedulerJobGroupAction action = RemoveSchedulerJobsFromSchedulerJobGroupAction()
action.schedulerJobGroupUuid = "fa287a3654d330658db1863b8a41a660"
action.schedulerJobUuids = [24634a04cc45397cb0298258a47ad650]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RemoveSchedulerJobsFromSchedulerJobGroupAction.Result res = action.call()查询定时任务记录(QuerySchedulerJobHistory)
API请求
URLs
GET zstack/v1/scheduler/job/historyHeaders
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/scheduler/job/history?q=schedulerJobGroupUuid=7ae6456c0b01324dae6d4bef358a5772可查询字段
运行CLI命令行工具,输入QuerySchedulerJobHistory并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"id": 1.0,
"triggerUuid": "add8c5eea85f41999baff295e47567bc",
"schedulerJobUuid": "d7696913343040d8b98de04d59727711",
"startTime": "Nov 14, 2017 10:20:57 PM",
"executeTime": 900.0,
"targetResourceUuid": "7cd923fa779044fd8510e8ee97aa579e",
"requestDump": "{\"bsUuid\":\"716078c20a0047a69102174c6097a690\"}",
"resultDump": "{\"apiId\":\"f8cf5b6281164e519c0575a73b1b0d9c\",\"success\":true,\"headers\":{},\"id\":\"d70a61ab1b20407c8df94ba7d90be081\",\"createdTime\":1557305707668}",
"success": true
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.5.0 |
| inventories | List | 详情参考inventories | 3.5.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.5.0 |
| description | String | 错误的概要描述 | 3.5.0 |
| details | String | 错误的详细信息 | 3.5.0 |
| elaboration | String | 保留字段,默认为null | 3.5.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.5.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.5.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| id | long | 3.5.0 | |
| triggerUuid | String | 定时器UUID | 3.5.0 |
| schedulerJobUuid | String | 定时任务UUID | 3.5.0 |
| schedulerJobGroupUuid | String | 定时任务组UUID | 3.5.0 |
| startTime | Timestamp | 开始时间 | 3.5.0 |
| executeTime | long | 执行时长 | 3.5.0 |
| targetResourceUuid | String | 目标资源UUID | 3.5.0 |
| requestDump | String | 任务请求 | 3.5.0 |
| resultDump | String | 任务结果 | 3.5.0 |
| success | boolean | 3.5.0 |
SDK示例
Java
SDK
QuerySchedulerJobHistoryAction action = new QuerySchedulerJobHistoryAction();
action.conditions = asList("schedulerJobGroupUuid=7ae6456c0b01324dae6d4bef358a5772");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QuerySchedulerJobHistoryAction.Result res = action.call();Python
SDK
QuerySchedulerJobHistoryAction action = QuerySchedulerJobHistoryAction()
action.conditions = ["schedulerJobGroupUuid=7ae6456c0b01324dae6d4bef358a5772"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QuerySchedulerJobHistoryAction.Result res = action.call()获取定时任务执行报告(GetSchedulerExecutionReport)
API请求
URLs
GET zstack/v1/scheduler/reportHeaders
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/scheduler/report?startTime=1.5856704E12&intervalTimeUnit=Month&range=4.0&schedulerJobTypes=vmBackup参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| startTime | long | query | 报告开始时间 | 3.9.0 | |
| intervalTimeUnit | String | query | 间隔时间单位 |
|
3.9.0 |
| range | int | query | 报告时间范围 | 3.9.0 | |
| schedulerJobTypes | List | query | 定时任务类型 | 3.9.0 | |
| systemTags (可选) | List | query | 3.9.0 | ||
| userTags (可选) | List | query | 3.9.0 |
API返回
返回示例
{
"successRecords": [
100.0,
99.0,
50.0,
0.0
],
"failureRecords": [
0.0,
1.0,
34.0,
0.0
],
"partialSuccessRecords": [
0.0,
0.0,
16.0,
0.0
],
"waitingRecords": [
0.0,
0.0,
0.0,
100.0
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| successRecords | List | 成功记录 | 3.9.0 |
| failureRecords | List | 失败记录 | 3.9.0 |
| partialSuccessRecords | List | 部分成功记录 | 3.9.0 |
| waitingRecords | List | 等待执行完成记录 | 3.9.0 |
| success | boolean | 3.9.0 | |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.9.0 |
| error | ErrorCode | 详情参考error | 3.9.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.9.0 |
| description | String | 错误的概要描述 | 3.9.0 |
| details | String | 错误的详细信息 | 3.9.0 |
| elaboration | String | 保留字段,默认为null | 3.9.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.9.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.9.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.9.0 |
| description | String | 错误的概要描述 | 3.9.0 |
| details | String | 错误的详细信息 | 3.9.0 |
| elaboration | String | 保留字段,默认为null | 3.9.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.9.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.9.0 |
SDK示例
Java
SDK
GetSchedulerExecutionReportAction action = new GetSchedulerExecutionReportAction();
action.startTime = 1.5856704E12;
action.intervalTimeUnit = "Month";
action.range = 4.0;
action.schedulerJobTypes = asList("vmBackup");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetSchedulerExecutionReportAction.Result res = action.call();Python
SDK
GetSchedulerExecutionReportAction action = GetSchedulerExecutionReportAction()
action.startTime = 1.5856704E12
action.intervalTimeUnit = "Month"
action.range = 4.0
action.schedulerJobTypes = [vmBackup]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetSchedulerExecutionReportAction.Result res = action.call()复用镜像存储为备份存储(AddDisasterImageStoreBackupStorage)
API请求
URLs
POST zstack/v1/backup-storage/image-store/disasterHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"attachPoint": "/test-bs",
"endPoint": "test12345-snp99.cn-shanghai.nas.aliyuncs.com",
"hostname": "192.168.1.8",
"username": "admin",
"password": "admin%pass",
"sshPort": 22,
"url": "/data/imagestore",
"name": "ImageStore",
"importImages": false
},
"systemTags": [],
"userTags": []
}Note: 上述示例中
systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"attachPoint":"/test-bs","endPoint":"test12345-snp99.cn-shanghai.nas.aliyuncs.com","hostname":"192.168.1.8","username":"admin","password":"admin%pass","sshPort":22,"url":"/data/imagestore","name":"ImageStore","importImages":false}}' \
http://localhost:8080/zstack/v1/backup-storage/image-store/disaster参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| attachPoint (可选) | String | body(包含在params结构中) |
0.6 | ||
| endPoint (可选) | String | body(包含在params结构中) |
0.6 | ||
| hostname | String | body(包含在params结构中) |
0.6 | ||
| username | String | body(包含在params结构中) |
0.6 | ||
| password (可选) | String | body(包含在params结构中) |
0.6 | ||
| sshPort (可选) | int | body(包含在params结构中) |
0.6 | ||
| url | String | body(包含在params结构中) |
0.6 | ||
| name | String | body(包含在params结构中) |
资源名称 | 0.6 | |
| description (可选) | String | body(包含在params结构中) |
资源的详细描述 | 0.6 | |
| type (可选) | String | body(包含在params结构中) |
0.6 | ||
| importImages (可选) | boolean | body(包含在params结构中) |
0.6 | ||
| resourceUuid (可选) | String | body(包含在params结构中) |
资源UUID | 0.6 | |
| tagUuids (可选) | List | body(包含在params结构中) |
标签UUID列表 | 3.4.0 | |
| systemTags (可选) | List | body | 系统标签 | 0.6 | |
| userTags (可选) | List | body | 用户标签 | 0.6 |
API返回
该API成功时返回一个空的JSON结构
{},出错时返回的JSON结构包含一个error字段,例如:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
AddDisasterImageStoreBackupStorageAction action = new AddDisasterImageStoreBackupStorageAction();
action.attachPoint = "/test-bs";
action.endPoint = "test12345-snp99.cn-shanghai.nas.aliyuncs.com";
action.hostname = "192.168.1.8";
action.username = "admin";
action.password = "admin%pass";
action.sshPort = 22;
action.url = "/data/imagestore";
action.name = "ImageStore";
action.importImages = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddDisasterImageStoreBackupStorageAction.Result res = action.call();Python
SDK
AddDisasterImageStoreBackupStorageAction action = AddDisasterImageStoreBackupStorageAction()
action.attachPoint = "/test-bs"
action.endPoint = "test12345-snp99.cn-shanghai.nas.aliyuncs.com"
action.hostname = "192.168.1.8"
action.username = "admin"
action.password = "admin%pass"
action.sshPort = 22
action.url = "/data/imagestore"
action.name = "ImageStore"
action.importImages = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddDisasterImageStoreBackupStorageAction.Result res = action.call()