VM Related Interfaces

Create VM from Volume Snapshot Group

POST/zstack/v1/vm-instances/from/volume-snapshots/group/{volumeSnapshotGroupUuid}

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "name": "vm1",
    "description": "this is a vm",
    "instanceOfferingUuid": "5dda0d1013a433e9959967199f819c60",
    "l3NetworkUuids": [
      "5fc19e24bedc32f58116ce6d63247f1a"
    ],
    "clusterUuid": "984aef8dfbb33c069c62fac5249ab044",
    "strategy": "InstantStart"
  },
  "systemTags": [],
  "userTags": []
}

In the example above, systemTags and userTags fields can be omitted. They are listed to indicate that the body can contain these two fields.

Curl Example

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":"5dda0d1013a433e9959967199f819c60","l3NetworkUuids":["5fc19e24bedc32f58116ce6d63247f1a"],"clusterUuid":"984aef8dfbb33c069c62fac5249ab044","strategy":"InstantStart"}}' http://localhost:8080/zstack/v1/vm-instances/from/volume-snapshots/group/da7e81e1d1793fdab7d5d05268d680a2

Parameter List

Name

Type

Location

Description

Allowed Values

Starting Version

name

String

body (included in params structure)

Resource name

 

4.1.0

description (optional)

String

body (included in params structure)

Resource description

 

4.1.0

instanceOfferingUuid (optional)

String

body (included in params structure)

Instance offering UUID

 

4.1.0

cpuNum (optional)

Integer

body (included in params structure)

CPU number

 

4.1.0

memorySize (optional)

Long

body (included in params structure)

Memory size

 

4.1.0

l3NetworkUuids (optional)

List

body (included in params structure)

L3 network UUID list

 

4.1.0

type (optional)

String

body (included in params structure)

VM type

  • UserVm
  • ApplianceVm

4.1.0

volumeSnapshotGroupUuid

String

url

Volume snapshot group UUID

 

4.1.0

zoneUuid (optional)

String

body (included in params structure)

Data Center UUID

 

4.1.0

clusterUuid (optional)

String

body (included in params structure)

Cluster UUID

 

4.1.0

hostUuid (optional)

String

body (included in params structure)

Host UUID

 

4.1.0

primaryStorageUuidForRootVolume (optional)

String

body (included in params structure)

Root volume primary storage UUID

 

4.1.0

defaultL3NetworkUuid (optional)

String

body (included in params structure)

Default L3 network UUID

 

4.1.0

strategy (optional)

String

body (included in params structure)

Creation strategy

  • InstantStart
  • CreateStopped

4.1.0

resourceUuid (optional)

String

body (included in params structure)

Resource UUID

 

4.1.0

tagUuids (optional)

List

body (included in params structure)

Tag UUID list

 

4.1.0

systemTags (optional)

List

body

System tags

 

4.1.0

userTags (optional)

List

body

User tags

 

4.1.0

rootVolumeSystemTags (optional)

List

body (included in params structure)

Root disk system tags

 

4.1.0

dataVolumeSystemTags (optional)

Map

body (included in params structure)

Data disk system tags. Key is the snapshot UUID

 

4.1.0

reservedMemorySize (optional)

Long

body (included in params structure)

 

 

4.7.21

vmNicParams (optional)

String

body (included in params structure)

NIC information

 

4.10.10

resetTpm (optional)

Boolean

body (included in params structure)

Whether to reset the TPM state

 

5.0.0

API Response

Response Example

{
  "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": 8589934592,
    "cpuNum": 1,
    "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,
        "state": "enable",
        "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": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-70eda0fe06163e67accf01a266fd5274/70eda0fe06163e67accf01a266fd5274.qcow2",
        "type": "Root",
        "format": "qcow2",
        "size": 107374182400,
        "actualSize": 21474836480,
        "deviceId": 0,
        "state": "Enabled",
        "status": "Ready",
        "createDate": "Nov 14, 2017 10:20:57 PM",
        "lastOpDate": "Nov 14, 2017 10:20:57 PM"
      }
    ]
  }
}
NameTypeDescriptionStarting Version
successboolean 0.6
errorErrorCodeError code. If not null, the operation failed. If null, the operation succeeded. See error for details.4.1.0
inventoryVmInstanceInventorySee inventory for details.4.1.0

error

NameTypeDescriptionStarting Version
codeStringError code. A globally unique identifier for the error, for example SYS.1000, HOST.10014.1.0
descriptionStringBrief description of the error4.1.0
detailsStringDetailed error information4.1.0
elaborationStringReserved field, defaults to null4.1.0
opaqueLinkedHashMapReserved field, defaults to null4.1.0
causeErrorCodeRoot error. The error that caused this error. If there is no original error, this field is null4.1.0

inventory

NameTypeDescriptionStarting Version
uuidStringResource UUID. Uniquely identifies the resource4.1.0
nameStringResource name4.1.0
descriptionStringResource description4.1.0
zoneUuidStringData Center UUID4.1.0
clusterUuidStringCluster UUID4.1.0
imageUuidStringImage UUID4.1.0
hostUuidStringHost UUID4.1.0
lastHostUuidString 4.1.0
instanceOfferingUuidStringInstance offering UUID4.1.0
rootVolumeUuidStringRoot disk UUID4.1.0
platformString 4.1.0
architectureString 0.6
defaultL3NetworkUuidString 4.1.0
typeString 4.1.0
hypervisorTypeString 4.1.0
memorySizeLong 4.1.0
cpuNumInteger 4.1.0
cpuSpeedLong 4.1.0
allocatorStrategyString 4.1.0
createDateTimestampCreate time4.1.0
lastOpDateTimestampLast modification time4.1.0
stateString 4.1.0
guestOsTypeString 4.1.2
vmNicsListSee vmNics for details.4.1.0
allVolumesListSee allVolumes for details.4.1.0
vmCdRomsListSee vmCdRoms for details.0.6

vmNics

NameTypeDescriptionStarting Version
uuidStringResource UUID. Uniquely identifies the resource4.1.0
vmInstanceUuidStringVM UUID4.1.0
l3NetworkUuidStringL3 network UUID4.1.0
ipStringIP address4.1.0
macStringMAC address4.1.0
hypervisorTypeStringVirtualization type4.1.0
netmaskStringSubnet mask4.1.0
gatewayStringGateway4.1.0
metaDataString 4.1.0
ipVersionIntegerIP address version4.1.0
driverTypeString 4.7.13
internalNameString 4.7.13
deviceIdIntegerDevice ID4.1.0
typeStringNIC type4.1.0
stateStringNIC state4.7.13
createDateTimestampCreate time4.1.0
lastOpDateTimestampLast modification time4.1.0
usedIpsListSee usedIps for details.4.1.0

usedIps

NameTypeDescriptionStarting Version
uuidStringResource UUID. Uniquely identifies the resource4.1.0
ipRangeUuidStringIP range UUID4.1.0
l3NetworkUuidStringL3 network UUID4.1.0
ipVersionIntegerIP protocol number4.1.0
ipStringIP address4.1.0
netmaskStringNetwork mask4.1.0
gatewayStringGateway address4.1.0
usedForString 4.1.0
ipInLonglong 4.1.0
vmNicUuidStringVM NIC UUID4.1.0
createDateTimestampCreate time4.1.0
lastOpDateTimestampLast modification time4.1.0

allVolumes

NameTypeDescriptionStarting Version
uuidStringResource UUID. Uniquely identifies the resource4.1.0
nameStringResource name4.1.0
descriptionStringResource description4.1.0
primaryStorageUuidStringPrimary storage UUID4.1.0
vmInstanceUuidStringVM UUID4.1.0
diskOfferingUuidStringDisk offering UUID4.1.0
rootImageUuidStringRoot image UUID4.1.0
installPathStringDisk path on primary storage4.1.0
typeStringDisk type, data disk/root disk4.1.0
formatStringDisk format4.1.0
sizeLongDisk size4.1.0
actualSizeLongActual disk size4.1.0
deviceIdInteger 4.1.0
stateStringWhether the disk is enabled4.1.0
statusStringDisk status4.1.0
createDateTimestampCreate time4.1.0
lastOpDateTimestampLast modification time4.1.0
isShareableBooleanWhether the disk is shareable4.1.0
volumeQosStringDisk QoS, format such as total=10485764.1.0
lastDetachDateTimestamp 4.7.13
lastVmInstanceUuidString 4.7.13

vmCdRoms

NameTypeDescriptionStarting Version
uuidStringResource UUID. Uniquely identifies the resource4.7.13
vmInstanceUuidStringVM UUID4.7.13
deviceIdInteger 4.7.13
isoUuidString 4.7.13
isoInstallPathString 4.7.13
nameStringResource name4.7.13
descriptionStringResource description4.7.13
createDateTimestampCreate time4.7.13
lastOpDateTimestampLast modification time4.7.13

SDK Examples

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

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"
res = action.call()