@@ -26,14 +26,16 @@ func ProfileDelete(ndp *wwapiv1.NodeDeleteParameter) (err error) {
|
||||
wwlog.Error("Failed to open node database: %s\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
if nodeDB.StringHash() != ndp.Hash && !ndp.Force {
|
||||
return fmt.Errorf("got wrong hash, not modifying profile database")
|
||||
}
|
||||
for _, p := range profileList {
|
||||
err := nodeDB.DelProfile(p.Id.Get())
|
||||
if err != nil {
|
||||
wwlog.Error("%s\n", err)
|
||||
} else {
|
||||
//count++
|
||||
wwlog.Verbose("Deleting node: %s\n", p.Id.Print())
|
||||
wwlog.Verbose("Deleting profile: %s\n", p.Id.Print())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package apiprofile
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/api/routes/wwapiv1"
|
||||
@@ -49,13 +50,17 @@ func FilteredProfiles(profileList *wwapiv1.NodeList) *wwapiv1.NodeYaml {
|
||||
/*
|
||||
Add profiles from yaml
|
||||
*/
|
||||
func ProfileAddFromYaml(nodeList *wwapiv1.NodeYaml) (err error) {
|
||||
func ProfileAddFromYaml(nodeList *wwapiv1.NodeAddParameter) (err error) {
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Could not open NodeDB: %s\n")
|
||||
}
|
||||
if nodeDB.StringHash() != nodeList.Hash && !nodeList.Force {
|
||||
return fmt.Errorf("got wrong hash, not modifying profile database")
|
||||
}
|
||||
|
||||
profileMap := make(map[string]*node.NodeConf)
|
||||
err = yaml.Unmarshal([]byte(nodeList.NodeConfMapYaml), profileMap)
|
||||
err = yaml.Unmarshal([]byte(nodeList.NodeConfYaml), profileMap)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Could not unmarshall Yaml: %s\n")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user