Skip to content

Commit

Permalink
feat: enhance Add-vROPSAdapterVcf (#779)
Browse files Browse the repository at this point in the history
- Enhanced `Add-vROPSAdapterVcf` cmdlet updated to provide additional output on progress and checks on configuration process.

Signed-off-by: Gary Blake <[email protected]>
  • Loading branch information
GaryJBlake authored Oct 1, 2024
1 parent 178e992 commit 61c4a20
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 36 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
- Enhanced `Export-CbrJsonSpec` cmdlet to export the DRaaS Connector hostname and FQDN.
- Enhanced `Add-NetworkSegment` cmdlet to return the pre-validation error correctly (removed breaks in the code).
- Enhanced `config.PowerValidatedSolutions` configuration file to include NSX version so be able to check for the binary for NSX Federation.
- Enhanced `Add-vROPSAdapterVcf` cmdlet updated to provide additional output on progress.
- Enhanced `Add-vROPSAdapterVcf` cmdlet updated to provide additional output on progress and checks on configuration process.
- Enhanced `Add-vCenterGlobalPermission` cmdlet to force synchronization of global permissions.
- Enhanced `Set-WorkspaceOneNtpConfig` cmdlet to handle a single NTP server.
- Enhanced `Invoke-DriDeployment` cmdlet to handle single NTP and DNS servers.
Expand Down
2 changes: 1 addition & 1 deletion PowerValidatedSolutions.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RootModule = 'PowerValidatedSolutions.psm1'

# Version number of this module.
ModuleVersion = '2.12.0.1047'
ModuleVersion = '2.12.0.1048'

# ID used to uniquely identify this module
GUID = 'a6dfed7b-65d2-4da2-bdcc-7f3d3df9b75d'
Expand Down
71 changes: 37 additions & 34 deletions PowerValidatedSolutions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -20650,41 +20650,44 @@ Function Add-vROPSAdapterVcf {
Write-Warning "Adding vSAN Adapter in VMware Aria Operations ($($vcfVropsDetails.loadBalancerFqdn)) for Workload Domain ($($workloadDomain.name)), already exists: SKIPPED"
}
if (-Not ((Get-vROPSAdapter | Where-Object { $_.resourceKey.name -eq "$($workloadDomain.name) - NSX" }))) {
$adapterJson = '{
"name": "'+ $workloadDomain.name + ' - NSX",
"description": "NSX Adapter - '+ $vcfNsxDetails.fqdn + '",
"adapterKindKey" : "NSXTAdapter",
"resourceKindKey" : "NSXTAdapterInstance",
"monitoringInterval": 5,
"collectorGroupId": "'+ (Get-vROPSCollectorGroup | Where-Object { $_.name -eq $collectorGroupName }).id + '",
"resourceIdentifiers" : [
{ "name": "NSXTHOST", "value": "'+ $($vcfNsxDetails.fqdn) + '" },
{ "name": "VCURL", "value": "'+ $($vcfVcenterDetails.fqdn) + '" }
],
"credential": {
"id": "'+ (Get-vROPSCredential | Where-Object { $_.name -match "NSX Credential - $($($vcfNsxDetails.fqdn).Split('.')[-0])" }).id + '"
}
}'
$adapterJson | Out-File .\nsxAddAdapter.json
Add-vROPSAdapter -json .\nsxAddAdapter.json | Out-Null
$testAdapter = Test-vROPSAdapterConnection -json .\nsxAddAdapter.json
$testAdapter | ConvertTo-Json -Depth 10 | Out-File .\nsxCreatedAdapter.json
Test-vROPSAdapterConnection -json .\nsxCreatedAdapter.json -patch | Out-Null
$adapterDetail = Get-Content -Path .\nsxCreatedAdapter.json -Raw | ConvertFrom-Json
$adapterDetail.PSObject.Properties.Remove('links')
$adapterDetail | Add-Member -NotePropertyName description -NotePropertyValue "NSX Adapter - $($vcfNsxDetails.fqdn)"
$adapterDetail.'adapter-certificates' = $adapterDetail.'adapter-certificates' | Select-Object * -ExcludeProperty certificateDetails
$adapterDetail.id = (Get-vROPSAdapter | Where-Object { $_.resourceKey.name -eq "$($workloadDomain.name) - NSX" }).id
$adapterDetail | ConvertTo-Json -Depth 100 | Out-File .\nsxPatchAdapter.json -Force
Set-vROPSAdapter -json .\nsxPatchAdapter.json -patch | Out-Null
#if (Get-vROPSAdapter | Where-Object { $_.resourceKey.name -eq "$($workloadDomain.name) - NSX" }) {
if (Request-ConfigurationCheck -timeoutSeconds 300 -command '(Get-vROPSAdapter | Where-Object { $_.resourceKey.name -eq "$($workloadDomain.name) - NSX" })') {
Start-vROPSAdapter -adapterId (Get-vROPSAdapter | Where-Object { $_.resourceKey.name -eq "$($workloadDomain.name) - NSX" }).id | Out-Null
}
if ((Get-vROPSAdapter | Where-Object { $_.resourceKey.name -eq "$($workloadDomain.name) - NSX" })) {
Write-Output "Adding NSX Adapter in VMware Aria Operations ($($vcfVropsDetails.loadBalancerFqdn)) for Workload Domain ($($workloadDomain.name)): SUCCESSFUL"
if (-Not ((Get-vROPSAdapter | Where-Object { $_.resourceKey.name -eq "$($workloadDomain.name) - NSX" }).description -match $vcfNsxDetails.fqdn)) {
$adapterJson = '{
"name": "'+ $workloadDomain.name + ' - NSX",
"description": "NSX Adapter - '+ $vcfNsxDetails.fqdn + '",
"adapterKindKey" : "NSXTAdapter",
"resourceKindKey" : "NSXTAdapterInstance",
"monitoringInterval": 5,
"collectorGroupId": "'+ (Get-vROPSCollectorGroup | Where-Object { $_.name -eq $collectorGroupName }).id + '",
"resourceIdentifiers" : [
{ "name": "NSXTHOST", "value": "'+ $($vcfNsxDetails.fqdn) + '" },
{ "name": "VCURL", "value": "'+ $($vcfVcenterDetails.fqdn) + '" }
],
"credential": {
"id": "'+ (Get-vROPSCredential | Where-Object { $_.name -match "NSX Credential - $($($vcfNsxDetails.fqdn).Split('.')[-0])" }).id + '"
}
}'
$adapterJson | Out-File .\nsxAddAdapter.json
Add-vROPSAdapter -json .\nsxAddAdapter.json | Out-Null
$testAdapter = Test-vROPSAdapterConnection -json .\nsxAddAdapter.json
$testAdapter | ConvertTo-Json -Depth 10 | Out-File .\nsxCreatedAdapter.json
Test-vROPSAdapterConnection -json .\nsxCreatedAdapter.json -patch | Out-Null
$adapterDetail = Get-Content -Path .\nsxCreatedAdapter.json -Raw | ConvertFrom-Json
$adapterDetail.PSObject.Properties.Remove('links')
$adapterDetail | Add-Member -NotePropertyName description -NotePropertyValue "NSX Adapter - $($vcfNsxDetails.fqdn)"
$adapterDetail.'adapter-certificates' = $adapterDetail.'adapter-certificates' | Select-Object * -ExcludeProperty certificateDetails
$adapterDetail.id = (Get-vROPSAdapter | Where-Object { $_.resourceKey.name -eq "$($workloadDomain.name) - NSX" }).id
$adapterDetail | ConvertTo-Json -Depth 100 | Out-File .\nsxPatchAdapter.json -Force
Set-vROPSAdapter -json .\nsxPatchAdapter.json -patch | Out-Null
if (Request-ConfigurationCheck -timeoutSeconds 300 -command '(Get-vROPSAdapter | Where-Object { $_.resourceKey.name -eq "$($workloadDomain.name) - NSX" })') {
Start-vROPSAdapter -adapterId (Get-vROPSAdapter | Where-Object { $_.resourceKey.name -eq "$($workloadDomain.name) - NSX" }).id | Out-Null
}
if ((Get-vROPSAdapter | Where-Object { $_.resourceKey.name -eq "$($workloadDomain.name) - NSX" })) {
Write-Output "Adding NSX Adapter in VMware Aria Operations ($($vcfVropsDetails.loadBalancerFqdn)) for Workload Domain ($($workloadDomain.name)): SUCCESSFUL"
} else {
Write-Error "Adding NSX Adapter in VMware Aria Operations ($($vcfVropsDetails.loadBalancerFqdn)) for Workload Domain ($($workloadDomain.name)): POST_VALIDATION_FAILED"
}
} else {
Write-Error "Adding NSX Adapter in VMware Aria Operations ($($vcfVropsDetails.loadBalancerFqdn)) for Workload Domain ($($workloadDomain.name)): POST_VALIDATION_FAILED"
Write-Warning "Adding NSX Adapter in VMware Aria Operations ($($vcfVropsDetails.loadBalancerFqdn)) for Workload Domain ($($workloadDomain.name)), shared NSX Manager: SKIPPED"
}
} else {
Write-Warning "Adding NSX Adapter in VMware Aria Operations ($($vcfVropsDetails.loadBalancerFqdn)) for Workload Domain ($($workloadDomain.name)), already exists: SKIPPED"
Expand Down

0 comments on commit 61c4a20

Please sign in to comment.