Highlighted
Enthusiast
Enthusiast

API Call to Migrate VM Between Resource Pools

Jump to solution

Hello All,

After upgrading our vCloud instances to version 10, we've found that the ability to migrate VMs between resource pools has been removed from the GUI. Support tells us this functionality is still possible, but only through an API call:

https://[redacted].com/api/admin/extension/resourcePool/[id]/action/migrateVms

I've searched through VMware's documentation but can only find very sparse info on this API call. I did locate an example on Tom Fojta's blog... from 2013 - https://fojta.wordpress.com/2013/01/13/vcloud-director-online-migration-of-virtual-data-center/

When I craft a query and requisite parameters based on that example, I get a 404 error in return. I'm able to query each entity separately, so I'm not sure what is triggering the 404. I'm guessing the API call has changed since his post 7 years ago.

Here is the body of my request:

<MigrateParams xmlns="http://www.vmware.com/vcloud/extension/v1.5" xmlns:vcloud_v1.5="http://www.vmware.com/vcloud/v1.5">

    <VmRef href="https://[redacted].com/api/vApp/[id of VM to be migrated]"/>
    <ResourcePoolRef>
        <VimServerRef name="[FQDN of vCenter]" href="https://[redacted].com/api/admin/extension/vimServer/[id of vCenter]" type="application/vnd.vmware.admin.vmwvirtualcenter+xml"/>
        <MoRef>[MoRef of target resource pool]</MoRef>
        <VimObjectType>RESOURCE_POOL</VimObjectType>
    </ResourcePoolRef>
</MigrateParams>

 Has anyone used this API call before who might be able to give me a clue as to what I'm getting wrong?

Thanks

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Enthusiast
Enthusiast

I was able to figure this out with some help from support. I was using the incorrect header value for "Content-Type" and a glitch in my Postman instance was preventing me from changing it. Reinstalled Postman and was able to supply the correct header which is "application/vnd.vmware.admin.migrateVmParams+xml"

View solution in original post

0 Kudos
3 Replies
Highlighted
VMware Employee
VMware Employee

Here is a sample request that is known to work (it's part of the vCD test suite): 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:MigrateParams xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ns2="http://www.vmware.com/vcloud/extension/v1.5" xmlns:ns3="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:ns4="http://schemas.dmtf.org/ovf/envelope/1" xmlns:ns5="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ns6="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:ns7="http://www.vmware.com/schema/ovf" xmlns:ns8="http://schemas.dmtf.org/ovf/environment/1" xmlns:ns9="http://www.vmware.com/vcloud/versions">
<ns2:VmRef href="https://wdc-vcd-sp-static-34-49.eng.vmware.com/api/vApp/vm-a7dcd89e-23a0-480e-9090-ef91cec094da" id="urn:vcloud:vm:a7dcd89e-23a0-480e-9090-ef91cec094da" name="vm-1" type="application/vnd.vmware.vcloud.vm+xml"/>
<ns2:ResourcePoolRef>
<ns2:VimServerRef href="https://wdc-vcd-sp-static-34-49.eng.vmware.com/api/admin/extension/vimServer/40412aad-523d-406a-8257..." id="urn:vcloud:vimserver:40412aad-523d-406a-8257-e67d3d079b3f" name="vc1" type="application/vnd.vmware.admin.vmwvirtualcenter+xml"/>
<ns2:MoRef>resgroup-273</ns2:MoRef>
<ns2:VimObjectType>RESOURCE_POOL</ns2:VimObjectType>
</ns2:ResourcePoolRef>
</ns2:MigrateParams>

I think you are missing proper IDs in your handcrafted body.

 

Highlighted
Enthusiast
Enthusiast

Thanks for the reply!

I tried using the sample you posted but I still get the same 404 response.

Is there any way to determine which ID might be wrong? I'm able to successfully query the VM ID and the vCenter server ID, so I have at least confirmed that the IDs I'm supplying are valid.

I tried running the request without the "ResourcePoolRef" parameter just to see what would happen (since the documentation indicates it is optional) and I get the same 404. I feel like I'm missing something basic.

0 Kudos
Highlighted
Enthusiast
Enthusiast

I was able to figure this out with some help from support. I was using the incorrect header value for "Content-Type" and a glitch in my Postman instance was preventing me from changing it. Reinstalled Postman and was able to supply the correct header which is "application/vnd.vmware.admin.migrateVmParams+xml"

View solution in original post

0 Kudos