Skip to content

Commit

Permalink
Merge pull request vmware-tanzu#773 from bryanv/bryanv/fetch-just-hos…
Browse files Browse the repository at this point in the history
…t-summary-hardware-prop

🌱 Fetch only Host Summary.Hardware.cpuMhz for min CPU calculation
  • Loading branch information
bryanv authored Oct 25, 2024
2 parents 64ac056 + 4aa630e commit cc8c077
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/providers/vsphere/vcenter/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ func ClusterMinCPUFreq(ctx context.Context, cluster *object.ClusterComputeResour

var hosts []mo.HostSystem
pc := property.DefaultCollector(cluster.Client())
if err := pc.Retrieve(ctx, cr.Host, []string{"summary"}, &hosts); err != nil {
if err := pc.Retrieve(ctx, cr.Host, []string{"summary.hardware.cpuMhz"}, &hosts); err != nil {
return 0, err
}

var minFreq uint64
for _, h := range hosts {
if hw := h.Summary.Hardware; hw != nil {
for i := range hosts {
if hw := hosts[i].Summary.Hardware; hw != nil {
hostCPUMHz := uint64(hw.CpuMhz)
if hostCPUMHz < minFreq || minFreq == 0 {
minFreq = hostCPUMHz
Expand Down

0 comments on commit cc8c077

Please sign in to comment.