bugfix
Some checks are pending
CI / Test (push) Waiting to run
CI / End-to-End (push) Waiting to run
CI / Publish Docker (push) Blocked by required conditions
CI / Lint (push) Waiting to run
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-13 15:24:38 +10:00
parent af9818ae7f
commit 68aa108467

View File

@@ -35,11 +35,14 @@ func (c *CronTask) RunVmCheck(ctx context.Context, logger *slog.Logger) error {
for _, evt := range events {
logger.Debug("Checking event", "event", evt)
// TODO - get a list of unique vcenters, then process each event in batches
// to avoid doing unnecessary login/logout of vcenter
c.Logger.Debug("connecting to vcenter")
vc := vcenter.New(c.Logger)
vc.Login(evt.Source)
//vmObject, err := vc.FindVMByName(vm.CloudEvent.Data.VM.Name)
//vmObject, err := vc.FindVMByID(vm.CloudEvent.Data.VM.VM.Value)
datacenter = evt.DatacenterName.String
vmObject, err := vc.FindVMByIDWithDatacenter(evt.VmId.String, evt.DatacenterId.String)
if err != nil {
@@ -48,7 +51,6 @@ func (c *CronTask) RunVmCheck(ctx context.Context, logger *slog.Logger) error {
c.Logger.Debug("didn't find VM", "vm_id", evt.VmId.String)
numRam = 0
numVcpus = 0
datacenter = evt.DatacenterName.String
} else {
c.Logger.Debug("found VM")
//prettyPrint(vmObject)
@@ -56,7 +58,8 @@ func (c *CronTask) RunVmCheck(ctx context.Context, logger *slog.Logger) error {
// calculate VM properties we want to store
if vmObject.Vm.Config != nil {
numRam = vmObject.Vm.Config.Hardware.MemoryMB
numVcpus = vmObject.Vm.Config.Hardware.NumCPU * vmObject.Vm.Config.Hardware.NumCoresPerSocket
//numVcpus = vmObject.Vm.Config.Hardware.NumCPU * vmObject.Vm.Config.Hardware.NumCoresPerSocket
numVcpus = vmObject.Vm.Config.Hardware.NumCPU
} else {
c.Logger.Error("Empty VM config")
}