copy shim/grub on default profile container change

Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
Christian Goll
2023-07-20 12:17:46 +02:00
committed by Jonathon Anderson
parent 2fe98e5f55
commit 03ef7447e9
8 changed files with 76 additions and 49 deletions

View File

@@ -271,6 +271,10 @@ func ContainerImport(cip *wwapiv1.ContainerImportParameter) (containerName strin
err = errors.Wrap(err, "failed to update profile")
return
}
err = warewulfd.CopyShimGrub()
if err != nil {
wwlog.Warn("couldn't copy shim/grub of default container: %s", err)
}
}
}
// TODO: We need this in a function with a flock around it.

View File

@@ -8,6 +8,7 @@ import (
"github.com/hpcng/warewulf/internal/pkg/api/routes/wwapiv1"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/util"
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
"github.com/hpcng/warewulf/internal/pkg/wwlog"
"github.com/pkg/errors"
"gopkg.in/yaml.v2"
@@ -24,7 +25,21 @@ func ProfileSet(set *wwapiv1.ProfileSetParameter) (err error) {
if err != nil {
return errors.Wrap(err, "Could not open database")
}
return apinode.DbSave(&nodeDB)
var pConf node.NodeConf
err = yaml.Unmarshal([]byte(set.NodeConfYaml), &pConf)
if err != nil {
wwlog.Error(fmt.Sprintf("%v", err.Error()))
return
}
dbError := apinode.DbSave(&nodeDB)
if util.InSlice(set.ProfileNames, "default") {
err = warewulfd.CopyShimGrub()
if err != nil {
wwlog.Warn("shim/grub couldn't be copied: %s", err)
}
}
return dbError
}
// ProfileSetParameterCheck does error checking on ProfileSetParameter.