VM Related Interfaces

Create VM Instance from VM Template

POST/zstack/v1/vm-instances/{templatedVmInstanceUuid}/create-vmInstance-from-templated-vmInstance

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "names": [
      "vm1",
      "vm2"
    ],
    "strategy": "InstantStart"
  },
  "systemTags": [],
  "userTags": []
}

In the example above, the systemTags and userTags fields are optional. 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":{"names":["vm1","vm2"],"strategy":"InstantStart"}}' \
http://localhost:8080/zstack/v1/vm-instances/36b46cb654273e779b0a260932eff9e4/create-vmInstance-from-templated-vmInstance

Parameter List

Name

Type

Location

Description

Allowed Values

Starting Version

name

List

body(Contained in theparamsstructure)

List of VM instance names

 

4.2.6

templatedVmInstanceUuid

String

url

Template VM instance UUID

 

4.2.6

strategy (Optional)

String

body(Contained in theparamsstructure)

Creation strategy

  • InstantStart
  • JustCreate
  • CreateStopped

4.2.6

description (Optional)

String

body(Contained in theparamsstructure)

Detailed description of the resource

 

4.2.6

cpuNum (Optional)

Integer

body(Contained in theparamsstructure)

Number of CPU cores

 

4.2.6

memorySize (Optional)

Long

body(Contained in theparamsstructure)

Memory size

 

4.2.6

reservedMemorySize (Optional)

Long

body(Contained in theparamsstructure)

Reserved memory size

 

4.2.6

l3NetworkUuids (Optional)

List

body(Contained in theparamsstructure)

List of Distributed Port Group UUIDs. You can specify one or more Distributed Port Groups, and the VM creates a NIC on each network.

 

4.2.6

defaultL3NetworkUuid (Optional)

String

body(Contained in theparamsstructure)

Default Distributed Port Group UUID

 

4.2.6

vmNicParams (Optional)

String

body(Contained in theparamsstructure)

NIC information

 

4.2.6

diskAOs (Optional)

List

body(Contained in theparamsstructure)

Disks

 

4.2.6

zoneUuid (Optional)

String

body(Contained in theparamsstructure)

Data Center UUID

 

4.2.6

clusterUuid (Optional)

String

body(Contained in theparamsstructure)

Cluster UUID

 

4.2.6

hostUuid (Optional)

String

body(Contained in theparamsstructure)

Host UUID

 

4.2.6

instanceOfferingUuid (Optional)

String

body(Contained in theparamsstructure)

Instance offering UUID

 

4.2.6

type (Optional)

String

body(Contained in theparamsstructure)

VM instance type

 

4.2.6

systemTags (Optional)

List

body

System tags

 

4.2.6

userTags (Optional)

List

body

User tags

 

4.2.6

API Response

Response Example

{
  "result": {
    "numberOfClonedVm": 1,
    "inventories": [
      {
        "inventory": {
          "uuid": "ab705dd924a9364f894ae26e809ec49b",
          "name": "new vm name",
          "description": "web server VM",
          "zoneUuid": "b46d69aa62a6367ab22697617734ad20",
          "clusterUuid": "bdbde667b79b341391c61492d6710585",
          "imageUuid": "3d0ed05e73e43bd1ac7be7e083286977",
          "hostUuid": "f356b94b091c33619e50ee93c63ea1e2",
          "lastHostUuid": "0accca7bf978353a852a0dba7379efc6",
          "instanceOfferingUuid": "e41ee31d1eae3f239d2f8736ac2eda2d",
          "rootVolumeUuid": "7367b12147a5355fbdbcdc3379a4f776",
          "platform": "Linux",
          "defaultL3NetworkUuid": "31f5ccd03eb031e3a652fe24cc6483f3",
          "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",
          "allVolumes": [
            {
              "uuid": "7367b12147a5355fbdbcdc3379a4f776",
              "name": "Root-Volume-For-VM-ab705dd924a9364f894ae26e809ec49b",
              "primaryStorageUuid": "6d24676efd2c3b028ea6bfdef66cc6a1",
              "vmInstanceUuid": "ab705dd924a9364f894ae26e809ec49b",
              "diskOfferingUuid": "3431860972293269988a28f4b6f8ad68",
              "rootImageUuid": "3d0ed05e73e43bd1ac7be7e083286977",
              "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-7367b12147a5355fbdbcdc3379a4f776/7367b12147a5355fbdbcdc3379a4f776.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 4.2.6
resultCloneVmInstanceResultsFor details, seeresult4.2.6
errorErrorCodeError code. If not null, the operation failed. This field is null when the operation succeeds. For details, seeerror4.2.6

result

NameTypeDescriptionStarting Version
numberOfClonedVmint 4.2.6
inventoriesListFor details, seeinventories4.2.6

inventories

NameTypeDescriptionStarting Version
errorErrorCodeError code. If not null, the operation failed. This field is null when the operation succeeds. For details, seeerror4.2.6
inventoryVmInstanceInventoryFor details, seeinventory4.2.6

error

NameTypeDescriptionStarting Version
codeStringError code number. A globally unique identifier for the error, e.g., SYS.1000, HOST.1001.0.6
descriptionStringBrief description of the error0.6
detailsStringDetailed information about the error0.6
elaborationStringReserved field. Defaults to null.0.6
opaqueLinkedHashMapReserved field. Defaults to null.0.6
causeErrorCodeRoot error. The source error that caused the current error. This field is null if there is no root cause.0.6

inventory

NameTypeDescriptionStarting Version
uuidStringUUID of the resource. Uniquely identifies the resource.0.6
nameStringResource name0.6
descriptionStringDetailed description of the resource0.6
zoneUuidStringData Center UUID0.6
clusterUuidStringCluster UUID0.6
imageUuidStringImage UUID0.6
hostUuidStringHost UUID0.6
lastHostUuidString 0.6
instanceOfferingUuidStringInstance offering UUID0.6
rootVolumeUuidStringRoot disk UUID0.6
platformString 0.6
architectureString 0.6
defaultL3NetworkUuidString 0.6
typeString 0.6
hypervisorTypeString 0.6
memorySizeLong 0.6
cpuNumInteger 0.6
cpuSpeedLong 0.6
allocatorStrategyString 0.6
createDateTimestampCreation time0.6
lastOpDateTimestampLast modification time0.6
stateString 0.6
guestOsTypeString 4.1.2
vmNicsListFor details, seevmNics0.6
allVolumesListFor details, seeallVolumes0.6
vmCdRomsListFor details, seevmCdRoms0.6

vmNics

NameTypeDescriptionStarting Version
uuidStringUUID of the resource. Uniquely identifies the resource.4.7.13
vmInstanceUuidStringVM instance UUID4.7.13
l3NetworkUuidStringDistributed Port Group UUID4.7.13
ipString 4.7.13
macString 4.7.13
hypervisorTypeString 4.7.13
netmaskString 4.7.13
gatewayString 4.7.13
metaDataString 4.7.13
ipVersionInteger 4.7.13
driverTypeString 4.7.13
internalNameString 4.7.13
deviceIdInteger 4.7.13
typeString 4.7.13
stateStringNIC Status4.7.13
createDateTimestampCreation time4.7.13
lastOpDateTimestampLast modification time4.7.13
usedIpsListFor details, seeusedIps4.7.13

usedIps

NameTypeDescriptionStarting Version
uuidStringUUID of the resource. Uniquely identifies the resource.4.7.13
ipRangeUuidStringIP Range UUID4.7.13
l3NetworkUuidStringDistributed Port Group UUID4.7.13
ipVersionInteger 4.7.13
ipString 4.7.13
netmaskString 4.7.13
gatewayString 4.7.13
usedForString 4.7.13
ipInLonglong 4.7.13
vmNicUuidStringVirtual Machine NIC UUID4.7.13
createDateTimestampCreation time4.7.13
lastOpDateTimestampLast modification time4.7.13

allVolumes

NameTypeDescriptionStarting Version
uuidStringUUID of the resource. Uniquely identifies the resource.4.7.13
nameStringResource name4.7.13
descriptionStringDetailed description of the resource4.7.13
primaryStorageUuidStringData Storage UUID4.7.13
vmInstanceUuidStringVM instance UUID4.7.13
diskOfferingUuidStringDisk Offering UUID4.7.13
rootImageUuidString 4.7.13
installPathString 4.7.13
typeString 4.7.13
formatString 4.7.13
sizeLong 4.7.13
actualSizeLong 4.7.13
deviceIdInteger 4.7.13
stateString 4.7.13
statusString 4.7.13
createDateTimestampCreation time4.7.13
lastOpDateTimestampLast modification time4.7.13
isShareableBoolean 4.7.13
volumeQosString 4.7.13
lastDetachDateTimestamp 4.7.13
lastVmInstanceUuidString 4.7.13

vmCdRoms

NameTypeDescriptionStarting Version
uuidStringUUID of the resource. Uniquely identifies the resource.4.7.13
vmInstanceUuidStringVM instance 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

error

NameTypeDescriptionStarting Version
codeStringError code number. A globally unique identifier for the error, e.g., SYS.1000, HOST.1001.0.6
descriptionStringBrief description of the error0.6
detailsStringDetailed information about the error0.6
elaborationStringReserved field. Defaults to null.0.6
opaqueLinkedHashMapReserved field. Defaults to null.0.6
causeErrorCodeRoot error. The source error that caused the current error. This field is null if there is no root cause.0.6

SDK Examples

Java SDK

CreateVmInstanceFromTemplatedVmInstanceAction action = new CreateVmInstanceFromTemplatedVmInstanceAction();
action.names = asList("vm1","vm2");
action.templatedVmInstanceUuid = "36b46cb654273e779b0a260932eff9e4";
action.strategy = "InstantStart";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVmInstanceFromTemplatedVmInstanceAction.Result res = action.call();

Python SDK

CreateVmInstanceFromTemplatedVmInstanceAction action = CreateVmInstanceFromTemplatedVmInstanceAction()
action.names = [vm1, vm2]
action.templatedVmInstanceUuid = "36b46cb654273e779b0a260932eff9e4"
action.strategy = "InstantStart"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateVmInstanceFromTemplatedVmInstanceAction.Result res = action.call()