文档目录

从快照创建云主机(CreateVmInstanceFromVolumeSnapshot)

API请求

URLs
POST zstack/v1/vm-instances/from/volume-snapshots/{volumeSnapshotUuid}
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "name": "vm1",
    "description": "this is a vm",
    "instanceOfferingUuid": "6900e329296732aca0e3658bcdcdd3ce",
    "l3NetworkUuids": [
      "990ffab4793036d29fc92142889f9ef2"
    ],
    "clusterUuid": "cd44bab6f1d43e59bbc885f869e89388",
    "strategy": "InstantStart"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTagsuserTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"vm1","description":"this is a vm","instanceOfferingUuid":"6900e329296732aca0e3658bcdcdd3ce","l3NetworkUuids":["990ffab4793036d29fc92142889f9ef2"],"clusterUuid":"cd44bab6f1d43e59bbc885f869e89388","strategy":"InstantStart"}}' http://localhost:8080/zstack/v1/vm-instances/from/volume-snapshots/f81c959344783f19ae4fc76f1e770201
参数列表
名字 类型 位置 描述 可选值 起始版本
name String body(包含在params结构中) 资源名称 4.1.0
description (可选) String body(包含在params结构中) 资源的详细描述 4.1.0
instanceOfferingUuid (可选) String body(包含在params结构中) 计算规格UUID 4.1.0
cpuNum (可选) Integer body(包含在params结构中) CPU数量 4.1.0
memorySize (可选) Long body(包含在params结构中) 内存大小 4.1.0
l3NetworkUuids List body(包含在params结构中) 三层网络UUID 4.1.0
type (可选) String body(包含在params结构中) 云主机系统平台类型
  • UserVm
  • ApplianceVm
4.1.0
volumeSnapshotUuid String url 快照组UUID 4.1.0
platform (可选) String body(包含在params结构中) 云主机系统平台类型
  • Linux
  • Windows
  • Other
  • Paravirtualization
  • WindowsVirtio
4.1.0
zoneUuid (可选) String body(包含在params结构中) 区域UUID 4.1.0
clusterUuid (可选) String body(包含在params结构中) 集群UUID 4.1.0
hostUuid (可选) String body(包含在params结构中) 物理机UUID 4.1.0
primaryStorageUuid (可选) String body(包含在params结构中) 主存储UUID 4.1.0
defaultL3NetworkUuid (可选) String body(包含在params结构中) 默认三层网络UUID 4.1.0
strategy (可选) String body(包含在params结构中) 创建策略
  • InstantStart
  • CreateStopped
4.1.0
resourceUuid (可选) String body(包含在params结构中) 资源UUID 4.1.0
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 4.1.0
systemTags (可选) List body 系统标签 4.1.0
userTags (可选) List body 用户标签 4.1.0

API返回

返回示例
{
  "inventory": {
    "uuid": "109d10001c5c3553a7f2333e6a48610a",
    "name": "Test-VM",
    "description": "web server VM",
    "zoneUuid": "f31cb809cf0b3c668953e2507d5467b2",
    "clusterUuid": "fdfdf92e7bbe3212ab6530b11d8e0af5",
    "imageUuid": "96acc892dd793fb98c1924d54eb27a88",
    "hostUuid": "8eb85f51f10c30c0a6305b73d2002899",
    "lastHostUuid": "59ae08c1f6ed3638b6e4aa35b5a30d2e",
    "instanceOfferingUuid": "8b6d6aabad773972a0549539099e3e68",
    "rootVolumeUuid": "70eda0fe06163e67accf01a266fd5274",
    "platform": "Linux",
    "defaultL3NetworkUuid": "5ec42284ceaa3ad18f2b498e98ab6acc",
    "type": "UserVm",
    "hypervisorType": "KVM",
    "memorySize": 8.589934592E9,
    "cpuNum": 1.0,
    "allocatorStrategy": "LastHostPreferredAllocatorStrategy",
    "createDate": "Nov 14, 2017 10:20:57 PM",
    "lastOpDate": "Nov 14, 2017 10:20:57 PM",
    "state": "Running",
    "vmNics": [
      {
        "uuid": "b6d840187f1932209c21888923f5f35e",
        "vmInstanceUuid": "109d10001c5c3553a7f2333e6a48610a",
        "usedIpUuid": "54e8db987a4a333c80a87e4a84ab7675",
        "l3NetworkUuid": "5ec42284ceaa3ad18f2b498e98ab6acc",
        "ip": "192.168.1.10",
        "mac": "00:0c:29:bd:99:fc",
        "hypervisorType": "KVM",
        "netmask": "255.255.255.0",
        "gateway": "192.168.1.1",
        "deviceId": 0.0,
        "createDate": "Nov 14, 2017 10:20:57 PM",
        "lastOpDate": "Nov 14, 2017 10:20:57 PM"
      }
    ],
    "allVolumes": [
      {
        "uuid": "70eda0fe06163e67accf01a266fd5274",
        "name": "Root-Volume-For-VM-109d10001c5c3553a7f2333e6a48610a",
        "primaryStorageUuid": "0739abbe904639649da74cdcf0abd25f",
        "vmInstanceUuid": "109d10001c5c3553a7f2333e6a48610a",
        "rootImageUuid": "96acc892dd793fb98c1924d54eb27a88",
        "installPath": "/Cloud_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-70eda0fe06163e67accf01a266fd5274/70eda0fe06163e67accf01a266fd5274.qcow2",
        "type": "Root",
        "format": "qcow2",
        "size": 1.073741824E11,
        "actualSize": 2.147483648E10,
        "deviceId": 0.0,
        "state": "Enabled",
        "status": "Ready",
        "createDate": "Nov 14, 2017 10:20:57 PM",
        "lastOpDate": "Nov 14, 2017 10:20:57 PM"
      }
    ]
  }
}
名字 类型 描述 起始版本
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 4.1.0
inventory VmInstanceInventory 详情参考inventory 4.1.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 4.1.0
description String 错误的概要描述 4.1.0
details String 错误的详细信息 4.1.0
elaboration String 保留字段,默认为null 4.1.0
opaque LinkedHashMap 保留字段,默认为null 4.1.0
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 4.1.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.1.0
name String 资源名称 4.1.0
description String 资源的详细描述 4.1.0
zoneUuid String 区域UUID 4.1.0
clusterUuid String 集群UUID 4.1.0
imageUuid String 镜像UUID 4.1.0
hostUuid String 物理机UUID 4.1.0
lastHostUuid String 4.1.0
instanceOfferingUuid String 计算规格UUID 4.1.0
rootVolumeUuid String 根云盘UUID 4.1.0
platform String 4.1.0
defaultL3NetworkUuid String 4.1.0
type String 4.1.0
hypervisorType String 4.1.0
memorySize Long 4.1.0
cpuNum Integer 4.1.0
cpuSpeed Long 4.1.0
allocatorStrategy String 4.1.0
createDate Timestamp 创建时间 4.1.0
lastOpDate Timestamp 最后一次修改时间 4.1.0
state String 4.1.0
vmNics List 详情参考vmNics 4.1.0
allVolumes List 详情参考allVolumes 4.1.0
#vmNics
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.1.0
vmInstanceUuid String 云主机UUID 4.1.0
l3NetworkUuid String 三层网络UUID 4.1.0
ip String IP地址 4.1.0
mac String MAC地址 4.1.0
hypervisorType String 虚拟化类型 4.1.0
netmask String 子网掩码 4.1.0
gateway String 网关 4.1.0
metaData String 4.1.0
ipVersion Integer IP地址版本 4.1.0
deviceId Integer 设备ID 4.1.0
type String 网卡类型 4.1.0
createDate Timestamp 创建时间 4.1.0
lastOpDate Timestamp 最后一次修改时间 4.1.0
usedIps List 详情参考usedIps 4.1.0
#usedIps
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.1.0
ipRangeUuid String IP段UUID 4.1.0
l3NetworkUuid String 三层网络UUID 4.1.0
ipVersion Integer IP协议号 4.1.0
ip String IP地址 4.1.0
netmask String 网络掩码 4.1.0
gateway String 网关地址 4.1.0
usedFor String 4.1.0
ipInLong long 4.1.0
vmNicUuid String 云主机网卡UUID 4.1.0
createDate Timestamp 创建时间 4.1.0
lastOpDate Timestamp 最后一次修改时间 4.1.0
#allVolumes
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.1.0
name String 资源名称 4.1.0
description String 资源的详细描述 4.1.0
primaryStorageUuid String 主存储UUID 4.1.0
vmInstanceUuid String 云主机UUID 4.1.0
diskOfferingUuid String 云盘规格UUID 4.1.0
rootImageUuid String 云盘根镜像UUID 4.1.0
installPath String 云盘在主存储上的路径 4.1.0
type String 云盘类型,数据云盘/根云盘 4.1.0
format String 云盘格式 4.1.0
size Long 云盘大小 4.1.0
actualSize Long 云盘真实大小 4.1.0
deviceId Integer 4.1.0
state String 云盘是否开启 4.1.0
status String 云盘状态 4.1.0
createDate Timestamp 创建时间 4.1.0
lastOpDate Timestamp 最后一次修改时间 4.1.0
isShareable Boolean 是否共享云盘 4.1.0
volumeQos String 云盘Qos,格式如total=1048576 4.1.0

SDK示例

Java SDK
CreateVmInstanceFromVolumeSnapshotGroupAction action = new CreateVmInstanceFromVolumeSnapshotGroupAction();
action.name = "vm1";
action.description = "this is a vm";
action.instanceOfferingUuid = "5dda0d1013a433e9959967199f819c60";
action.l3NetworkUuids = asList("5fc19e24bedc32f58116ce6d63247f1a");
action.volumeSnapshotGroupUuid = "da7e81e1d1793fdab7d5d05268d680a2";
action.clusterUuid = "984aef8dfbb33c069c62fac5249ab044";
action.strategy = "InstantStart";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVmInstanceFromVolumeSnapshotGroupAction.Result res = action.call();
Python SDK
CreateVmInstanceFromVolumeSnapshotGroupAction action = CreateVmInstanceFromVolumeSnapshotGroupAction()
action.name = "vm1"
action.description = "this is a vm"
action.instanceOfferingUuid = "5dda0d1013a433e9959967199f819c60"
action.l3NetworkUuids = [5fc19e24bedc32f58116ce6d63247f1a]
action.volumeSnapshotGroupUuid = "da7e81e1d1793fdab7d5d05268d680a2"
action.clusterUuid = "984aef8dfbb33c069c62fac5249ab044"
action.strategy = "InstantStart"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateVmInstanceFromVolumeSnapshotGroupAction.Result res = action.call()
开发手册 | 5.5.30 | ZStack Cloud · ZCF | ZStack 资源中心