Merge pull request #116 from mslacken/kernel-container

Added container option for kernel import
This commit is contained in:
Gregory M. Kurtzer
2021-09-08 16:10:14 -07:00
committed by GitHub
2 changed files with 16 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"github.com/hpcng/warewulf/internal/pkg/container"
"github.com/hpcng/warewulf/internal/pkg/kernel"
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/hpcng/warewulf/internal/pkg/warewulfd"
@@ -14,6 +15,15 @@ import (
func CobraRunE(cmd *cobra.Command, args []string) error {
for _, arg := range args {
// Checking if container flag was set, then overwriting OptRoot
if OptContainer != "" {
if container.ValidSource(OptContainer) == true {
OptRoot = container.RootFsDir(OptContainer)
} else {
wwlog.Printf(wwlog.ERROR, " %s is not a valid container", OptContainer)
os.Exit(1)
}
}
output, err := kernel.Build(arg, OptRoot)
if err != nil {
wwlog.Printf(wwlog.ERROR, "Failed building kernel: %s\n", err)

View File

@@ -13,10 +13,11 @@ var (
RunE: CobraRunE,
Args: cobra.MinimumNArgs(1),
}
BuildAll bool
ByNode bool
SetDefault bool
OptRoot string
BuildAll bool
ByNode bool
SetDefault bool
OptRoot string
OptContainer string
)
func init() {
@@ -24,6 +25,7 @@ func init() {
baseCmd.PersistentFlags().BoolVarP(&ByNode, "node", "n", false, "Build overlay for a particular node(s)")
baseCmd.PersistentFlags().BoolVar(&SetDefault, "setdefault", false, "Set this kernel for the default profile")
baseCmd.PersistentFlags().StringVarP(&OptRoot, "root", "r", "/", "Import kernel from root (chroot) directory")
baseCmd.PersistentFlags().StringVarP(&OptContainer, "container", "c", "", "Import kernel from container")
}
// GetRootCommand returns the root cobra.Command for the application.