PrimaryStorageMigrateVm

API Request

URLs
PUT zstack/v1/vm-instances/{vmInstanceUuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "primaryStorageMigrateVm": {
    "dstPrimaryStorageUuid": "21e2f323f0f73feca4269e4056497281",
    "withDataVolumes": true,
    "withSnapshots": false
  },
  "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","withDataVolumes":true,"withSnapshots":false}}' http://localhost:8080/zstack/v1/vm-instances/332389a8b7453ccd85e625ef581694e9/actions
Request Parameters
Name Type Location Description Optional 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
systemTags List body Optional. The system tags. 3.1.0
userTags List body Optional. The user tags. 3.1.0

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": 8.589934592E9,
    "cpuNum": 1.0,
    "allocatorStrategy": "LastHostPreferredAllocatorStrategy",
    "createDate": "Nov 14, 2017 10:20:57 PM",
    "lastOpDate": "Nov 14, 2017 10:20:57 PM",
    "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.0,
        "createDate": "Nov 14, 2017 10:20:57 PM",
        "lastOpDate": "Nov 14, 2017 10:20:57 PM"
      }
    ],
    "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": 1.073741824E11,
        "actualSize": 2.147483648E10,
        "deviceId": 0.0,
        "state": "Enabled",
        "status": "Ready",
        "createDate": "Nov 14, 2017 10:20:57 PM",
        "lastOpDate": "Nov 14, 2017 10:20:57 PM"
      },
      {
        "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": 5.36870912E11,
        "actualSize": 1.073741824E11,
        "deviceId": 1.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
error ErrorCode The error code. If not null, the operation fails, or vice versa. For more information, see error. 3.1.0
inventory VmInstanceInventory See inventory. 3.1.0
#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. 3.1.0
name String The resource name. 3.1.0
description String The detailed description of the resource. 3.1.0
zoneUuid String The zone UUID. 3.1.0
clusterUuid String The cluster UUID. 3.1.0
imageUuid String The image UUID. 3.1.0
hostUuid String The host UUID. 3.1.0
lastHostUuid String 3.1.0
instanceOfferingUuid String The instance offering UUID. 3.1.0
rootVolumeUuid String The root volume UUID. 3.1.0
platform String 3.1.0
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 The creation date. 3.1.0
lastOpDate Timestamp The last operation date. 3.1.0
state String 3.1.0
vmNics List See vmNics. 3.1.0
allVolumes List See allVolumes. 3.1.0
#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
#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

SDK Sample

Java SDK
PrimaryStorageMigrateVmAction action = new PrimaryStorageMigrateVmAction();
action.vmInstanceUuid = "332389a8b7453ccd85e625ef581694e9";
action.dstPrimaryStorageUuid = "21e2f323f0f73feca4269e4056497281";
action.withDataVolumes = true;
action.withSnapshots = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
PrimaryStorageMigrateVmAction.Result res = action.call();
Python SDK
PrimaryStorageMigrateVmAction action = PrimaryStorageMigrateVmAction()
action.vmInstanceUuid = "332389a8b7453ccd85e625ef581694e9"
action.dstPrimaryStorageUuid = "21e2f323f0f73feca4269e4056497281"
action.withDataVolumes = true
action.withSnapshots = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
PrimaryStorageMigrateVmAction.Result res = action.call()