VMware Cloud Community
Camberton
Enthusiast
Enthusiast
Jump to solution

Workflow list and extend virtual machine disk

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

Reply
0 Kudos
1 Solution

Accepted Solutions
tschoergez
Leadership
Leadership
Jump to solution

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;

View solution in original post

Reply
0 Kudos
6 Replies
tschoergez
Leadership
Leadership
Jump to solution

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;

Reply
0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

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 Smiley Wink

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Burke-
VMware Employee
VMware Employee
Jump to solution

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 Smiley Wink

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
tschoergez
Leadership
Leadership
Jump to solution

like 🙂 That's a new one, not available back then when I built the action above. Thanks for mentioning!

Reply
0 Kudos
Burke-
VMware Employee
VMware Employee
Jump to solution

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

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos
Camberton
Enthusiast
Enthusiast
Jump to solution

Thank you very much to all 2

I missed the action.

I'll test immediately, but the solution is.


Best regards

Reply
0 Kudos