posted

16 Comments

My colleague Frank Denneman recently asked me whether there was a new vSphere API for the new enhancement made to vMotion in vSphere 5.1, which would allow you to migrate a live running virtual machine without the need of shared storage. The simple answer is no, the new enhancement to vMotion operation has been integrated into the existing Storage vMotion API call which is the RelocateVM_Task method.

If you specify both the datastore and host property in the VirtualMachineRelocateSpec to the RelocateVM_Task method, you will be performing a combined vMotion + Storage vMotion. If you just specify the datastore property, then a regular Storage vMotion will be performed. For a regular vMotion operation, you will need to use the MigrateVM_Task method. To get more details, please refer to the vSphere API Reference Guide.

To demonstrate how the RelocateVM_Task method works for a combined vMotion + Storage vMotion, I created a simple vSphere SDK for Perl script called migrateVM.pl. You will need a system with the vCLI installed or use the vMA appliance.

Disclaimer: These script are provided for informational/educational purposes only. It should be thoroughly tested before attempting to use in a production environment.

In the example below, I have two ESXi 5.1 hosts (172.30.0.243 & 172.30.0.251) and they both contain only local datastores (local-datastore-2 & local-datastore-3). I will be migrating a virtual machine called FRANK which resides on one of the ESXi host on local storage to the other ESXi host with only local storage.

FRANK currently resides on ESXi host 172.30.0.251 and datastore local-datastore-3 as seen in the screenshot of our vSphere Web Client.

Now we perform the combined vMotion + Storage vMotion by connecting to our vCenter Server and specifying the –vmname (Virtual Machine to migrate), –vihost (ESXi host to migrate to) and –datastore (datastore to migrate to ) property.

If we go back and refresh the vSphere Web Client, we should see a RELOCATED tasks completion and the FRANK virtual machine has been moved to ESXi host 172.30.0.243 and datastore local-datastore-2.

Get notification of new blog postings and more by following lamw on Twitter:  @lamw