Skip to content

Commit b4dd76b

Browse files
authored
PWX-29976: Datastore recommendation in vSphere 8 (#138)
vSphere 8.0 is making it mandatory to specify NumCPUs and MemoryMB. This was stopping px from coming up on such cluster. This patch fixes it. Signed-off-by: Naveen Revanna <nrevanna@purestorage.com>
1 parent 9ecda22 commit b4dd76b

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

vsphere/vsphere.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030

3131
const (
3232
vSphereDataStoreLock = "vsphere-ds-lock"
33+
configProperty = "config.hardware"
3334
)
3435

3536
type vsphereOps struct {
@@ -818,6 +819,16 @@ func recommendDatastore(
818819
}
819820

820821
resourcePoolRef := resourcePool.Reference()
822+
var o mo.VirtualMachine
823+
err = vmObj.Properties(ctx, vmObj.Reference(), []string{configProperty}, &o)
824+
if err != nil || o.Config == nil {
825+
// In case of an error defaulting to 4 CPUs and 8GB
826+
spec.NumCPUs = 4
827+
spec.MemoryMB = 8 * 1024
828+
} else {
829+
spec.NumCPUs = o.Config.Hardware.NumCPU
830+
spec.MemoryMB = int64(o.Config.Hardware.MemoryMB)
831+
}
821832

822833
sps := types.StoragePlacementSpec{
823834
Type: string(types.StoragePlacementSpecPlacementTypeCreate),

0 commit comments

Comments
 (0)