VM Related Interfaces

Migrate Virtual Machine

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

Migrate a Virtual Machine to another Host using hot migration.

Headers

Authorization: OAuth the-session-uuid

Body

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

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
vmInstanceUuidStringurlVirtual Machine UUID 0.6
hostUuid (optional)Stringbody(contained in migrateVm structure)Host UUID 0.6
migrateFromDestination (optional)Booleanbody(contained in migrateVm structure)Initiate migration command from the migration destination host 2.3
allowUnknown (optional)booleanbody(contained in migrateVm structure)Allow Virtual Machines in unknown state 4.6.21
strategy (optional)Stringbody(contained in migrateVm structure) auto-converge4.6.21
systemTags (optional)Listbody  0.6
userTags (optional)ListbodyUser Tags 0.6
downTime (optional)Integerbody(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"
      }
    ]
  }
}
NameTypeDescriptionStarting Version
successboolean 4.6.21
errorErrorCodeError code. If not null, indicates operation failure. This field is null when the operation succeeds. See error0.6
inventoryVmInstanceInventorySee inventory0.6

error

NameTypeDescriptionStarting Version
codeStringError code number, a globally unique identifier for the error, for example SYS.1000, HOST.10010.6
descriptionStringBrief description of the error0.6
detailsStringDetailed error information0.6
elaborationStringReserved field, defaults to null0.6
opaqueLinkedHashMapReserved field, defaults to null0.6
causeErrorCodeRoot cause, the source error that triggered the current error. If there is no original error, this field is null0.6

inventory

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource0.6
nameStringResource name0.6
descriptionStringDetailed description of the resource0.6
zoneUuidStringData Center UUID0.6
clusterUuidStringCluster UUID0.6
imageUuidStringImage UUID0.6
hostUuidStringHost UUID0.6
lastHostUuidString 0.6
instanceOfferingUuidStringCompute Offering UUID0.6
rootVolumeUuidStringRoot Volume UUID0.6
platformString 0.6
architectureString 4.6.21
defaultL3NetworkUuidString 0.6
typeString 0.6
hypervisorTypeString 0.6
memorySizeLong 0.6
cpuNumInteger 0.6
cpuSpeedLong 0.6
allocatorStrategyString 0.6
createDateTimestampCreation Time0.6
lastOpDateTimestampLast Operation Date0.6
stateString 0.6
guestOsTypeString 4.6.21
vmNicsListSee vmNics0.6
allVolumesListSee allVolumes0.6
vmCdRoms See vmCdRoms4.6.21

vmNics

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource0.6
vmInstanceUuidStringVirtual Machine UUID0.6
l3NetworkUuidStringL3 Network UUID0.6
ipString 0.6
macString 0.6
hypervisorTypeString 4.7.13
netmaskString 0.6
gatewayString 0.6
metaDataString 0.6
ipVersionIntegerIP protocol version3.1.0
driverTypeString 4.7.13
internalNameString 4.7.13
deviceIdInteger 0.6
typeString 4.7.13
stateStringNIC status4.7.13
createDateTimestampCreation Time0.6
lastOpDateTimestampLast Operation Date0.6
usedIpsListSee usedIps0.6

usedIps

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource0.6
ipRangeUuidStringIP Range UUID0.6
l3NetworkUuidStringL3 Network UUID0.6
ipVersionIntegerIP Protocol Version3.1.0
ipStringIP Address0.6
netmaskStringNetwork Mask0.6
gatewayStringGateway Address0.6
usedForString 0.6
ipInLonglong 0.6
vmNicUuidStringVirtual Machine NIC UUID3.1.0
createDateTimestampCreation Time0.6
lastOpDateTimestampLast Operation Date0.6

allVolumes

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource0.6
nameStringResource name0.6
descriptionStringDetailed description of the resource0.6
primaryStorageUuidStringPrimary Storage UUID0.6
vmInstanceUuidStringVirtual Machine UUID0.6
diskOfferingUuidStringDisk Offering UUID0.6
rootImageUuidString 0.6
installPathString 0.6
typeString 0.6
formatString 0.6
sizeLong 0.6
actualSizeLong 0.6
deviceIdInteger 0.6
stateString 0.6
statusString 0.6
createDateTimestampCreation Time0.6
lastOpDateTimestampLast Operation Date0.6
isShareableBoolean 0.6
volumeQosString 4.7.13
lastDetachDateTimestamp 4.7.13
lastVmInstanceUuidString 4.7.13

vmCdRoms

NameTypeDescriptionStarting Version
uuidStringResource UUID, uniquely identifies the resource4.6.21
vmInstanceUuidStringVirtual Machine UUID4.6.21
deviceIdInteger 4.6.21
isoUuidString 4.6.21
isoInstallPathString 4.6.21
nameStringResource name4.6.21
descriptionStringDetailed description of the resource4.6.21
createDateTimestampCreation Time4.6.21
lastOpDateTimestampLast Operation Date4.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()