Restored profile list tests and resolved exposed bugs

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2024-10-17 23:58:37 -04:00
parent 0be1e8464a
commit 30ac144044
25 changed files with 252 additions and 122 deletions

View File

@@ -37,7 +37,6 @@ func NodeDelete(ndp *wwapiv1.NodeDeleteParameter) (err error) {
if err != nil {
wwlog.Error("%s", err)
} else {
//count++
wwlog.Verbose("Deleting node: %s\n", n.Id())
}
}

View File

@@ -39,7 +39,7 @@ func FilteredNodes(nodeList *wwapiv1.NodeList) *wwapiv1.NodeYaml {
os.Exit(1)
}
nodeMap, _ := nodeDB.FindAllNodes()
nodeMap = node.FilterByName(nodeMap, nodeList.Output)
nodeMap = node.FilterNodeListByName(nodeMap, nodeList.Output)
buffer, _ := yaml.Marshal(nodeMap)
retVal := wwapiv1.NodeYaml{
NodeConfMapYaml: string(buffer),

View File

@@ -32,7 +32,7 @@ func NodeList(nodeGet *wwapiv1.GetNodeList) (nodeList wwapiv1.NodeList, err erro
if nodeGet.Type == wwapiv1.GetNodeList_Simple {
nodeList.Output = append(nodeList.Output,
fmt.Sprintf("%s:=:%s:=:%s", "NODE NAME", "PROFILES", "NETWORK"))
for _, n := range node.FilterByName(nodes, nodeGet.Nodes) {
for _, n := range node.FilterNodeListByName(nodes, nodeGet.Nodes) {
var netNames []string
for k := range n.NetDevs {
netNames = append(netNames, k)
@@ -44,7 +44,7 @@ func NodeList(nodeGet *wwapiv1.GetNodeList) (nodeList wwapiv1.NodeList, err erro
} else if nodeGet.Type == wwapiv1.GetNodeList_Network {
nodeList.Output = append(nodeList.Output,
fmt.Sprintf("%s:=:%s:=:%s:=:%s:=:%s:=:%s", "NODE", "NETWORK", "HWADDR", "IPADDR", "GATEWAY", "DEVICE"))
for _, n := range node.FilterByName(nodes, nodeGet.Nodes) {
for _, n := range node.FilterNodeListByName(nodes, nodeGet.Nodes) {
if len(n.NetDevs) > 0 {
for name := range n.NetDevs {
nodeList.Output = append(nodeList.Output,
@@ -62,7 +62,7 @@ func NodeList(nodeGet *wwapiv1.GetNodeList) (nodeList wwapiv1.NodeList, err erro
} else if nodeGet.Type == wwapiv1.GetNodeList_Ipmi {
nodeList.Output = append(nodeList.Output,
fmt.Sprintf("%s:=:%s:=:%s:=:%s:=:%s", "NODE", "IPMI IPADDR", "IPMI PORT", "IPMI USERNAME", "IPMI INTERFACE"))
for _, n := range node.FilterByName(nodes, nodeGet.Nodes) {
for _, n := range node.FilterNodeListByName(nodes, nodeGet.Nodes) {
nodeList.Output = append(nodeList.Output,
fmt.Sprintf("%s:=:%s:=:%s:=:%s:=:%s:=:%s", n.Id(),
n.Ipmi.Ipaddr.String(),
@@ -74,7 +74,7 @@ func NodeList(nodeGet *wwapiv1.GetNodeList) (nodeList wwapiv1.NodeList, err erro
} else if nodeGet.Type == wwapiv1.GetNodeList_Long {
nodeList.Output = append(nodeList.Output,
fmt.Sprintf("%s:=:%s:=:%s:=:%s", "NODE NAME", "KERNEL OVERRIDE", "CONTAINER", "OVERLAYS (S/R)"))
for _, n := range node.FilterByName(nodes, nodeGet.Nodes) {
for _, n := range node.FilterNodeListByName(nodes, nodeGet.Nodes) {
nodeList.Output = append(nodeList.Output,
fmt.Sprintf("%s:=:%s:=:%s:=:%s", n.Id(),
n.Kernel.Override,
@@ -82,7 +82,7 @@ func NodeList(nodeGet *wwapiv1.GetNodeList) (nodeList wwapiv1.NodeList, err erro
strings.Join(n.SystemOverlay, ",")+"/"+strings.Join(n.RuntimeOverlay, ",")))
}
} else if nodeGet.Type == wwapiv1.GetNodeList_All {
for _, n := range node.FilterByName(nodes, nodeGet.Nodes) {
for _, n := range node.FilterNodeListByName(nodes, nodeGet.Nodes) {
nodeList.Output = append(nodeList.Output,
fmt.Sprintf("%s:=:%s:=:%s:=:%s", "NODE", "FIELD", "PROFILE", "VALUE"))
fields := nodeDB.GetFields(n)
@@ -92,7 +92,7 @@ func NodeList(nodeGet *wwapiv1.GetNodeList) (nodeList wwapiv1.NodeList, err erro
}
}
} else if nodeGet.Type == wwapiv1.GetNodeList_YAML || nodeGet.Type == wwapiv1.GetNodeList_JSON {
filterNodes := node.FilterByName(nodes, nodeGet.Nodes)
filterNodes := node.FilterNodeListByName(nodes, nodeGet.Nodes)
var buf []byte
if nodeGet.Type == wwapiv1.GetNodeList_JSON {
buf, _ = json.MarshalIndent(filterNodes, "", " ")

View File

@@ -41,7 +41,6 @@ func NodeSetParameterCheck(set *wwapiv1.ConfSetParameter) (nodeDB node.NodeYaml,
wwlog.Error("Could not open configuration: %s", err)
return
}
//func AbstractSetParameterCheck(set *wwapiv1.ConfSetParameter, confMap map[string]*node.NodeConf, confs []string) (count uint, err error) {
if set == nil {
err = fmt.Errorf("node set parameter is nil")
return