I want to find the VM file system usage, but only on VMs that have a vmdk on a particular device. The VM host could have storage from multiple devices, for instance EMC and IBM devices. I only want to know the amount of space used by VMs that have storage on an IBM device.
I'm trying to use powercli to find this information, but I can't 'tie' the information together. I'm not a VMWare admin, and so I'm having a hard time finding the correlation (and if my terminology is incorrect, sorry about that.)
I can find only the IBM disks with the following command:
Get-VMHost <host> | Get-VMHostHba -type FibreChannel | Get-ScsiLun -CanonicalName eui* -LunType disk
I can also get the file system usage with the following:
$AllVMs = Get-VMHost <host> | Get-VM
ForEach ($VM in $AllVMs) {
$Views = $VM | Get-View
ForEach ($View in $Views) {
Foreach ($Disk in $View.Guest.Disk) {
$disk.DiskPath
([math]::Round($disk.Capacity/ 1MB))
([math]::Round($disk.FreeSpace / 1MB))
}
}
}
However, how can I be sure that c:\ on host1 is on an IBM array and not an EMC array?
The connection you're looking for is the datastore; each LUN on the IBM SAN is formatted into a "datastore" by VMware for storage of virtual hard disks.
Unfortunately, the DiskInfo object that you're ending up with has no information about which datastore it resides on.. which is kinda weak in my opinion.
I don't have a system with PowerCLI installed on to test this on right this second, but instead of enumerating
Guest.Disk
, try theHardDisk
property on the object returned byGet-VM
. ItsFilename
property should give you some indication of which datastore it resides on, even if it's just a unique ID.I was able to find the answer to this at the following link:
http://communities.vmware.com/thread/240466
From there, I was able to tie the VMHost and disk to the VM and the Guest information.