VM Related Interfaces

Create VM from OVF Template

POST/zstack/v1/ovf/create-vm-instance

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "xmlBase64": "PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4KPEVudmVsb3BlIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5kbXR",
    "jsonImageInfos": "[{\"ovfId\":\"vm-1-system.vmdk\",\"type\":\"Download\",\"installPath\":\"http://xxx/vm-1-system.vmdk\"}]",
    "backupStorageUuid": "3302f082e39d3ba8a246de74179e5512",
    "jsonCreateVmParam": "{\"name\":\"a\",\"clusterUuid\":\"e79b1a7be3183216a99874e942a7dd4a\",\"l3NetworkUuids\":[\"4f4b50d7cb6d3a9a944172b73653a593\"]}",
    "deleteImageAfterSuccess": true,
    "deleteImageOnFail": false
  },
  "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":{"xmlBase64":"PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4KPEVudmVsb3BlIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5kbXR","jsonImageInfos":"[{\"ovfId\":\"vm-1-system.vmdk\",\"type\":\"Download\",\"installPath\":\"http://xxx/vm-1-system.vmdk\"}]","backupStorageUuid":"3302f082e39d3ba8a246de74179e5512","jsonCreateVmParam":"{\"name\":\"a\",\"clusterUuid\":\"e79b1a7be3183216a99874e942a7dd4a\",\"l3NetworkUuids\":[\"4f4b50d7cb6d3a9a944172b73653a593\"]}","deleteImageAfterSuccess":true,"deleteImageOnFail":false}}' \
http://localhost:8080/zstack/v1/ovf/create-vm-instance

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
xmlBase64Stringbody (included in params structure)Resource name 4.4.6
jsonImageInfosStringbody (included in params structure)JSON string describing the mapping between disk IDs in OVF and image files 4.4.6
backupStorageUuidStringbody (included in params structure)Backup storage UUID for storing uploaded image files 4.4.6
jsonCreateVmParamStringbody (included in params structure)JSON string containing VM creation parameters 4.4.6
deleteImageAfterSuccess (optional)booleanbody (included in params structure)Delete image file after successful deployment 4.4.6
deleteImageOnFail (optional)booleanbody (included in params structure)Delete image file after failed deployment 4.4.6
resourceUuid (optional)Stringbody (included in params structure)Resource UUID 4.4.6
tagUuids (optional)Listbody (included in params structure)Tag UUID list 4.4.6
systemTags (optional)ListbodySystem tags 4.4.6
userTags (optional)ListbodyUser tags 4.4.6

API Response

Response Example

{
  "inventory": {
    "uuid": "ef8b74d3a7f931c3aacf258c20d25411",
    "name": "test-ovf",
    "description": "web server VM",
    "zoneUuid": "5f3cdedd4a823bfcadd45385f034b763",
    "clusterUuid": "2bb23d2c0a013338add7cedf2615ac39",
    "imageUuid": "f47e5dbf886e3d16b8097294efd63b37",
    "hostUuid": "82bad7cada82377684459e59292937b4",
    "lastHostUuid": "00e742c03afe3cd68234aa9c9352d5a7",
    "instanceOfferingUuid": "a9a166f625e23886a7227bdb472da645",
    "rootVolumeUuid": "3e92e577418835a3bfeb0d770e898052",
    "platform": "Linux",
    "defaultL3NetworkUuid": "e4f37ede6e563fe5943ae8b8c7c008d6",
    "type": "UserVm",
    "hypervisorType": "KVM",
    "memorySize": 4294967296.0,
    "cpuNum": 4.0,
    "allocatorStrategy": "LastHostPreferredAllocatorStrategy",
    "createDate": "Nov 14, 2017 2:20:57 PM",
    "lastOpDate": "Nov 14, 2017 2:20:57 PM",
    "state": "Running",
    "vmNics": [
      {
        "uuid": "d5a26fdfdcff30748b22b85f4d7fadbe",
        "vmInstanceUuid": "ef8b74d3a7f931c3aacf258c20d25411",
        "usedIpUuid": "4423412a12653cb3af73231e16e526cf",
        "l3NetworkUuid": "e4f37ede6e563fe5943ae8b8c7c008d6",
        "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.0,
        "createDate": "Nov 14, 2017 2:20:57 PM",
        "lastOpDate": "Nov 14, 2017 2:20:57 PM"
      }
    ],
    "allVolumes": [
      {
        "uuid": "3e92e577418835a3bfeb0d770e898052",
        "name": "Root-Volume-For-VM-ef8b74d3a7f931c3aacf258c20d25411",
        "primaryStorageUuid": "353a440b83283acca73e3d3fd2cca0c5",
        "vmInstanceUuid": "ef8b74d3a7f931c3aacf258c20d25411",
        "diskOfferingUuid": "323969fdd2273f1a8e42aef10a9e8c6b",
        "rootImageUuid": "f47e5dbf886e3d16b8097294efd63b37",
        "installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-3e92e577418835a3bfeb0d770e898052/3e92e577418835a3bfeb0d770e898052.qcow2",
        "type": "Root",
        "format": "qcow2",
        "size": 107374182400.0,
        "actualSize": 21474836480.0,
        "deviceId": 0.0,
        "state": "Enabled",
        "status": "Ready",
        "createDate": "Nov 14, 2017 2:20:57 PM",
        "lastOpDate": "Nov 14, 2017 2:20:57 PM"
      }
    ]
  }
}
NameTypeDescriptionStarting Version
successboolean 4.4.6
inventoryVmInstanceInventorySee inventory for details.4.4.6
errorErrorCodeError code. If not null, the operation failed. If null, the operation succeeded. See error for details.4.4.6

inventory

NameTypeDescriptionStarting Version
uuidStringResource UUID. Uniquely identifies the resource4.4.6
nameStringResource name4.4.6
descriptionStringResource description4.4.6
zoneUuidStringData Center UUID4.4.6
clusterUuidStringCluster UUID4.4.6
imageUuidStringImage UUID4.4.6
hostUuidStringHost UUID4.4.6
lastHostUuidString 4.4.6
instanceOfferingUuidStringInstance offering UUID4.4.6
rootVolumeUuidStringRoot disk UUID4.4.6
platformString 4.4.6
architectureString 4.4.6
defaultL3NetworkUuidString 4.4.6
typeString 4.4.6
hypervisorTypeString 4.4.6
memorySizeLong 4.4.6
cpuNumInteger 4.4.6
cpuSpeedLong 4.4.6
allocatorStrategyString 4.4.6
createDateTimestampCreate time4.4.6
lastOpDateTimestampLast modification time4.4.6
stateString 4.4.6
guestOsTypeString 4.4.6
vmNicsListSee vmNics for details.4.4.6
allVolumesListSee allVolumes for details.4.4.6
vmCdRomsListSee vmCdRoms for details.4.4.6

vmNics

NameTypeDescriptionStarting Version
uuidStringResource UUID. Uniquely identifies the resource4.4.6
vmInstanceUuidStringVM UUID4.4.6
l3NetworkUuidStringL3 network UUID4.4.6
ipStringIP address4.4.6
macStringMAC address4.4.6
hypervisorTypeStringVirtualization type4.4.6
netmaskStringSubnet mask4.4.6
gatewayStringGateway4.4.6
metaDataString 4.4.6
ipVersionIntegerIP address version4.4.6
driverTypeString 4.4.6
internalNameString 4.4.6
deviceIdIntegerDevice ID4.4.6
typeStringNIC type4.4.6
createDateTimestampCreate time4.4.6
lastOpDateTimestampLast modification time4.4.6
usedIpsListSee usedIps for details.4.4.6

usedIps

NameTypeDescriptionStarting Version
uuidStringResource UUID. Uniquely identifies the resource4.4.6
ipRangeUuidStringIP range UUID4.4.6
l3NetworkUuidStringL3 network UUID4.4.6
ipVersionIntegerIP protocol number4.4.6
ipStringIP address4.4.6
netmaskStringNetwork mask4.4.6
gatewayStringGateway address4.4.6
usedForString 4.4.6
ipInLonglong 4.4.6
vmNicUuidStringVM NIC UUID4.4.6
createDateTimestampCreate time4.4.6
lastOpDateTimestampLast modification time4.4.6

allVolumes

NameTypeDescriptionStarting Version
uuidStringResource UUID. Uniquely identifies the resource4.4.6
nameStringResource name4.4.6
descriptionStringResource description4.4.6
primaryStorageUuidStringPrimary storage UUID4.4.6
vmInstanceUuidStringVM UUID4.4.6
diskOfferingUuidStringDisk offering UUID4.4.6
rootImageUuidStringRoot image UUID4.4.6
installPathStringDisk path on primary storage4.4.6
typeStringDisk type, data disk/root disk4.4.6
formatStringDisk format4.4.6
sizeLongDisk size4.4.6
actualSizeLongActual disk size4.4.6
deviceIdInteger 4.4.6
stateStringWhether the disk is enabled4.4.6
statusStringDisk status4.4.6
createDateTimestampCreate time4.4.6
lastOpDateTimestampLast modification time4.4.6
isShareableBooleanWhether the disk is shareable4.4.6
volumeQosStringDisk QoS, format such as total=10485764.4.6

vmCdRoms

NameTypeDescriptionStarting Version
uuidStringResource UUID. Uniquely identifies the resource4.4.6
vmInstanceUuidStringVM UUID4.4.6
deviceIdInteger 4.4.6
isoUuidString 4.4.6
isoInstallPathString 4.4.6
nameStringResource name4.4.6
descriptionStringResource description4.4.6
createDateTimestampCreate time4.4.6
lastOpDateTimestampLast modification time4.4.6

error

NameTypeDescriptionStarting Version
codeStringError code. A globally unique identifier for the error, for example SYS.1000, HOST.10014.4.6
descriptionStringBrief description of the error4.4.6
detailsStringDetailed error information4.4.6
elaborationStringReserved field, defaults to null4.4.6
opaqueLinkedHashMapReserved field, defaults to null4.4.6
causeErrorCodeRoot error. The error that caused this error. If there is no original error, this field is null4.4.6

SDK Examples

Java SDK

CreateVmInstanceFromOvfAction action = new CreateVmInstanceFromOvfAction();
action.xmlBase64 = "PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4KPEVudmVsb3BlIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5kbXR";
action.jsonImageInfos = "[{"ovfId":"vm-1-system.vmdk","type":"Download","installPath":"http://xxx/vm-1-system.vmdk"}]";
action.backupStorageUuid = "3302f082e39d3ba8a246de74179e5512";
action.jsonCreateVmParam = "{"name":"a","clusterUuid":"e79b1a7be3183216a99874e942a7dd4a","l3NetworkUuids":["4f4b50d7cb6d3a9a944172b73653a593"]}";
action.deleteImageAfterSuccess = true;
action.deleteImageOnFail = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateVmInstanceFromOvfAction.Result res = action.call();

Python SDK

action = CreateVmInstanceFromOvfAction()
action.xmlBase64 = "PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4KPEVudmVsb3BlIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5kbXR"
action.jsonImageInfos = "[{"ovfId":"vm-1-system.vmdk","type":"Download","installPath":"http://xxx/vm-1-system.vmdk"}]"
action.backupStorageUuid = "3302f082e39d3ba8a246de74179e5512"
action.jsonCreateVmParam = "{"name":"a","clusterUuid":"e79b1a7be3183216a99874e942a7dd4a","l3NetworkUuids":["4f4b50d7cb6d3a9a944172b73653a593"]}"
action.deleteImageAfterSuccess = true
action.deleteImageOnFail = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()