Skip to content

Instantly share code, notes, and snippets.

@michaelrice
Forked from hartsock/rdm.py
Created May 4, 2014 20:14
Show Gist options
  • Save michaelrice/75f0c21535269eb769bc to your computer and use it in GitHub Desktop.
Save michaelrice/75f0c21535269eb769bc to your computer and use it in GitHub Desktop.
# first get the disks...
disks = [d for d in vm.config.hardware.device
if isinstance(d, pyVmomi.vim.vm.device.VirtualDisk) and
isinstance(d.backing, pyVmomi.vim.vm.device.VirtualDisk.RawDiskMappingVer1BackingInfo)]
print d.deviceInfo.deviceName
# then later
ss = vm.runtime.host.configManager.storageSystem
for d in disks:
try:
lun = [l for l in ss.storageDeviceInfo.scsiLun
if d.deviceName == l.deviceName][0]
print d.deviceInfo.label, lun.canonicalName
except IndexError:
print 'Disk not found'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment