The following vSphere SDK for Perl Script provides an example of performing a vSphere 5.1 vMotion of a live running virtual machine and changing both it's datastore as well as host using the RelocateVM_Task() vSphere API.
Here is an example of running the script:
./migrateVM.pl --server 172.30.0.221 --username root --vmname FRANK --vihost 172.30.0.243 --datastore local-datastore-2
You will need to be connecting to a vSphere 5.1 vCenter Server and specify the following parameters:
--vmname = Name of the Virtual Machine to migrate
--vihost = Name of ESXi host to migrate to
--datastore = Name of the datastore to migrate to
Here are a few screenshots:



For more details, please refer to this blog post.