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 {
|
for _, evt := range events {
|
||||||
logger.Debug("Checking event", "event", evt)
|
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")
|
c.Logger.Debug("connecting to vcenter")
|
||||||
vc := vcenter.New(c.Logger)
|
vc := vcenter.New(c.Logger)
|
||||||
vc.Login(evt.Source)
|
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)
|
vmObject, err := vc.FindVMByIDWithDatacenter(evt.VmId.String, evt.DatacenterId.String)
|
||||||
|
|
||||||
if err != nil {
|
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)
|
c.Logger.Debug("didn't find VM", "vm_id", evt.VmId.String)
|
||||||
numRam = 0
|
numRam = 0
|
||||||
numVcpus = 0
|
numVcpus = 0
|
||||||
datacenter = evt.DatacenterName.String
|
|
||||||
} else {
|
} else {
|
||||||
c.Logger.Debug("found VM")
|
c.Logger.Debug("found VM")
|
||||||
//prettyPrint(vmObject)
|
//prettyPrint(vmObject)
|
||||||
@@ -56,7 +58,8 @@ func (c *CronTask) RunVmCheck(ctx context.Context, logger *slog.Logger) error {
|
|||||||
// calculate VM properties we want to store
|
// calculate VM properties we want to store
|
||||||
if vmObject.Vm.Config != nil {
|
if vmObject.Vm.Config != nil {
|
||||||
numRam = vmObject.Vm.Config.Hardware.MemoryMB
|
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 {
|
} else {
|
||||||
c.Logger.Error("Empty VM config")
|
c.Logger.Error("Empty VM config")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user