CloneVmInstance
API Request
URLs
PUT zstack/v1/vm-instances/{vmInstanceUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"cloneVmInstance": {
"strategy": "InstantStart",
"names": [
"vm1",
"vm2"
],
"full": false
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"cloneVmInstance":{"strategy":"InstantStart","names":["vm1","vm2"],"full":false}}' \
http://localhost:8080/zstack/v1/vm-instances/c4d628c203433f64b062ad07c8edf10d/actionsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| vmInstanceUuid | String | url | The VM instance UUID. | 0.6 | |
| strategy | String | body (contained in the cloneVmInstance structure) | Optional. The strategy. |
Note: JustCreate creates only a VM record without any
initialization, and this VM is not displayed on the
UI. |
0.6 |
| names | List | body (contained in the cloneVmInstance structure) | The VM instance name list. | 0.6 | |
| full | Boolean | body (contained in the cloneVmInstance structure) | Optional. Whether to clone the data volume that is attached to the VM instance. | 2.5.0 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 | |
| primaryStorageUuidForRootVolume | String | body (contained in the cloneVmInstance structure) | Optional. | 4.6.21 | |
| primaryStorageUuidForDataVolume | String | body (contained in the cloneVmInstance structure) | Optional | 4.6.21 | |
| rootVolumeSystemTags | List | body (contained in the cloneVmInstance structure) | Optional | 4.6.21 | |
| dataVolumeSystemTags | List | body (contained in the cloneVmInstance structure) | Optional. | 4.6.21 | |
| clusterUuid | String | body (contained in the cloneVmInstance structure) | Optional. The cluster UUID. | 4.6.21 | |
| hostUuid | String | body (contained in the cloneVmInstance structure) | Optional. The host UUID. | 4.6.21 | |
| vmNicParams | List | body (contained in the cloneVmInstance structure) | Optional. The VM NIC parameter. | 5.1.0 |
API Response
Sample
Response
{
"result": {
"numberOfClonedVm": 1,
"inventories": [
{
"inventory": {
"uuid": "327b60d6b8cd31489ade6f4830bcec16",
"name": "new vm name",
"description": "web server VM",
"zoneUuid": "d886a09330e13282b7a320a98d0a53ec",
"clusterUuid": "f6f07dff7ede3b8cac7c8595a1698832",
"imageUuid": "3b7ff22eb60d38318835817ba6a2b6a2",
"hostUuid": "70c0f5223d083dfea2f1a02f69906306",
"lastHostUuid": "123f7f85f82f3e99940836d97ae18e04",
"instanceOfferingUuid": "001537d10c433857a7a98ae0a362c910",
"rootVolumeUuid": "c8be7ec6a8573d98a580b457a7245141",
"platform": "Linux",
"defaultL3NetworkUuid": "2ac50b85591b3e87b2686c529cf062f9",
"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": "c8be7ec6a8573d98a580b457a7245141",
"name": "Root-Volume-For-VM-327b60d6b8cd31489ade6f4830bcec16",
"primaryStorageUuid": "c2a27c5268493a5cba84b94e37b86b4d",
"vmInstanceUuid": "327b60d6b8cd31489ade6f4830bcec16",
"diskOfferingUuid": "358e00e7245a39b9aa1c1849d6ba9701",
"rootImageUuid": "3b7ff22eb60d38318835817ba6a2b6a2",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-c8be7ec6a8573d98a580b457a7245141/c8be7ec6a8573d98a580b457a7245141.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 | 0.6 | |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 0.6 |
| result | CloneVmInstanceResults | See result. | 0.6 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
#result
| Name | Type | Description | Starting Version |
|---|---|---|---|
| numberOfClonedVm | int | 0.6 | |
| inventories | List | See inventories. | 0.6 |
#inventories
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| name | String | The resource name. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| zoneUuid | String | The zone UUID. | 0.6 |
| clusterUuid | String | The cluster UUID. | 0.6 |
| imageUuid | String | The image UUID. | 0.6 |
| hostUuid | String | The host UUID. | 0.6 |
| lastHostUuid | String | 0.6 | |
| instanceOfferingUuid | String | The instance offering UUID. | 0.6 |
| rootVolumeUuid | String | The root volume UUID. | 0.6 |
| platform | String | 0.6 | |
| architecture | String | 4.6.21 | |
| 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 | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
| state | String | 0.6 | |
| guestOsType | String | 4.6.21 | |
| vmNics | List | See vmNics. | 0.6 |
| allVolumes | List | See allVolumes. | 0.6 |
| vmCdRoms | List | See cmCdRoms. | 4.6.21 |
#vmNics
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 4.7.13 |
| vmInstanceUuid | String | The VM instance UUID. | 4.7.13 |
| l3NetworkUuid | String | The L3 network UUID. | 4.7.13 |
| ip | String | 4.7.13 | |
| mac | 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 | The NIC state. | 4.7.13 |
| createDate | Timestamp | The creation date. | 4.7.13 |
| lastOpDate | Timestamp | The last operation date. | 4.7.13 |
| usedIps | List | See usedIps. | 4.7.13 |
#usedIps
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 5.0.0 |
| ipRangeUuid | String | The IP range UUID. | 5.0.0 |
| l3NetworkUuid | String | The L3 network UUID. | 5.0.0 |
| ipVersion | Integer | 5.0.0 | |
| ip | String | 5.0.0 | |
| netmask | String | 5.0.0 | |
| gateway | String | 5.0.0 | |
| usedFor | String | 5.0.0 | |
| ipInLong | long | 5.0.0 | |
| vmNicUuid | String | The UUID of the VM NIC. | 5.0.0 |
| createDate | Timestamp | The creation date. | 5.0.0 |
| lastOpDate | Timestamp | The last operation date. | 5.0.0 |
#allVolumes
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 4.7.13 |
| name | String | The resource name. | 4.7.13 |
| description | String | The detailed description of the resource. | 4.7.13 |
| primaryStorageUuid | String | The primary storage UUID. | 4.7.13 |
| vmInstanceUuid | String | The VM instance UUID. | 4.7.13 |
| diskOfferingUuid | String | The 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 | The creation date. | 4.7.13 |
| lastOpDate | Timestamp | The last operation date. | 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 | The resource UUID. | 4.7.13 |
| vmInstanceUuid | String | The VM instance UUID. | 4.7.13 |
| deviceId | Integer | 4.7.13 | |
| isoUuid | String | 4.7.13 | |
| isoInstallPath | String | 4.7.13 | |
| name | String | The resource name. | 4.7.13 |
| description | String | Optional. The detailed description of the resource. | 4.7.13 |
| createDate | Timestamp | The creation date. | 4.7.13 |
| lastOpDate | Timestamp | The last operation date. | 4.7.13 |
SDK Sample
Java
SDK
CloneVmInstanceAction action = new CloneVmInstanceAction();
action.vmInstanceUuid = "c4d628c203433f64b062ad07c8edf10d";
action.strategy = "InstantStart";
action.names = asList("vm1","vm2");
action.full = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CloneVmInstanceAction.Result res = action.call();Python
SDK
CloneVmInstanceAction action = CloneVmInstanceAction()
action.vmInstanceUuid = "c4d628c203433f64b062ad07c8edf10d"
action.strategy = "InstantStart"
action.names = [vm1, vm2]
action.full = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CloneVmInstanceAction.Result res = action.call()