Cloud Motion with vSphere Replication is the newest migration type that has been added to the Hybrid Cloud Extension (HCX) solution, which was also demonstrated during the VMworld US 2018 keynote (watch here). Unlike the traditional Bulk Migration, which also uses vSphere Replication to perform the initial replication, Cloud Motion with VR does not incur any downtime during the VM switch over. This is possible with our most beloved vSphere feature, vMotion!
With Bulk Migration, the VM on the source vCenter Server must be shutdown before the newly replicated VM on the destination vCenter Server can be powered on or else a network conflict will occur. Using Cloud Motion with VR, the VM is simply vMotion'ed from the source vCenter Server to the destination vCenter Server and because the VM's storage has already been replicated, the only thing that needs to transfer is the memory state of the VM.
All three HCX Migration Types can be scheduled from the HCX UI using the vSphere Client or automated using the HCX API. The latter option is definitely ideal for customers with large number of migrations but it can also help with smaller migrations as it reduces the amount of user input required when using the UI and ultimately, this reduces user errors.
To help demonstrate the HCX Migration APIs, I have updated my VMware HCX PowerShell Module to include the following two new functions:
- New-HcxMigration
- Get-HcxMigration
In the example below, we will be migrating three VMs from our onPrem vCenter Server named: SJC-CNA-97, SJC-CNA-98 and SJC-CNA-99 to VMC vCenter Server. There are three VM Networks (Distributed Portgroups) that are in use by these VMs: SJC-CORP-WORKLOADS, SJC-CORP-INTERNAL-1 and SJC-CORP-INTERNAL-2 and we would like to map these the VMC vCenter Server VM Networks: sddc-cgw-network-1, sddc-cgw-network-2 and sddc-cgw-network-3 When using the HCX UI, you need to manually map the source/destination network for each VM that you wish to migrate, this definitely gets challenging when you are doing more than 1-2 VMs. We will take a look at how you can easily migrate a handful to few hundred VMs and only specifying the minimum amount of input including optimizing on the network mapping using the functions below.
Step 1 - Import the updated VMware HCX PowerShell Module:
Import-Module ./VMware.HCX.psm1
Step 2 - Connect to your onPrem HCX Manager with the same credentials you would use when logging into the vSphere Client:
Connect-HcxServer -Server $HCXServer -Username $HCXUsername -Password $HCXPassword
Step 3 - Connect to both your onPrem and VMware Cloud on AWS vCenter Server using the Connect-VIServer cmdlet and store the connections to the following two variables (which will be referenced latter):
$cloudVC = Connect-VIServer -Server $CloudVCName -User $CloudVCUsername -Password $CloudVCPassword
$onPremVC = Connect-VIServer -Server $OnPremVCName -User $OnPremVCUsername -Password $onPremVCPassword
Step 4 - The New-HcxMigration function can be used to validate a migration as well as performing the actual migration. It takes in both an -onPremVCConnection and -cloudVCConnection which we have from Step 3. It then takes a -MigrationType (Cold, vMotion, VR or bulkVMotion), -VMs which is an array of VM names, -NetworkMappings which is hashtable mapping your source VM networks to the destination VM networks and finally the start and end time of the switch over which is defined by -StartTime and -EndTime arguments. By default, the function only performs validation of the requested migration and if there are any errors in the validation, each issue is listed in the output
New-HcxMigration -onPremVCConnection $onPremVC -cloudVCConnection $cloudVC ` -MigrationType bulkVMotion ` -VMs @("SJC-CNA-97","SJC-CNA-98","SJC-CNA-99") ` -NetworkMappings @{"SJC-CORP-WORKLOADS"="sddc-cgw-network-1";"SJC-CORP-INTERNAL-1"="sddc-cgw-network-2";"SJC-CORP-INTERNAL-2"="sddc-cgw-network-3"} ` -StartTime "Sep 24 2018 2:00 PM" ` -EndTime "Sep 24 2018 3:00 PM"
Step 5 - If the requested migration validates successfully, you can then re-run the same command but now passing -ValidateOnly with value of $true to actually initiate the HCX migration.
New-HcxMigration -onPremVCConnection $onPremVC -cloudVCConnection $cloudVC ` -MigrationType bulkVMotion ` -VMs @("SJC-CNA-97","SJC-CNA-98","SJC-CNA-99") ` -NetworkMappings @{"SJC-CORP-WORKLOADS"="sddc-cgw-network-1";"SJC-CORP-INTERNAL-1"="sddc-cgw-network-2";"SJC-CORP-INTERNAL-2"="sddc-cgw-network-3"} ` -StartTime "Sep 24 2018 2:00 PM" ` -EndTime "Sep 24 2018 3:00 PM" ` -ValidateOnly $false
If the migration request is submitted successfully, you will get back a list of migration IDs, one for each VM, which we can then use to monitor the migration progress.
You can also confirm the migration has started by going to the HCX UI
Step 6 - If you wish to monitor the progress of your migration, we can use the Get-HcxMigration function which supports a number of arguments.
If you wish to list all migrations, including ones that have completed, have failed or are in progress, run the following command:
Get-HcxMigration
If you wish to only list active migrations, simply add the -RunningMigrations option using the following command:
Get-HcxMigration -RunningMigrations
If you wish to list a specific migration, simply add -MigrationID and the ID using the following command:
Get-HcxMigration -MigrationId b8f2e75a-7e49-4e6a-8565-5485ab6af887
Thanks for the comment!