VMware Cloud Community
SG1234
Enthusiast
Enthusiast

identify disks from a storage device

all -- I will need to find out if an RDM disk associated with a Virtual machine is residing on a particular storage device - so if the host is connected to several Storage arrays - I need to filter the RDMs only to those coming from a specific array

I am using the script given in this thread

however  , I also need the 'target identifier' along with disk id --

please advise

~Sai Garimella

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership

Did you already try the script in LUN report – datastore, RDM and node visibility ?

It will list the VM and the harddisk name for those that are RDM disks.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

SG1234
Enthusiast
Enthusiast

yes -- along with this I need the target identifier as well -- this will tell me which storage array the disk belongs to

in excfg-mpath -l for a given lun this is under 'Target Identifier:'

Reply
0 Kudos
SG1234
Enthusiast
Enthusiast

LucD/All -- is there a way to determine the target identifier for the RDM Luns ?

Reply
0 Kudos
LucD
Leadership
Leadership

Try like this

$report = @()
$vms = Get-VM
foreach($vm in $vms){
   
$pathTab = @{}
   
$esxcli = Get-EsxCli -VMHost $vm.VMHost
   
$esxcli.storage.core.path.list() | %{
       
$pathTab.Add($_.Device.Split('.')[1],$_.TargetIdentifier)
    }
   
foreach($dev in $vm.ExtensionData.Config.Hardware.Device){
       
if(($dev.gettype()).Name -eq "VirtualDisk"){
           
if(($dev.Backing.CompatibilityMode -eq "physicalMode") -or
                (
$dev.Backing.CompatibilityMode -eq "virtualMode")){
               
$row = "" | select VMName, VMHost, HDDeviceName, HDTargetID, HDFileName, HDMode, HDsize
               
$row.VMName = $vm.Name
               
$row.VMHost = $vm.VMHost.Name
               
$row.HDDeviceName = $dev.Backing.DeviceName
               
$row.HDTargetID = $pathTab[$dev.Backing.LunUuid.SubString(10,32)]
               
$row.HDFileName = $dev.Backing.FileName
               
$row.HDMode = $dev.Backing.CompatibilityMode
               
$row.HDSize = $dev.CapacityInKB
               
$report += $row
            }
        }
    }
}
$report


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
SG1234
Enthusiast
Enthusiast

hd targetid is blank

Reply
0 Kudos
LucD
Leadership
Leadership

What is the output of

$esxcli.storage.core.path.list()

in your environment ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos