VM Related Interfaces
Migrate Virtual Machine
Migrate a Virtual Machine to another Host using hot migration.
Headers
Authorization: OAuth the-session-uuidBody
{
"migrateVm": {
"hostUuid": "7571fb72e52b3fcab1a6992e7eef4cce",
"migrateFromDestination": false,
"allowUnknown": false,
"downTime": 300
},
"systemTags": [],
"userTags": []
}The systemTags and userTags fields in the example above are optional. Listed to indicate these fields can be included in the body.
Curl Example
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \-X PUT -d '{"migrateVm":{"hostUuid":"7571fb72e52b3fcab1a6992e7eef4cce","migrateFromDestination":false,"allowUnknown":false,"downTime":300}}' \
http://localhost:8080/zstack/v1/vm-instances/c53c9b6235703b8ab96c1cc35859242d/actionsParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| vmInstanceUuid | String | url | Virtual Machine UUID | 0.6 | |
| hostUuid (optional) | String | body(contained in migrateVm structure) | Host UUID | 0.6 | |
| migrateFromDestination (optional) | Boolean | body(contained in migrateVm structure) | Initiate migration command from the migration destination host | 2.3 | |
| allowUnknown (optional) | boolean | body(contained in migrateVm structure) | Allow Virtual Machines in unknown state | 4.6.21 | |
| strategy (optional) | String | body(contained in migrateVm structure) | auto-converge | 4.6.21 | |
| systemTags (optional) | List | body | 0.6 | ||
| userTags (optional) | List | body | User Tags | 0.6 | |
| downTime (optional) | Integer | body(contained in migrateVm structure) | Hot migration host downtime | 4.6.21 |
API Response
Return Example
{
"inventory": {
"uuid": "1124f021672c3de9848fa567b632a6bb",
"name": "Test-VM",
"description": "web server VM",
"zoneUuid": "fdfd5d0dfdc936e284792eabf72c52db",
"clusterUuid": "f42a18b125ba3d61bae560bccec84741",
"imageUuid": "5e6155ea150b31bc8f7789acf9f42b12",
"hostUuid": "d51ee2645a3130ffb294a0c28a121c5c",
"lastHostUuid": "9d32be2f483b3995bff142d072fb410a",
"instanceOfferingUuid": "07d4a48c8cd5365992c6916b07f770ef",
"rootVolumeUuid": "4172134623e6332fbb9092cd105bde77",
"platform": "Linux",
"defaultL3NetworkUuid": "4f49dce686663b81b7d8acbe75a879ac",
"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",
"vmNics": [
{
"uuid": "f5231a1c912e3a6592f1816b5812b660",
"vmInstanceUuid": "1124f021672c3de9848fa567b632a6bb",
"usedIpUuid": "c9f0e849407f3f5d86376560e00f31ae",
"l3NetworkUuid": "4f49dce686663b81b7d8acbe75a879ac",
"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,
"state": "enable",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
],
"allVolumes": [
{
"uuid": "4172134623e6332fbb9092cd105bde77",
"name": "Root-Volume-For-VM-1124f021672c3de9848fa567b632a6bb",
"primaryStorageUuid": "fe9f085199453903b09c5de54b6d194e",
"vmInstanceUuid": "1124f021672c3de9848fa567b632a6bb",
"diskOfferingUuid": "66805a23b6e3362d9527f3f4dcfe4402",
"rootImageUuid": "5e6155ea150b31bc8f7789acf9f42b12",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-4172134623e6332fbb9092cd105bde77/4172134623e6332fbb9092cd105bde77.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.6.21 | |
| error | ErrorCode | Error code. If not null, indicates operation failure. This field is null when the operation succeeds. See error | 0.6 |
| inventory | VmInstanceInventory | See inventory | 0.6 |
error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 0.6 |
| description | String | Brief description of the error | 0.6 |
| details | String | Detailed error information | 0.6 |
| elaboration | String | Reserved field, defaults to null | 0.6 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 0.6 |
| cause | ErrorCode | Root cause, the source error that triggered the current error. If there is no original error, this field is null | 0.6 |
inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID, 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 | Compute Offering UUID | 0.6 |
| rootVolumeUuid | String | 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 | Creation Time | 0.6 |
| lastOpDate | Timestamp | 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 | See vmCdRoms | 4.6.21 |
vmNics
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID, uniquely identifies the resource | 0.6 |
| vmInstanceUuid | String | Virtual Machine UUID | 0.6 |
| l3NetworkUuid | String | L3 Network UUID | 0.6 |
| ip | String | 0.6 | |
| mac | String | 0.6 | |
| hypervisorType | String | 4.7.13 | |
| netmask | String | 0.6 | |
| gateway | String | 0.6 | |
| metaData | String | 0.6 | |
| ipVersion | Integer | IP protocol version | 3.1.0 |
| driverType | String | 4.7.13 | |
| internalName | String | 4.7.13 | |
| deviceId | Integer | 0.6 | |
| type | String | 4.7.13 | |
| state | String | NIC status | 4.7.13 |
| createDate | Timestamp | Creation Time | 0.6 |
| lastOpDate | Timestamp | Last Operation Date | 0.6 |
| usedIps | List | See usedIps | 0.6 |
usedIps
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID, uniquely identifies the resource | 0.6 |
| ipRangeUuid | String | IP Range UUID | 0.6 |
| l3NetworkUuid | String | L3 Network UUID | 0.6 |
| ipVersion | Integer | IP Protocol Version | 3.1.0 |
| ip | String | IP Address | 0.6 |
| netmask | String | Network Mask | 0.6 |
| gateway | String | Gateway Address | 0.6 |
| usedFor | String | 0.6 | |
| ipInLong | long | 0.6 | |
| vmNicUuid | String | Virtual Machine NIC UUID | 3.1.0 |
| createDate | Timestamp | Creation Time | 0.6 |
| lastOpDate | Timestamp | Last Operation Date | 0.6 |
allVolumes
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID, uniquely identifies the resource | 0.6 |
| name | String | Resource name | 0.6 |
| description | String | Detailed description of the resource | 0.6 |
| primaryStorageUuid | String | Primary Storage UUID | 0.6 |
| vmInstanceUuid | String | Virtual Machine UUID | 0.6 |
| diskOfferingUuid | String | Disk Offering UUID | 0.6 |
| rootImageUuid | String | 0.6 | |
| installPath | String | 0.6 | |
| type | String | 0.6 | |
| format | String | 0.6 | |
| size | Long | 0.6 | |
| actualSize | Long | 0.6 | |
| deviceId | Integer | 0.6 | |
| state | String | 0.6 | |
| status | String | 0.6 | |
| createDate | Timestamp | Creation Time | 0.6 |
| lastOpDate | Timestamp | Last Operation Date | 0.6 |
| isShareable | Boolean | 0.6 | |
| volumeQos | String | 4.7.13 | |
| lastDetachDate | Timestamp | 4.7.13 | |
| lastVmInstanceUuid | String | 4.7.13 |
vmCdRoms
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID, uniquely identifies the resource | 4.6.21 |
| vmInstanceUuid | String | Virtual Machine UUID | 4.6.21 |
| deviceId | Integer | 4.6.21 | |
| isoUuid | String | 4.6.21 | |
| isoInstallPath | String | 4.6.21 | |
| name | String | Resource name | 4.6.21 |
| description | String | Detailed description of the resource | 4.6.21 |
| createDate | Timestamp | Creation Time | 4.6.21 |
| lastOpDate | Timestamp | Last Operation Date | 4.6.21 |
SDK Examples
Java SDK
MigrateVmAction action = new MigrateVmAction();
action.vmInstanceUuid = "c53c9b6235703b8ab96c1cc35859242d";
action.hostUuid = "7571fb72e52b3fcab1a6992e7eef4cce";
action.migrateFromDestination = false;
action.allowUnknown = false;
action.downTime = 300;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
MigrateVmAction.Result res = action.call();Python SDK
action = MigrateVmAction()
action.vmInstanceUuid = "c53c9b6235703b8ab96c1cc35859242d"
action.hostUuid = "7571fb72e52b3fcab1a6992e7eef4cce"
action.migrateFromDestination = false
action.allowUnknown = false
action.downTime = 300
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()