This is a short follow-up to a previous post I wrote about the cool integrations between vRNI and VMC. Martijn recently put together a great little Fling that enables customers to synchronize their group of VMs created by vRNI with HCX mobility groups.
Let’s have a look at it in more details:
HCX has a feature called “Mobility Groups” where you can organize your VMs into groups of applications that you want to move to/from the Cloud together.
You can manually create these Mobility Groups by manually selecting the VMs. For example, I selected 3 VMs in my group and I can go ahead and migrate them.
That’s fine but obviously that’s a manual process. Alternatively, you can leverage another VMware application that can automatically group application based on flows, tags, VM names, etc.. Again, read my previous post to find out more about this.
That application is of course vRealize Network Insight and conveniently our resident genius Martijn put together a script that leverages PowerCLI to export the applications created in vRNI to HCX mobility groups.
If you look above, I’ve got application groups created by vRNI. In summary, the idea is:
- Use vRNI to analyze the estate and based on flow data, VM names or other critera, automatically group them together in applications
- Automatically sync these groups from vRNI into HCX mobility groups
- Migrate the HCX mobility group one at a time (VMs within a mobility group will likely have dependencies and that’s why it makes sense to migrate them all together).
So how do I copy the 8 application groups I have in vRNI above to the 8 mobility groups in HCX? Do I do this manually or do I use some cool automation? I think you know the answer already.
The Fling is essentially a PowerShell script. You don’t need to be an expert at PowerShell / PowerCLI in order to run it.
First, you need PowerShell 7. Follow the instructions here.
Start your PowerShell terminal (as an administrator ideally, to avoid further issues).
Then you need to install PowerCLI with this command:
Install-Module -Name VMware.PowerCLI
You need to install both the PowerVRNI and HCX modules:
Install-Module PowervRNI Install-Module VMware.VimAutomation.Hcx
Download the Fling here.
Get all the credentials from HCX and vRNI. I’m using vRNI Cloud (the SaaS version of vRNI) so I don’t use username/password but a token.
And then, navigate to the folder with the sync-vrni-to-hcx.ps1 script and just run the command below (once you have created the variables $vrni_token, $hcx_server, $hcx_user, $destination_vc and $destination_hcx).
./sync-vrni-to-hcx.ps1 -vRNI_Cloud_API_Token $vrni_token -HCX_Server $hcx_server -HCX_Username $hcx_user -HCX_DestinationVC $destination_vc -HCX_DestinationCloud $destination_hcx -SkipCertificateCheck
And the magic starts!
All the groups appear in my HCX:
And I can start migrating groups in waves:
If you get the following error message:
You might need to run this command to overwrite the security policy:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
If you get some authentication errors, check that you have access to the HCX platforms and that the credentials are correct!
If you run into some issues, you can look directly in the sync-vrni-to-hcx.ps1 and try to run the commands separately (I had to do that to realize I was using the wrong HCX credentials).
Enjoy the Fling!