##############################################################################
# Setup variables for deserialization if output is too big
#
Add-Type -AssemblyName System.Web.Extensions
$javaScriptSerializer = New-Object System.Web.Script.Serialization.JavaScriptSerializer
$javaScriptSerializer.MaxJsonLength = [System.Int32]::MaxValue
$javaScriptSerializer.RecursionLimit = 99
# Common parameters used for the web service calls
$securePwd = ConvertTo-SecureString "rw" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("rw", $securePwd)
# Create Drives Group object to act as container for Drives
$drivesGroupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='NetAppSANtricity.DrivesGroup']$")
# Adding properties that associate DriveGroup with its parent StoragePool
$drivesGroupInstance.AddProperty("$MPElement[Name='NetAppSANtricity.DrivesGroup']/storagePoolWwn$", $poolWWN)
$drivesGroupInstance.AddProperty("$MPElement[Name='NetAppSANtricity.DrivesGroup']/storagePoolName$", $poolName)
$drivesGroupInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Drives")
#Add key properties of parent storage pool
$drivesGroupInstance.AddProperty("$MPElement[Name='NetAppSANtricity.StoragePool']/wwn$", $poolWWN)
$discoveryData.AddInstance($drivesGroupInstance)
# Get HwInventory for use with determining tray/drawer/slot information
$url = ""
$url = $baseUrl + $arrayWWN + "/hardware-inventory/"
$hwInventory = Invoke-RestMethod $url -Credential $cred
if ($hwInventory.GetType().FullName -eq "System.String")
{
$hwInventory = $javaScriptSerializer.DeserializeObject($hwInventory)
}
$hwTrays = $hwInventory.trays
# Get the drives that are associated with this Storage Pool
$url = ""
$url = $baseUrl + $arrayWWN + "/drives/"
$allDrives = Invoke-RestMethod $url -Credential $cred
if ($allDrives.GetType().FullName -eq "System.String")
{
$allDrives = $javaScriptSerializer.DeserializeObject($allDrives)
}
foreach ($drive in $allDrives)
{
if ($drive.currentVolumeGroupRef -eq $poolVolGroupRef)
{
# Loop through hwInventory/trays
foreach($hwTray in $hwTrays)
{
if ($hwTray.trayRef -eq $drive.physicalLocation.trayRef)
{
$foundTray = $hwTray
}
}
$trayLabel = "" + $foundTray.trayId + "/"
$slotLabel = $drive.physicalLocation.locationPosition
# if the componentType is a tray, then there are no drawers, and thus set it to 0
if ($drive.physicalLocation.locationParent.typedReference.componentType -eq "tray")
{
$drawerLabel = "0/"
}
elseif ($drive.physicalLocation.locationParent.typedReference.componentType -eq "drawer")
{
# Find drawer by looking at symbolRef
$symbolRef = $drive.physicalLocation.locationParent.typedReference.symbolRef
# Drawer # is the 21st # in the symbolRef - this is cheesy, fix it!
$symbolRef = $symbolRef.substring(21,1)
$drawerLabel = $symbolRef + "/"
}
$driveLabel = $trayLabel + $drawerLabel + $slotLabel
# Split the label up to get tray, drawer, and slot
$dts = $driveLabel + " (Tray/Drawer/Slot)"