Updated wwctl node export to include node IDs

- Fixed: #1718

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-02-10 13:41:40 -07:00
parent db30008433
commit 900426ce81
3 changed files with 21 additions and 28 deletions

View File

@@ -2,33 +2,12 @@ package apinode
import (
"fmt"
"os"
"github.com/warewulf/warewulf/internal/pkg/api/routes/wwapiv1"
"github.com/warewulf/warewulf/internal/pkg/node"
"github.com/warewulf/warewulf/internal/pkg/wwlog"
"gopkg.in/yaml.v3"
)
/*
Returns filtered list of nodes
*/
func FilteredNodes(nodeList *wwapiv1.NodeList) *wwapiv1.NodeYaml {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open nodeDB: %s\n", err)
os.Exit(1)
}
nodeMap, _ := nodeDB.FindAllNodes()
nodeMap = node.FilterNodeListByName(nodeMap, nodeList.Output)
buffer, _ := yaml.Marshal(nodeMap)
retVal := wwapiv1.NodeYaml{
NodeConfMapYaml: string(buffer),
Hash: nodeDB.StringHash(),
}
return &retVal
}
/*
Add nodes from yaml
*/