alt

The vCenter Orchestrator plug-ins are coming with a lot of built in workflows and action scripts. The first thing to do when looking for functionality is to browse the library or use the search filter to find these.

If you do not get exactly what you are looking for, there are chances that some of the existing workflows and actions will contain close enough examples. If you do not find any of these you can still use the API explorer to create your own.

Today there was a community post about getting VM Guest information using the vCloud Director plug-in for vCO. While I answered there I thought it would be helpful to publish it here. Here is how I do it:

For the sake of simplicity I am assuming starting with a vApp input in the workflow set as an input of a scriptable box.

First I need to get the VMs within this vApp.

In the API explorator look at the vApp methods & properties:

VclVapp API Explorer

You can see there is vApp.getChildrenVms();

To avoid doing typos press ctrl espace after the "." : This will bring the completion window like this:

 

Autocomplete

 

Now that you have got the VMs in the vApp you need to get their guestCustomization:

 

VvlVM API Explorer

Once you have identified the right method to do it, you need to check VclGuestCustomizationSection to know what properties are available.

VclGuestCustomization API Explorer

 So if for example we need the Guest OS computer name we can use the computername property.

So to get guest information:

var vms = vApp.getChildrenVms();

for each (var vm in vms) { //iterating the vms
    var getGuestCustomizationSection = vm.getGuestCustomizationSection();
    System.log(getGuestCustomizationSection.computerName);
}

The methodology above applies to any vCenter Orchestrator plug-in.

to be re-usable, versionable this peace of code can be embedded in an action that would return an array of vm names (strings)

var vmNames = new Array();

var vms = vApp.getChildrenVms();

for each (var vm in vms) { //iterating the vms
    var getGuestCustomizationSection = vm.getGuestCustomizationSection();
    vmNames.push(getGuestCustomizationSection.computerName);
}

return vmNames;