Using CloudClient to bulk change vRA Reservations
What happens when you have ~500 VMs in vRealize Automation that need to have their reservations changed? You figure out a way to script that tedious process. (This will provide some background and more details on a recent VMware Communities post.)
I first started looking at what I was most familiar with - PowervRA - a great community supported, PowerShell wrapper for the vRA API stack. Unfortunately, PowervRA does not offer reservation manipulation - only reporting.
CloudClient is a Java application wrapper for the vRA API. Bulk changing reservations is one use case, but several other uses exist in the documentation from that download site.
To use CloudClient in a wrapper script, we must first save our password by interactively launching CloudClient and executing the login keyfile
command. This command specifies an output location for the encrypted file and prompts for a password. Most CloudClient activities require authentication with both vRA and vRA’s IaaS component.
With the files saved, I can then create a CloudConfig.properties file
With the CloudConfig.properties file in place at the same level as the ./bin
folder, I can execute my commands directly from PowerShell
This works great for single VMs, but for migrating several hundred - and ensuring the VMs you’re requesting are indeed on the wrong reservation takes a bit more effort. If I connect to vRA with PowervRA, I can gather a list of VMs on the “old” reservation and pass that list of applicable servers to the CloudClient command line. Alternatively, if I provide a list of VMs to PowerShell, I can validate which are on the old reservation and update only those.
The final source can be found below: