Hi
I'm trying to write a script that would automate moving hundreds of VMs from one reservation to another. I used PowerShell and CloudClient to do the actual move but now I'm trying to figure out how to get a list of VMs that belong to the old reservation. Since PowervRA is not supported by vRA 7.4 and the export button within the UI disappeared in version 7.4, is there another way to export that list? Does anyone know if it can be done using vRO or CloudClient?
Thank you,
You can most certainly do it via vRO, but I don't have the custom code needed to do so.
Check here for how this hangs together - Working with vCloud Automation Center IaaS entities
There's a Schema diagram there which you can examine but the crucial part you want is here
The IaaS HostReservation entity keeps a link to the VirtualMachines which belong to it
You can retrieve them from the vRA IaaS plugin like this
Once you have them in vRO you can
- print the details in CSV format in the log stream
- Write the CSV to a ResourceElement
- etc
HTH
Slight correction, the objects returned will be vCAC:Entity but you can the properties for a vCAC VM from those like this
Once you've got the properties for each VM you can access values for the CSV like this
var hostname = vmProperties.get("Hostname");
var ipAddress = vmProperties.get("VirtualMachine.Network0.Address");
etc.
Check the vRA Extensibilty or Custom Properties guides to details on the values you can retrieve here
Oh wow this is awesome ... thank you very much eoinbyrne. I will try it out when I get back into the office.
I knew it could be done in vRO I just wasn't able to figure out where to start, I still have a lot to learn about vRO .... this is great thanks.
This is awesome I finally understand how the vCAC entities works .... yayyy!!!
Here's my final code in case someone else is interested.
var modelName = "ManagementModelEntities.svc";
var entitySetName = "HostReservations";
var filter = {'HostReservationName':reservation}; //filters for a specific reservationName
var reservationEntities = vCACEntityManager.readModelEntitiesByCustomFilter(vCACHost.id , modelName, entitySetName, filter, null);
for each (var reservationEntity in reservationEntities){
var vmReservationEntity = reservationEntity.getLink (vCACHost, "VirtualMachines");
if (vmReservationEntity != null){
for each (var vmName in vmReservationEntity) {
System.log (vmName.getProperty("VirtualMachineName"));
}
}
}
Thanks again guys for all the help.