Merge pull request #1728 from anderbubble/fix-1718
Updated `wwctl node export` to include node IDs
This commit is contained in:
@@ -2,18 +2,31 @@ package export
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
apinode "github.com/warewulf/warewulf/internal/pkg/api/node"
|
||||
"github.com/warewulf/warewulf/internal/pkg/api/routes/wwapiv1"
|
||||
"github.com/warewulf/warewulf/internal/pkg/hostlist"
|
||||
"github.com/warewulf/warewulf/internal/pkg/node"
|
||||
"github.com/warewulf/warewulf/internal/pkg/util"
|
||||
"github.com/warewulf/warewulf/internal/pkg/wwlog"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
args = hostlist.Expand(args)
|
||||
filterList := wwapiv1.NodeList{
|
||||
Output: args,
|
||||
registry, err := node.New()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nodeListMsg := apinode.FilteredNodes(&filterList)
|
||||
wwlog.Info(nodeListMsg.NodeConfMapYaml)
|
||||
nodeMap := make(map[string]*node.Node)
|
||||
names := hostlist.Expand(args)
|
||||
if len(names) == 0 {
|
||||
names = registry.ListAllNodes()
|
||||
}
|
||||
for _, name := range hostlist.Expand(names) {
|
||||
if n, err := registry.GetNode(name); err == nil {
|
||||
nodeMap[name] = &n
|
||||
}
|
||||
}
|
||||
y, err := util.EncodeYaml(nodeMap)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
wwlog.Output("%s", y)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user