Days updates, fixes, and UI updates
This commit is contained in:
75
internal/app/wwctl/overlay/imprt/main.go
Normal file
75
internal/app/wwctl/overlay/imprt/main.go
Normal file
@@ -0,0 +1,75 @@
|
||||
package imprt
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/config"
|
||||
"github.com/hpcng/warewulf/internal/pkg/overlay"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
"path"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
config := config.New()
|
||||
overlayName := args[0]
|
||||
source := args[1]
|
||||
var dest string
|
||||
var overlaySource string
|
||||
|
||||
if len(args) == 3 {
|
||||
dest = args[2]
|
||||
} else {
|
||||
dest = source
|
||||
}
|
||||
|
||||
if SystemOverlay == true {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Importing '%s' into system overlay '%s:%s'\n", source, overlayName, dest)
|
||||
overlaySource = config.SystemOverlaySource(overlayName)
|
||||
} else {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Importing '%s' into runtime overlay '%s:%s'\n", source, overlayName, dest)
|
||||
overlaySource = config.RuntimeOverlaySource(overlayName)
|
||||
}
|
||||
|
||||
if util.IsDir(overlaySource) == false {
|
||||
wwlog.Printf(wwlog.ERROR, "Overlay does not exist: %s\n", overlayName)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err := util.CopyFile(source, path.Join(overlaySource, dest))
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Failed copying file into overlay sourcedir:\n")
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if NoOverlayUpdate == false {
|
||||
nodes, err := assets.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Cloud not get nodeList: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var updateNodes []assets.NodeInfo
|
||||
|
||||
for _, node := range nodes {
|
||||
if SystemOverlay == true && node.SystemOverlay == overlayName {
|
||||
updateNodes = append(updateNodes, node)
|
||||
} else if node.RuntimeOverlay == overlayName {
|
||||
updateNodes = append(updateNodes, node)
|
||||
}
|
||||
}
|
||||
|
||||
if SystemOverlay == true {
|
||||
wwlog.Printf(wwlog.INFO, "Updating System Overlays...\n")
|
||||
return overlay.SystemBuild(updateNodes, true)
|
||||
} else {
|
||||
wwlog.Printf(wwlog.INFO, "Updating Runtime Overlays...\n")
|
||||
return overlay.RuntimeBuild(updateNodes, true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
28
internal/app/wwctl/overlay/imprt/root.go
Normal file
28
internal/app/wwctl/overlay/imprt/root.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package imprt
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "import [overlay name] [source file] (dest location)",
|
||||
Short: "Import Warewulf Overlay files",
|
||||
Long: "Warewulf Import overlay files",
|
||||
RunE: CobraRunE,
|
||||
Args: cobra.RangeArgs(2, 3),
|
||||
Aliases: []string{"cp"},
|
||||
}
|
||||
SystemOverlay bool
|
||||
PermMode int32
|
||||
NoOverlayUpdate bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().BoolVarP(&SystemOverlay, "system", "s", false, "Show system overlays instead of runtime")
|
||||
baseCmd.PersistentFlags().Int32VarP(&PermMode, "mode", "m", 0755, "Permission mode for directory")
|
||||
baseCmd.PersistentFlags().BoolVarP(&NoOverlayUpdate, "noupdate", "n", false, "Don't update overlays")
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
Reference in New Issue
Block a user