Hi
I must create a workflow who list virtual disks from a virtual machine defined in input parameter.
So i have 2 questions :
How can i list disks for a specific virtual machine ?
- I don't find how to access this information
- Is it possible to populate a presentation field after selecting virtual machine ?
,
Best regards
Hi,
find below code from an action that loops through all devices of a given VM and returns an array with the device keys. You can then use this in a decorator for the workflow to let the user select a disk.
Cheers,
Joerg
var devices = vm.config.hardware.device;
var diskCount = 0;
var diskArray = new Array();
if ( devices != null ) {
//System.debug("all devices: " + devices);
//loop through devices ...
for ( device in devices ) {
if ( devices[device] instanceof VcVirtualDisk ) {
System.debug("Found disk: " + devices[device]);
diskCount++;
diskArray[diskCount] = devices[device].key;
}
}
}
System.debug("diskAry: " + diskArray);
return diskArray;
Hi,
find below code from an action that loops through all devices of a given VM and returns an array with the device keys. You can then use this in a decorator for the workflow to let the user select a disk.
Cheers,
Joerg
var devices = vm.config.hardware.device;
var diskCount = 0;
var diskArray = new Array();
if ( devices != null ) {
//System.debug("all devices: " + devices);
//loop through devices ...
for ( device in devices ) {
if ( devices[device] instanceof VcVirtualDisk ) {
System.debug("Found disk: " + devices[device]);
diskCount++;
diskArray[diskCount] = devices[device].key;
}
}
}
System.debug("diskAry: " + diskArray);
return diskArray;
There is actually a library action:
com.vmware.library.vc.storage.sdrs --> getVmDiskIds
That returns an array of the disk IDs for a given VM
This action could then be used as the action in a predefined list of elements property for the presentation of your workflow. When setting that up, you'll be prompted for which input/attribute to use for the vm input for the action... end result: After selecting a VM, the action will be run and provide a list of disk ids in the disk input field. Of course this means you would need to understand what the disk IDs mean
like 🙂 That's a new one, not available back then when I built the action above. Thanks for mentioning!
Oh, if you want to see how to pull all this together into something that might make a little more sense to someone running the workflow using vCO Client or vSphere Web Client, you should look at my package here: Add or Delete RDM from VM
Thank you very much to all 2
I missed the action.
I'll test immediately, but the solution is.
Best regards