VMware {code} Community
vnshilpa
Contributor
Contributor
Jump to solution

An RDM or a virtual disk??

Hi All,

how do i check the virtaul disk of the virtual machine is an RDM or a virtual disk using SDK ???

Regards,

SHILPA

Reply
0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

You want to query the VM(s) disks to ensure it's a VirtualDisk & its disk backing is of VirtualDiskRawDiskMappingVer1BackingInfo. From here you can get more information about the RDM to see if its physical or virtual compatibility mode,etc: http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.vm.device.VirtualDisk....

Here's a quick snippet of Perl code that shows how you can query by obtaining a VM view and look at the configured disks:

my $devices = $vm_view->config->hardware->device;
foreach my $device (@$devices) {
       my $device_name = $device->deviceInfo->label;
       if ( ($device->isa('VirtualDisk')) && ($device->backing->isa('VirtualDiskRawDiskMappingVer1BackingInfo')) ) {
               print $device_name, " is an RDM\n";
	}
}

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

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

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

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

View solution in original post

Reply
0 Kudos
2 Replies
lamw
Community Manager
Community Manager
Jump to solution

You want to query the VM(s) disks to ensure it's a VirtualDisk & its disk backing is of VirtualDiskRawDiskMappingVer1BackingInfo. From here you can get more information about the RDM to see if its physical or virtual compatibility mode,etc: http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.vm.device.VirtualDisk....

Here's a quick snippet of Perl code that shows how you can query by obtaining a VM view and look at the configured disks:

my $devices = $vm_view->config->hardware->device;
foreach my $device (@$devices) {
       my $device_name = $device->deviceInfo->label;
       if ( ($device->isa('VirtualDisk')) && ($device->backing->isa('VirtualDiskRawDiskMappingVer1BackingInfo')) ) {
               print $device_name, " is an RDM\n";
	}
}

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

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

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

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

Reply
0 Kudos
vnshilpa
Contributor
Contributor
Jump to solution

Thank you:)

Reply
0 Kudos