Src/Private/Get-AbrOntapRepRelations.ps1
|
function Get-AbrOntapRepRelationship { <# .SYNOPSIS Used by As Built Report to retrieve NetApp ONTAP SnapMirror relationship information from the Cluster Management Network .DESCRIPTION .NOTES Version: 0.6.12 Author: Jonathan Colon Twitter: @jcolonfzenpr Github: rebelinux .EXAMPLE .LINK #> [CmdletBinding()] param ( ) begin { Write-PScriboMessage 'Collecting ONTAP SnapMirror relationship information.' } process { try { $ReplicaData = Get-NcSnapmirror -Controller $Array $ReplicaObj = @() if ($ReplicaData) { foreach ($Item in $ReplicaData) { try { $lag = [timespan]::fromseconds($Item.LagTime).tostring() $time = $lag.Split('.').Split(':') $lagtime = $time[0] + ' days, ' + $time[1] + ' hrs, ' + $time[2] + ' mins, ' + $time[0] + ' secs' $inObj = [ordered] @{ 'Source Vserver' = $Item.SourceVserver 'Source Location' = $Item.SourceLocation 'Destination Vserver' = $Item.DestinationVserver 'Destination Location' = $Item.DestinationLocation 'Mirror State' = $Item.MirrorState 'Schedule' = ${Item}?.Schedule?.toUpper() 'Relationship Type' = switch ($Item.RelationshipType) { 'extended_data_protection' { 'XDP' } 'data_protection' { 'DP' } 'transition_data_protection' { 'TDP' } 'restore' { 'RST' } 'load_sharing' { 'LS' } default { $Item.RelationshipType } } 'Policy' = $Item.Policy 'Policy Type' = $Item.PolicyType 'Unhealthy Reason' = ($Null -eq $Item.UnhealthyReason) ? 'None': $Item.UnhealthyReason 'Lag Time' = $lagtime 'Status' = ${Item}?.Status?.toUpper() } $ReplicaObj = [pscustomobject](ConvertTo-HashToYN $inObj) if ($Healthcheck.Replication.Relationship) { $ReplicaObj | Where-Object { $_.'Unhealthy Reason' -ne 'None' } | Set-Style -Style Warning -Property 'Unhealthy Reason' } $TableParams = @{ Name = "SnapMirror relationship - $($Item.SourceLocation)" List = $true ColumnWidths = 30, 70 } if ($Report.ShowTableCaptions) { $TableParams['Caption'] = "- $($TableParams.Name)" } $ReplicaObj | Table @TableParams if ($Healthcheck.Replication.Relationship -and ($ReplicaObj | Where-Object { $_.'Unhealthy Reason' -ne 'None' })) { Paragraph 'Health Check:' -Bold -Underline BlankLine Paragraph { Text 'Best Practice:' -Bold Text 'Ensure that all SnapMirror relationships are healthy to maintain data replication integrity.' } BlankLine } } catch { Write-PScriboMessage -IsWarning $_.Exception.Message } } } } catch { Write-PScriboMessage -IsWarning $_.Exception.Message } } end {} } |