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

This commit is contained in:
2024-09-13 15:26:57 +10:00
parent 68aa108467
commit d3b9b22a09

View File

@@ -21,6 +21,7 @@ func (c *CronTask) RunVmCheck(ctx context.Context, logger *slog.Logger) error {
numVcpus int32
numRam int32
datacenter string
foundVm bool
)
logger.Debug("Started Events processing", "time", time.Now())
@@ -60,6 +61,7 @@ func (c *CronTask) RunVmCheck(ctx context.Context, logger *slog.Logger) error {
numRam = vmObject.Vm.Config.Hardware.MemoryMB
//numVcpus = vmObject.Vm.Config.Hardware.NumCPU * vmObject.Vm.Config.Hardware.NumCoresPerSocket
numVcpus = vmObject.Vm.Config.Hardware.NumCPU
foundVm = true
} else {
c.Logger.Error("Empty VM config")
}
@@ -70,15 +72,20 @@ func (c *CronTask) RunVmCheck(ctx context.Context, logger *slog.Logger) error {
c.Logger.Error("unable to logout of vcenter", "error", err)
}
c.Logger.Debug("Simulate adding to Inventory", "vm_name", evt.VmName.String, "vcpus", numVcpus, "ram", numRam, "dc", datacenter)
if foundVm {
c.Logger.Debug("Simulate adding to Inventory", "vm_name", evt.VmName.String, "vcpus", numVcpus, "ram", numRam, "dc", datacenter)
// mark this event as processed
err = c.Database.Queries().UpdateEventsProcessed(ctx, evt.Eid)
if err != nil {
c.Logger.Error("Unable to mark this event as processed", "event_id", evt.Eid, "error", err)
// mark this event as processed
err = c.Database.Queries().UpdateEventsProcessed(ctx, evt.Eid)
if err != nil {
c.Logger.Error("Unable to mark this event as processed", "event_id", evt.Eid, "error", err)
} else {
c.Logger.Debug("Marked event as processed", "event_id", evt.Eid)
}
} else {
c.Logger.Debug("Marked event as processed", "event_id", evt.Eid)
c.Logger.Debug("Not simulate adding to Inventory due to missing vcenter config property", "vm_name", evt.VmName.String)
}
}
//fmt.Printf("processing at %s", time.Now())