Building set commands for nodes and groups and templating out CLI further

This commit is contained in:
Gregory Kurtzer
2020-11-21 01:48:38 -08:00
parent 982816b474
commit 1d1a02b305
14 changed files with 305 additions and 39 deletions

View File

@@ -10,9 +10,10 @@ import (
func CobraRunE(cmd *cobra.Command, args []string) error {
var err error
var c int
var count int
var nodes []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)
@@ -23,18 +24,35 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
os.Exit(1)
}
if SetVnfs != "" {
fmt.Printf("Setting vnfs to: %s\n", SetVnfs)
c, err = n.SetNodeVal("n0000", "vnfs", SetVnfs)
if len(args) > 0 {
nodes, err = nodeDB.SearchByNameList(args)
} else {
cmd.Usage()
os.Exit(1)
}
if err != nil {
wwlog.Printf(wwlog.ERROR, "Cloud not get nodeList: %s\n", err)
os.Exit(1)
}
for _, n := range nodes {
if SetVnfs != "" {
fmt.Printf("Setting vnfs to: %s\n", SetVnfs)
c, _ := nodeDB.SetNodeVal(n.Id, "vnfs", SetVnfs)
count += c
}
if SetKernel != "" {
fmt.Printf("Setting kernel to: %s\n", SetVnfs)
c, _ := nodeDB.SetNodeVal(n.Id, "kernel", SetKernel)
count += c
}
}
fmt.Printf("set count: %d\n", c)
fmt.Printf("set count: %d\n", count)
a, err := n.FindByHwaddr("00:0c:29:23:8b:48")
// nodeDB.AddGroup("moo")
nodeDB.AddNode("moo", "node01")
fmt.Printf("VNFS: %s\n", a.Vnfs)
//n.Persist()
nodeDB.Persist()
return nil
}