VMware Cloud Community
pascallaroche99
Enthusiast
Enthusiast
Jump to solution

How to retrieve the DiskType of VirtualDisk?

Hi all,

I am looking of a way to find the disktype of a virtual disk through vCO. I want to mass storage vMotion a bunch of VM but before doing the Storage vMotion I want to validate if the VM has RDM attach to it. If yes, I will skip the storage vMotion.

I find that vm.config.hardware.device has VC:VirtualDisk object in it but this object has no disktype.

I find a VC:VirtualDiskType, but how to retrieve this information for an existing disk?

Thanks.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
stvkpln
Virtuoso
Virtuoso
Jump to solution

Pretty straightforward...

var devices = vCenterVm.config.hardware.device;

for each (var d in devices) {

  if (d.backing instanceof VcVirtualDiskRawDiskMappingVer1BackingInfo) { System.debug("RDMv1 found"); }

  if (d.backing instanceof VcVirtualDiskRawDiskVer2BackingInfo) { System.debug("RDMv2 found"; }

}

Alternately, you can look at the device.backing value, as well. That'll show you if it's an RDM, thin or thick provisioned disk.

-Steve

View solution in original post

0 Kudos
2 Replies
stvkpln
Virtuoso
Virtuoso
Jump to solution

Pretty straightforward...

var devices = vCenterVm.config.hardware.device;

for each (var d in devices) {

  if (d.backing instanceof VcVirtualDiskRawDiskMappingVer1BackingInfo) { System.debug("RDMv1 found"); }

  if (d.backing instanceof VcVirtualDiskRawDiskVer2BackingInfo) { System.debug("RDMv2 found"; }

}

Alternately, you can look at the device.backing value, as well. That'll show you if it's an RDM, thin or thick provisioned disk.

-Steve
0 Kudos
pascallaroche99
Enthusiast
Enthusiast
Jump to solution

Thanks Steve!

0 Kudos