[CI SKIP] bugfixes for vm deletion tracking

This commit is contained in:
2026-01-20 16:33:31 +11:00
parent a9e522cc84
commit 0517ef88c3
7 changed files with 1016 additions and 398 deletions

12
main.go
View File

@@ -19,8 +19,9 @@ import (
"vctp/server/router"
"crypto/sha256"
"github.com/go-co-op/gocron/v2"
"log/slog"
"github.com/go-co-op/gocron/v2"
)
var (
@@ -37,6 +38,7 @@ const fallbackEncryptionKey = "5L1l3B5KvwOCzUHMAlCgsgUTRAYMfSpa"
func main() {
settingsPath := flag.String("settings", "/etc/dtms/vctp.yml", "Path to settings YAML")
runInventoryOnce := flag.Bool("run-inventory", false, "Run a single inventory snapshot across all configured vCenters and exit")
flag.Parse()
bootstrapLogger := log.New(log.LevelInfo, log.OutputText)
@@ -178,6 +180,14 @@ func main() {
FirstHourlySnapshotCheck: true,
}
// One-shot mode: run a single inventory snapshot across all configured vCenters and exit.
if *runInventoryOnce {
logger.Info("Running one-shot inventory snapshot across all vCenters")
ct.RunVcenterSnapshotHourly(ctx, logger)
logger.Info("One-shot inventory snapshot complete; exiting")
return
}
cronSnapshotFrequency = durationFromSeconds(s.Values.Settings.VcenterInventorySnapshotSeconds, 3600)
logger.Debug("Setting VM inventory snapshot cronjob frequency to", "frequency", cronSnapshotFrequency)