Optimized sorting methods across nodes and profiles

This commit is contained in:
Gregory Kurtzer
2021-04-25 15:43:35 -07:00
parent a321709901
commit 4bc523a052
15 changed files with 266 additions and 234 deletions

View File

@@ -1,6 +1,7 @@
package console
import (
"fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/node"
@@ -11,27 +12,32 @@ import (
func CobraRunE(cmd *cobra.Command, args []string) error {
var returnErr error = nil
var nodeList []node.NodeInfo
n, err := node.New()
nodeDB, err := node.New()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err)
os.Exit(1)
}
if len(args) == 1 {
nodeList, _ = n.SearchByName(args[0])
nodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Cloud not get nodeList: %s\n", err)
os.Exit(1)
}
if len(args) > 0 {
nodes = node.FilterByName(nodes, args)
} else {
wwlog.Printf(wwlog.ERROR, "Please specify a node\n")
os.Exit(255)
cmd.Usage()
os.Exit(1)
}
if len(nodeList) == 0 {
wwlog.Printf(wwlog.ERROR, "No nodes found matching: '%s'\n", args[0])
os.Exit(255)
if len(nodes) == 0 {
fmt.Printf("No nodes found\n")
os.Exit(1)
}
for _, node := range nodeList {
for _, node := range nodes {
if node.IpmiIpaddr.Get() == "" {
wwlog.Printf(wwlog.ERROR, "%s: No IPMI IP address\n", node.Id.Get())