Building set commands for nodes and groups and templating out CLI further
This commit is contained in:
22
internal/app/wwctl/group/add/main.go
Normal file
22
internal/app/wwctl/group/add/main.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package add
|
||||
|
||||
import (
|
||||
"github.com/hpcng/warewulf/internal/pkg/node"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
)
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
nodeDB, err := node.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Failed opening node database: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
nodeDB.AddGroup(args[0])
|
||||
nodeDB.Persist()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
25
internal/app/wwctl/group/add/root.go
Normal file
25
internal/app/wwctl/group/add/root.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package add
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "add",
|
||||
Short: "Add a new node group",
|
||||
Long: "Add a new node group ",
|
||||
RunE: CobraRunE,
|
||||
}
|
||||
SetVnfs string
|
||||
SetKernel string
|
||||
// SetGroupLevel bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseCmd.PersistentFlags().StringVarP(&SetVnfs, "vnfs", "V", "", "Set node Virtual Node File System (VNFS)")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetKernel, "kernel", "K", "", "Set Kernel version for nodes")
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
Reference in New Issue
Block a user