From a1bf59b47e49e322e9c49ce98b78e5c47ef1b6a3 Mon Sep 17 00:00:00 2001
From: Ryan Johnson <johnsonryan@vmware.com>
Date: Tue, 3 Jan 2023 10:00:52 -0500
Subject: [PATCH] fix(overview): exclude hcx hosts

Updates `Request0VcenterOverview` to use the PowerVCF cmdlets to return the workload domain's cluster and host counts from the SDDC Manager inventory versus directly from the vSphere inventory. This will ensure that the host count does not include any HCX nodes and addresses #44.

Signed-off-by: Ryan Johnson <johnsonryan@vmware.com>
---
 VMware.CloudFoundation.Reporting.psm1 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/VMware.CloudFoundation.Reporting.psm1 b/VMware.CloudFoundation.Reporting.psm1
index 4982c5d5..9a3c720d 100644
--- a/VMware.CloudFoundation.Reporting.psm1
+++ b/VMware.CloudFoundation.Reporting.psm1
@@ -8131,8 +8131,8 @@ Function Request-VcenterOverview {
                                     $customObject | Add-Member -notepropertyname "Domain Name" -notepropertyvalue $domain.name
                                 }
                                 $customObject | Add-Member -notepropertyname "Domain Type" -notepropertyvalue $domain.type.ToLower()
-                                $customObject | Add-Member -notepropertyname "Total Clusters" -notepropertyvalue (Get-Cluster -Server $vcfVcenterDetails.fqdn).Count
-                                $customObject | Add-Member -notepropertyname "Total Hosts" -notepropertyvalue (Get-VMHost -Server $vcfVcenterDetails.fqdn).Count
+                                $customObject | Add-Member -notepropertyname "Total Clusters" -notepropertyvalue (Get-VCFWorkloadDomain -id $domain.id).clusters.Count
+                                $customObject | Add-Member -notepropertyname "Total Hosts" -notepropertyvalue (Get-VCFHost | Where-Object {$_.domain.id -eq $domain.id}).Count
                                 $customObject | Add-Member -notepropertyname "Total VMs" -notepropertyvalue (Get-VM -Server $vcfVcenterDetails.fqdn).Count
                                 $customObject | Add-Member -notepropertyname "Powered On" -notepropertyvalue (Get-VM -Server $vcfVcenterDetails.fqdn | Where-Object {$_.PowerState -eq "PoweredOn"}).Count
                                 $customObject | Add-Member -notepropertyname "Powered Off" -notepropertyvalue (Get-VM -Server $vcfVcenterDetails.fqdn | Where-Object {$_.PowerState -eq "PoweredOff"}).Count