{backup,snapshot}: Log and display in control

This commit is contained in:
Tom Wiesing 2022-10-03 11:22:45 +02:00
parent 3b112f1b8e
commit 630da9e12f
No known key found for this signature in database
17 changed files with 294 additions and 44 deletions

View file

@ -62,28 +62,43 @@ type disIndex struct {
Config *config.Config
Instances []instances.WissKIInfo
Instances []instances.WissKIInfo
TotalCount int
RunningCount int
StoppedCount int
Backups []models.Snapshot
}
func (dis *Control) disIndex(r *http.Request) (idx disIndex, err error) {
// load instances
idx.Instances, err = dis.allinstances(r)
if err != nil {
return
}
var group errgroup.Group
// count how many are running and how many are stopped
for _, i := range idx.Instances {
if i.Running {
idx.RunningCount++
} else {
idx.StoppedCount++
group.Go(func() error {
// load instances
idx.Instances, err = dis.allinstances(r)
if err != nil {
return err
}
}
idx.TotalCount = len(idx.Instances)
// count how many are running and how many are stopped
for _, i := range idx.Instances {
if i.Running {
idx.RunningCount++
} else {
idx.StoppedCount++
}
}
idx.TotalCount = len(idx.Instances)
return nil
})
// get the log entries
group.Go(func() (err error) {
idx.Backups, err = dis.Instances.SnapshotLogFor("")
return
})
// get the static properties
idx.Config = dis.Config
@ -91,6 +106,9 @@ func (dis *Control) disIndex(r *http.Request) (idx disIndex, err error) {
// current time
idx.Time = time.Now().UTC()
// wait for everything!
group.Wait()
return
}