2 Replies Latest reply on Dec 13, 2009 3:39 PM by Benomatic

    Link Datastore Name with ConsoleDeviceName and CanonicalName

    Benomatic Novice

       

       

       

       

      Hi Folks,

       

       

      I would like to link 3 parameters, ConsoleDeviceName, CanonicalName and "Datastore Name".

       

       

      The twice first  (ConsoleDeviceName, CanonicalName) can i get with "Get-VMHost "MyESXHost" | Get-ScsiLun"

       

       

      but how can I get the Datastore Name ?

       

       

      http://communities.vmware.com/servlet/JiveServlet/downloadImage/7964/12-9-2009+1-11-11+PM.png

       

       

      thanks for help

       

       

        • 1. Re: Link Datastore Name with ConsoleDeviceName and CanonicalName
          ykalchev Expert
          VMware Employees

          Hi,

          In order to get datastore name for each lun you need to examine disk extent information for each datastore attached to the host and link them using lun cannonical names. VMFS datastore disk extent information is available in HostScsiDiskPartition object. Here is an example code how to do that:

           

          $h = Get-VMhost "MyESXHost"
          
          # collect VMFS datastore name and extent cannonical names into a hashtable
          $dsLunList = @{}
          $dsView = $h | Get-Datastore | ? {$_.Type -eq "VMFS"} | Get-View 
          foreach ($ds in $dsView) {
               foreach ($diskExtent in $ds.Info.Vmfs.Extent) {
                    $dsLunList[http://$diskExtent.DiskName|http://$diskExtent.DiskName] = $ds.Info.Name
               }
          } 
          
          #populate datastore name for each lun if available
          $lunList = @()
          $h | Get-ScsiLun | % {
               $lun = "" | select ConsoleDeviceName, CanonicalName, DatastoreName
               $lun.ConsoleDeviceName = $_.ConsoleDeviceName
               $lun.CanonicalName = $_.CanonicalName
               
               if ($dsLunList.ContainsKey($_.CanonicalName)) {
                    $lun.DatastoreName = $dsLunList[http://$_.CanonicalName|http://$_.CanonicalName]
               }
               
               $lunList += $lun
          }
          
          $lunList
          

           

           

          Regards,

          Yasen

          • 2. Re: Link Datastore Name with ConsoleDeviceName and CanonicalName
            Benomatic Novice

            Big Thanks ! Yasen, that is what I want