1+ function Export-AbrOntapDiagram {
2+ <#
3+ . SYNOPSIS
4+ Used by As Built Report to export NetApp Ontap infrastructure diagram
5+ . DESCRIPTION
6+ Documents the configuration of NetApp Ontap in Word/HTML/Text formats using PScribo.
7+ . NOTES
8+ Version: 0.6.8
9+ Author: Jonathan Colon
10+ Twitter: @jcolonfzenpr
11+ Github: rebelinux
12+ Credits: Iain Brighton (@iainbrighton) - PScribo module
13+
14+ . LINK
15+ https://github.com/AsBuiltReport/AsBuiltReport.NetApp.Ontap
16+ #>
17+
18+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute (" PSAvoidUsingCmdletAliases" , " " , Scope = " Function" )]
19+
20+ [CmdletBinding ()]
21+ param (
22+ $DiagramObject ,
23+ [string ] $MainDiagramLabel = ' Change Me' ,
24+ [Parameter (Mandatory = $true )]
25+ [string ] $FileName
26+ )
27+
28+ begin {
29+ Write-PScriboMessage - Message " EnableDiagrams set to $ ( $Options.EnableDiagrams ) ."
30+ }
31+
32+ process {
33+ if ($Options.EnableDiagrams ) {
34+ Write-PScriboMessage - Message " Collecting NetApp Ontap Infrastructure diagram"
35+
36+ $RootPath = Split-Path (Split-Path $PSScriptRoot - Parent) - Parent
37+ [System.IO.FileInfo ]$IconPath = Join-Path $RootPath ' icons'
38+
39+ $DiagramParams = @ {
40+ ' FileName' = $FileName
41+ ' OutputFolderPath' = $OutputFolderPath
42+ ' MainDiagramLabel' = $MainDiagramLabel
43+ ' MainDiagramLabelFontsize' = 28
44+ ' MainDiagramLabelFontcolor' = ' #565656'
45+ ' MainDiagramLabelFontname' = ' Segoe UI Black'
46+ ' IconPath' = $IconPath
47+ ' ImagesObj' = $Images
48+ ' LogoName' = ' AsBuiltReport_LOGO'
49+ ' SignatureLogoName' = ' Abr_LOGO_Footer'
50+ ' WaterMarkText' = $Options.DiagramWaterMark
51+ ' Direction' = & {
52+ if ($MainDiagramLabel -eq ' Cluster Replication Diagram' ) {
53+ ' left-to-right'
54+ } else {
55+ ' top-to-bottom'
56+ }
57+ }
58+ }
59+
60+ if ($Options.DiagramTheme -eq ' Black' ) {
61+ $DiagramParams.add (' MainGraphBGColor' , ' Black' )
62+ $DiagramParams.add (' Edgecolor' , ' White' )
63+ $DiagramParams.add (' Fontcolor' , ' White' )
64+ $DiagramParams.add (' NodeFontcolor' , ' White' )
65+ $DiagramParams.add (' WaterMarkColor' , ' White' )
66+ } elseif ($Options.DiagramTheme -eq ' Neon' ) {
67+ $DiagramParams.add (' MainGraphBGColor' , ' grey14' )
68+ $DiagramParams.add (' Edgecolor' , ' gold2' )
69+ $DiagramParams.add (' Fontcolor' , ' gold2' )
70+ $DiagramParams.add (' NodeFontcolor' , ' gold2' )
71+ $DiagramParams.add (' WaterMarkColor' , ' #FFD700' )
72+ } else {
73+ $DiagramParams.add (' WaterMarkColor' , ' #333333' )
74+ }
75+
76+ if ($Options.ExportDiagrams ) {
77+ if (-not $Options.ExportDiagramsFormat ) {
78+ $DiagramFormat = ' png'
79+ } else {
80+ $DiagramFormat = $Options.ExportDiagramsFormat
81+ }
82+ $DiagramParams.Add (' Format' , $DiagramFormat )
83+ } else {
84+ $DiagramParams.Add (' Format' , " base64" )
85+ }
86+
87+ if ($Options.EnableDiagramDebug ) {
88+
89+ $DiagramParams.Add (' DraftMode' , $True )
90+
91+ }
92+
93+ if ($Options.EnableDiagramSignature ) {
94+ $DiagramParams.Add (' Signature' , $True )
95+ $DiagramParams.Add (' AuthorName' , $Options.SignatureAuthorName )
96+ $DiagramParams.Add (' CompanyName' , $Options.SignatureCompanyName )
97+ }
98+
99+ if ($Options.ExportDiagrams ) {
100+ try {
101+ Write-PScriboMessage - Message " Generating NetApp Ontap diagram"
102+ $Graph = $DiagramObject
103+ if ($Graph ) {
104+ Write-PScriboMessage - Message " Saving NetApp Ontap diagram"
105+ $Diagram = New-Diagrammer @DiagramParams - InputObject $Graph
106+ if ($Diagram ) {
107+ foreach ($OutputFormat in $DiagramFormat ) {
108+ Write-Information - MessageData " Saved '$ ( $FileName ) .$ ( $OutputFormat ) ' diagram to '$ ( $OutputFolderPath ) '." - InformationAction Continue
109+ }
110+ }
111+ }
112+ } catch {
113+ Write-PScriboMessage - IsWarning - Message " Unable to export the NetApp Diagram: $ ( $_.Exception.Message ) "
114+ }
115+ }
116+ try {
117+ $DiagramParams.Remove (' Format' )
118+ $DiagramParams.Add (' Format' , " base64" )
119+
120+ $Graph = $DiagramObject
121+ $Diagram = New-Diagrammer @DiagramParams - InputObject $Graph
122+ if ($Diagram ) {
123+ if ((Get-DiaImagePercent - GraphObj $Diagram ).Width -gt 600 ) { $ImagePrty = 40 } else { $ImagePrty = 30 }
124+ Section - Style Heading2 $MainDiagramLabel {
125+ Image - Base64 $Diagram - Text " NetApp Ontap Diagram" - Percent $ImagePrty - Align Center
126+ Paragraph " Image preview: Opens the image in a new tab to view it at full resolution." - Tabs 2
127+ }
128+ }
129+ } catch {
130+ Write-PScriboMessage - IsWarning - Message " Unable to generate the Ontap Diagram: $ ( $_.Exception.Message ) "
131+ }
132+ }
133+ }
134+
135+ end {}
136+ }
0 commit comments