Src/Private/Get-AbrOntapVserverCGNamespace.ps1
|
function Get-AbrOntapVserverCGNamespace { <# .SYNOPSIS Used by As Built Report to retrieve NetApp ONTAP Vserver Consistency Groups Namespace information from the Cluster Management Network .DESCRIPTION .NOTES Version: 0.6.12 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux .EXAMPLE .LINK #> param ( [Parameter ( Position = 0, Mandatory)] $CGObj ) begin { Write-PScriboMessage 'Collecting ONTAP Vserver Consistency Groups namespace information.' } process { try { $NamespaceData = $CGObj.namespaces $CGNamespaceObj = @() if ($NamespaceData) { foreach ($Item in $NamespaceData) { try { $inObj = [ordered] @{ 'Name' = $Item.Name.Split('/')[3] 'Capacity' = ($Item.space.size | ConvertTo-FormattedNumber -ErrorAction SilentlyContinue -NumberFormatString 0.0 -Type Datasize) ?? '--' 'Used' = ($Item.space.used | ConvertTo-FormattedNumber -ErrorAction SilentlyContinue -NumberFormatString 0.0 -Type Datasize) ?? '--' 'OS Type' = $Item.os_type 'Volume State' = $Item.status.container_state 'Mapped' = $Item.status.mapped 'Read Only' = $Item.status.read_only 'State' = $Item.status.state } $CGNamespaceObj += [pscustomobject](ConvertTo-HashToYN $inObj) } catch { Write-PScriboMessage -IsWarning $_.Exception.Message } } if ($Healthcheck.Vserver.CG) { $CGNamespaceObj | Where-Object { $_.'Volume State' -ne 'online' } | Set-Style -Style Warning -Property 'Volume State' $CGNamespaceObj | Where-Object { $_.'Mapped' -eq 'No' } | Set-Style -Style Warning -Property 'Mapped' $CGNamespaceObj | Where-Object { $_.'Read Only' -eq 'Yes' } | Set-Style -Style Warning -Property 'Read Only' $CGNamespaceObj | Where-Object { $_.'State' -eq 'offline' } | Set-Style -Style Warning -Property 'State' } $TableParams = @{ Name = "Consistency Group Namespace - $($CGObj.Name)" List = $false ColumnWidths = 30, 10, 9, 10, 11, 10, 10, 10 } if ($Report.ShowTableCaptions) { $TableParams['Caption'] = "- $($TableParams.Name)" } $CGNamespaceObj | Sort-Object -Property Name | Table @TableParams if ($Healthcheck.Vserver.CG -and ($CGNamespaceObj | Where-Object { $_.'State' -eq 'offline' })) { Paragraph 'Health Check:' -Bold -Underline BlankLine Paragraph { Text 'Best Practice:' -Bold Text 'Ensure that all namespaces within the Consistency Group are online to maintain data availability and integrity.' } BlankLine } } } catch { Write-PScriboMessage -IsWarning $_.Exception.Message } } end {} } |