从硬盘快照创建根硬盘镜像
从硬盘快照创建根硬盘镜像。
Headers
Authorization: OAuth the-session-uuidBody
{
"params": {
"name": "My Root Volume Template",
"backupStorageUuids": [
"41a9753ebf8031ef83b41ebed095b783"
],
"system": false
},
"systemTags": [],
"userTags": []
}上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"My Root Volume Template","backupStorageUuids":["41a9753ebf8031ef83b41ebed095b783"],"system":false}}' \
http://localhost:8080/zstack/v1/images/root-volume-templates/from/volume-snapshots/f31fda67d1be32998cef3f3d9a280e1c参数列表
名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
snapshotUuid | String | url | 快照UUID |
| 0.6 |
name | String | body(包含在params结构中) | 根硬盘镜像名称 |
| 0.6 |
description (可选) | String | body(包含在 | 根硬盘镜像的详细描述 |
| 0.6 |
guestOsType (可选) | String | body(包含在 | 根硬盘客户机操作系统类型 |
| 0.6 |
backupStorageUuids | List | body(包含在 | 镜像仓库UUID列表 |
| 0.6 |
platform (可选) | String | body(包含在 | 根硬盘镜像对应的系统平台 |
| 0.6 |
system (可选) | boolean | body(包含在 | 是否系统根硬盘镜像 |
| 0.6 |
resourceUuid (可选) | String | body(包含在 | 根硬盘镜像UUID。若指定,根硬盘镜像会使用该字段值作为UUID。 |
| 0.6 |
architecture (可选) | String | body(包含在params结构中) |
|
| 4.0.0 |
tagUuids (可选) | List | body(包含在params结构中) | 标签UUID列表 |
| 4.0.0 |
systemTags (可选) | List | body | 系统标签 |
| 0.6 |
userTags (可选) | List | body | 用户标签 |
| 0.6 |
API返回
返回示例
{
"inventory": {
"uuid": "cfe7842a8c1a30a1870965a7d6133760",
"name": "My Root Volume Template",
"mediaType": "RootVolumeTemplate",
"platform": "Linux",
"format": "raw",
"backupStorageRefs": [
{
"id": 0.0,
"imageUuid": "cfe7842a8c1a30a1870965a7d6133760",
"backupStorageUuid": "f5f16e1618323606a7501b50be251c05",
"installPath": "ceph://zs-images/0cd599ec519249489475112a058bb93a",
"status": "Ready"
}
]
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 0.6 |
| inventory | ImageInventory | 详情参考inventory | 0.6 |
| failures | List | 详情参考failures | 0.6 |
error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 0.6 |
| description | String | 错误的概要描述 | 0.6 |
| details | String | 错误的详细信息 | 0.6 |
| elaboration | String | 保留字段,默认为null | 0.6 |
| opaque | LinkedHashMap | 保留字段,默认为null | 0.6 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 0.6 |
inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 0.6 |
| name | String | 资源名称 | 0.6 |
| description | String | 资源的详细描述 | 0.6 |
| state | String | 镜像的启动状态 | 4.0.0 |
| status | String | 镜像的就绪状态 | 4.0.0 |
| size | Long | 镜像大小 | 4.0.0 |
| actualSize | Long | 镜像真实容量 | 4.0.0 |
| md5Sum | String | 镜像的md5值 | 4.0.0 |
| url | String | 镜像的URL地址 | 4.0.0 |
| mediaType | String | 镜像的类型 | 4.0.0 |
| guestOsType | String | 镜像对应的客户机操作系统类型 | 4.0.0 |
| type | String | 内部使用字段 | 4.0.0 |
| platform | String | 镜像的系统平台 | 4.0.0 |
| format | String | 镜像的格式,比如:raw | 4.0.0 |
| system | Boolean | 标识是否为系统镜像 | 4.0.0 |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
| backupStorageRefs | List | 详情参考backupStorageRefs | 0.6 |
backupStorageRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| imageUuid | String | 镜像UUID | 0.6 |
| backupStorageUuid | String | 镜像存储UUID | 0.6 |
| installPath | String | 在镜像仓库上的安装路径 | 4.0.0 |
| exportUrl | String | 导出镜像的url | 4.0.0 |
| exportMd5Sum | String | 导出镜像的md5值 | 4.0.0 |
| status | String | 镜像就绪状态 | 4.0.0 |
| createDate | Timestamp | 创建时间 | 0.6 |
| lastOpDate | Timestamp | 最后一次修改时间 | 0.6 |
failures
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| backupStorageUuid | String | 镜像存储UUID | 0.6 |
| error | ErrorCode | 详情参考error | 0.6 |
SDK示例
Java SDK
CreateRootVolumeTemplateFromVolumeSnapshotAction action = new CreateRootVolumeTemplateFromVolumeSnapshotAction();
action.snapshotUuid = "f31fda67d1be32998cef3f3d9a280e1c";
action.name = "My Root Volume Template";
action.backupStorageUuids = asList("41a9753ebf8031ef83b41ebed095b783");
action.system = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateRootVolumeTemplateFromVolumeSnapshotAction.Result res = action.call();Python SDK
CreateRootVolumeTemplateFromVolumeSnapshotAction action = CreateRootVolumeTemplateFromVolumeSnapshotAction()
action.snapshotUuid = "f31fda67d1be32998cef3f3d9a280e1c"
action.name = "My Root Volume Template"
action.backupStorageUuids = [41a9753ebf8031ef83b41ebed095b783]
action.system = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateRootVolumeTemplateFromVolumeSnapshotAction.Result res = action.call()