VM Related Interfaces

Create VM Instance from Volume Snapshot

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": []
}

In the above example, 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":"6900e329296732aca0e3658bcdcdd3ce","l3NetworkUuids":["990ffab4793036d29fc92142889f9ef2"],"clusterUuid":"cd44bab6f1d43e59bbc885f869e89388","strategy":"InstantStart"}}' \
http://localhost:8080/zstack/v1/vm-instances/from/volume-snapshots/f81c959344783f19ae4fc76f1e770201

Parameter List

Name

Type

Location

Description

Allowed Values

Starting Version

name

String

body (contained in params structure)

Resource name

 

4.1.0

description (Optional)

String

body (contained in params structure)

Detailed description of the resource

 

4.1.0

instanceOfferingUuid (Optional)

String

body (contained in params structure)

Instance offering UUID

 

4.1.0

cpuNum (Optional)

Integer

body (contained in params structure)

CPU number

 

4.1.0

memorySize (Optional)

Long

body (contained in params structure)

Memory size

 

4.1.0

l3NetworkUuids

List

body (contained in params structure)

L3 network UUID list

 

4.1.0

type (Optional)

String

body (contained in params structure)

VM type

  • UserVm
  • ApplianceVm

4.1.0

vmNicParams (Optional)

String

body (contained in params structure)

NIC information

 

4.0.0

volumeSnapshotUuid

String

url

Volume snapshot group UUID

 

4.1.0

platform (Optional)

String

body (contained in params structure)

VM platform

  • Linux
  • Windows
  • Other
  • Paravirtualization
  • WindowsVirtio

4.1.0

zoneUuid (Optional)

String

body (contained in params structure)

Data Center UUID

 

4.1.0

clusterUuid (Optional)

String

body (contained in params structure)

Cluster UUID

 

4.1.0

hostUuid (Optional)

String

body (contained in params structure)

Host UUID

 

4.1.0

primaryStorageUuid (Optional)

String

body (contained in params structure)

Primary Storage UUID

 

4.1.0

defaultL3NetworkUuid (Optional)

String

body (contained in params structure)

Default L3 network UUID

 

4.1.0

strategy (Optional)

String

body (contained in params structure)

Creation strategy

  • InstantStart
  • CreateStopped

4.1.0

resourceUuid (Optional)

String

body (contained in params structure)

Resource UUID

 

4.1.0

tagUuids (Optional)

List

body (contained 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 (contained in params structure)

Root volume system tags

 

4.1.0

reservedMemorySize (Optional)

Long

body (contained in params structure)

 

 

4.7.21

API Response

Response Example

{
  "inventory": {
    "uuid": "56331ef0c0713bc09dc2dc160fd4d48a",
    "name": "Test-VM",
    "description": "web server VM",
    "zoneUuid": "49783ceb7da734aab1ea137f2b7b82ac",
    "clusterUuid": "ebfbd2a6e08a3b78b70c9b6093f40d37",
    "imageUuid": "9a4914937dcd3149810793f8b040e8ad",
    "hostUuid": "2665407c38f932c08f3fb33bb6c8f3f4",
    "lastHostUuid": "2a847b5699b535d7a78b57cd411ffeac",
    "instanceOfferingUuid": "041ff292e60f31079dd8e6e3c9c26c72",
    "rootVolumeUuid": "98648a22b2c639ee88571bf1c429caba",
    "platform": "Linux",
    "defaultL3NetworkUuid": "4f80edbb396b346c9af4dcce48f94fb5",
    "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": "1e1b705f391c3f40a2b6ae447d0e12ca",
        "vmInstanceUuid": "56331ef0c0713bc09dc2dc160fd4d48a",
        "usedIpUuid": "bf85263c007d3959a166599181daa4b7",
        "l3NetworkUuid": "4f80edbb396b346c9af4dcce48f94fb5",
        "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": "98648a22b2c639ee88571bf1c429caba",
        "name": "Root-Volume-For-VM-56331ef0c0713bc09dc2dc160fd4d48a",
        "primaryStorageUuid": "406362409f493e14952262df535e9cf8",
        "vmInstanceUuid": "56331ef0c0713bc09dc2dc160fd4d48a",
        "rootImageUuid": "9a4914937dcd3149810793f8b040e8ad",
        "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-98648a22b2c639ee88571bf1c429caba/98648a22b2c639ee88571bf1c429caba.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. This field is null when the operation succeeds. See error4.1.0
inventoryVmInstanceInventorySee inventory4.1.0

error

NameTypeDescriptionStarting Version
codeStringError code number, 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 cause. The source error that triggered the current error. This field is null if there is no original error4.1.0

inventory

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource4.1.0
nameStringResource name4.1.0
descriptionStringDetailed description of the resource4.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 volume UUID4.1.0
platformString 4.1.0
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
createDateTimestampCreation time4.1.0
lastOpDateTimestampLast modification time4.1.0
stateString 4.1.0
guestOsTypeString 4.1.2
vmNicsListSee vmNics4.1.0
allVolumesListSee allVolumes4.1.0
vmCdRomsListSee vmCdRoms0.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
hypervisorTypeStringHypervisor type4.1.0
netmaskStringNetmask4.1.0
gatewayStringGateway4.1.0
metaDataString 4.1.0
ipVersionIntegerIP version4.1.0
driverTypeString 4.7.13
internalNameString 4.7.13
deviceIdIntegerDevice ID4.1.0
typeStringNIC type4.1.0
stateStringNIC state4.7.13
createDateTimestampCreation time4.1.0
lastOpDateTimestampLast modification time4.1.0
usedIpsListSee usedIps4.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
createDateTimestampCreation time4.1.0
lastOpDateTimestampLast modification time4.1.0

allVolumes

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource4.1.0
nameStringResource name4.1.0
descriptionStringDetailed description of the resource4.1.0
primaryStorageUuidStringPrimary Storage UUID4.1.0
vmInstanceUuidStringVM UUID4.1.0
diskOfferingUuidStringDisk offering UUID4.1.0
rootImageUuidStringRoot image UUID4.1.0
installPathStringVolume install path on the primary storage4.1.0
typeStringVolume type, data volume/root volume4.1.0
formatStringVolume format4.1.0
sizeLongVolume size4.1.0
actualSizeLongActual volume size4.1.0
deviceIdInteger 4.1.0
stateStringVolume state4.1.0
statusStringVolume status4.1.0
createDateTimestampCreation time4.1.0
lastOpDateTimestampLast modification time4.1.0
isShareableBooleanWhether it is a shared volume4.1.0
volumeQosString 4.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
descriptionStringDetailed description of the resource4.7.13
createDateTimestampCreation time4.7.13
lastOpDateTimestampLast modification time4.7.13

SDK Examples

Java SDK

CreateVmInstanceFromVolumeSnapshotAction action = new CreateVmInstanceFromVolumeSnapshotAction();
action.name = "vm1";
action.description = "this is a vm";
action.instanceOfferingUuid = "6900e329296732aca0e3658bcdcdd3ce";
action.l3NetworkUuids = asList("990ffab4793036d29fc92142889f9ef2");
action.volumeSnapshotUuid = "f81c959344783f19ae4fc76f1e770201";
action.clusterUuid = "cd44bab6f1d43e59bbc885f869e89388";
action.strategy = "InstantStart";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVmInstanceFromVolumeSnapshotAction.Result res = action.call();

Python SDK

action = CreateVmInstanceFromVolumeSnapshotAction()
action.name = "vm1"
action.description = "this is a vm"
action.instanceOfferingUuid = "6900e329296732aca0e3658bcdcdd3ce"
action.l3NetworkUuids = [990ffab4793036d29fc92142889f9ef2]
action.volumeSnapshotUuid = "f81c959344783f19ae4fc76f1e770201"
action.clusterUuid = "cd44bab6f1d43e59bbc885f869e89388"
action.strategy = "InstantStart"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()