This is a work in progress API shift as the data structure has changed and I'm cleaning the interface.

This commit is contained in:
Gregory Kurtzer
2020-12-03 07:34:26 -08:00
parent 931a3cce05
commit eaf6bb1196
23 changed files with 665 additions and 825 deletions

View File

@@ -15,7 +15,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
var numNodes int
var numGroups int
nodeDB, err := node.New()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Failed to open node database: %s\n", err)
@@ -27,12 +26,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
wwlog.Printf(wwlog.ERROR, "Could not load all nodes: %s\n", err)
os.Exit(1)
}
groups, err := nodeDB.FindAllGroups()
if err != nil {
wwlog.Printf(wwlog.ERROR, "Could not load all groups: %s\n", err)
os.Exit(1)
}
for _, p := range args {
err := nodeDB.DelProfile(p)
@@ -44,22 +37,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
for _, np := range n.Profiles {
if np == p {
numNodes++
wwlog.Printf(wwlog.VERBOSE, "Removing profile from node %s: %s\n", n.Fqdn.Get(), p)
wwlog.Printf(wwlog.VERBOSE, "Removing profile from node %s: %s\n", n.Id.Get(), p)
n.Profiles = util.SliceRemoveElement(n.Profiles, p)
nodeDB.NodeUpdate(n)
}
}
}
for _, g := range groups {
for _, np := range g.Profiles {
if np == p {
numGroups++
wwlog.Printf(wwlog.VERBOSE, "Removing profile from group %s: %s\n", g.Id, p)
g.Profiles = util.SliceRemoveElement(g.Profiles, p)
nodeDB.GroupUpdate(g)
}
}
}
count++
}