Fleshed out the framework of most of the wwctl overlay command group.
This commit is contained in:
58
internal/app/wwctl/overlay/build/main.go
Normal file
58
internal/app/wwctl/overlay/build/main.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/assets"
|
||||
"github.com/hpcng/warewulf/internal/pkg/overlay"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
|
||||
var updateNodes []assets.NodeInfo
|
||||
|
||||
if len(args) > 0 && BuildAll == false {
|
||||
nodes, err := assets.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Cloud not get nodeList: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for _, node := range nodes {
|
||||
if SystemOverlay == true && node.SystemOverlay == args[0] {
|
||||
updateNodes = append(updateNodes, node)
|
||||
} else if node.RuntimeOverlay == args[0] {
|
||||
updateNodes = append(updateNodes, node)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var err error
|
||||
updateNodes, err = assets.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Cloud not get nodeList: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.DEBUG, "Checking on system overlay update\n")
|
||||
if SystemOverlay == true || BuildAll == true {
|
||||
wwlog.Printf(wwlog.INFO, "Updating System Overlays...\n")
|
||||
err := overlay.SystemBuild(updateNodes, true)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.WARN, "Some system overlays failed to be generated\n")
|
||||
}
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.DEBUG, "Checking on system overlay update\n")
|
||||
if SystemOverlay == false || BuildAll == true {
|
||||
wwlog.Printf(wwlog.INFO, "Updating Runtime Overlays...\n")
|
||||
err := overlay.RuntimeBuild(updateNodes, true)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.WARN, "Some runtime overlays failed to be generated\n")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
25
internal/app/wwctl/overlay/build/root.go
Normal file
25
internal/app/wwctl/overlay/build/root.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package build
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "build [overlay name]",
|
||||
Short: "Build/Rebuild an overlay",
|
||||
Long: "Build or rebuild a Warewulf overlay ",
|
||||
RunE: CobraRunE,
|
||||
}
|
||||
SystemOverlay bool
|
||||
BuildAll bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().BoolVarP(&SystemOverlay, "system", "s", false, "Show System Overlays as well")
|
||||
baseCmd.PersistentFlags().BoolVarP(&BuildAll, "all", "a", false, "Build all overlays (runtime and system)")
|
||||
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
13
internal/app/wwctl/overlay/copy/main.go
Normal file
13
internal/app/wwctl/overlay/copy/main.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package copy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
fmt.Printf("This will copy '%s' to overlay '%s'\n", args[1], args[0])
|
||||
|
||||
return nil
|
||||
}
|
||||
25
internal/app/wwctl/overlay/copy/root.go
Normal file
25
internal/app/wwctl/overlay/copy/root.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package copy
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "copy [overlay name] [source file] (dest location)",
|
||||
Short: "Copy Warewulf Overlay files",
|
||||
Long: "Warewulf Copy overlay files",
|
||||
RunE: CobraRunE,
|
||||
Args: cobra.RangeArgs(2, 3),
|
||||
Aliases: []string{"import"},
|
||||
}
|
||||
SystemOverlay bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().BoolVarP(&SystemOverlay, "system", "s", false, "Show system overlays instead of runtime")
|
||||
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
@@ -2,11 +2,117 @@ package delete
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"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 {
|
||||
fmt.Printf("Delete: Hello World\n")
|
||||
var overlayPath string
|
||||
config := config.New()
|
||||
|
||||
if SystemOverlay == true {
|
||||
overlayPath = config.SystemOverlaySource(args[0])
|
||||
} else {
|
||||
overlayPath = config.RuntimeOverlaySource(args[0])
|
||||
}
|
||||
|
||||
if overlayPath == "" {
|
||||
wwlog.Printf(wwlog.ERROR, "Overlay name did not render: '%s'\n", args[0])
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if util.IsDir(overlayPath) == false {
|
||||
wwlog.Printf(wwlog.ERROR, "Overlay name does not exist: '%s'\n", args[0])
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(args) == 1 {
|
||||
if Force == true {
|
||||
err := os.RemoveAll(overlayPath)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Failed deleting overlay: %s\n", args[0])
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
err := os.Remove(overlayPath)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Failed deleting overlay: %s\n", args[0])
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
} else if len(args) > 1 {
|
||||
for i := 1; i < len(args); i++ {
|
||||
removePath := path.Join(overlayPath, args[i])
|
||||
|
||||
if Force == true {
|
||||
err := os.RemoveAll(removePath)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Failed deleting file from overlay: %s:%s\n", args[0], args[i])
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
err := os.Remove(removePath)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Failed deleting overlay: %s:%s\n", args[0], args[i])
|
||||
wwlog.Printf(wwlog.ERROR, "%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
if RmEmptyDirs == true {
|
||||
// Cleanup any empty directories left behind...
|
||||
i := path.Dir(removePath)
|
||||
for i != overlayPath {
|
||||
wwlog.Printf(wwlog.DEBUG, "Evaluating directory to remove: %s\n", i)
|
||||
err := os.Remove(i)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
wwlog.Printf(wwlog.VERBOSE, "Removed empty directory: %s\n", i)
|
||||
i = path.Dir(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("Deleted from overlay: %s:%s\n", args[0], args[1])
|
||||
|
||||
// Everything below this point is to update the relevant overlays
|
||||
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 == args[0] {
|
||||
updateNodes = append(updateNodes, node)
|
||||
} else if node.RuntimeOverlay == args[0] {
|
||||
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
|
||||
}
|
||||
@@ -10,17 +10,18 @@ var (
|
||||
Short: "Delete Warewulf Overlay files",
|
||||
Long: "Warewulf Delete overlay files",
|
||||
RunE: CobraRunE,
|
||||
Args: cobra.ExactArgs(1),
|
||||
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
Aliases: []string{"rm", "del"},
|
||||
}
|
||||
SystemOverlay bool
|
||||
Force bool
|
||||
|
||||
RmEmptyDirs bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().BoolVarP(&SystemOverlay, "system", "s", false, "Show system overlays instead of runtime")
|
||||
baseCmd.PersistentFlags().BoolVar(&Force, "force", false, "Force deletion of a non-empty overlay")
|
||||
baseCmd.PersistentFlags().BoolVarP(&Force, "force", "f", false, "Force deletion of a non-empty overlay")
|
||||
baseCmd.PersistentFlags().BoolVarP(&RmEmptyDirs, "empty", "e", false, "Remove empty directories")
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,15 @@ package edit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"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"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
@@ -16,12 +19,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var overlaySourceDir string
|
||||
|
||||
|
||||
if len(args) < 2 {
|
||||
fmt.Printf("wwctl overlay edit [overlay name] [overlay file]\n")
|
||||
cmd.Help()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if SystemOverlay == true {
|
||||
overlaySourceDir = config.SystemOverlaySource(args[0])
|
||||
} else {
|
||||
@@ -37,18 +34,75 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
wwlog.Printf(wwlog.DEBUG, "Will edit overlay file: %s\n", overlayFile)
|
||||
|
||||
err := os.MkdirAll(path.Dir(overlayFile), 0755)
|
||||
if CreateDirs == true {
|
||||
err := os.MkdirAll(path.Dir(overlayFile), 0755)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not create directory: %s\n", path.Dir(overlayFile))
|
||||
os.Exit(1)
|
||||
}
|
||||
} else {
|
||||
if util.IsDir(path.Dir(overlayFile)) == false {
|
||||
wwlog.Printf(wwlog.ERROR, "Can not create file, parent directory does not exist, try adding the\n")
|
||||
wwlog.Printf(wwlog.ERROR, "'--parents' option to create the directory.\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
if util.IsFile(overlayFile) == false && filepath.Ext(overlayFile) == ".ww" {
|
||||
wwlog.Printf(wwlog.WARN, "This is a new file, creating some default content\n")
|
||||
|
||||
w, err := os.OpenFile(overlayFile, os.O_RDWR|os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.WARN, "Could not create file for writing: %s\n", err)
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "# This is a Warewulf Template file.\n")
|
||||
fmt.Fprintf(w, "#\n")
|
||||
fmt.Fprintf(w, "# This file (suffix '.ww') will be automatically rewritten without the suffix\n")
|
||||
fmt.Fprintf(w, "# when the overlay is rendered for the individual nodes. Here are some examples\n")
|
||||
fmt.Fprintf(w, "# of macros and logic which can be used within this file:\n")
|
||||
fmt.Fprintf(w, "#\n")
|
||||
fmt.Fprintf(w, "# Node FQDN = {{.Fqdn}}\n")
|
||||
fmt.Fprintf(w, "# Node Group = {{.GroupName}}\n")
|
||||
fmt.Fprintf(w, "# Network Config = {{.NetDevs.eth0.Ipaddr}}, {{.NetDevs.eth0.Hwaddr}}, etc.\n")
|
||||
fmt.Fprintf(w, "#\n")
|
||||
fmt.Fprintf(w, "# Goto the documentation pages for more information: http://www.hpcng.org/...\n")
|
||||
fmt.Fprintf(w, "\n")
|
||||
}
|
||||
|
||||
err := util.ExecInteractive(editor, overlayFile)
|
||||
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not create directory: %s\n", path.Dir(overlayFile))
|
||||
wwlog.Printf(wwlog.ERROR, "Editor process existed with non-zero\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if editor == "" {
|
||||
wwlog.Printf(wwlog.WARN, "No default editor provided, will use `nano`.")
|
||||
editor = "nano"
|
||||
// Everything below this point is to update the relevant overlays
|
||||
nodes, err := assets.FindAllNodes()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Cloud not get nodeList: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
return util.ExecInteractive(editor, overlayFile)
|
||||
var updateNodes []assets.NodeInfo
|
||||
|
||||
for _, node := range nodes {
|
||||
if SystemOverlay == true && node.SystemOverlay == args[0] {
|
||||
updateNodes = append(updateNodes, node)
|
||||
} else if node.RuntimeOverlay == args[0] {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,13 @@ var (
|
||||
}
|
||||
SystemOverlay bool
|
||||
ListFiles bool
|
||||
|
||||
CreateDirs bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().BoolVarP(&SystemOverlay, "system", "s", false, "Show system overlays instead of runtime")
|
||||
baseCmd.PersistentFlags().BoolVarP(&ListFiles, "files", "f", false, "List files contained within a given overlay")
|
||||
baseCmd.PersistentFlags().BoolVarP(&CreateDirs, "parents", "p", false, "Create any necessary parent directories")
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
@@ -18,10 +20,18 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
var nodeList []assets.NodeInfo
|
||||
|
||||
if SystemOverlay == true {
|
||||
fmt.Printf("%-25s %-8s %-8s\n", "SYSTEM OVERLAY NAME", "NODES", "FILES")
|
||||
if ListLong == false {
|
||||
fmt.Printf("%-30s %-12s %-12s\n", "SYSTEM OVERLAY NAME", "NODES", "FILES/DIRS")
|
||||
} else {
|
||||
fmt.Printf("%-10s %5s %-5s %-18s %s\n", "PERM MODE", "UID", "GID", "SYSTEM-OVERLAY", "FILE PATH")
|
||||
}
|
||||
o, err = overlay.FindAllSystemOverlays()
|
||||
} else {
|
||||
fmt.Printf("%-25s %-8s %-8s\n", "RUNTIME OVERLAY NAME", "NODES", "FILES")
|
||||
if ListLong == false {
|
||||
fmt.Printf("%-30s %-12s %-12s\n", "RUNTIME OVERLAY NAME", "NODES", "FILES/DIRS")
|
||||
} else {
|
||||
fmt.Printf("%-10s %5s %-5s %-18s %s\n", "PERM MODE", "UID", "GID", "RUNTIME-OVERLAY", "FILE PATH")
|
||||
}
|
||||
o, err = overlay.FindAllRuntimeOverlays()
|
||||
}
|
||||
if err != nil {
|
||||
@@ -67,17 +77,32 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
files := util.FindFiles(path)
|
||||
|
||||
wwlog.Printf(wwlog.DEBUG, "Iterating overlay path: %s\n", path)
|
||||
if ListFiles == true {
|
||||
if ListContents == true {
|
||||
var fileCount int
|
||||
for file := range files {
|
||||
fmt.Printf("%-25s %-8d /%s\n", name, set[name], files[file])
|
||||
fileCount ++
|
||||
fmt.Printf("%-30s %-12d /%-12s\n", name, set[name], files[file])
|
||||
fileCount++
|
||||
}
|
||||
if fileCount == 0 {
|
||||
fmt.Printf("%-25s %-8d %-8d\n", name, set[name], 0)
|
||||
fmt.Printf("%-30s %-12d %-12d\n", name, set[name], 0)
|
||||
}
|
||||
} else if ListLong == true {
|
||||
for file := range files {
|
||||
s, err := os.Stat(files[file])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
fileMode := s.Mode()
|
||||
perms := fileMode & os.ModePerm
|
||||
|
||||
sys := s.Sys()
|
||||
|
||||
fmt.Printf("%v %5d %-5d %-18s /%s\n", perms, sys.(*syscall.Stat_t).Uid, sys.(*syscall.Stat_t).Gid, o[overlay], files[file])
|
||||
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("%-25s %-8d %-8d\n", name, set[name], len(files))
|
||||
fmt.Printf("%-30s %-12d %-12d\n", name, set[name], len(files))
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@@ -10,14 +10,17 @@ var (
|
||||
Short: "List Warewulf Overlays",
|
||||
Long: "Warewulf List overlay",
|
||||
RunE: CobraRunE,
|
||||
Aliases: []string{"ls"},
|
||||
}
|
||||
SystemOverlay bool
|
||||
ListFiles bool
|
||||
ListContents bool
|
||||
ListLong bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().BoolVarP(&SystemOverlay, "system", "s", false, "Show system overlays instead of runtime")
|
||||
baseCmd.PersistentFlags().BoolVarP(&ListFiles, "files", "f", false, "List files contained within a given overlay")
|
||||
baseCmd.PersistentFlags().BoolVarP(&ListContents, "all", "a", false, "List the contents of overlays")
|
||||
baseCmd.PersistentFlags().BoolVarP(&ListLong, "long", "l", false, "List 'long' of all overlay contents")
|
||||
|
||||
}
|
||||
|
||||
|
||||
71
internal/app/wwctl/overlay/mkdir/main.go
Normal file
71
internal/app/wwctl/overlay/mkdir/main.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package mkdir
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"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()
|
||||
var overlaySourceDir string
|
||||
// mode := uint32(strconv.ParseUint(PermMode, 8, 32))
|
||||
|
||||
|
||||
if SystemOverlay == true {
|
||||
overlaySourceDir = config.SystemOverlaySource(args[0])
|
||||
} else {
|
||||
overlaySourceDir = config.RuntimeOverlaySource(args[0])
|
||||
}
|
||||
|
||||
if util.IsDir(overlaySourceDir) == false {
|
||||
wwlog.Printf(wwlog.ERROR, "Overlay does not exist: %s\n", args[0])
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
overlayDir := path.Join(overlaySourceDir, args[1])
|
||||
|
||||
wwlog.Printf(wwlog.DEBUG, "Will create directory in overlay: %s:%s\n", args[0], overlayDir)
|
||||
|
||||
err := os.MkdirAll(overlayDir, 0755)
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not create directory: %s\n", path.Dir(overlayDir))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Created directory within overlay: %s:%s\n", args[0], args[1])
|
||||
|
||||
// Everything below this point is to update the relevant overlays
|
||||
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 == args[0] {
|
||||
updateNodes = append(updateNodes, node)
|
||||
} else if node.RuntimeOverlay == args[0] {
|
||||
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/mkdir/root.go
Normal file
28
internal/app/wwctl/overlay/mkdir/root.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package mkdir
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "mkdir [overlay name] [directory path]",
|
||||
Short: "Create a new directory",
|
||||
Long: "Create a new directory within a Warewulf overlay",
|
||||
RunE: CobraRunE,
|
||||
Args: cobra.MinimumNArgs(2),
|
||||
}
|
||||
SystemOverlay bool
|
||||
// PermMode os.FileMode
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().BoolVarP(&SystemOverlay, "system", "s", false, "Show System Overlays as well")
|
||||
// This will be added back as soon as I figure out how to properly handle the FileMode case
|
||||
// baseCmd.PersistentFlags().Uint32VarP(&PermMode, "mode", "m", 0755, "Permission mode for directory")
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
package overlay
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/overlay/build"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/overlay/copy"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/overlay/create"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/overlay/delete"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/overlay/edit"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/overlay/list"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/overlay/mkdir"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/overlay/show"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
@@ -27,6 +30,9 @@ func init() {
|
||||
baseCmd.AddCommand(create.GetCommand())
|
||||
baseCmd.AddCommand(edit.GetCommand())
|
||||
baseCmd.AddCommand(delete.GetCommand())
|
||||
baseCmd.AddCommand(mkdir.GetCommand())
|
||||
baseCmd.AddCommand(build.GetCommand())
|
||||
baseCmd.AddCommand(copy.GetCommand())
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user