Merge pull request #1926 from MatthewHink/mhink-node-dupicate
Fail API add node if node exists
This commit is contained in:
@@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Updated 70-persistent-net.rules.ww to use `(lower $netdev.Type)` for case-insensitive comparison of "infiniband".
|
||||
- Fixed a regression in SELinux support by restoring the `/run` mount during wwinit. #1910
|
||||
- Fixed `wwctl profile set` for disks, partitions and file systems. #1883
|
||||
- Do not let API add a node that exists
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -123,9 +123,13 @@ func addNode() usecase.Interactor {
|
||||
|
||||
u := usecase.NewInteractor(func(ctx context.Context, input addNodeInput, output *node.Node) error {
|
||||
wwlog.Debug("api.addNode(ID:%v, Node:%+v)", input.ID, input.Node)
|
||||
// registry is the warewulf node "db" yaml file.
|
||||
if registry, err := node.New(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
if _, ok := registry.Nodes[input.ID]; ok {
|
||||
return status.Wrap(fmt.Errorf("node name '%s' already exists", input.ID), status.InvalidArgument)
|
||||
}
|
||||
for _, profile := range input.Node.Profiles {
|
||||
if _, ok := registry.NodeProfiles[profile]; !ok {
|
||||
return status.Wrap(fmt.Errorf("profile '%s' does not exist", profile), status.InvalidArgument)
|
||||
|
||||
Reference in New Issue
Block a user