1+ function Get-AbrOntapVserverNamespaceStorage {
2+ <#
3+ . SYNOPSIS
4+ Used by As Built Report to retrieve NetApp ONTAP vserver namespace information from the Cluster Management Network
5+ . DESCRIPTION
6+
7+ . NOTES
8+ Version: 0.6.7
9+ Author: Jonathan Colon
10+ Twitter: @jcolonfzenpr
11+ Github: rebelinux
12+ . EXAMPLE
13+
14+ . LINK
15+
16+ #>
17+ param (
18+ [Parameter (
19+ Position = 0 ,
20+ Mandatory )]
21+ [string ]
22+ $Vserver
23+ )
24+
25+ begin {
26+ Write-PScriboMessage " Collecting ONTAP Vserver namespace information."
27+ }
28+
29+ process {
30+ try {
31+ $VserverNamespace = Get-NcNvmeNamespace - VserverContext $Vserver - Controller $Arra
32+ $VserverObj = @ ()
33+ if ($VserverNamespace ) {
34+ foreach ($Item in $VserverNamespace ) {
35+ try {
36+ $namespacemap = Get-NcNvmeSubsystemMap - Vserver $Vserver - Controller $Array | Where-Object { $_.Path -eq $Item.Path }
37+ $namespacepath = $Item.Path.split (' /' )
38+ $namespace = $namespacepath [3 ]
39+ $available = $Item.Size - $Item.SizeUsed
40+ $used = ($Item.SizeUsed / $Item.Size ) * 100
41+ $inObj = [ordered ] @ {
42+ ' Namespace Name' = $namespace
43+ ' Parent Volume' = $Item.Volume
44+ ' Path' = $Item.Path
45+ ' Serial Number' = $Item.Uuid
46+ ' Subsystem Map' = Switch (($namespacemap ).count) {
47+ 0 { " None" }
48+ default { $namespacemap.Subsystem }
49+ }
50+ ' Home Node ' = $Item.Node
51+ ' Capacity' = $Item.Size | ConvertTo-FormattedNumber - Type Datasize - ErrorAction SilentlyContinue
52+ ' Available' = $available | ConvertTo-FormattedNumber - Type Datasize - ErrorAction SilentlyContinue
53+ ' Used' = $used | ConvertTo-FormattedNumber - Type Percent - ErrorAction SilentlyContinue
54+ ' OS Type' = $Item.Ostype
55+ ' Is Mapped' = Switch ([string ]::IsNullOrEmpty($Item.Subsystem )) {
56+ $true { " No" }
57+ $false { " Yes" }
58+ default { $Item.Subsystem }
59+ }
60+ ' ReadOnly' = ConvertTo-TextYN $Item.IsReadOnly
61+ ' Status' = Switch ($Item.State ) {
62+ ' online' { ' Up' }
63+ ' offline' { ' Down' }
64+ default { $Item.Online }
65+ }
66+ }
67+ $VserverObj = [pscustomobject ]$inobj
68+
69+ if ($Healthcheck.Vserver.Status ) {
70+ $VserverObj | Where-Object { $_ .' Status' -like ' Down' } | Set-Style - Style Warning - Property ' Status'
71+ $VserverObj | Where-Object { $_ .' Used' -ge 90 } | Set-Style - Style Critical - Property ' Used'
72+ $VserverObj | Where-Object { $_ .' Is Mapped' -eq ' No' } | Set-Style - Style Warning - Property ' Is Mapped'
73+ }
74+
75+ $TableParams = @ {
76+ Name = " Namespace - $ ( $namespace ) "
77+ List = $true
78+ ColumnWidths = 25 , 75
79+ }
80+ if ($Report.ShowTableCaptions ) {
81+ $TableParams [' Caption' ] = " - $ ( $TableParams.Name ) "
82+ }
83+ $VserverObj | Sort-Object - Property ' Namespace Name' | Table @TableParams
84+ } catch {
85+ Write-PScriboMessage - IsWarning $_.Exception.Message
86+ }
87+ }
88+ }
89+ } catch {
90+ Write-PScriboMessage - IsWarning $_.Exception.Message
91+ }
92+ }
93+
94+ end {}
95+
96+ }
0 commit comments