mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-07-22 20:41:40 +02:00
Extend archive manager
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/ClusterCockpit/cc-backend/internal/config"
|
||||
"github.com/ClusterCockpit/cc-backend/pkg/archive"
|
||||
@@ -15,26 +16,36 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
var srcPath, flagConfigFile, flagLogLevel string
|
||||
var flagLogDateTime bool
|
||||
var srcPath, flagConfigFile, flagLogLevel, flagRemoveCluster, flagRemoveAfter, flagRemoveBefore string
|
||||
var flagLogDateTime, flagValidate bool
|
||||
|
||||
flag.StringVar(&srcPath, "s", "./var/job-archive", "Specify the source job archive path. Default is ./var/job-archive")
|
||||
flag.BoolVar(&flagLogDateTime, "logdate", false, "Set this flag to add date and time to log messages")
|
||||
flag.StringVar(&flagLogLevel, "loglevel", "warn", "Sets the logging level: `[debug,info,warn (default),err,fatal,crit]`")
|
||||
flag.StringVar(&flagConfigFile, "config", "./config.json", "Specify alternative path to `config.json`")
|
||||
flag.StringVar(&flagRemoveCluster, "remove-cluster", "", "Remove cluster from archive and database")
|
||||
flag.StringVar(&flagRemoveBefore, "remove-before", "", "Remove all jobs with start time before date")
|
||||
flag.StringVar(&flagRemoveAfter, "remove-after", "", "Remove all jobs with start time after date")
|
||||
flag.BoolVar(&flagValidate, "validate", false, "Set this flag to validate a job archive against the json schema")
|
||||
flag.Parse()
|
||||
|
||||
archiveCfg := fmt.Sprintf("{\"kind\": \"file\",\"path\": \"%s\"}", srcPath)
|
||||
|
||||
log.Init(flagLogLevel, flagLogDateTime)
|
||||
config.Init(flagConfigFile)
|
||||
config.Keys.Validate = true
|
||||
|
||||
if err := archive.Init(json.RawMessage(archiveCfg), false); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ar := archive.GetHandle()
|
||||
|
||||
for job := range ar.Iter(true) {
|
||||
log.Printf("Validate %s - %d\n", job.Meta.Cluster, job.Meta.JobID)
|
||||
if flagValidate {
|
||||
config.Keys.Validate = true
|
||||
for job := range ar.Iter(true) {
|
||||
log.Printf("Validate %s - %d\n", job.Meta.Cluster, job.Meta.JobID)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
ar.Info()
|
||||
}
|
||||
|
Reference in New Issue
Block a user