Need to move virtual machines between resource pools in a Provider vDC
search cancel

Need to move virtual machines between resource pools in a Provider vDC


Article ID: 322119


Updated On:


VMware Cloud Director


Provide examples of using the API to move virtual machines between resource pools


Note: please be aware that the ability to do this via the UI was added as a feature in vCloud Director version 10.3.

1. Get Authenticated:

2. Use the API to list out the provider vDCs

Sample response information:
    <VMWProviderVdcRecord cpuAllocationMhz="xxxxxx" cpuLimitMhz="xxxxx" cpuUsedMhz="xxxx" isBusy="false" isDeleted="false" isEnabled="true" memoryAllocationMB="xxxx" memoryLimitMB="xxxx" memoryUsedMB="xxxxx" name="Merge" numberOfDatastores="x" numberOfResourcePools="x" numberOfStorageProfiles="xx" numberOfVdcs="x" status="READY" storageAllocationMB="xxxx" storageLimitMB="xxxxx" storageUsedMB="xxxxx" href="<PROVIDER_VDC_UUID>"

3. Using the provider ID from above to list the resource pools:<PROVIDER_VDC_UUID>/resourcePools

Sample response information:
        <Link rel="migrateVms" href="<RESOURCE_POOL_UUID>/action/migrateVms"/>

4: Using the resource pool ID found in Step 3, list the virtual machines:<RESOURCE_POOL_UUID>/vmList?show=all&pageSize=xxx

Sample response information:
    <ResourcePoolVMRecord containerName="TestMovevApp" guestOs="Other 3.x Linux (32-bit)" hardwareVersion="11" isBusy="false" isDeployed="true" name="TestMoveVM" status="POWERED_ON" href="<VIRTUAL_MACHINE_UUID>" taskStatusName="vappDeploy" task="<TASK_UUID>" taskStatus="success" taskDetails=" "/>

5: Put everything together in a POST statement:<RESOURCE_POOL_UUID>/action/migrateVms

Add a Content-Type header:

<MigrateParams xmlns = "http://www.xxxxxxxx/vcloud/extension/v1.5" xmlns:vcloud_v1.5 = "http://www.xxxxxxxx/vcloud/v1.5" >
     <VmRef href = "<VIRTUAL_MACHINE_UUID>" />
         <VimServerRef href = "<VCENTER_UUID>" type="appliance/vnd.xxxxxx.admin.vmwvirtualcenter+xml" />
         <MoRef>resgroup-xx</MoRef >

This section is from step 4 :<VIRTUAL_MACHINE_UUID>  

This section is from step 3<VCENTER_UUID>       

This resource pool is found during step 3

NOTE: You can add multiple VmRef records to the same request