add vm power state and template
This commit is contained in:
@@ -26,6 +26,8 @@ func (c *CronTask) RunVmCheck(ctx context.Context, logger *slog.Logger) error {
|
||||
totalDiskGB float64
|
||||
srmPlaceholder int
|
||||
foundVm bool
|
||||
isTemplate int
|
||||
poweredOn int
|
||||
)
|
||||
|
||||
logger.Debug("Started Events processing", "time", time.Now())
|
||||
@@ -57,6 +59,7 @@ func (c *CronTask) RunVmCheck(ctx context.Context, logger *slog.Logger) error {
|
||||
numRam = 0
|
||||
numVcpus = 0
|
||||
totalDiskGB = 0
|
||||
isTemplate = 0
|
||||
} else {
|
||||
c.Logger.Debug("found VM")
|
||||
srmPlaceholder = 0 // Default assumption
|
||||
@@ -80,11 +83,27 @@ func (c *CronTask) RunVmCheck(ctx context.Context, logger *slog.Logger) error {
|
||||
srmPlaceholder = 1
|
||||
}
|
||||
|
||||
if vmObject.Vm.Config.Template {
|
||||
isTemplate = 1
|
||||
} else {
|
||||
isTemplate = 0
|
||||
}
|
||||
|
||||
foundVm = true
|
||||
} else {
|
||||
c.Logger.Error("Empty VM config")
|
||||
}
|
||||
|
||||
//if (types.VirtualMachineRuntimeInfo{}) != vmObject.Vm.Runtime {
|
||||
//if runtime, ok := vmObject.Vm.Runtime.(types.VirtualMachineRuntimeInfo); ok {
|
||||
c.Logger.Debug("VM has runtime data", "power_state", vmObject.Vm.Runtime.PowerState)
|
||||
if vmObject.Vm.Runtime.PowerState == "" {
|
||||
poweredOn = 0
|
||||
} else {
|
||||
poweredOn = 1
|
||||
}
|
||||
//}
|
||||
|
||||
}
|
||||
err = vc.Logout()
|
||||
if err != nil {
|
||||
@@ -109,6 +128,8 @@ func (c *CronTask) RunVmCheck(ctx context.Context, logger *slog.Logger) error {
|
||||
Folder: sql.NullString{String: vmObject.FolderPath, Valid: vmObject.FolderPath != ""},
|
||||
ResourcePool: sql.NullString{String: vmObject.ResourcePool, Valid: vmObject.ResourcePool != ""},
|
||||
SrmPlaceholder: sql.NullInt64{Int64: int64(srmPlaceholder), Valid: true},
|
||||
IsTemplate: sql.NullInt64{Int64: int64(isTemplate), Valid: true},
|
||||
PowerState: sql.NullInt64{Int64: int64(poweredOn), Valid: true},
|
||||
}
|
||||
|
||||
c.Logger.Debug("database params", "params", params)
|
||||
|
Reference in New Issue
Block a user