added size of containers

This commit is contained in:
Christian Goll
2022-09-14 16:32:56 +02:00
parent 71bf385cb7
commit 396f3238c1
3 changed files with 54 additions and 3 deletions

View File

@@ -298,12 +298,28 @@ func ContainerList() (containerInfo []*wwapiv1.ContainerInfo, err error) {
if err != nil {
wwlog.Error("%s\n", err)
}
size, err := util.DirSize(container.SourceDir(source))
if err != nil {
wwlog.Error("%s\n", err)
}
imgSize, err := os.Stat(container.ImageFile(source))
if err != nil {
wwlog.Error("%s\n", err)
}
size += imgSize.Size()
imgSize, err = os.Stat(container.ImageFile(source) + ".gz")
if err != nil {
wwlog.Error("%s\n", err)
}
size += imgSize.Size()
containerInfo = append(containerInfo, &wwapiv1.ContainerInfo{
Name: source,
NodeCount: uint32(nodemap[source]),
KernelVersion: kernelVersion,
CreateDate: uint64(creationTime.ModTime().Unix()),
ModDate: uint64(modTime.ModTime().Unix()),
Size: uint64(size),
})
}