Skip to content

Commit

Permalink
Add rotate support
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelinux committed Dec 24, 2023
1 parent bb54e6b commit 4e3263c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
9 changes: 5 additions & 4 deletions Src/Private/Get-DiagBackupToViProxy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ function Get-DiagBackupToViProxy {
node $ESxiHost.Name @{Label=(Get-NodeIcon -Name $ESxiHost.Name -Type 'VBR_ESXi_Server' -Align "Center" -Rows $ESXiInfo)}
edge -From ESXiBackupProxy:s -To $ESxiHost.Name @{style=$EdgeDebug.style; color=$EdgeDebug.color}
}
edge -from VMWAREBackupProxyMain:s -to ESXiBackupProxy:n @{minlen=2; style='dashed'}
}
else {
$Group = Split-array -inArray $EsxiObjs -size 4
Expand All @@ -78,13 +77,15 @@ function Get-DiagBackupToViProxy {
$Start++
$ESXiNum++
}
edge -from VMWAREBackupProxyMain:s -to ESXiBackupProxy:n @{minlen=2; style='dashed'}
}
}
if ($EsxiObjs) {
edge -from vSphereInfraDummy:s -to ESXiBackupProxy:n @{minlen=2; style='dashed'}
}
}

# Dummy Node used for subgraph centering
node vSphereInfraDummy @{Label='HyperVInfraDummy'; style=$EdgeDebug.style; color=$EdgeDebug.color; shape='box'}
node vSphereInfraDummy @{Label='vSphereInfraDummy'; style=$EdgeDebug.style; color=$EdgeDebug.color; shape='box'}
edge -from VMWAREBackupProxyMain:s -to vSphereInfraDummy:n @{minlen=2; style=$EdgeDebug.style; color=$EdgeDebug.color}

if ($VirtObjs) {
Expand Down Expand Up @@ -136,7 +137,7 @@ function Get-DiagBackupToViProxy {
# Edge Lines from Dummy Node vCenter Servers to Dummy Node vSphere Virtual Infrastructure
edge -from vCenterServers:s -to $VirtObjs.Name @{style=$EdgeDebug.style; color=$EdgeDebug.color}
# Edge Lines from Dummy Node vSphere Virtual Infrastructure to Dummy Node vCenter Servers
edge -from VMWAREBackupProxyMain:s -to vCenterServers:n @{minlen=2; style='dashed'}
edge -from vSphereInfraDummy:s -to vCenterServers:n @{minlen=2; style='dashed'}
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions Src/Private/Get-DiagBackupToWanAccel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ function Get-DiagBackupToWanAccel {
edge -From WANACCELSERVER -To $WANOBJ.Name @{minlen=1; style=$EdgeDebug.style; color=$EdgeDebug.color}
}
Rank $WanAccel.Name
Record WANACCEL @(
'Name'
'Environment'
'Test <I>[string]</I>'
)
}
edge $BackupServerInfo.Name -to WANACCELSERVER @{minlen=3; xlabel=($WanAccel.TrafficPort[0])}
}
Expand Down
41 changes: 32 additions & 9 deletions Src/Public/New-VeeamDiagram.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ param (
[string] $Direction = 'top-to-bottom',

[Parameter(
Mandatory = $true,
Mandatory = $false,
HelpMessage = 'Please provide the path to the diagram output file'
)]
[ValidateScript( { Test-Path -Path $_ -IsValid })]
Expand Down Expand Up @@ -205,7 +205,7 @@ begin {
$Credential = New-Object System.Management.Automation.PSCredential ($Username, $SecurePassword)
}

if (!(Test-Path $OutputFolderPath)) {
if (($Format -ne "base64") -and !(Test-Path $OutputFolderPath)) {
Write-Error "OutputFolderPath '$OutputFolderPath' is not a valid folder path."
break
}
Expand Down Expand Up @@ -389,11 +389,16 @@ process {
} else {Write-Warning "No Scale-Out Backup Repository available to diagram"}
}
elseif ($DiagramType -eq 'Backup-to-All') {
Get-DiagBackupToProxy
if (Get-DiagBackupToHvProxy) {
Get-DiagBackupToHvProxy
} else {Write-Warning "No HyperV Proxy Infrastructure available to diagram"}
if (Get-DiagBackupToViProxy) {
Get-DiagBackupToViProxy
} else {Write-Warning "No vSphere Proxy Infrastructure available to diagram"}
Get-DiagBackupToWanAccel
Get-DiagBackupToRepo
Get-DiagBackupToSobr
# Get-DiagBackupToTape
Get-DiagBackupToTape
}
}

Expand All @@ -412,6 +417,7 @@ process {
Write-ColorOutput -Color green "Diagram '$FileName' has been saved to '$OutputFolderPath'."
} else {
$Document = Export-PSGraph -Source $Graph -DestinationPath "$($OutputFolderPath)$($FileName)" -OutputFormat $OutputFormat
#Fix icon path issue with svg output
$images = Select-String -Path $($Document.fullname) -Pattern '<image xlink:href=".*png".*>' -AllMatches
foreach($match in $images) {
$matchFound = $match -Match '"(.*png)"'
Expand All @@ -432,11 +438,28 @@ process {
} else {
$Document = Export-PSGraph -Source $Graph -DestinationPath "$($OutputFolderPath)$($FileName)" -OutputFormat 'png'
if ($Document) {
$Base64 = [convert]::ToBase64String((get-content $Document -encoding byte))
if ($Base64) {
Remove-Item -Path $Document.FullName
$Base64
} else {Remove-Item -Path $Document.FullName}
# Code used to allow rotating image!
if ($Rotate) {
Add-Type -AssemblyName System.Windows.Forms
$RotatedIMG = new-object System.Drawing.Bitmap $Document.FullName
$RotatedIMG.RotateFlip("Rotate90FlipNone")
$RotatedIMG.Save($Document.FullName,"png")
if ($RotatedIMG) {
$Base64 = [convert]::ToBase64String((get-content $Document -encoding byte))
if ($Base64) {
Remove-Item -Path $Document.FullName
$Base64
} else {Remove-Item -Path $Document.FullName}
}
} else {
# Code used to output image to base64 format
$Base64 = [convert]::ToBase64String((get-content $Document -encoding byte))
if ($Base64) {
Remove-Item -Path $Document.FullName
$Base64
} else {Remove-Item -Path $Document.FullName}

}
}
}
} catch {
Expand Down

0 comments on commit 4e3263c

Please sign in to comment.