Skip to content

Instantly share code, notes, and snippets.

@dlinsley
Created March 14, 2017 17:32
Show Gist options
  • Save dlinsley/4a689534dc9e52c132c277e6b15b158a to your computer and use it in GitHub Desktop.
Save dlinsley/4a689534dc9e52c132c277e6b15b158a to your computer and use it in GitHub Desktop.
Get selected networks in a vRA Reservation for a given Virtual Machine
// VMware vRealize Orchestrator action sample
//
// Starting with a Virtual Machine: this sample determines the Reservation it is associated with
// Then it gets the names of the Networks selected in the Reservation.
//
// For vRO/vRA 7.0+
//
// Action Inputs:
// vcacVm - vCAC:VirtualMachine vCAC Virtual Machine
//
// Return type: Array/string - The networks selected in the reservation.
var networkNames = [];
var vmEntity = vcacVm.getEntity();
var host = Server.findForType("vCAC:VCACHost",vmEntity.hostId);
var hostReservationEntity = vmEntity.getLink(host,"HostReservation")[0];
var hostNicToReservations = hostReservationEntity.getLink(host,"HostNicToReservations");
System.log("Number of Networks selected in Reservation: "+hostNicToReservations.length);
for each (var nicMapping in hostNicToReservations) {
var hostNicEntity = nicMapping.getLink(host,"HostNic")[0];
var networkName = hostNicEntity.getProperty("NetworkName");
networkNames.push(networkName);
System.log(" "+networkName);
}
return networkNames;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment