bugfix
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
Reference in New Issue
Block a user