Skip to content

Commit

Permalink
fix: add connection check (#209)
Browse files Browse the repository at this point in the history
Added information in the HTML report if a vCenter Server authentication fails to be caught.

Signed-off-by: Jared Burns <jared.burns@broadcom.com>
  • Loading branch information
burnsjared0415 authored Feb 6, 2024
1 parent c2b32de commit 4079cde
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release History

## v2.6.1

> Release Date: Not Released
Bugfix:

- Updated `Request-VcenterStorageHealth` cmdlet to output an error message if authentication to vCenter Server fails. [GH-209] https://github.com/vmware/powershell-module-for-vmware-cloud-foundation-reporting/pull/209

## v2.6.0

> Release Date: 2024-01-30
Expand Down
2 changes: 1 addition & 1 deletion VMware.CloudFoundation.Reporting.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RootModule = '.\VMware.CloudFoundation.Reporting.psm1'

# Version number of this module.
ModuleVersion = '2.6.0.1001'
ModuleVersion = '2.6.1.1000'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
25 changes: 20 additions & 5 deletions VMware.CloudFoundation.Reporting.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -5116,13 +5116,28 @@ Function Request-VcenterStorageHealth {
# Reference: https://kb.vmware.com/s/article/76563.
$command = 'df -h | grep -e "^/" | grep -v "/dev/loop" | grep -v "/dev/mapper/archive_vg-archive"'
$vcenter = (Get-VCFWorkloadDomain | Where-Object { $_.name -eq $domain }).vcenters
$vcenterfqdn = $vcenter.fqdn
$rootPass = (Get-VCFCredential | Where-Object { $_.credentialType -eq "SSH" -and $_.resource.resourceName -eq $vcenter.fqdn }).password
$dfOutput = Invoke-VMScript -VM ($vcenter.fqdn.Split(".")[0]) -ScriptText $command -GuestUser root -GuestPassword $rootPass -Server $vcfVcenterDetails.fqdn
if ($PsBoundParameters.ContainsKey("failureOnly")) {
Format-DfStorageHealth -dfOutput $dfOutput -systemFqdn $vcenter.fqdn -failureOnly
} else {
Format-DfStorageHealth -dfOutput $dfOutput -systemFqdn $vcenter.fqdn
}
if ($dfOutput.ExitCode -eq 0) {
if ($PsBoundParameters.ContainsKey("failureOnly")) {
Format-DfStorageHealth -dfOutput $dfOutput -systemFqdn $vcenter.fqdn -failureOnly
} else {
Format-DfStorageHealth -dfOutput $dfOutput -systemFqdn $vcenter.fqdn
}
} else {
$alert = "RED"
$message = "vCenter Connection check failed!"
$elementObject = New-Object System.Collections.ArrayList
$elementObject = New-Object -TypeName psobject
$elementObject | Add-Member -NotePropertyName 'Component' -NotePropertyValue "vCenter"
$elementObject | Add-Member -NotePropertyName 'Resource' -NotePropertyValue $vcenterfqdn
$elementObject | Add-Member -NotePropertyName 'Alert' -NotePropertyValue $alert
$elementObject | Add-Member -NotePropertyName 'Message' -NotePropertyValue $message
$customObject += $elementObject
}
$customObject | Sort-Object Component, Resource

}
Disconnect-VIServer * -Force -Confirm:$false -WarningAction SilentlyContinue | Out-Null
}
Expand Down

0 comments on commit 4079cde

Please sign in to comment.