VM Related Interfaces

Create Templated Virtual Machine From Virtual Machine

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

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "name": "vm1"
  },
  "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"}}' \
http://localhost:8080/zstack/v1/vm-instances/326c05ee121432628ddabd7036ea94ff/create-templated-vmInstance

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
nameStringbody (contained in params structure)Virtual Machine template name 4.2.6
vmInstanceUuidStringurlVirtual Machine UUID 4.2.6
clusterUuid (Optional)Stringbody (contained in params structure)Cluster UUID 4.2.6
hostUuid (Optional)Stringbody (contained in params structure)Host UUID 4.2.6
systemTags (Optional)ListbodySystem Tag 4.2.6
userTags (Optional)ListbodyUser Tag 4.2.6

API Response

Response Example

{
  "templatedVmInstanceInventory": {
    "uuid": "0878457833cd33fda63afc7423f2ce58",
    "name": "templated vmInstance"
  }
}
NameTypeDescriptionStarting Version
successboolean 4.2.6
templatedVmInstanceInventoryTemplatedVmInstanceInventoryFor details, see templatedVmInstanceInventory4.2.6
errorErrorCodeError code. If not null, the operation failed. When the operation succeeds, this field is null. For details, see error4.2.6

templatedVmInstanceInventory

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource4.2.6
nameStringResource name4.2.6
zoneUuidStringData Center UUID4.2.6
createDateTimestampCreate time4.2.6
lastOpDateTimestampLast modification time4.2.6

error

NameTypeDescriptionStarting Version
codeStringError code number, a globally unique identifier of the error, for example SYS.1000, HOST.10010.6
descriptionStringBrief description of the error0.6
detailsStringDetailed error information0.6
elaborationStringReserved field, defaults to null0.6
opaqueLinkedHashMapReserved field, defaults to null0.6
causeErrorCodeRoot cause. The error that triggered the current error. If there is no original error, this field is null0.6

SDK Examples

Java SDK

CreateTemplatedVmInstanceFromVmInstanceAction action = new CreateTemplatedVmInstanceFromVmInstanceAction();
action.name = "vm1";
action.vmInstanceUuid = "326c05ee121432628ddabd7036ea94ff";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateTemplatedVmInstanceFromVmInstanceAction.Result res = action.call();

Python SDK

CreateTemplatedVmInstanceFromVmInstanceAction action = CreateTemplatedVmInstanceFromVmInstanceAction()
action.name = "vm1"
action.vmInstanceUuid = "326c05ee121432628ddabd7036ea94ff"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateTemplatedVmInstanceFromVmInstanceAction.Result res = action.call()