从硬盘快照创建根硬盘镜像

POST/zstack/v1/images/root-volume-templates/from/volume-snapshots/{snapshotUuid}

从硬盘快照创建根硬盘镜像。

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "name": "My Root Volume Template",
    "backupStorageUuids": [
      "41a9753ebf8031ef83b41ebed095b783"
    ],
    "system": false
  },
  "systemTags": [],
  "userTags": []
}

上述示例中systemTagsuserTags字段可以省略。列出是为了表示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(包含在params结构中)

根硬盘镜像的详细描述

 

0.6

guestOsType (可选)

String

body(包含在params结构中)

根硬盘客户机操作系统类型

 

0.6

backupStorageUuids

List

body(包含在params结构中)

镜像仓库UUID列表

 

0.6

platform (可选)

String

body(包含在params结构中)

根硬盘镜像对应的系统平台

  • Linux
  • Windows
  • WindowsVirtio
  • Other
  • Paravirtualization

0.6

system (可选)

boolean

body(包含在params结构中)

是否系统根硬盘镜像

 

0.6

resourceUuid (可选)

String

body(包含在params结构中)

根硬盘镜像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"
      }
    ]
  }
}
名字类型描述起始版本
errorErrorCode错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error0.6
inventoryImageInventory详情参考inventory0.6
failuresList详情参考failures0.6

error

名字类型描述起始版本
codeString错误码号,错误的全局唯一标识,例如SYS.1000, HOST.10010.6
descriptionString错误的概要描述0.6
detailsString错误的详细信息0.6
elaborationString保留字段,默认为null0.6
opaqueLinkedHashMap保留字段,默认为null0.6
causeErrorCode根错误,引发当前错误的源错误,若无原错误,该字段为null0.6

inventory

名字类型描述起始版本
uuidString资源的UUID,唯一标示该资源0.6
nameString资源名称0.6
descriptionString资源的详细描述0.6
stateString镜像的启动状态4.0.0
statusString镜像的就绪状态4.0.0
sizeLong镜像大小4.0.0
actualSizeLong镜像真实容量4.0.0
md5SumString镜像的md5值4.0.0
urlString镜像的URL地址4.0.0
mediaTypeString镜像的类型4.0.0
guestOsTypeString镜像对应的客户机操作系统类型4.0.0
typeString内部使用字段4.0.0
platformString镜像的系统平台4.0.0
formatString镜像的格式,比如:raw4.0.0
systemBoolean标识是否为系统镜像4.0.0
createDateTimestamp创建时间0.6
lastOpDateTimestamp最后一次修改时间0.6
backupStorageRefsList详情参考backupStorageRefs0.6

backupStorageRefs

名字类型描述起始版本
imageUuidString镜像UUID0.6
backupStorageUuidString镜像存储UUID0.6
installPathString在镜像仓库上的安装路径4.0.0
exportUrlString导出镜像的url4.0.0
exportMd5SumString导出镜像的md5值4.0.0
statusString镜像就绪状态4.0.0
createDateTimestamp创建时间0.6
lastOpDateTimestamp最后一次修改时间0.6

failures

名字类型描述起始版本
backupStorageUuidString镜像存储UUID0.6
errorErrorCode详情参考error0.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()