Added container option for kernel import
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user