Hello everyone,

So the VMM team finally announced BETA at MMS in March. One request we heard from you during the event is the need to visualize storage.  VMM 2012 goes a long way to integrate storage automation into VMM using SMI-S based providers. Through these providers, VMM gets a lot of great data. You can use this data to visualize your storage environment. Below is one example of how I modified an existing NetApp PowerShell script that generates a Visio diagram with aggregate, volume, and LUN information.

Check out NetApp for Microsoft Environments blog for the latest and greatest news from NetApp, including scripts, tools, and best practices - http://blogs.netapp.com/msenviro/

For this example, I downloaded the following:

  1. Download the NetApp Visio stencils and extract them all into your "My Documents\My Shapes" directory. if the link is broken then go to http://www.visiocafe.com/downloads/netapp/ too get the latest.

 Make sure to launch this script from a client that has the VMM administrator console installed on it. This script assumes LOCALHOST.

Here is a sample of a small environment:

 

And a more complicated environment:

##script##

$shpFile1 = "\NetApp-Logic-Icons.vss"
$shpFile2 = "\NetApp-Equipment-Icons.vss"

function connect-visioobject ($firstObj, $secondObj) {
 $shpConn = $pagObj.Drop($pagObj.Application.ConnectorToolDataObject, 0, 0)

 #// Connect its Begin to the 'From' shape:
 $connectBegin = $shpConn.CellsU("BeginX").GlueTo($firstObj.CellsU("PinX"))    
 #// Connect its End to the 'To' shape:
 $connectEnd = $shpConn.CellsU("EndX").GlueTo($secondObj.CellsU("PinX"))
}

function add-visioobject ($mastObj, $item) {     
 Write-Host "Adding $item"   
 # Drop the selected stencil on the active page, with the coordinates x, y     
 $shpObj = $pagObj.Drop($mastObj, $x, $y)    
 # Enter text for the object     
 $shpObj.Text = $item   
 #Return the visioobject to be used    
return $shpObj
}

#Establish connection to VMM Server (assumes the VMM server is running on the same machine executing the script)
$vmm = Get-VMMServer localhost | Out-Null

#list the arrays under VMM's management
Get-SCStorageArray | ft Name, Model, FirmwareVersion

$FASName = read-host "Enter the Name of your NetApp array"
If ($FASName -eq "") { Write-Host "No selection made, script now exiting." ; exit }

#Get array, pools, LUNs
$array = Get-SCStorageArray -Name $FASName.Trim()
$allPools = @()
$allPools = Get-SCStoragePool | where {$_.StorageArray -eq $array}
$allLUNs = @()
$allLUNs = Get-SCStorageLogicalUnit | where {$allPools -contains $_.StoragePool}

#construct the volumes manually from the list of LUNs and their containing pool
$allVols = @()
#get all volumes
Foreach ($lun in $allLUNs)
{
    $volName = $lun.Name.split("/")
    $volume = New-Object PSObject
    Add-Member -MemberType NoteProperty -Name Name -Value ($volName[2] + "/") -InputObject $volume
    Add-Member -MemberType NoteProperty -Name StoragePool -Value $lun.StoragePool -InputObject $Volume
    $hashmatch = $false
    $allVols += $volume
}
$allVols = $allVols | Select-Object -Unique Name, StoragePool

# Create an instance of Visio and create a document based on the Basic Diagram template.
$AppVisio = New-Object -ComObject Visio.Application
$AppVisio.AutoLayout = $true
$docsObj = $AppVisio.Documents
$DocObj = $docsObj.Add("Basic Network Diagram.vst")
# Set the active page of the document to page 1
$pagsObj = $AppVisio.ActiveDocument.Pages
$pagObj = $pagsObj.Item(1)

# Load a set of stencils and select one to drop
$stnPath = [system.Environment]::GetFolderPath('MyDocuments') + "\My Shapes"
$stnObj1 = $AppVisio.Documents.Add($stnPath + $shpFile1)
$FlexVOLObj = $stnObj1.Masters.Item("FlexVol")
$poolObj = $stnObj1.Masters.Item("Raid Grp Aggregate Storage")
$LUNObj = $stnObj1.Masters.Item("Cylinder")
$stnObj2 = $AppVisio.Documents.Add($stnPath + $shpFile2)
$FASObj = $stnObj2.Masters.Item("FAS3000 Double controllers")

#Draw objects
$y = $allPools.Count * 1.50 / 2
$x = 1.50
$FASObj = add-visioobject $FASObj $FASName

$x = 3.50
$y += 2

Foreach ($pool in $allPools) {
 $poolObj = add-visioobject $poolObj $pool.Name
 connect-visioobject $FASObj $poolObj   
 $y += 1.5        

Foreach ($volume in $allVols) {  
If ($volume.StoragePool -eq $pool) {
$x += 2.50
$volInfo = "Volume Name: " + $volume.Name # + "`r`n" + "Total Size (GB): " + "{0:n2}" -f + ($volume.SizeTotal / 1gb) + "`r`n" + "Size Used: " + "{0:n2}" -f ($volume.SizeUsed / 1gb)        
$FlexVOLObj = add-visioobject $FlexVOLObj $volInfo                                 
connect-visioobject $poolObj $FlexVOLObj                       

$t_x = $x
$t_y = $y

 Foreach ($lun in $allLUNs) {   
If (($lun.StoragePool -eq $pool) -and ($lun.Name -match $volume.Name)) {  
                          
 $x += .5              
 $y += .25                                   
 $lunInfo = "LUN Name: " + $lun.Name + "`r`n" + "Total Size (GB): " + "{0:n2}" -f ($lun.TotalCapacity / 1024 / 1024)                
 $LUNObj = add-visioobject $LUNObj $lunInfo               
 connect-visioobject $FlexVOLObj $LUNObj
 } 
 }                                
 $x = $t_x              
 $y = $t_y
}  
}   
 $x = 3.50
 $y += 2.50    
}

# Resize to fit page
$pagObj.ResizeToFitContents()

You can find the original script here: http://communities.netapp.com/docs/DOC-6411

--Hector