Skip to content

Commit

Permalink
Merge pull request #11 from vmware-samples/dev-gjb-#10
Browse files Browse the repository at this point in the history
Fix Add-vROPSAdapterSddcHealth
  • Loading branch information
GaryJBlake authored Feb 18, 2022
2 parents b0f6d0c + 258b1ff commit dc48b89
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions PowerValidatedSolutions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -6953,25 +6953,37 @@ Function Add-vROPSAdapterSddcHealth {
if (($vcfVropsDetails = Get-vROPsServerDetail -fqdn $server -username $user -password $pass)) {
if (Test-vROPSConnection -server $vcfVropsDetails.loadBalancerFqdn) {
if (Test-vROPSAuthentication -server $vcfVropsDetails.loadBalancerFqdn -user $vcfVropsDetails.adminUser -pass $vcfVropsDetails.adminPass) {
$vropsVersion = ((Get-vROPSVersion).releaseName -split '\s+' -match '\S')[-1]
if ($remoteCollectors = (Get-vROPSCollector | Where-Object {$_.type -eq "REMOTE"})) {
Foreach ($collector in $remoteCollectors) {
$adapterName = "SDDC Health Adapter Instance -" + ($collector.name -Split ("vRealize Operations Manager Collector-"))
$json = '{
"resourceKey": {
"name": "'+ $adapterName +'",
"adapterKindKey": "SDDCHealthAdapter",
"resourceKindKey": "SDDCHealth Instance"
},
"description": "SDDC Health Adapter for'+ ($collector.name -Split ("vRealize Operations Manager Collector-")) +'",
"collectorId": '+ $($collector.id) +',
"monitoringInterval": 5
}'
if ($vropsVersion -lt "8.5.0") {
$json = '{
"resourceKey": {
"name": "'+ $adapterName +'",
"adapterKindKey": "SDDCHealthAdapter",
"resourceKindKey": "SDDCHealth Instance"
},
"description": "SDDC Health Adapter for'+ ($collector.name -Split ("vRealize Operations Manager Collector-")) +'",
"collectorId": '+ $($collector.id) +',
"monitoringInterval": 5
}'
}
else {
$json = '{
"name": "'+ $adapterName +'",
"adapterKindKey": "SDDCHealthAdapter",
"description": "SDDC Health Adapter for'+ ($collector.name -Split ("vRealize Operations Manager Collector-")) +'",
"collectorId": '+ $($collector.id) +',
"monitoringInterval": 5
}'
}

$json | Out-File .\addAdapter.json
if (!(Get-vROPSAdapter | Where-Object {$_.resourceKey.name -eq $adapterName})) {
Add-vROPSAdapter -json .\addAdapter.json | Out-Null
if (Get-vROPSAdapter | Where-Object {$_.resourceKey.name -eq $adapterName}) {
Start-vROPSAdapter -adapterId (Get-vROPSAdapter | Where-Object {$_.resourceKey.name -eq $adapterName}) | Out-Null
Start-vROPSAdapter -adapterId (Get-vROPSAdapter | Where-Object {$_.resourceKey.name -eq $adapterName}).id | Out-Null
Write-Output "Adding Adapter ($adapterName) to vRealize Operations Manager ($($vcfVropsDetails.loadBalancerFqdn)): SUCCESSFUL"
}
else {
Expand Down

0 comments on commit dc48b89

Please sign in to comment.