with vSphere SDK for Perl I would like to get the following: I already
get the datastore and physical disk info for all the VMs of all the
hosts of a Datacenter. I want to relate this info with the VMs guest OS disk
info, i.e.: which vm->config->hardware->device('VirtualDisk') corresponds to which vm->guest->disk (disk or partition). Is this possible?
You may have to leverage VIX or a remote scripting protocol like WMI on Windows (SSH on Linux) to do so.
You'd want to get it's SCSI information and compare (C:\ on SCSI0:0) that to the disk information from the SDK.
I agree with Reuben, if you want to stay within the VMware APIs without having to rely on other remote tools such as WMI for Windows or SSH for Linux, VMware VIX would be able to provide you those details. If you use VI Java API for instance, there's some integration between VIX API and vSphere API.
Here is a very simple script that I wrote awhile back that does a mapping from a VM's VMDK to Datastore to physical devices supported the VMFS volume - . You'll want to do something similar but extract out the VM's logical disk and it's partition information and SCSI bus and then compare that to SCSI devices in the VM and map that to the actual VMDK.
VMware vExpert 2009,2010
If you find this information useful, please award points for "correct" or "helpful".
The SCSI bus information is not very reliable IMHO. Depending on the guest operating system, a disk attached to, say, 1:2 scsi node on the virtual machine may actually end up on 1:3 or 1:1 or anywhere else actually. We found this out the hard way while automating a bunch of test cases while I was at VMware. The only reliable way of figuring out the real disks that I can recommend is by looking at the UUID of the VMDK files themselves. You can open the disk descriptor while to look at the UUID or use the vmkfstools command with the -J (I think) option to fetch the UUID and then inside the guest do the same for all disks.
This may (or may not) be possible directly using the vsphere APIs. Have a look at the VirtualDiskManager/VirtualDisk objects to see if you can get the UUID of a disk from there. The guest side tasks can be done using the VIX APIs.
thank you. I got the UUID on the host side. The problem is the guest side. Right now I can not get the Vix API (virtual disk API) to work (some error about licensing - although we are using licensed versions for vCenter and hosts). Also, I am not to fond of having to use a C-coded executable to access the guest, when for the host I can use scripting language. Anyway, I am still trying...