PrimaryStorageMigrateVm
API Request
URLs
PUT zstack/v1/vm-instances/{vmInstanceUuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"primaryStorageMigrateVm": {
"dstPrimaryStorageUuid": "21e2f323f0f73feca4269e4056497281",
"dstHostUuid": "2208f64378cc3b5fa4a11609ca4ef524",
"withDataVolumes": true,
"withSnapshots": false,
"downTime": 300,
"bandwidth": 0
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl
Sample
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/actionsRequest Parameters
| Name | Type | Location | Description | Valid Value | Starting Version |
|---|---|---|---|---|---|
| vmInstanceUuid | String | url | The VM instance UUID. | 3.1.0 | |
| dstPrimaryStorageUuid | String | body (contained in the primaryStorageMigrateVm structure) | The UUID of the destination primary storage. | 3.1.0 | |
| withDataVolumes | boolean | body (contained in the primaryStorageMigrateVm structure) | Optional. Migrates the VM instance with its data volumes. | 3.1.0 | |
| withSnapshots | boolean | body (contained in the primaryStorageMigrateVm structure) | Optional. Migrates the VM instance with its snapshots. | 3.1.0 | |
| dstHostUuid | String | body (contained in the primaryStorageMigrateVm structure) | Optional. | 4.0.0 | |
| systemTags | List | body | Optional. The system tags. | 3.1.0 | |
| userTags | List | body | Optional. The user tags. | 3.1.0 | |
| strategy | String | body (contained in the primaryStorageMigrateVm structure) | 4.6.0 | ||
| downTime | Integer | body (contained in the migrateVm structure) | Optional. The VM down time during the hot migration. | 4.6.21 | |
| bandwidth | long | body (contained in the migrateVm structure) | Optional. The bandwidth of migration across primary storage, in the unit of MB/s | 4.7.11 |
API Response
Sample
Response
{
"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"
}
]
}
}#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 3.1.0 |
| description | String | The detailed description of the error. | 3.1.0 |
| details | String | The details about the error. | 3.1.0 |
| elaboration | String | The reserved field. Default value: null. | 3.1.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.1.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 3.1.0 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| name | String | The resource name. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| zoneUuid | String | The zone UUID. | 0.6 |
| clusterUuid | String | The cluster UUID. | 0.6 |
| imageUuid | String | The image UUID. | 0.6 |
| hostUuid | String | The host UUID. | 0.6 |
| lastHostUuid | String | 0.6 | |
| instanceOfferingUuid | String | The instance offering UUID. | 0.6 |
| rootVolumeUuid | String | The 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 | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
| state | String | 0.6 | |
| 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 | The resource UUID. | 3.1.0 |
| vmInstanceUuid | String | The VM instance UUID. | 3.1.0 |
| l3NetworkUuid | String | The 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 | The creation date. | 3.1.0 |
| lastOpDate | Timestamp | The last operation date. | 3.1.0 |
| usedIps | List | See usedIps. | 4.6.21 |
#usedIps
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 0.6 |
| ipRangeUuid | String | The IP range UUID. | 0.6 |
| l3NetworkUuid | String | The L3 network UUID. | 0.6 |
| ipVersion | Integer | The IP version. | 3.1.0 |
| ip | String | The IP address. | 0.6 |
| netmask | String | The netmask. | 0.6 |
| gateway | String | The gateway. | 0.6 |
| usedFor | String | 0.6 | |
| ipInLong | long | 0.6 | |
| vmNicUuid | String | The VM NIC UUID. | 3.1.0 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
#allVolumes
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 3.1.0 |
| name | String | The resource name. | 3.1.0 |
| description | String | The detailed description of the resource. | 3.1.0 |
| primaryStorageUuid | String | The primary storage UUID. | 3.1.0 |
| vmInstanceUuid | String | The VM instance UUID. | 3.1.0 |
| diskOfferingUuid | String | The 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 | The creation date. | 3.1.0 |
| lastOpDate | Timestamp | The last operation date. | 3.1.0 |
| isShareable | Boolean | 3.1.0 |
#vmCdRoms
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 4.6.21 |
| vmInstanceUuid | String | The VM instance UUID. | 4.6.21 |
| deviceId | Integer | 4.6.21 | |
| isoUuid | String | 4.6.21 | |
| isoInstallPath | String | 4.6.21 | |
| name | String | The resource name. | 4.6.21 |
| description | String | The detailed description of the resource. | 4.6.21 |
| createDate | Timestamp | The creation date. | 4.6.21 |
| lastOpDate | Timestamp | The last operation date. | 4.6.21 |
SDK Sample
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
PrimaryStorageMigrateVmAction 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"
PrimaryStorageMigrateVmAction.Result res = action.call()