From 875e37f4dedadcd08ba5f467c0494d208ec540fa Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Fri, 31 Dec 2021 03:38:12 +0000 Subject: [PATCH] Support node ranges in `wwctl node status` --- internal/app/wwctl/node/status/main.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/internal/app/wwctl/node/status/main.go b/internal/app/wwctl/node/status/main.go index 25d74e2c..877ac7e4 100644 --- a/internal/app/wwctl/node/status/main.go +++ b/internal/app/wwctl/node/status/main.go @@ -12,6 +12,7 @@ import ( "github.com/fatih/color" "github.com/hpcng/warewulf/internal/pkg/warewulfconf" "github.com/hpcng/warewulf/internal/pkg/wwlog" + "github.com/hpcng/warewulf/pkg/hostlist" "github.com/spf13/cobra" "golang.org/x/term" ) @@ -79,8 +80,24 @@ func CobraRunE(cmd *cobra.Command, args []string) error { fmt.Printf("%s\n", strings.Repeat("=", 80)) keys := make([]string, 0, len(nodeStatus.Nodes)) - for k := range nodeStatus.Nodes { - keys = append(keys, k) + + if len(args) > 0 { + tmpMap := make(map[string]bool) + nodeList := hostlist.Expand(args) + + for _, name := range nodeList { + tmpMap[name] = true + } + + for name := range nodeStatus.Nodes { + if _, ok := tmpMap[name]; ok { + keys = append(keys, name) + } + } + } else { + for k := range nodeStatus.Nodes { + keys = append(keys, k) + } } sort.Strings(keys)