Skip to content

Commit

Permalink
Merge pull request #23 from rebelinux/dev
Browse files Browse the repository at this point in the history
v0.5.9 public release
  • Loading branch information
rebelinux authored Feb 15, 2024
2 parents bfce763 + 8887da0 commit 09673bf
Show file tree
Hide file tree
Showing 32 changed files with 1,078 additions and 930 deletions.
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,26 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.5.9] - 2024-02-15

### Added

- Added Get-HTMLNodeTable cmdlet

### Changed

- Improved diagram layout
- Improved Get-HTMLTable cmdlet (Now allow MultiColumn table)

### Fixed

- Fixed CodeQL security alerts
- Fix for PSGraph hidden node interfering in edge calculation


## [0.5.8] - 2024-01-25

### Chaged
### Changed

- Added Graphviz libraries to local module folder. (No need to manually install Graphviz)
- Code improvements
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ The Veeam.Diagrammer supports the following Veeam Backup & Replication version;
### :closed_lock_with_key: Required Privileges

Only users with Veeam Backup Administrator role assigned can generate a Diagram

### PowerShell

This project is compatible with the following PowerShell versions;

<!-- ********** Update supported PowerShell versions ********** -->
| Windows PowerShell 5.1 | PowerShell 7 |
|:----------------------:|:--------------------:|
| :white_check_mark: | :x: |
| Windows PowerShell 5.1 | PowerShell 7 |
| :--------------------: | :----------: |
| :white_check_mark: | :x: |

## :wrench: System Requirements

Expand Down Expand Up @@ -123,7 +124,7 @@ _Note: You are not limited to installing the module to those example paths, you

### **New-VeeamDiagram**

The `New-VeeamDiagram` cmdlet is used to generate a Veeam Backup & Replication diagram. The type of diagram to generate is specified by using the `DiagramType` parameter. The DiagramType parameter relies on additional diagram modules being created alongside the defaults module. The `Target` parameter specifies one or more Veeam VBR servers on which to connect and run the diagram. User credentials to the system are specifed using the `Credential`, or the `Username` and `Password` parameters. One or more document formats, such as `PNG`, `PDF`, `SVG`, `BASE64` or `DOT` can be specified using the `Format` parameter. Additional parameters are outlined below.
The `New-VeeamDiagram` cmdlet is used to generate a Veeam Backup & Replication diagram. The type of diagram to generate is specified by using the `DiagramType` parameter. The DiagramType parameter relies on additional diagram modules being created alongside the defaults module. The `Target` parameter specifies one or more Veeam VBR servers on which to connect and run the diagram. User credentials to the system are specified using the `Credential`, or the `Username` and `Password` parameters. One or more document formats, such as `PNG`, `PDF`, `SVG`, `BASE64` or `DOT` can be specified using the `Format` parameter. Additional parameters are outlined below.

```powershell
.PARAMETER DiagramType
Expand Down
36 changes: 13 additions & 23 deletions Src/Private/Convert-TableToHTML.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
function Convert-TableToHTML
{
function Convert-TableToHTML {
<#
.SYNOPSIS
Creates a html table object
Expand Down Expand Up @@ -105,47 +104,38 @@ function Convert-TableToHTML
$HeaderColor = "black",

[string]
$HeaderFontColor="white",
$HeaderFontColor = "white",

[string]
$BorderColor="white"
$BorderColor = "white"
)
begin
{
begin {
$tableData = [System.Collections.ArrayList]::new()
if ( [string]::IsNullOrEmpty($Label) )
{
if ( [string]::IsNullOrEmpty($Label) ) {
$Label = $Name
}
}
process
{
if ( $null -ne $ScriptBlock )
{
process {
if ( $null -ne $ScriptBlock ) {
$Row = $ScriptBlock.Invoke()
}

if ( $null -ne $RowScript )
{
$Row = foreach ( $node in $Row )
{
if ( $null -ne $RowScript ) {
$Row = foreach ( $node in $Row ) {
@($node).ForEach($RowScript)
}
}

$results = foreach ( $node in $Row )
{
$results = foreach ( $node in $Row ) {
Row -Label $node
}

foreach ( $node in $results )
{
foreach ( $node in $results ) {
[void]$tableData.Add($node)
}
}
end
{
end {
$html = "<TABLE CELLBORDER='1' BORDER='0' CELLSPACING='0'><TR><TD bgcolor='$HeaderColor' align='center'><font color='$HeaderFontColor'><B>{0}</B></font></TD></TR>{1}</TABLE>" -f $Label, ($tableData -join '')
Node $Name @{label = $html; shape = 'none'; fontname = $Fontname; fontsize = $FontSize; style = $Style; penwidth = 1; fillcolor = $Fillcolor; color = $BorderColor}
Node $Name @{label = $html; shape = 'none'; fontname = $Fontname; fontsize = $FontSize; style = $Style; penwidth = 1; fillcolor = $Fillcolor; color = $BorderColor }
}
}
100 changes: 100 additions & 0 deletions Src/Private/Get-DiagBackupServer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
function Get-DiagBackupServer {
<#
.SYNOPSIS
Function to build Backup Server object.
.DESCRIPTION
Build a diagram of the configuration of Veeam VBR in PDF/PNG/SVG formats using Psgraph.
.NOTES
Version: 0.5.8
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
.LINK
https://github.com/rebelinux/Veeam.Diagrammer
#>
[CmdletBinding()]

Param
(

)
process {
try {
SubGraph BackupServer -Attributes @{Label = 'Backup Server'; style = "rounded"; bgcolor = "#ceedc4"; fontsize = 18; penwidth = 2 } {
if (($DatabaseServerInfo.Name -ne $BackupServerInfo.Name) -and $EMServerInfo) {
Write-Verbose -Message "Collecting Backup Server, Database Server and Enterprise Manager Information."
$BSHASHTABLE = @{}
$DBHASHTABLE = @{}
$EMHASHTABLE = @{}

$BackupServerInfo.psobject.properties | ForEach-Object { $BSHASHTABLE[$_.Name] = $_.Value }
$DatabaseServerInfo.psobject.properties | ForEach-Object { $DBHASHTABLE[$_.Name] = $_.Value }
$EMServerInfo.psobject.properties | ForEach-Object { $EMHASHTABLE[$_.Name] = $_.Value }

Node $BackupServerInfo.Name -Attributes @{Label = $BSHASHTABLE.Label; fillColor = '#ceedc4'; shape = 'plain' }
Node $DatabaseServerInfo.Name -Attributes @{Label = $DBHASHTABLE.Label; fillColor = '#ceedc4'; shape = 'plain' }
Node $EMServerInfo.Name -Attributes @{Label = $EMHASHTABLE.Label; fillColor = '#ceedc4'; shape = 'plain' }

if ($Dir -eq 'LR') {
Rank $EMServerInfo.Name, $DatabaseServerInfo.Name
Edge -From $EMServerInfo.Name -To $BackupServerInfo.Name @{arrowtail = "normal"; arrowhead = "normal"; minlen = 3; }
Edge -From $DatabaseServerInfo.Name -To $BackupServerInfo.Name @{arrowtail = "normal"; arrowhead = "normal"; minlen = 3; xlabel = $DatabaseServerInfo.DBPort }
} else {
Rank $EMServerInfo.Name, $BackupServerInfo.Name, $DatabaseServerInfo.Name
Edge -From $EMServerInfo.Name -To $BackupServerInfo.Name @{arrowtail = "normal"; arrowhead = "normal"; minlen = 3; }
Edge -From $BackupServerInfo.Name -To $DatabaseServerInfo.Name @{arrowtail = "normal"; arrowhead = "normal"; minlen = 3; xlabel = $DatabaseServerInfo.DBPort }
}
} elseif (($DatabaseServerInfo.Name -ne $BackupServerInfo.Name) -and (-Not $EMServerInfo)) {
Write-Verbose -Message "Not Enterprise Manager Found: Collecting Backup Server and Database server Information."
$BSHASHTABLE = @{}
$DBHASHTABLE = @{}

$BackupServerInfo.psobject.properties | ForEach-Object { $BSHASHTABLE[$_.Name] = $_.Value }
$DatabaseServerInfo.psobject.properties | ForEach-Object { $DBHASHTABLE[$_.Name] = $_.Value }

Node $BackupServerInfo.Name -Attributes @{Label = $BSHASHTABLE.Label; fillColor = '#ceedc4'; shape = 'plain' }
Node $DatabaseServerInfo.Name -Attributes @{Label = $DBHASHTABLE.Label; fillColor = '#ceedc4'; shape = 'plain' }

if ($Dir -eq 'LR') {
Rank $BackupServerInfo.Name, $DatabaseServerInfo.Name
Edge -From $DatabaseServerInfo.Name -To $BackupServerInfo.Name @{arrowtail = "normal"; arrowhead = "normal"; minlen = 3; xlabel = $DatabaseServerInfo.DBPort }
} else {
Rank $BackupServerInfo.Name, $DatabaseServerInfo.Name
Edge -From $BackupServerInfo.Name -To $DatabaseServerInfo.Name @{arrowtail = "normal"; arrowhead = "normal"; minlen = 3; xlabel = $DatabaseServerInfo.DBPort }
}
} elseif ($EMServerInfo -and ($DatabaseServerInfo.Name -eq $BackupServerInfo.Name)) {
Write-Verbose -Message "Database server colocated with Backup Server: Collecting Backup Server and Enterprise Manager Information."
$BSHASHTABLE = @{}
$EMHASHTABLE = @{}

$BackupServerInfo.psobject.properties | ForEach-Object { $BSHASHTABLE[$_.Name] = $_.Value }
$EMServerInfo.psobject.properties | ForEach-Object { $EMHASHTABLE[$_.Name] = $_.Value }

Node $BackupServerInfo.Name -Attributes @{Label = $BSHASHTABLE.Label; fillColor = '#ceedc4'; shape = 'plain' }
Node $EMServerInfo.Name -Attributes @{Label = $EMHASHTABLE.Label; fillColor = '#ceedc4'; shape = 'plain' }

if ($Dir -eq 'LR') {
Rank $EMServerInfo.Name, $BackupServerInfo.Name
Edge -From $EMServerInfo.Name -To $BackupServerInfo.Name @{arrowtail = "normal"; arrowhead = "normal"; minlen = 3; }
} else {
Rank $EMServerInfo.Name, $BackupServerInfo.Name
Edge -From $BackupServerInfo.Name -To $EMServerInfo.Name @{arrowtail = "normal"; arrowhead = "normal"; minlen = 3; }
}
} else {
Write-Verbose -Message "Database server colocated with Backup Server and no Enterprise Manager found: Collecting Backup Server Information."
$BSHASHTABLE = @{}
$BackupServerInfo.psobject.properties | ForEach-Object { $BSHASHTABLE[$_.Name] = $_.Value }
Node Left @{Label = 'Left'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain'; fillColor = 'transparent' }
Node Leftt @{Label = 'Leftt'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain'; fillColor = 'transparent' }
Node Right @{Label = 'Right'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain'; fillColor = 'transparent' }
Node $BackupServerInfo.Name -Attributes @{Label = $BSHASHTABLE.Label; fillColor = '#ceedc4'; shape = 'plain' }
Edge Left, Leftt, $BackupServerInfo.Name, Right @{style = $EdgeDebug.style; color = $EdgeDebug.color }
Rank Left, Leftt, $BackupServerInfo.Name, Right
}
}
} catch {
$_
}
}
end {}
}
35 changes: 20 additions & 15 deletions Src/Private/Get-DiagBackupToFileProxy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function Get-DiagBackupToFileProxy {
.DESCRIPTION
Build a diagram of the configuration of Veeam VBR in PDF/PNG/SVG formats using Psgraph.
.NOTES
Version: 0.5.6
Version: 0.5.9
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
Expand All @@ -18,6 +18,12 @@ function Get-DiagBackupToFileProxy {
(

)

begin {
# Get Veeam Backup Server Object
Get-DiagBackupServer
}

process {
try {
$FileBackupProxy = Get-VbrBackupProxyInfo -Type 'nas'
Expand All @@ -35,37 +41,36 @@ function Get-DiagBackupToFileProxy {
fontsize = 18
penwidth = 1.5
labelloc = 't'
color=$SubGraphDebug.color
style='dashed,rounded'
color = $SubGraphDebug.color
style = 'dashed,rounded'
}
SubGraph MainSubGraph -Attributes $ProxiesAttr -ScriptBlock {
# Dummy Node used for subgraph centering
node DummyFileProxy @{Label=$DiagramDummyLabel; fontsize=18; fontname="Segoe Ui Black"; fontcolor='#005f4b'; shape='plain'}
Node DummyFileProxy @{Label = $DiagramDummyLabel; fontsize = 18; fontname = "Segoe Ui Black"; fontcolor = '#005f4b'; shape = 'plain' }
if ($Dir -eq "TB") {
node FileLeft @{Label='FileLeft'; style=$EdgeDebug.style; color=$EdgeDebug.color; shape='plain'; fillColor='transparent'}
node FileLeftt @{Label='FileLeftt'; style=$EdgeDebug.style; color=$EdgeDebug.color; shape='plain'; fillColor='transparent'}
node FileRight @{Label='FileRight'; style=$EdgeDebug.style; color=$EdgeDebug.color; shape='plain'; fillColor='transparent'}
edge FileLeft,FileLeftt,DummyFileProxy,FileRight @{style=$EdgeDebug.style; color=$EdgeDebug.color}
rank FileLeft,FileLeftt,DummyFileProxy,FileRight
Node FileLeft @{Label = 'FileLeft'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain'; fillColor = 'transparent' }
Node FileLeftt @{Label = 'FileLeftt'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain'; fillColor = 'transparent' }
Node FileRight @{Label = 'FileRight'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain'; fillColor = 'transparent' }
Edge FileLeft, FileLeftt, DummyFileProxy, FileRight @{style = $EdgeDebug.style; color = $EdgeDebug.color }
Rank FileLeft, FileLeftt, DummyFileProxy, FileRight
}
foreach ($ProxyObj in $FileBackupProxy) {
$PROXYHASHTABLE = @{}
$ProxyObj.psobject.properties | ForEach-Object { $PROXYHASHTABLE[$_.Name] = $_.Value }
node $ProxyObj -NodeScript {$_.Name} @{Label=$PROXYHASHTABLE.Label; fontname="Segoe Ui"}
edge -From DummyFileProxy -To $ProxyObj.Name @{constraint="true"; minlen=1; style=$EdgeDebug.style; color=$EdgeDebug.color}
Node $ProxyObj -NodeScript { $_.Name } @{Label = $PROXYHASHTABLE.Label; fontname = "Segoe Ui" }
Edge -From DummyFileProxy -To $ProxyObj.Name @{constraint = "true"; minlen = 1; style = $EdgeDebug.style; color = $EdgeDebug.color }
}
Rank $FileBackupProxy.Name
}

if ($Dir -eq 'LR') {
edge $BackupServerInfo.Name -to DummyFileProxy @{minlen=3;}
Edge $BackupServerInfo.Name -To DummyFileProxy @{minlen = 3}
} else {
edge $BackupServerInfo.Name -to DummyFileProxy @{minlen=3;}
Edge $BackupServerInfo.Name -To DummyFileProxy @{minlen = 3}
}
}
}
}
catch {
} catch {
$_
}
}
Expand Down
35 changes: 20 additions & 15 deletions Src/Private/Get-DiagBackupToHvProxy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function Get-DiagBackupToHvProxy {
.DESCRIPTION
Build a diagram of the configuration of Veeam VBR in PDF/PNG/SVG formats using Psgraph.
.NOTES
Version: 0.5.6
Version: 0.5.9
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
Expand All @@ -18,6 +18,12 @@ function Get-DiagBackupToHvProxy {
(

)

begin {
# Get Veeam Backup Server Object
Get-DiagBackupServer
}

process {
try {
$HyperVBackupProxy = Get-VbrBackupProxyInfo -Type 'hyperv'
Expand All @@ -34,36 +40,35 @@ function Get-DiagBackupToHvProxy {
fontsize = 18
penwidth = 1.5
labelloc = 't'
color=$SubGraphDebug.color
style='dashed,rounded'
color = $SubGraphDebug.color
style = 'dashed,rounded'
}
SubGraph MainSubGraph -Attributes $ProxiesAttr -ScriptBlock {
# Dummy Node used for subgraph centering
node DummyHyperVProxy @{Label=$DiagramDummyLabel; fontsize=18; fontname="Segoe Ui Black"; fontcolor='#005f4b'; shape='plain'}
Node DummyHyperVProxy @{Label = $DiagramDummyLabel; fontsize = 18; fontname = "Segoe Ui Black"; fontcolor = '#005f4b'; shape = 'plain' }
if ($Dir -eq "TB") {
node HvLeft @{Label='HvLeft'; style=$EdgeDebug.style; color=$EdgeDebug.color; shape='plain'; fillColor='transparent'}
node HvLeftt @{Label='HvLeftt'; style=$EdgeDebug.style; color=$EdgeDebug.color; shape='plain'; fillColor='transparent'}
node HvRight @{Label='HvRight'; style=$EdgeDebug.style; color=$EdgeDebug.color; shape='plain'; fillColor='transparent'}
edge HvLeft,HvLeftt,DummyHyperVProxy,HvRight @{style=$EdgeDebug.style; color=$EdgeDebug.color}
rank HvLeft,HvLeftt,DummyHyperVProxy,HvRight
Node HvLeft @{Label = 'HvLeft'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain'; fillColor = 'transparent' }
Node HvLeftt @{Label = 'HvLeftt'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain'; fillColor = 'transparent' }
Node HvRight @{Label = 'HvRight'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain'; fillColor = 'transparent' }
Edge HvLeft, HvLeftt, DummyHyperVProxy, HvRight @{style = $EdgeDebug.style; color = $EdgeDebug.color }
Rank HvLeft, HvLeftt, DummyHyperVProxy, HvRight
}
foreach ($ProxyObj in $HyperVBackupProxy) {
$PROXYHASHTABLE = @{}
$ProxyObj.psobject.properties | ForEach-Object { $PROXYHASHTABLE[$_.Name] = $_.Value }
node $ProxyObj -NodeScript {$_.Name} @{Label=$PROXYHASHTABLE.Label; fontname="Segoe Ui"}
edge -From DummyHyperVProxy -To $ProxyObj.Name @{constraint="true"; minlen=1; style=$EdgeDebug.style; color=$EdgeDebug.color}
Node $ProxyObj -NodeScript { $_.Name } @{Label = $PROXYHASHTABLE.Label; fontname = "Segoe Ui" }
Edge -From DummyHyperVProxy -To $ProxyObj.Name @{constraint = "true"; minlen = 1; style = $EdgeDebug.style; color = $EdgeDebug.color }
}
Rank $HyperVBackupProxy.Name
}

if ($Dir -eq 'LR') {
edge $BackupServerInfo.Name -to DummyHyperVProxy @{minlen=3;}
Edge $BackupServerInfo.Name -To DummyHyperVProxy @{minlen = 3 }
} else {
edge $BackupServerInfo.Name -to DummyHyperVProxy @{minlen=3;}
Edge $BackupServerInfo.Name -To DummyHyperVProxy @{minlen = 3 }
}
}
}
catch {
} catch {
$_
}
}
Expand Down
Loading

0 comments on commit 09673bf

Please sign in to comment.