Migrate VM Across Data Storage
Headers
Authorization: OAuth the-session-uuidBody
{
"primaryStorageMigrateVm": {
"dstPrimaryStorageUuid": "21e2f323f0f73feca4269e4056497281",
"dstHostUuid": "2208f64378cc3b5fa4a11609ca4ef524",
"withDataVolumes": true,
"withSnapshots": false,
"downTime": 300,
"bandwidth": 0
},
"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 PUT -d '{"primaryStorageMigrateVm":{"dstPrimaryStorageUuid":"21e2f323f0f73feca4269e4056497281"," dstHostUuid":"2208f64378cc3b5fa4a11609ca4ef524","withDataVolumes":true,"withSnapshots":false,"downTime":300,"bandwidth":0}}' \
http://localhost:8080/zstack/v1/vm-instances/332389a8b7453ccd85e625ef581694e9/actionsParameter List
| Name | Type | Location | Description | Allowed Values | Starting Version |
|---|---|---|---|---|---|
| vmInstanceUuid | String | url | VM Instance UUID | 3.1.0 | |
| dstPrimaryStorageUuid | String | body(contained in the primaryStorageMigrateVm structure) | Destination Data Storage UUID | 3.1.0 | |
| withDataVolumes (Optional) | boolean | body(contained in the primaryStorageMigrateVm structure) | Migrate with data volumes | 3.1.0 | |
| withSnapshots (Optional) | boolean | body(contained in the primaryStorageMigrateVm structure) | Migrate with snapshots | 3.1.0 | |
| systemTags (Optional) | List | body | 3.1.0 | ||
| userTags (Optional) | List | body | 3.1.0 | ||
| dstHostUuid (Optional) | String | body(contained in the primaryStorageMigrateVm structure) | 4.0.0 | ||
| strategy (Optional) | String | body(contained in the primaryStorageMigrateVm structure) | 4.6.0 | ||
| downTime (Optional) | Integer | body(contained in the primaryStorageMigrateVm structure) | Migration downtime | 4.6.21 | |
| bandwidth (Optional) | long | body(contained in the primaryStorageMigrateVm structure) | Migration bandwidth limit in MB/s | 4.7.11 |
API Response
Response Example
{
"inventory": {
"uuid": "f483af349d39312c8078d142c40fb721",
"name": "Test-VM",
"description": "web server VM",
"zoneUuid": "b7280443258337bb9e8d2abf4a014644",
"clusterUuid": "a2c0ace5be2d35b5a365067a0127b377",
"imageUuid": "14fb13b692e837dfa31d75ffc02d4d4d",
"hostUuid": "f0690203b1463867bcb2f5a48a1fa91a",
"lastHostUuid": "655acef664af39e9b6b7fec0d4de56c0",
"instanceOfferingUuid": "772a66f21ef23ba7a69ad292e4489ebb",
"rootVolumeUuid": "65b10a950f1336f48b770f98b25176eb",
"platform": "Linux",
"defaultL3NetworkUuid": "80c8af5ff0a135e18a3e7a4d2223ebd2",
"type": "UserVm",
"hypervisorType": "KVM",
"memorySize": 8589934592,
"cpuNum": 1,
"allocatorStrategy": "LastHostPreferredAllocatorStrategy",
"createDate": "Nov 14, 2017 9:20:57 AM",
"lastOpDate": "Nov 14, 2017 9:20:57 AM",
"state": "Running",
"vmNics": [
{
"uuid": "b16455db309330289acb58edbfabd4b7",
"vmInstanceUuid": "f483af349d39312c8078d142c40fb721",
"usedIpUuid": "27787a727c143a7aada42e6c3b111887",
"l3NetworkUuid": "80c8af5ff0a135e18a3e7a4d2223ebd2",
"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 9:20:57 AM",
"lastOpDate": "Nov 14, 2017 9:20:57 AM"
}
],
"allVolumes": [
{
"uuid": "65b10a950f1336f48b770f98b25176eb",
"name": "Root-Volume-For-VM-f483af349d39312c8078d142c40fb721",
"primaryStorageUuid": "55245463f914331c954909475279c3b0",
"vmInstanceUuid": "f483af349d39312c8078d142c40fb721",
"diskOfferingUuid": "b2cb37282f5034fb808dff68dc18db9e",
"rootImageUuid": "14fb13b692e837dfa31d75ffc02d4d4d",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-65b10a950f1336f48b770f98b25176eb/65b10a950f1336f48b770f98b25176eb.qcow2",
"type": "Root",
"format": "qcow2",
"size": 107374182400,
"actualSize": 21474836480,
"deviceId": 0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 9:20:57 AM",
"lastOpDate": "Nov 14, 2017 9:20:57 AM"
},
{
"uuid": "97bf368f3bde3490b0c08d37ac8bc747",
"name": "Data-Volume-For-VM-f483af349d39312c8078d142c40fb721",
"primaryStorageUuid": "4df2eddd6ac1307ebbff27d0044f72e9",
"vmInstanceUuid": "f483af349d39312c8078d142c40fb721",
"diskOfferingUuid": "06ea8f5a59843b8aa4d18d9c6d2b7a1d",
"installPath": "/zstack_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-97bf368f3bde3490b0c08d37ac8bc747/97bf368f3bde3490b0c08d37ac8bc747.qcow2",
"type": "Data",
"format": "qcow2",
"size": 536870912000,
"actualSize": 107374182400,
"deviceId": 1,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 9:20:57 AM",
"lastOpDate": "Nov 14, 2017 9:20:57 AM"
}
]
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| success | boolean | 4.6.0 | |
| error | ErrorCode | Error code. If not null, the operation failed. When the operation succeeds, this field is null. See error | 3.1.0 |
| inventory | VmInstanceInventory | See inventory | 3.1.0 |
error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | Error code number, a globally unique identifier for the error, for example SYS.1000, HOST.1001 | 3.1.0 |
| description | String | Brief description of the error | 3.1.0 |
| details | String | Detailed error information | 3.1.0 |
| elaboration | String | Reserved field, defaults to null | 3.1.0 |
| opaque | LinkedHashMap | Reserved field, defaults to null | 3.1.0 |
| cause | ErrorCode | Root cause, the source error that caused the current error. If there is no original error, this field is null | 3.1.0 |
inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID, uniquely identifies the resource | 3.1.0 |
| name | String | Resource Name | 3.1.0 |
| description | String | Resource Description | 3.1.0 |
| zoneUuid | String | Data Center UUID | 3.1.0 |
| clusterUuid | String | Cluster UUID | 3.1.0 |
| imageUuid | String | Image UUID | 3.1.0 |
| hostUuid | String | Host UUID | 3.1.0 |
| lastHostUuid | String | 3.1.0 | |
| instanceOfferingUuid | String | Instance Offering UUID | 3.1.0 |
| rootVolumeUuid | String | Root Volume UUID | 3.1.0 |
| platform | String | 3.1.0 | |
| architecture | String | 4.6.21 | |
| defaultL3NetworkUuid | String | 3.1.0 | |
| type | String | 3.1.0 | |
| hypervisorType | String | 3.1.0 | |
| memorySize | Long | 3.1.0 | |
| cpuNum | Integer | 3.1.0 | |
| cpuSpeed | Long | 3.1.0 | |
| allocatorStrategy | String | 3.1.0 | |
| createDate | Timestamp | Create Time | 3.1.0 |
| lastOpDate | Timestamp | Last Modification Time | 3.1.0 |
| state | String | 3.1.0 | |
| guestOsType | String | 4.6.21 | |
| vmNics | List | See vmNics | 3.1.0 |
| allVolumes | List | See allVolumes | 3.1.0 |
| vmCdRoms | List | See vmCdRoms | 4.6.21 |
vmNics
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID, uniquely identifies the resource | 3.1.0 |
| vmInstanceUuid | String | VM Instance UUID | 3.1.0 |
| l3NetworkUuid | String | L3 Network UUID | 3.1.0 |
| ip | String | 3.1.0 | |
| mac | String | 3.1.0 | |
| netmask | String | 3.1.0 | |
| gateway | String | 3.1.0 | |
| metaData | String | 3.1.0 | |
| deviceId | Integer | 3.1.0 | |
| createDate | Timestamp | Create Time | 3.1.0 |
| lastOpDate | Timestamp | Last Modification Time | 3.1.0 |
| usedIps | List | See usedIps | 4.6.21 |
usedIps
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID, uniquely identifies the resource | 4.6.21 |
| ipRangeUuid | String | IP Range UUID | 4.6.21 |
| l3NetworkUuid | String | L3 Network UUID | 4.6.21 |
| ipVersion | Integer | IP Protocol Version | 4.6.21 |
| ip | String | IP Address | 4.6.21 |
| netmask | String | Network Mask | 4.6.21 |
| gateway | String | Gateway Address | 4.6.21 |
| usedFor | String | 4.6.21 | |
| ipInLong | long | 4.6.21 | |
| vmNicUuid | String | VM NIC UUID | 4.6.21 |
| createDate | Timestamp | Create Time | 4.6.21 |
| lastOpDate | Timestamp | Last Modification Time | 4.6.21 |
allVolumes
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID, uniquely identifies the resource | 3.1.0 |
| name | String | Resource Name | 3.1.0 |
| description | String | Resource Description | 3.1.0 |
| primaryStorageUuid | String | Data Storage UUID | 3.1.0 |
| vmInstanceUuid | String | VM Instance UUID | 3.1.0 |
| diskOfferingUuid | String | Disk Offering UUID | 3.1.0 |
| rootImageUuid | String | 3.1.0 | |
| installPath | String | 3.1.0 | |
| type | String | 3.1.0 | |
| format | String | 3.1.0 | |
| size | Long | 3.1.0 | |
| actualSize | Long | 3.1.0 | |
| deviceId | Integer | 3.1.0 | |
| state | String | 3.1.0 | |
| status | String | 3.1.0 | |
| createDate | Timestamp | Create Time | 3.1.0 |
| lastOpDate | Timestamp | Last Modification Time | 3.1.0 |
| isShareable | Boolean | 3.1.0 |
vmCdRoms
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | Resource UUID, uniquely identifies the resource | 4.6.21 |
| vmInstanceUuid | String | VM Instance 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 | Resource Description | 4.6.21 |
| createDate | Timestamp | Create Time | 4.6.21 |
| lastOpDate | Timestamp | Last Modification Time | 4.6.21 |
SDK Examples
Java SDK
PrimaryStorageMigrateVmAction action = new PrimaryStorageMigrateVmAction();
action.vmInstanceUuid = "332389a8b7453ccd85e625ef581694e9";
action.dstPrimaryStorageUuid = "21e2f323f0f73feca4269e4056497281";
action.dstHostUuid = "2208f64378cc3b5fa4a11609ca4ef524";
action.withDataVolumes = true;
action.withSnapshots = false;
action.downTime = 300;
action.bandwidth = 0;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
PrimaryStorageMigrateVmAction.Result res = action.call();Python SDK
action = PrimaryStorageMigrateVmAction()
action.vmInstanceUuid = "332389a8b7453ccd85e625ef581694e9"
action.dstPrimaryStorageUuid = "21e2f323f0f73feca4269e4056497281"
action.dstHostUuid = "2208f64378cc3b5fa4a11609ca4ef524"
action.withDataVolumes = true
action.withSnapshots = false
action.downTime = 300
action.bandwidth = 0
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()