VM Related Interfaces
Create VM from OVF Template
Headers
Authorization: OAuth the-session-uuidBody
{
"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-instanceParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| xmlBase64 | String | body (included in params structure) | Resource name | 4.4.6 | |
| jsonImageInfos | String | body (included in params structure) | JSON string describing the mapping between disk IDs in OVF and image files | 4.4.6 | |
| backupStorageUuid | String | body (included in params structure) | Backup storage UUID for storing uploaded image files | 4.4.6 | |
| jsonCreateVmParam | String | body (included in params structure) | JSON string containing VM creation parameters | 4.4.6 | |
| deleteImageAfterSuccess (optional) | boolean | body (included in params structure) | Delete image file after successful deployment | 4.4.6 | |
| deleteImageOnFail (optional) | boolean | body (included in params structure) | Delete image file after failed deployment | 4.4.6 | |
| resourceUuid (optional) | String | body (included in params structure) | Resource UUID | 4.4.6 | |
| tagUuids (optional) | List | body (included in params structure) | Tag UUID list | 4.4.6 | |
| systemTags (optional) | List | body | System tags | 4.4.6 | |
| userTags (optional) | List | body | User 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"
}
]
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 4.4.6 | |
| inventory | VmInstanceInventory | See inventory for details. | 4.4.6 |
| error | ErrorCode | Error code. If not null, the operation failed. If null, the operation succeeded. See error for details. | 4.4.6 |
inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID. Uniquely identifies the resource | 4.4.6 |
| name | String | Resource name | 4.4.6 |
| description | String | Resource description | 4.4.6 |
| zoneUuid | String | Data Center UUID | 4.4.6 |
| clusterUuid | String | Cluster UUID | 4.4.6 |
| imageUuid | String | Image UUID | 4.4.6 |
| hostUuid | String | Host UUID | 4.4.6 |
| lastHostUuid | String | 4.4.6 | |
| instanceOfferingUuid | String | Instance offering UUID | 4.4.6 |
| rootVolumeUuid | String | Root disk UUID | 4.4.6 |
| platform | String | 4.4.6 | |
| architecture | String | 4.4.6 | |
| defaultL3NetworkUuid | String | 4.4.6 | |
| type | String | 4.4.6 | |
| hypervisorType | String | 4.4.6 | |
| memorySize | Long | 4.4.6 | |
| cpuNum | Integer | 4.4.6 | |
| cpuSpeed | Long | 4.4.6 | |
| allocatorStrategy | String | 4.4.6 | |
| createDate | Timestamp | Create time | 4.4.6 |
| lastOpDate | Timestamp | Last modification time | 4.4.6 |
| state | String | 4.4.6 | |
| guestOsType | String | 4.4.6 | |
| vmNics | List | See vmNics for details. | 4.4.6 |
| allVolumes | List | See allVolumes for details. | 4.4.6 |
| vmCdRoms | List | See vmCdRoms for details. | 4.4.6 |
vmNics
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID. Uniquely identifies the resource | 4.4.6 |
| vmInstanceUuid | String | VM UUID | 4.4.6 |
| l3NetworkUuid | String | L3 network UUID | 4.4.6 |
| ip | String | IP address | 4.4.6 |
| mac | String | MAC address | 4.4.6 |
| hypervisorType | String | Virtualization type | 4.4.6 |
| netmask | String | Subnet mask | 4.4.6 |
| gateway | String | Gateway | 4.4.6 |
| metaData | String | 4.4.6 | |
| ipVersion | Integer | IP address version | 4.4.6 |
| driverType | String | 4.4.6 | |
| internalName | String | 4.4.6 | |
| deviceId | Integer | Device ID | 4.4.6 |
| type | String | NIC type | 4.4.6 |
| createDate | Timestamp | Create time | 4.4.6 |
| lastOpDate | Timestamp | Last modification time | 4.4.6 |
| usedIps | List | See usedIps for details. | 4.4.6 |
usedIps
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID. Uniquely identifies the resource | 4.4.6 |
| ipRangeUuid | String | IP range UUID | 4.4.6 |
| l3NetworkUuid | String | L3 network UUID | 4.4.6 |
| ipVersion | Integer | IP protocol number | 4.4.6 |
| ip | String | IP address | 4.4.6 |
| netmask | String | Network mask | 4.4.6 |
| gateway | String | Gateway address | 4.4.6 |
| usedFor | String | 4.4.6 | |
| ipInLong | long | 4.4.6 | |
| vmNicUuid | String | VM NIC UUID | 4.4.6 |
| createDate | Timestamp | Create time | 4.4.6 |
| lastOpDate | Timestamp | Last modification time | 4.4.6 |
allVolumes
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID. Uniquely identifies the resource | 4.4.6 |
| name | String | Resource name | 4.4.6 |
| description | String | Resource description | 4.4.6 |
| primaryStorageUuid | String | Primary storage UUID | 4.4.6 |
| vmInstanceUuid | String | VM UUID | 4.4.6 |
| diskOfferingUuid | String | Disk offering UUID | 4.4.6 |
| rootImageUuid | String | Root image UUID | 4.4.6 |
| installPath | String | Disk path on primary storage | 4.4.6 |
| type | String | Disk type, data disk/root disk | 4.4.6 |
| format | String | Disk format | 4.4.6 |
| size | Long | Disk size | 4.4.6 |
| actualSize | Long | Actual disk size | 4.4.6 |
| deviceId | Integer | 4.4.6 | |
| state | String | Whether the disk is enabled | 4.4.6 |
| status | String | Disk status | 4.4.6 |
| createDate | Timestamp | Create time | 4.4.6 |
| lastOpDate | Timestamp | Last modification time | 4.4.6 |
| isShareable | Boolean | Whether the disk is shareable | 4.4.6 |
| volumeQos | String | Disk QoS, format such as total=1048576 | 4.4.6 |
vmCdRoms
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID. Uniquely identifies the resource | 4.4.6 |
| vmInstanceUuid | String | VM UUID | 4.4.6 |
| deviceId | Integer | 4.4.6 | |
| isoUuid | String | 4.4.6 | |
| isoInstallPath | String | 4.4.6 | |
| name | String | Resource name | 4.4.6 |
| description | String | Resource description | 4.4.6 |
| createDate | Timestamp | Create time | 4.4.6 |
| lastOpDate | Timestamp | Last modification time | 4.4.6 |
error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code. A globally unique identifier for the error, for example SYS.1000, HOST.1001 | 4.4.6 |
| description | String | Brief description of the error | 4.4.6 |
| details | String | Detailed error information | 4.4.6 |
| elaboration | String | Reserved field, defaults to null | 4.4.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 4.4.6 |
| cause | ErrorCode | Root error. The error that caused this error. If there is no original error, this field is null | 4.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()