add modifictation and creation date
This commit is contained in:
@@ -2,6 +2,7 @@ package list
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/api/container"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
@@ -16,12 +17,16 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("%-25s %-6s %-6s\n", "CONTAINER NAME", "NODES", "KERNEL VERSION")
|
||||
fmt.Printf("%-16s %-6s %-16s %-18s %-18s\n", "CONTAINER NAME", "NODES", "KERNEL VERSION", "CREATION TIME", "MODIFICATION TIME")
|
||||
for i := 0; i < len(containerInfo); i++ {
|
||||
fmt.Printf("%-25s %-6d %-6s\n",
|
||||
createTime := time.Unix(int64(containerInfo[i].CreateDate), 0)
|
||||
modTime := time.Unix(int64(containerInfo[i].ModDate), 0)
|
||||
fmt.Printf("%-16s %-6d %-16s %-18s %-18s\n",
|
||||
containerInfo[i].Name,
|
||||
containerInfo[i].NodeCount,
|
||||
containerInfo[i].KernelVersion)
|
||||
containerInfo[i].KernelVersion,
|
||||
createTime.Format(time.RFC822),
|
||||
modTime.Format(time.RFC822))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -290,11 +290,22 @@ func ContainerList() (containerInfo []*wwapiv1.ContainerInfo, err error) {
|
||||
wwlog.Debug("Finding kernel version for: %s\n", source)
|
||||
kernelVersion := container.KernelVersion(source)
|
||||
|
||||
creationTime, err := os.Stat(container.SourceDir(source))
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
}
|
||||
modTime, err := os.Stat(container.ImageFile(source))
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
}
|
||||
containerInfo = append(containerInfo, &wwapiv1.ContainerInfo{
|
||||
Name: source,
|
||||
NodeCount: uint32(nodemap[source]),
|
||||
KernelVersion: kernelVersion,
|
||||
CreateDate: uint64(creationTime.ModTime().Unix()),
|
||||
ModDate: uint64(modTime.ModTime().Unix()),
|
||||
})
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -43,6 +43,9 @@ message ContainerInfo {
|
||||
string name = 1;
|
||||
uint32 nodeCount = 2;
|
||||
string kernelVersion = 3;
|
||||
uint64 createDate = 4; // creation date in unix time
|
||||
uint64 modDate = 5; // date of last modification in unix time
|
||||
uint64 size = 6; // size of chroot and images in bytes
|
||||
}
|
||||
|
||||
// ContainerListResponse has all information that ContainerList provides.
|
||||
|
||||
Reference in New Issue
Block a user