Migrate VM Across Data Storage

PUT/zstack/v1/vm-instances/{vmInstanceUuid}/actions

Headers

Authorization: OAuth the-session-uuid

Body

{
  "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/actions

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
vmInstanceUuidStringurlVM Instance UUID 3.1.0
dstPrimaryStorageUuidStringbody(contained in the primaryStorageMigrateVm structure)Destination Data Storage UUID 3.1.0
withDataVolumes (Optional)booleanbody(contained in the primaryStorageMigrateVm structure)Migrate with data volumes 3.1.0
withSnapshots (Optional)booleanbody(contained in the primaryStorageMigrateVm structure)Migrate with snapshots 3.1.0
systemTags (Optional)Listbody  3.1.0
userTags (Optional)Listbody  3.1.0
dstHostUuid (Optional)Stringbody(contained in the primaryStorageMigrateVm structure)  4.0.0
strategy (Optional)Stringbody(contained in the primaryStorageMigrateVm structure)  4.6.0
downTime (Optional)Integerbody(contained in the primaryStorageMigrateVm structure)Migration downtime 4.6.21
bandwidth (Optional)longbody(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"
      }
    ]
  }
}
NameTypeDescriptionStarting Version
successboolean 4.6.0
errorErrorCodeError code. If not null, the operation failed. When the operation succeeds, this field is null. See error3.1.0
inventoryVmInstanceInventorySee inventory3.1.0

error

NameTypeDescriptionStarting Version
codeStringError code number, a globally unique identifier for the error, for example SYS.1000, HOST.10013.1.0
descriptionStringBrief description of the error3.1.0
detailsStringDetailed error information3.1.0
elaborationStringReserved field, defaults to null3.1.0
opaqueLinkedHashMapReserved field, defaults to null3.1.0
causeErrorCodeRoot cause, the source error that caused the current error. If there is no original error, this field is null3.1.0

inventories

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource3.1.0
nameStringResource Name3.1.0
descriptionStringResource Description3.1.0
zoneUuidStringData Center UUID3.1.0
clusterUuidStringCluster UUID3.1.0
imageUuidStringImage UUID3.1.0
hostUuidStringHost UUID3.1.0
lastHostUuidString 3.1.0
instanceOfferingUuidStringInstance Offering UUID3.1.0
rootVolumeUuidStringRoot Volume UUID3.1.0
platformString 3.1.0
architectureString 4.6.21
defaultL3NetworkUuidString 3.1.0
typeString 3.1.0
hypervisorTypeString 3.1.0
memorySizeLong 3.1.0
cpuNumInteger 3.1.0
cpuSpeedLong 3.1.0
allocatorStrategyString 3.1.0
createDateTimestampCreate Time3.1.0
lastOpDateTimestampLast Modification Time3.1.0
stateString 3.1.0
guestOsTypeString 4.6.21
vmNicsListSee vmNics3.1.0
allVolumesListSee allVolumes3.1.0
vmCdRomsListSee vmCdRoms4.6.21

vmNics

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource3.1.0
vmInstanceUuidStringVM Instance UUID3.1.0
l3NetworkUuidStringL3 Network UUID3.1.0
ipString 3.1.0
macString 3.1.0
netmaskString 3.1.0
gatewayString 3.1.0
metaDataString 3.1.0
deviceIdInteger 3.1.0
createDateTimestampCreate Time3.1.0
lastOpDateTimestampLast Modification Time3.1.0
usedIpsListSee usedIps4.6.21

usedIps

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource4.6.21
ipRangeUuidStringIP Range UUID4.6.21
l3NetworkUuidStringL3 Network UUID4.6.21
ipVersionIntegerIP Protocol Version4.6.21
ipStringIP Address4.6.21
netmaskStringNetwork Mask4.6.21
gatewayStringGateway Address4.6.21
usedForString 4.6.21
ipInLonglong 4.6.21
vmNicUuidStringVM NIC UUID4.6.21
createDateTimestampCreate Time4.6.21
lastOpDateTimestampLast Modification Time4.6.21

allVolumes

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource3.1.0
nameStringResource Name3.1.0
descriptionStringResource Description3.1.0
primaryStorageUuidStringData Storage UUID3.1.0
vmInstanceUuidStringVM Instance UUID3.1.0
diskOfferingUuidStringDisk Offering UUID3.1.0
rootImageUuidString 3.1.0
installPathString 3.1.0
typeString 3.1.0
formatString 3.1.0
sizeLong 3.1.0
actualSizeLong 3.1.0
deviceIdInteger 3.1.0
stateString 3.1.0
statusString 3.1.0
createDateTimestampCreate Time3.1.0
lastOpDateTimestampLast Modification Time3.1.0
isShareableBoolean 3.1.0

vmCdRoms

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource4.6.21
vmInstanceUuidStringVM Instance UUID4.6.21
deviceIdInteger 4.6.21
isoUuidString 4.6.21
isoInstallPathString 4.6.21
nameStringResource Name4.6.21
descriptionStringResource Description4.6.21
createDateTimestampCreate Time4.6.21
lastOpDateTimestampLast Modification Time4.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()