Create VM Instance from VM Template
Headers
Authorization: OAuth the-session-uuidBody
{
"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-vmInstanceParameter List
Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
name | List | body(Contained in the | List of VM instance names |
| 4.2.6 |
templatedVmInstanceUuid | String | url | Template VM instance UUID |
| 4.2.6 |
strategy (Optional) | String | body(Contained in the | Creation strategy |
| 4.2.6 |
description (Optional) | String | body(Contained in the | Detailed description of the resource |
| 4.2.6 |
cpuNum (Optional) | Integer | body(Contained in the | Number of CPU cores |
| 4.2.6 |
memorySize (Optional) | Long | body(Contained in the | Memory size |
| 4.2.6 |
reservedMemorySize (Optional) | Long | body(Contained in the | Reserved memory size |
| 4.2.6 |
l3NetworkUuids (Optional) | List | body(Contained in the | 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 the | Default Distributed Port Group UUID |
| 4.2.6 |
vmNicParams (Optional) | String | body(Contained in the | NIC information |
| 4.2.6 |
diskAOs (Optional) | List | body(Contained in the | Disks |
| 4.2.6 |
zoneUuid (Optional) | String | body(Contained in the | Data Center UUID |
| 4.2.6 |
clusterUuid (Optional) | String | body(Contained in the | Cluster UUID |
| 4.2.6 |
hostUuid (Optional) | String | body(Contained in the | Host UUID |
| 4.2.6 |
instanceOfferingUuid (Optional) | String | body(Contained in the | Instance offering UUID |
| 4.2.6 |
type (Optional) | String | body(Contained in the | 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"
}
]
}
}
]
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 4.2.6 | |
| result | CloneVmInstanceResults | For details, seeresult | 4.2.6 |
| error | ErrorCode | Error code. If not null, the operation failed. This field is null when the operation succeeds. For details, seeerror | 4.2.6 |
result
| Name | Type | Description | Starting Version |
|---|---|---|---|
| numberOfClonedVm | int | 4.2.6 | |
| inventories | List | For details, seeinventories | 4.2.6 |
inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | Error code. If not null, the operation failed. This field is null when the operation succeeds. For details, seeerror | 4.2.6 |
| inventory | VmInstanceInventory | For details, seeinventory | 4.2.6 |
error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number. A globally unique identifier for the error, e.g., SYS.1000, HOST.1001. | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed information about the error | 0.6 |
| elaboration | String | Reserved field. Defaults to null. | 0.6 |
| opaque | LinkedHashMap | Reserved field. Defaults to null. | 0.6 |
| cause | ErrorCode | Root error. The source error that caused the current error. This field is null if there is no root cause. | 0.6 |
inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | UUID of the resource. Uniquely identifies the resource. | 0.6 |
| name | String | Resource name | 0.6 |
| description | String | Detailed description of the resource | 0.6 |
| zoneUuid | String | Data Center UUID | 0.6 |
| clusterUuid | String | Cluster UUID | 0.6 |
| imageUuid | String | Image UUID | 0.6 |
| hostUuid | String | Host UUID | 0.6 |
| lastHostUuid | String | 0.6 | |
| instanceOfferingUuid | String | Instance offering UUID | 0.6 |
| rootVolumeUuid | String | Root disk UUID | 0.6 |
| platform | String | 0.6 | |
| architecture | String | 0.6 | |
| defaultL3NetworkUuid | String | 0.6 | |
| type | String | 0.6 | |
| hypervisorType | String | 0.6 | |
| memorySize | Long | 0.6 | |
| cpuNum | Integer | 0.6 | |
| cpuSpeed | Long | 0.6 | |
| allocatorStrategy | String | 0.6 | |
| createDate | Timestamp | Creation time | 0.6 |
| lastOpDate | Timestamp | Last modification time | 0.6 |
| state | String | 0.6 | |
| guestOsType | String | 4.1.2 | |
| vmNics | List | For details, seevmNics | 0.6 |
| allVolumes | List | For details, seeallVolumes | 0.6 |
| vmCdRoms | List | For details, seevmCdRoms | 0.6 |
vmNics
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | UUID of the resource. Uniquely identifies the resource. | 4.7.13 |
| vmInstanceUuid | String | VM instance UUID | 4.7.13 |
| l3NetworkUuid | String | Distributed Port Group UUID | 4.7.13 |
| ip | String | 4.7.13 | |
| mac | String | 4.7.13 | |
| hypervisorType | String | 4.7.13 | |
| netmask | String | 4.7.13 | |
| gateway | String | 4.7.13 | |
| metaData | String | 4.7.13 | |
| ipVersion | Integer | 4.7.13 | |
| driverType | String | 4.7.13 | |
| internalName | String | 4.7.13 | |
| deviceId | Integer | 4.7.13 | |
| type | String | 4.7.13 | |
| state | String | NIC Status | 4.7.13 |
| createDate | Timestamp | Creation time | 4.7.13 |
| lastOpDate | Timestamp | Last modification time | 4.7.13 |
| usedIps | List | For details, seeusedIps | 4.7.13 |
usedIps
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | UUID of the resource. Uniquely identifies the resource. | 4.7.13 |
| ipRangeUuid | String | IP Range UUID | 4.7.13 |
| l3NetworkUuid | String | Distributed Port Group UUID | 4.7.13 |
| ipVersion | Integer | 4.7.13 | |
| ip | String | 4.7.13 | |
| netmask | String | 4.7.13 | |
| gateway | String | 4.7.13 | |
| usedFor | String | 4.7.13 | |
| ipInLong | long | 4.7.13 | |
| vmNicUuid | String | Virtual Machine NIC UUID | 4.7.13 |
| createDate | Timestamp | Creation time | 4.7.13 |
| lastOpDate | Timestamp | Last modification time | 4.7.13 |
allVolumes
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | UUID of the resource. Uniquely identifies the resource. | 4.7.13 |
| name | String | Resource name | 4.7.13 |
| description | String | Detailed description of the resource | 4.7.13 |
| primaryStorageUuid | String | Data Storage UUID | 4.7.13 |
| vmInstanceUuid | String | VM instance UUID | 4.7.13 |
| diskOfferingUuid | String | Disk Offering UUID | 4.7.13 |
| rootImageUuid | String | 4.7.13 | |
| installPath | String | 4.7.13 | |
| type | String | 4.7.13 | |
| format | String | 4.7.13 | |
| size | Long | 4.7.13 | |
| actualSize | Long | 4.7.13 | |
| deviceId | Integer | 4.7.13 | |
| state | String | 4.7.13 | |
| status | String | 4.7.13 | |
| createDate | Timestamp | Creation time | 4.7.13 |
| lastOpDate | Timestamp | Last modification time | 4.7.13 |
| isShareable | Boolean | 4.7.13 | |
| volumeQos | String | 4.7.13 | |
| lastDetachDate | Timestamp | 4.7.13 | |
| lastVmInstanceUuid | String | 4.7.13 |
vmCdRoms
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | UUID of the resource. Uniquely identifies the resource. | 4.7.13 |
| vmInstanceUuid | String | VM instance UUID | 4.7.13 |
| deviceId | Integer | 4.7.13 | |
| isoUuid | String | 4.7.13 | |
| isoInstallPath | String | 4.7.13 | |
| name | String | Resource name | 4.7.13 |
| description | String | Detailed description of the resource | 4.7.13 |
| createDate | Timestamp | Creation time | 4.7.13 |
| lastOpDate | Timestamp | Last modification time | 4.7.13 |
error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number. A globally unique identifier for the error, e.g., SYS.1000, HOST.1001. | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed information about the error | 0.6 |
| elaboration | String | Reserved field. Defaults to null. | 0.6 |
| opaque | LinkedHashMap | Reserved field. Defaults to null. | 0.6 |
| cause | ErrorCode | Root 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()