Skip to content

Commit

Permalink
feat: add support for aria operations for logs shutdown
Browse files Browse the repository at this point in the history
Added option to check if Aria Operation for Logs exists and gracefully shutdown the components in `PowerManagement-ManagementDomain.ps1`.

Signed-off-by: Jared Burns <jared.burns@broadcom.com>
  • Loading branch information
burnsjared0415 committed Jan 31, 2024
1 parent 0756647 commit 2fefb09
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Refactor:

- Replaced the use of `Test-NetConnection` to with `Test-EndpointConnection` from the PowerShell module `PowerValidatedSolutions`. [GH-85](https://github.com/vmware/powershell-module-for-vmware-cloud-foundation-power-management/pull/85)
- Replaced current if statement `nsxtedgeNodes` to check for Virtual Machines running on Overlay Network. [GH-86] (https://github.com/vmware/powershell-module-for-vmware-cloud-foundation-power-management/pull/86)
- Added Check for vRLI deployment and will shutdown if it exist `Get-vRSLCMEnvironmentVMs` [GH-87] https://github.com/vmware/powershell-module-for-vmware-cloud-foundation-power-management/pull/87

Chore:

Expand Down
24 changes: 23 additions & 1 deletion SampleScripts/PowerManagement-ManagementDomain.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,28 @@ if ($PsBoundParameters.ContainsKey("shutdown") -or $PsBoundParameters.ContainsKe
Exit
}
}
# Check if VMware Aria Operations for Logs exists in environment, if so it will shutdown the nodes.
if (Test-VCFConnection -server $server) {
if (Test-VCFAuthentication -server $server -user $user -pass $pass) {
if (($vcfVrslcmDetails = Get-vRSLCMServerDetail -fqdn $server -username $user -password $pass)) {
if (Test-vRSLCMAuthentication -server $vcfVrslcmDetails.fqdn -user $vcfVrslcmDetails.adminUser -pass $vcfVrslcmDetails.adminPass) {
$productid = "vrli"
$vmlist = Get-vRSLCMEnvironmentVMs -server $server -user $user -pass $pass -productid $productid
if ($vmlist -ne $null) {
$domain = Get-VCFWorkloadDomain | Select-Object name, type | Where-Object { $_.type -eq "MANAGEMENT" }
if (($vcfVcenterDetails = Get-vCenterServerDetail -server $server -user $user -pass $pass -domain $domain.name)) {
if (Test-vSphereConnection -server $($vcfVcenterDetails.fqdn)) {
if (Test-vSphereAuthentication -server $vcfVcenterDetails.fqdn -user $vcfVcenterDetails.ssoAdmin -pass $vcfVcenterDetails.ssoAdminPass) {
Write-PowerManagementLogMessage -Type INFO -Message "Stopping the VMware Aria Operations for Logs nodes..." -Colour Green
Stop-CloudComponent -server $vcfVcenterDetails.fqdn -user $vcfVcenterDetails.ssoAdmin -pass $vcfVcenterDetails.ssoAdminPass -nodes $vmlist -timeout 600
}
}
}
}
}
}
}
}

# Check if there are any running Virtual Machines on the Overlay Networks before shutting down Edge Cluster.
if ($nsxtEdgeNodes) {
Expand All @@ -516,7 +538,7 @@ if ($PsBoundParameters.ContainsKey("shutdown") -or $PsBoundParameters.ContainsKe
$vmName = $vm.Name
$powerState = $vm.PowerState
if ($powerState -eq "PoweredOn") {
Write-Output "VM Name: $vmName, Power State: $powerState, Please power off the VM(s) Connect to NSX-T Segments before you shutdown Edge Cluster"
Write-PowerManagementLogMessage -Type Error -Message "VM Name: $vmName, Power State: $powerState, Please power off the virtual machines connected to NSX Segments before you shutdown an NSX Edge Cluster" -Colour Red
$stopExecuted = $true
}
if (-not $stopExecuted) {
Expand Down
2 changes: 1 addition & 1 deletion VMware.CloudFoundation.PowerManagement.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RootModule = 'VMware.CloudFoundation.PowerManagement.psm1'

# Version number of this module.
ModuleVersion = '1.4.1.1001'
ModuleVersion = '1.4.1.1002'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down

0 comments on commit 2fefb09

Please sign in to comment.