VMware {code} Community
listener
Contributor
Contributor

what perl function let's you get vmdisk names?

In vminfo.pl the number of virtual disks is displayed to the user. I would like to know, what function do you use to get the name and location of all those virtual disks?

elsif($_ eq 'virtualdisks') {

if (defined ($vm_view->summary->config->numVirtualDisks)) {

print_log($vm_view->summary->config->numVirtualDisks,

"virtualDisks","Virtual Disks");

}

Is there something like a $vm_view->summary->config->nameVirtualDisks?

thanks,

holly

0 Kudos
1 Reply
lamw
Community Manager
Community Manager

There is no specific "Perl" function that does this, these are all properties via the vSphere API which can be accessed via the Perl SDK.

What you need to do is loop through a VM's device list which is an array - http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.vm.device.VirtualDevi... and look for device type "VirtualDisk".

From here, if you're looking for the displayName of the disk such as "Hard Disk 1"/etc. you'll want to query deviceInfo->Name - http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.Description.html. If you're looking for the full path which includes the datastore + VMDK name, then you'll need to query backing->fileName - http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.vm.device.VirtualDevi...

Here is a vSphere SDK for Perl script which implements these two properties along with others with respect to a VM's VMDKs:

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos