VMware Cloud Community
JMC13
Contributor
Contributor

cross vcenter vmotion

Does anyone have a workflow to vmotion a vm across vcenters with different SSO domains (supposed to be possible but only through orchestrator in v7)

6 Replies
tschoergez
Leadership
Leadership

Hi,

as it happens, I'm currently working on that topic 🙂

Here's the API call for source vCenter:

var serviceLocator = new VcServiceLocator();

serviceLocator.credential = new VcServiceLocatorNamePassword();

serviceLocator.credential.username = username;

serviceLocator.credential.password = password;

serviceLocator.instanceUuid = targetVCInstanceUUID;

serviceLocator.sslThumbprint = sslThumbprint;

serviceLocator.url = url;

var relocateSpec = new VcVirtualMachineRelocateSpec();

relocateSpec.datastore = new VcManagedObjectReference();

relocateSpec.datastore.type = "Datastore";

relocateSpec.datastore.value = targetDatastoreMoId;

relocateSpec.pool = new VcManagedObjectReference();

relocateSpec.pool.type = "ResourcePool";

relocateSpec.pool.value = targetResourcePoolMoId;

relocateSpec.host = new VcManagedObjectReference();

relocateSpec.host.type = "HostSystem";

relocateSpec.host.value = targetHostMoId;

var devices = vm.config.hardware.device;

var arr = [];

arr.push (new VcVirtualDeviceConfigSpec());

relocateSpec.deviceChange = arr;

relocateSpec.deviceChange[0] = new VcVirtualDeviceConfigSpec();

relocateSpec.deviceChange[0].operation = VcVirtualDeviceConfigSpecOperation.edit;

for (var i in devices) {

  if (System.getModule("com.vmware.library.vc.vm.network").isSupportedNic(devices[i])) {

  var backing = devices[i].backing;

  backing.deviceName = targetNetworkName;

  relocateSpec.deviceChange[0].device = devices[i];

  relocateSpec.deviceChange[0].device.backing = backing;

  }

}

relocateSpec.service = serviceLocator;

System.log("Start migration of VM " + vm);

relocateVmTask = vm.relocateVM_Task(relocateSpec);

Find attached a screenshot of the workflow to see the parameters (ignore participantId and participantName).

Currently this logic only supports VMs with one NIC, and standard vSwitch. For more NICs and vDS support you have to exand /change the device change parts of the script above.

Here's some example data (so you get the right format for vCenter URL and SSL thumbprint:

participantObj.targetVCInstanceUUID = "d9dd6319-7d13-48d3-9b79-cddb27f1bcbe";

participantObj.targetResourcePoolMoId = "resgroup-202";

participantObj.targetDatastoreMoId = "datastore-143";

participantObj.targetHostMoId = "host-29";

participantObj.targetNetworkName = "VM Network";

participantObj.username = "administrator@vsphere.local";

participantObj.password = "blahblah";

participantObj.sslThumbprint = "25:ce:76:57:a1:c4:3b:56:06:68:2d:7d:9c:e1:5b:1e:e0:8e:53:74";

participantObj.url = "https://vcsa-01a.acme.local/sdk";

From my link / todo list 🙂

http://www.virtuallyghetto.com/2016/05/automating-cross-vcenter-vmotion-xvc-vmotion-between-the-same...

http://vthinkbeyondvm.com/want-to-vmotion-a-vm-from-one-vcenter-server-to-another-vcenter-using-vsph...

Extracting SSL Thumbprint from initial Connect-VIServer

https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=10037...

Cross vCenter Server vMotion requirements in VMware vSphere 6.0 (2106952) | VMware KB

make sure to specify

Regards,

Joerg

Reply
0 Kudos
tschoergez
Leadership
Leadership

In my case I'm migrating to a vCenter that is NOT known / registered in the vRO the workflow runs on, therefore the moids for target inventory are just plain text (the workflow gets from some additional logic upfront).

If your target vCenter is connected to the same vRO, you can of course use the vRO inventory objects directly as input, and get their managed object ids programmatically, same for vCenter UUID. Not sure about the credentials and SSL thumbprint though, that might be a bit more tricky...

Reply
0 Kudos
JMC13
Contributor
Contributor

thanks,  if you do any more work with this let me know, also if you do vds. 

Reply
0 Kudos
sbeaver
Leadership
Leadership

Here is what I have started working with that is able to move a VM to a different vCenter with a different PSC but in the same SSO domain as well as handle moving from DVS to DVS.

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
Reply
0 Kudos
JMC13
Contributor
Contributor

When I try to import your package I get a wrong key error message.  Can you post the code for your workflow?

Reply
0 Kudos
evil242
Enthusiast
Enthusiast

So I stumbled on this solution as I'm working on a workflow to migrate VRA managed VMs from old cluster to new cluster with NSX.

Tasks I need to complete is

  • add to new reservation.
  • update vra Extensible Attributes
  • migrate same vcenter, but new cluster with new datastore
  • update IP Address, GW, and Subnet mask

So it appears that the workflow from https://vbombarded.wordpress.com/2018/03/20/cross-vcenter-vmotion-with-vrealize-orchestrator/ will do the migration. 

And I've already made workflows that update the EAs. 

But question is how to update the IP network config in the VM?

Damion Terrell  .   +  (He/Him)  +  . *  .  +   @   + .    *  .    +      .                    
Core IT Service Specialist * . + * . + . + . + * +
UNM – IT Platforms – VIS + . . . . . . . . .
. + . + * . + * .
* . . + . . . . + . + * + .
“You learn the job of the person above you, * + . + * @
and you teach your job to the person below you..” . * +
Reply
0 Kudos