VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot

Unable to get RDM details of VM from Nimble RDMs

Hi,

we have two storage vendors, Pure and Nimble, Below script works for Pure, where I can get the Pure RDMs from a VM but I am unable to get Nimble RDM details of VM from Nimble RDMs.

Please help!!

Get-Cluster -PipelineVariable clus |
ForEach-Object -Process {
$rndNum = Get-Random -Maximum 99999

$LunInfoDef = @"
public string ClusterName;
public string Vendor;
public string CanonicalName;
public string UsedBy;
public string SizeGB;
public string DSC;
"@
$LunInfoDef = "public struct LunInfo" + $rndNum + "{`n" + $LunInfoDef

$esxServers = $clus | Get-VMHost | Sort-Object -Property Name
$esxServers | % {
$LunInfoDef += ("`n`tpublic string " + ($_.ExtensionData.config.Network.DnsConfig.Hostname) + ";")
}
$LunInfoDef += "`n}"

Add-Type -Language CsharpVersion3 -TypeDefinition $LunInfoDef

$scsiTab = @{ }
$esxServers | % {
$esxImpl = $_

# Get SCSI LUNs
$version = [Version]$esxImpl.Version
if ($version.Major -eq 6 -and $version.Minor -eq 0)
{
$esxImpl.ExtensionData.Config.StorageDevice.ScsiLun | Where-Object { $_.LunType -eq 'disk' } | % {
$key = $esxImpl.ExtensionData.config.Network.DnsConfig.Hostname + "-" + $_.DiskName.Split(".")[1]
$capacityGB = $_.Capacity.Block * $_.Capacity.BlockSize / 1GB
$lunUuid = $_.Uuid
$lun = $esxImpl.ExtensionData.Config.StorageDevice.MultipathInfo.Lun | Where-Object { $_.Id -eq $lunUuid }
$lunId = $lun.Path[0].Name.Split('L')[1]
$scsiTab[$key] = $_.CanonicalName, "", $capacityGB, $lunId, "", $_.Vendor
}
}
Else
{
$esxImpl | Get-ScsiLun | where { $_.LunType -eq "Disk" } | % {

$key = $esxImpl.ExtensionData.config.Network.DnsConfig.Hostname + "-" + $_.CanonicalName.Split(".")[1]
if (!$scsiTab.ContainsKey($key))
{
$lunId = $_.RuntimeName.Split('L')[1]
$scsiTab[$key] = $_.CanonicalName, "", $_.CapacityGB, $lunId, "", $_.Vendor
}
}
}

# Get the VMFS datastores
$esxImpl | Get-Datastore | Where-Object { $_.Type -eq "VMFS" } | Get-View | % {
$dsName = $_.Name
$dscName = ''
if ($_.Parent.Type -eq 'StoragePod')
{
$dscName = Get-View -Id $_.Parent -Property Name -Server $esxImpl.Uid.Split('@')[1].Split(':')[0] | Select -ExpandProperty Name
}
$_.Info.Vmfs.Extent | % {
$key = $esxImpl.ExtensionData.config.Network.DnsConfig.Hostname + "-" + $_.DiskName.Split(".")[1]
$scsiTab[$key][1] = $dsName
$scsiTab[$key][4] = $dscName
}
}
}

# Get the RDM disks
$clus | Get-VM | Get-View | % {
$vm = $_
$vm.Config.Hardware.Device | Where-Object { $_.gettype().Name -eq "VirtualDisk" } | % {
if ($_.Backing.PSObject.Properties['CompatibilityMode'] -and "physicalMode", "virtualMode" -contains $_.Backing.CompatibilityMode)
{
$disk = $_.Backing.LunUuid.Substring(10, 32)
$key = (Get-View $vm.Runtime.Host).config.Network.DnsConfig.Hostname + "-" + $disk
$scsiTab[$key][1] = $vm.Name + "/" + $_.DeviceInfo.Label
}
}
}

$scsiTab.GetEnumerator() | Group-Object -Property { $_.Key.Split("-")[1] } | % {
$lun = New-Object ("LunInfo" + $rndNum)
$lun.ClusterName = $clus
$_.Group | % {
$esxName = $_.Key.Split("-")[0]
$lun.$esxName = $_.Value[3]
if (!$lun.CanonicalName) { $lun.CanonicalName = $_.Value[0] }
if (!$lun.UsedBy) { $lun.UsedBy = $_.Value[1] }
if (!$lun.SizeGB) { $lun.SizeGB = [math]::Round($_.Value[2], 0) }
if (!$lun.Vendor) {$lun.Vendor = $_.Value[5]}
$lun.DSC = $_.Value[4]
}
$lun
} |
Export-Excel -Path $csvName -AutoFilter -AutoSize -WorksheetName $clus.name
}

 

I am getting few errors as below

Cannot index into a null array.
At D:\Free_LUNs_Info_2.0.ps1:93 char:17
+ ... $scsiTab[$key][1] = $vm.Name + "/" + $_.DeviceInfo.Label
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray

 

0 Kudos
23 Replies
ganapa2000
Hot Shot
Hot Shot

LucD,

Any luck on this ? I am awaiting for your update 🙂

0 Kudos
ganapa2000
Hot Shot
Hot Shot

LucD,

Please help!! 🙂

0 Kudos
ganapa2000
Hot Shot
Hot Shot

LucD,

Any luck on the request. I am unable to get the details for Nimble devices.

Please help!!!

0 Kudos
LucD
Leadership
Leadership

No, acn't find a solution I'm afraid


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

0 Kudos