diff --git a/internal/app/wwctl/configure/dhcp/main.go b/internal/app/wwctl/configure/dhcp/main.go index 61829c3f..da3dc414 100644 --- a/internal/app/wwctl/configure/dhcp/main.go +++ b/internal/app/wwctl/configure/dhcp/main.go @@ -23,6 +23,11 @@ type dhcpTemplate struct { } func CobraRunE(cmd *cobra.Command, args []string) error { + if SetShow == false && SetPersist == false { + fmt.Println(cmd.Help()) + os.Exit(0) + } + return Configure(SetShow) } diff --git a/internal/app/wwctl/configure/dhcp/root.go b/internal/app/wwctl/configure/dhcp/root.go index 57837262..dfd0c30a 100644 --- a/internal/app/wwctl/configure/dhcp/root.go +++ b/internal/app/wwctl/configure/dhcp/root.go @@ -7,16 +7,18 @@ import ( var ( baseCmd = &cobra.Command{ Use: "dhcp", - Short: "DHCP configuration", - Long: "DHCP Config", - RunE: CobraRunE, + Short: "Manage and initialize DHCP", + Long: "DHCP is a dependent service to Warewulf. This command will configure DHCP as defined\n" + + "in the warewulf.conf file.", + RunE: CobraRunE, } - SetShow bool + SetShow bool + SetPersist bool ) func init() { baseCmd.PersistentFlags().BoolVarP(&SetShow, "show", "s", false, "Show configuration (don't update)") - + baseCmd.PersistentFlags().BoolVar(&SetShow, "persist", false, "Persist the configuration and initialize the service") } // GetRootCommand returns the root cobra.Command for the application. diff --git a/internal/app/wwctl/configure/hosts/main.go b/internal/app/wwctl/configure/hosts/main.go index 4cab1e2b..2f8e4c6f 100644 --- a/internal/app/wwctl/configure/hosts/main.go +++ b/internal/app/wwctl/configure/hosts/main.go @@ -1,13 +1,14 @@ package hosts import ( + "bytes" + "fmt" "github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/warewulfconf" "github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/spf13/cobra" "os" - "bytes" "text/template" ) @@ -15,12 +16,17 @@ type TemplateStruct struct { PrevHostFile string Ipaddr string Fqdn string - AllNodes []node.NodeInfo + AllNodes []node.NodeInfo } func CobraRunE(cmd *cobra.Command, args []string) error { var replace TemplateStruct + if SetShow == false && SetPersist == false { + fmt.Println(cmd.Help()) + os.Exit(0) + } + if util.IsFile("/etc/warewulf/hosts.tmpl") == false { wwlog.Printf(wwlog.WARN, "Template not found, not updating host file\n") return nil @@ -50,7 +56,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { wwlog.Printf(wwlog.WARN, "%s\n", err) } else { // if /etc/hosts.ww does not exist, backup /etc/hosts to /etc/hosts.wwbackup - if ! util.IsFile("/etc/hosts.wwbackup") { + if !util.IsFile("/etc/hosts.wwbackup") { err = util.CopyFile("/etc/hosts", "/etc/hosts.wwbackup") if err != nil { wwlog.Printf(wwlog.ERROR, "%s\n", err) diff --git a/internal/app/wwctl/configure/hosts/root.go b/internal/app/wwctl/configure/hosts/root.go index 666c67db..5be05e85 100644 --- a/internal/app/wwctl/configure/hosts/root.go +++ b/internal/app/wwctl/configure/hosts/root.go @@ -5,15 +5,18 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ Use: "hosts", - Short: "NFS configuration", - Long: "NFS Config", - RunE: CobraRunE, + Short: "Update the /etc/hosts file", + Long: "Write out the /etc/hosts file based on the Warewulf template (hosts.tmpl) in the\n" + + "Warewulf configuration directory.", + RunE: CobraRunE, } - SetShow bool + SetShow bool + SetPersist bool ) func init() { baseCmd.PersistentFlags().BoolVarP(&SetShow, "show", "s", false, "Show configuration (don't update)") + baseCmd.PersistentFlags().BoolVar(&SetShow, "persist", false, "Persist the configuration and initialize the service") } // GetRootCommand returns the root cobra.Command for the application. diff --git a/internal/app/wwctl/configure/nfs/main.go b/internal/app/wwctl/configure/nfs/main.go index e4aea60a..984c7ea7 100644 --- a/internal/app/wwctl/configure/nfs/main.go +++ b/internal/app/wwctl/configure/nfs/main.go @@ -11,6 +11,11 @@ import ( func CobraRunE(cmd *cobra.Command, args []string) error { + if SetShow == false && SetPersist == false { + fmt.Println(cmd.Help()) + os.Exit(0) + } + controller, err := warewulfconf.New() if err != nil { wwlog.Printf(wwlog.ERROR, "%s\n", err) diff --git a/internal/app/wwctl/configure/nfs/root.go b/internal/app/wwctl/configure/nfs/root.go index b0681bcd..e8a10e87 100644 --- a/internal/app/wwctl/configure/nfs/root.go +++ b/internal/app/wwctl/configure/nfs/root.go @@ -5,15 +5,18 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ Use: "nfs", - Short: "NFS configuration", - Long: "NFS Config", - RunE: CobraRunE, + Short: "Manage and initialize NFS", + Long: "NFS is an optional dependent service of Warewulf, this tool will automatically\n" + + "configure NFS as per the configuration in the warewulf.conf file.", + RunE: CobraRunE, } - SetShow bool + SetShow bool + SetPersist bool ) func init() { baseCmd.PersistentFlags().BoolVarP(&SetShow, "show", "s", false, "Show configuration (don't update)") + baseCmd.PersistentFlags().BoolVar(&SetPersist, "persist", false, "Persist the configuration and initialize the service") } // GetRootCommand returns the root cobra.Command for the application. diff --git a/internal/app/wwctl/configure/root.go b/internal/app/wwctl/configure/root.go index faa2e74c..21d43277 100644 --- a/internal/app/wwctl/configure/root.go +++ b/internal/app/wwctl/configure/root.go @@ -14,9 +14,10 @@ import ( var ( baseCmd = &cobra.Command{ Use: "configure", - Short: "Configure Warewulf services", - Long: "Warewulf Service Initialization", - RunE: CobraRunE, + Short: "Manage system services", + Long: "This application allows you to manage and initialize Warewulf dependent system\n" + + "services based on the configuration in the warewulf.conf file.", + RunE: CobraRunE, } SetDoAll bool ) diff --git a/internal/app/wwctl/configure/ssh/main.go b/internal/app/wwctl/configure/ssh/main.go index eee4afeb..50e1eb92 100644 --- a/internal/app/wwctl/configure/ssh/main.go +++ b/internal/app/wwctl/configure/ssh/main.go @@ -10,6 +10,10 @@ import ( ) func CobraRunE(cmd *cobra.Command, args []string) error { + if SetPersist == false { + fmt.Println(cmd.Help()) + os.Exit(0) + } if os.Getuid() == 0 { fmt.Printf("Updating system keys\n") diff --git a/internal/app/wwctl/configure/ssh/root.go b/internal/app/wwctl/configure/ssh/root.go index 69ef0f9e..8865ea00 100644 --- a/internal/app/wwctl/configure/ssh/root.go +++ b/internal/app/wwctl/configure/ssh/root.go @@ -5,16 +5,17 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ Use: "ssh", - Short: "SSH configuration", - Long: "SSH Config", - RunE: CobraRunE, + Short: "Manage and initialize SSH", + Long: "SSH is an optionally dependent service for Warewulf, this tool will automatically\n" + + "setup the ssh keys nodes using the 'default' system overlay as well as user owned\n" + + "keys.", + RunE: CobraRunE, } - SetShow bool + SetPersist bool ) func init() { -// baseCmd.PersistentFlags().BoolVarP(&SetShow, "show", "s", false, "Show configuration (don't update)") - + baseCmd.PersistentFlags().BoolVar(&SetPersist, "persist", false, "Persist the configuration and initialize the service") } // GetRootCommand returns the root cobra.Command for the application. diff --git a/internal/app/wwctl/configure/tftp/main.go b/internal/app/wwctl/configure/tftp/main.go index 5ab6bcc5..8085cd59 100644 --- a/internal/app/wwctl/configure/tftp/main.go +++ b/internal/app/wwctl/configure/tftp/main.go @@ -12,6 +12,11 @@ import ( ) func CobraRunE(cmd *cobra.Command, args []string) error { + if SetShow == false && SetPersist == false { + fmt.Println(cmd.Help()) + os.Exit(0) + } + return Configure(SetShow) } diff --git a/internal/app/wwctl/configure/tftp/root.go b/internal/app/wwctl/configure/tftp/root.go index 67394f2a..f14ab40a 100644 --- a/internal/app/wwctl/configure/tftp/root.go +++ b/internal/app/wwctl/configure/tftp/root.go @@ -5,15 +5,18 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ Use: "tftp", - Short: "TFTP configuration", - Long: "TFTP Config", - RunE: CobraRunE, + Short: "Manage and initialize TFTP", + Long: "TFTP is a dependent service of Warewulf, this tool will enable the tftp services\n" + + "on your Warewulf master.", + RunE: CobraRunE, } - SetShow bool + SetShow bool + SetPersist bool ) func init() { baseCmd.PersistentFlags().BoolVarP(&SetShow, "show", "s", false, "Show configuration (don't update)") + baseCmd.PersistentFlags().BoolVar(&SetPersist, "persist", false, "Persist the configuration and initialize the service") } // GetRootCommand returns the root cobra.Command for the application. diff --git a/internal/app/wwctl/container/build/main.go b/internal/app/wwctl/container/build/main.go index fe9c9d88..b9b20403 100644 --- a/internal/app/wwctl/container/build/main.go +++ b/internal/app/wwctl/container/build/main.go @@ -18,6 +18,11 @@ func CobraRunE(cmd *cobra.Command, args []string) error { containers = args } + if len(containers) == 0 { + fmt.Println(cmd.Help()) + os.Exit(0) + } + for _, c := range containers { if container.ValidSource(c) == false { wwlog.Printf(wwlog.ERROR, "VNFS name does not exist: %s\n", c) diff --git a/internal/app/wwctl/container/build/root.go b/internal/app/wwctl/container/build/root.go index 49ab376b..71d01222 100644 --- a/internal/app/wwctl/container/build/root.go +++ b/internal/app/wwctl/container/build/root.go @@ -4,11 +4,11 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ - Use: "build (container location | node search pattern)", - Short: "VNFS Image Build", - Long: "VNFS kernel images", + Use: "build [flags] [container name]...", + Short: "(Re)build a bootable VNFS image", + Long: "This command will build a bootable VNFS image from an imported container image.", RunE: CobraRunE, - Args: cobra.RangeArgs(0, 1), + Args: cobra.MinimumNArgs(1), } BuildForce bool BuildAll bool diff --git a/internal/app/wwctl/container/delete/root.go b/internal/app/wwctl/container/delete/root.go index 2171df6a..c753322a 100644 --- a/internal/app/wwctl/container/delete/root.go +++ b/internal/app/wwctl/container/delete/root.go @@ -4,15 +4,12 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ - Use: "delete", - Short: "Delete Source OCI VNFS images", - Long: "Delete Source OCI VNFS images ", + Use: "delete [flags] [container name]...", + Short: "Delete an imported container", + Long: "This command will delete a container that has been imported into Warewulf.", RunE: CobraRunE, Args: cobra.MinimumNArgs(1), } - SetForce bool - SetUpdate bool - SetBuild bool ) func init() { diff --git a/internal/app/wwctl/container/exec/root.go b/internal/app/wwctl/container/exec/root.go index 32b6c75b..ba57cf88 100644 --- a/internal/app/wwctl/container/exec/root.go +++ b/internal/app/wwctl/container/exec/root.go @@ -7,9 +7,11 @@ import ( var ( baseCmd = &cobra.Command{ - Use: "exec", - Short: "Spawn any command inside a Warewulf container", - Long: "Run a command inside a Warewulf container ", + Use: "exec [flags] [container name]", + Short: "Run a command inside of a Warewulf container", + Long: "This command will allow you to run any command inside of a given\n" + + "warewulf container. This is commonly used with an interactive shell such as /bin/bash\n" + + "to run a virtual environment within the container.", RunE: CobraRunE, Args: cobra.MinimumNArgs(1), FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true}, @@ -18,7 +20,6 @@ var ( func init() { baseCmd.AddCommand(child.GetCommand()) - } // GetRootCommand returns the root cobra.Command for the application. diff --git a/internal/app/wwctl/container/pull/main.go b/internal/app/wwctl/container/imprt/main.go similarity index 99% rename from internal/app/wwctl/container/pull/main.go rename to internal/app/wwctl/container/imprt/main.go index 4a91d965..309b6824 100644 --- a/internal/app/wwctl/container/pull/main.go +++ b/internal/app/wwctl/container/imprt/main.go @@ -1,4 +1,4 @@ -package pull +package imprt import ( "fmt" diff --git a/internal/app/wwctl/container/pull/root.go b/internal/app/wwctl/container/imprt/root.go similarity index 70% rename from internal/app/wwctl/container/pull/root.go rename to internal/app/wwctl/container/imprt/root.go index 882a18f0..1725d06a 100644 --- a/internal/app/wwctl/container/pull/root.go +++ b/internal/app/wwctl/container/imprt/root.go @@ -1,14 +1,15 @@ -package pull +package imprt import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ - Use: "pull", - Short: "Pull Source OCI VNFS images", - Long: "Pull Source OCI VNFS images ", - RunE: CobraRunE, - Args: cobra.MinimumNArgs(1), + Use: "import [flags] [container source URI]", + Short: "Import a container into Warewulf", + Long: "This command will pull and import a container into Warewulf so it can be used\n" + + "as a source to create a bootable VNFS image.", + RunE: CobraRunE, + Args: cobra.MinimumNArgs(1), } SetForce bool SetUpdate bool @@ -21,7 +22,6 @@ func init() { baseCmd.PersistentFlags().BoolVarP(&SetUpdate, "update", "u", false, "Update and overwrite an existing container") baseCmd.PersistentFlags().BoolVarP(&SetBuild, "build", "b", false, "Build container when after pulling") baseCmd.PersistentFlags().BoolVar(&SetDefault, "setdefault", false, "Set this container for the default profile") - } // GetRootCommand returns the root cobra.Command for the application. diff --git a/internal/app/wwctl/container/list/root.go b/internal/app/wwctl/container/list/root.go index 80216bb9..273eb371 100644 --- a/internal/app/wwctl/container/list/root.go +++ b/internal/app/wwctl/container/list/root.go @@ -4,21 +4,14 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ - Use: "list", - Short: "List VNFS images", - Long: "List VNFS images ", - RunE: CobraRunE, + Use: "list [flags]", + Short: "List imported Warewulf containers", + Long: "This command will show you the containers that are imported into Warewulf.", + RunE: CobraRunE, + Aliases: []string{"ls"}, } - 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 diff --git a/internal/app/wwctl/container/root.go b/internal/app/wwctl/container/root.go index 00739fd7..d85be76f 100644 --- a/internal/app/wwctl/container/root.go +++ b/internal/app/wwctl/container/root.go @@ -4,8 +4,8 @@ import ( "github.com/hpcng/warewulf/internal/app/wwctl/container/build" "github.com/hpcng/warewulf/internal/app/wwctl/container/delete" "github.com/hpcng/warewulf/internal/app/wwctl/container/exec" + "github.com/hpcng/warewulf/internal/app/wwctl/container/imprt" "github.com/hpcng/warewulf/internal/app/wwctl/container/list" - "github.com/hpcng/warewulf/internal/app/wwctl/container/pull" "github.com/spf13/cobra" ) @@ -13,7 +13,9 @@ var ( baseCmd = &cobra.Command{ Use: "container", Short: "Container / VNFS image management", - Long: "Virtual Node File System (VNFS) image management", + Long: "Starting with version 4, Warewulf uses containers to build the bootable VNFS\n" + + "images for nodes to boot. These commands will help you import, management, and\n" + + "transform containers into bootable Warewulf VNFS images.", } test bool ) @@ -21,7 +23,7 @@ var ( func init() { baseCmd.AddCommand(build.GetCommand()) baseCmd.AddCommand(list.GetCommand()) - baseCmd.AddCommand(pull.GetCommand()) + baseCmd.AddCommand(imprt.GetCommand()) baseCmd.AddCommand(exec.GetCommand()) baseCmd.AddCommand(delete.GetCommand()) } diff --git a/internal/app/wwctl/kernel/build/main.go b/internal/app/wwctl/kernel/build/main.go deleted file mode 100644 index a605dae5..00000000 --- a/internal/app/wwctl/kernel/build/main.go +++ /dev/null @@ -1,107 +0,0 @@ -package build - -import ( - "fmt" - "github.com/hpcng/warewulf/internal/pkg/kernel" - "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 { - - for _, arg := range args { - output, err := kernel.Build(arg) - if err != nil { - wwlog.Printf(wwlog.ERROR, "Failed building kernel: %s\n", err) - os.Exit(1) - } else { - fmt.Printf("%s: %s\n", arg, output) - } - } - - if SetDefault == true { - if len(args) != 1 { - wwlog.Printf(wwlog.ERROR, "Can only set default for one kernel version\n") - } else { - nodeDB, err := node.New() - if err != nil { - wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err) - os.Exit(1) - } - - //TODO: Don't loop through profiles, instead have a nodeDB function that goes directly to the map - profiles, _ := nodeDB.FindAllProfiles() - for _, profile := range profiles { - wwlog.Printf(wwlog.DEBUG, "Looking for profile default: %s\n", profile.Id.Get()) - if profile.Id.Get() == "default" { - wwlog.Printf(wwlog.DEBUG, "Found profile default, setting kernel version to: %s\n", args[0]) - profile.KernelVersion.Set(args[0]) - nodeDB.ProfileUpdate(profile) - } - } - nodeDB.Persist() - fmt.Printf("Set default kernel version to: %s\n", args[0]) - } - } - - /* - var nodes []node.NodeInfo - set := make(map[string]int) - - n, err := node.New() - if err != nil { - wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err) - os.Exit(1) - } - - if len(args) == 1 && ByNode == true { - var err error - nodes, err = n.SearchByName(args[0]) - if err != nil { - wwlog.Printf(wwlog.ERROR, "Could not find nodes for search term: %s\n", args[0]) - os.Exit(1) - } - - for _, node := range nodes { - if node.KernelVersion.Defined() == true { - set[node.KernelVersion.Get()]++ - } - } - - } else if BuildAll == true { - var err error - nodes, err = n.FindAllNodes() - if err != nil { - wwlog.Printf(wwlog.ERROR, "Could not get list of nodes: %s\n", err) - os.Exit(1) - } - - for _, node := range nodes { - wwlog.Printf(wwlog.DEBUG, "evaluating node/kernel: %s/%s\n", node.Id.Get(), node.KernelVersion.Get()) - if node.KernelVersion.Defined() == true { - set[node.KernelVersion.Get()]++ - } - } - - } else if len(args) == 1 { - set[args[0]]++ - } else { - cmd.Usage() - os.Exit(1) - } - - for k := range set { - wwlog.Printf(wwlog.INFO, "Building kernel: %s\n", k) - err := kernel.Build(k) - if err != nil { - wwlog.Printf(wwlog.ERROR, "%s\n", err) - os.Exit(1) - } - } - - */ - - return nil -} diff --git a/internal/app/wwctl/kernel/build/root.go b/internal/app/wwctl/kernel/build/root.go deleted file mode 100644 index 9e873996..00000000 --- a/internal/app/wwctl/kernel/build/root.go +++ /dev/null @@ -1,29 +0,0 @@ -package build - -import ( - "github.com/spf13/cobra" -) - -var ( - baseCmd = &cobra.Command{ - Use: "build (kernel version | node search pattern)", - Short: "Kernel Image Build", - Long: "Build kernel images", - RunE: CobraRunE, - Args: cobra.MinimumNArgs(1), - } - BuildAll bool - ByNode bool - SetDefault bool -) - -func init() { - baseCmd.PersistentFlags().BoolVarP(&BuildAll, "all", "a", false, "Build all overlays (runtime and system)") - 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") -} - -// GetRootCommand returns the root cobra.Command for the application. -func GetCommand() *cobra.Command { - return baseCmd -} diff --git a/internal/app/wwctl/kernel/export/main.go b/internal/app/wwctl/kernel/export/main.go deleted file mode 100644 index dc10c347..00000000 --- a/internal/app/wwctl/kernel/export/main.go +++ /dev/null @@ -1,12 +0,0 @@ -package export - -import ( - "fmt" - "github.com/spf13/cobra" -) - -func CobraRunE(cmd *cobra.Command, args []string) error { - fmt.Printf("This command is coming soon...\n") - - return nil -} \ No newline at end of file diff --git a/internal/app/wwctl/kernel/export/root.go b/internal/app/wwctl/kernel/export/root.go deleted file mode 100644 index f3491682..00000000 --- a/internal/app/wwctl/kernel/export/root.go +++ /dev/null @@ -1,22 +0,0 @@ -package export - -import "github.com/spf13/cobra" - -var ( - baseCmd = &cobra.Command{ - Use: "export", - Short: "Kernel Image Export", - Long: "Export kernel image", - RunE: CobraRunE, - Args: cobra.ExactArgs(1), - - } -) - -func init() { -} - -// GetRootCommand returns the root cobra.Command for the application. -func GetCommand() *cobra.Command { - return baseCmd -} \ No newline at end of file diff --git a/internal/app/wwctl/kernel/imprt/main.go b/internal/app/wwctl/kernel/imprt/main.go index 010b38af..4109fc55 100644 --- a/internal/app/wwctl/kernel/imprt/main.go +++ b/internal/app/wwctl/kernel/imprt/main.go @@ -2,11 +2,49 @@ package imprt import ( "fmt" + "github.com/hpcng/warewulf/internal/pkg/kernel" + "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 { - fmt.Printf("This command is coming soon...\n") + + for _, arg := range args { + output, err := kernel.Build(arg) + if err != nil { + wwlog.Printf(wwlog.ERROR, "Failed building kernel: %s\n", err) + os.Exit(1) + } else { + fmt.Printf("%s: %s\n", arg, output) + } + } + + if SetDefault == true { + if len(args) != 1 { + wwlog.Printf(wwlog.ERROR, "Can only set default for one kernel version\n") + } else { + nodeDB, err := node.New() + if err != nil { + wwlog.Printf(wwlog.ERROR, "Could not open node configuration: %s\n", err) + os.Exit(1) + } + + //TODO: Don't loop through profiles, instead have a nodeDB function that goes directly to the map + profiles, _ := nodeDB.FindAllProfiles() + for _, profile := range profiles { + wwlog.Printf(wwlog.DEBUG, "Looking for profile default: %s\n", profile.Id.Get()) + if profile.Id.Get() == "default" { + wwlog.Printf(wwlog.DEBUG, "Found profile default, setting kernel version to: %s\n", args[0]) + profile.KernelVersion.Set(args[0]) + nodeDB.ProfileUpdate(profile) + } + } + nodeDB.Persist() + fmt.Printf("Set default kernel version to: %s\n", args[0]) + } + } return nil -} \ No newline at end of file +} diff --git a/internal/app/wwctl/kernel/imprt/root.go b/internal/app/wwctl/kernel/imprt/root.go index 4642f655..22881842 100644 --- a/internal/app/wwctl/kernel/imprt/root.go +++ b/internal/app/wwctl/kernel/imprt/root.go @@ -1,22 +1,30 @@ package imprt -import "github.com/spf13/cobra" +import ( + "github.com/spf13/cobra" +) var ( baseCmd = &cobra.Command{ - Use: "import", - Short: "Kernel Image Import", - Long: "Import kernel image", - RunE: CobraRunE, - Args: cobra.ExactArgs(1), - + Use: "import [flags] [kernel version]", + Short: "Import Kernel version into Warewulf", + Long: "This will import a Kernel version from the control node into Warewulf for nodes\n" + + "to be configured to boot on.", + RunE: CobraRunE, + Args: cobra.MinimumNArgs(1), } + BuildAll bool + ByNode bool + SetDefault bool ) func init() { + baseCmd.PersistentFlags().BoolVarP(&BuildAll, "all", "a", false, "Build all overlays (runtime and system)") + 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") } // GetRootCommand returns the root cobra.Command for the application. func GetCommand() *cobra.Command { return baseCmd -} \ No newline at end of file +} diff --git a/internal/app/wwctl/kernel/list/main.go b/internal/app/wwctl/kernel/list/main.go index 4b2132c7..155454b2 100644 --- a/internal/app/wwctl/kernel/list/main.go +++ b/internal/app/wwctl/kernel/list/main.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/hpcng/warewulf/internal/pkg/kernel" "github.com/hpcng/warewulf/internal/pkg/node" - "github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/spf13/cobra" "os" @@ -26,53 +25,10 @@ func CobraRunE(cmd *cobra.Command, args []string) error { nodemap[n.KernelVersion.Get()]++ } - fmt.Printf("%-35s %-6s %-6s\n", "VNFS NAME", "BUILT", "NODES") + fmt.Printf("%-35s %-6s\n", "VNFS NAME", "NODE#") for _, k := range kernels { - image := kernel.KernelImage(k) - - if nodemap[k] == 0 { - nodemap[k] = 0 - } - fmt.Printf("%-35s %-6t %-6d\n", k, util.IsFile(image), nodemap[k]) - + fmt.Printf("%-35s %6d\n", k, nodemap[k]) } - /* - nconfig, _ := node.New() - nodes, _ := nconfig.FindAllNodes() - nodemap := make(map[string]int) - - for _, n := range nodes { - nodemap[n.KernelVersion.Get()]++ - } - - images, _ := ioutil.ReadDir(config.KernelParentDir()) - - fmt.Printf("%-38s %-16s %-16s %s\n", "KERNEL VERSION", "KERNEL SIZE(k)", "KMODS SIZE(k)", "NODES") - fmt.Println(strings.Repeat("=", 80)) - - for _, file := range images { - if util.IsDir(path.Join(config.KernelParentDir(), file.Name())) { - var kernel_size int64 - var kmods_size int64 - if util.IsFile(config.KernelImage(file.Name())) { - s, _ := os.Stat(config.KernelImage(file.Name())) - kernel_size = s.Size() / 1024 - } - if util.IsFile(config.KmodsImage(file.Name())) { - s, _ := os.Stat(config.KmodsImage(file.Name())) - kmods_size = s.Size() / 1024 - } - - if nodemap[file.Name()] > 0 { - fmt.Printf("%-38s %-16d %-16d %d\n", file.Name(), kernel_size, kmods_size, nodemap[file.Name()]) - } else { - fmt.Printf("%-38s %-16d %-16d %d\n", file.Name(), kernel_size, kmods_size, 0) - } - } - } - - */ - return nil } diff --git a/internal/app/wwctl/kernel/list/root.go b/internal/app/wwctl/kernel/list/root.go index 40b34c72..2fcceb4b 100644 --- a/internal/app/wwctl/kernel/list/root.go +++ b/internal/app/wwctl/kernel/list/root.go @@ -4,11 +4,12 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ - Use: "list", - Short: "List Installed Kernel Images", - Long: "List installed kernel images", - RunE: CobraRunE, - Args: cobra.ExactArgs(0), + Use: "list [flags]", + Short: "List imported Kernel images", + Long: "This command will list the kernels that have been imported into Warewulf.", + RunE: CobraRunE, + Args: cobra.ExactArgs(0), + Aliases: []string{"ls"}, } ) @@ -18,4 +19,4 @@ func init() { // GetRootCommand returns the root cobra.Command for the application. func GetCommand() *cobra.Command { return baseCmd -} \ No newline at end of file +} diff --git a/internal/app/wwctl/kernel/root.go b/internal/app/wwctl/kernel/root.go index 5dd0bc7c..3dcdd34b 100644 --- a/internal/app/wwctl/kernel/root.go +++ b/internal/app/wwctl/kernel/root.go @@ -1,8 +1,6 @@ package kernel import ( - "github.com/hpcng/warewulf/internal/app/wwctl/kernel/build" - "github.com/hpcng/warewulf/internal/app/wwctl/kernel/export" "github.com/hpcng/warewulf/internal/app/wwctl/kernel/imprt" "github.com/hpcng/warewulf/internal/app/wwctl/kernel/list" "github.com/spf13/cobra" @@ -10,15 +8,14 @@ import ( var ( baseCmd = &cobra.Command{ - Use: "kernel", - Short: "Kernel Image Management", - Long: "Management of Warewulf Kernels to be used for bootstrapping nodes", + Use: "kernel", + Short: "Kernel Image Management", + Long: "This command is for management of Warewulf Kernels to be used for\n" + + "bootstrapping nodes", } ) func init() { - baseCmd.AddCommand(build.GetCommand()) - baseCmd.AddCommand(export.GetCommand()) baseCmd.AddCommand(imprt.GetCommand()) baseCmd.AddCommand(list.GetCommand()) } @@ -26,4 +23,4 @@ func init() { // GetRootCommand returns the root cobra.Command for the application. func GetCommand() *cobra.Command { return baseCmd -} \ No newline at end of file +} diff --git a/internal/app/wwctl/node/add/root.go b/internal/app/wwctl/node/add/root.go index da7f8d60..fdc264d1 100644 --- a/internal/app/wwctl/node/add/root.go +++ b/internal/app/wwctl/node/add/root.go @@ -4,9 +4,9 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ - Use: "add", - Short: "Add new node", - Long: "Add new node ", + Use: "add [flags] [node pattern]", + Short: "Add new node to Warewulf", + Long: "This command will add a new node to Warewulf.", RunE: CobraRunE, Args: cobra.MinimumNArgs(1), } diff --git a/internal/app/wwctl/node/console/root.go b/internal/app/wwctl/node/console/root.go index f2515e5f..6a4e1b9f 100644 --- a/internal/app/wwctl/node/console/root.go +++ b/internal/app/wwctl/node/console/root.go @@ -6,9 +6,10 @@ import ( var ( powerCmd = &cobra.Command{ - Use: "console", - Short: "IPMI console", - Long: "Start IPMI console for a singe node", + Use: "console [flags] [node pattern]", + Short: "Connect to IPMI console", + Long: "Start IPMI console for a singe node.", + Args: cobra.MinimumNArgs(1), RunE: CobraRunE, } ) diff --git a/internal/app/wwctl/node/delete/root.go b/internal/app/wwctl/node/delete/root.go index 9a7b5a7d..1c4a1e4a 100644 --- a/internal/app/wwctl/node/delete/root.go +++ b/internal/app/wwctl/node/delete/root.go @@ -4,13 +4,15 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ - Use: "delete", - Short: "Set node configurations", - Long: "Set node configurations ", - RunE: CobraRunE, + Use: "delete [flags] [node pattern]...", + Short: "Delete a node from Warewulf", + Long: "This command will remove a node from the Warewulf node configuration.", + Args: cobra.MinimumNArgs(1), + RunE: CobraRunE, + Aliases: []string{"rm", "del"}, } - SetForce string - SetGroup string + SetForce string + SetGroup string SetController string ) diff --git a/internal/app/wwctl/node/list/root.go b/internal/app/wwctl/node/list/root.go index 9bc4fe3c..b72903ed 100644 --- a/internal/app/wwctl/node/list/root.go +++ b/internal/app/wwctl/node/list/root.go @@ -4,14 +4,15 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ - Use: "list", - Short: "List all nodes", - Long: "List all nodes", - RunE: CobraRunE, + Use: "list [flags] (node pattern)", + Short: "List nodes matching pattern", + Long: "This command will show you configured nodes.", + RunE: CobraRunE, + Aliases: []string{"ls"}, } - ShowNet bool + ShowNet bool ShowIpmi bool - ShowAll bool + ShowAll bool ShowLong bool ) diff --git a/internal/app/wwctl/node/root.go b/internal/app/wwctl/node/root.go index af8686fb..64d693e0 100644 --- a/internal/app/wwctl/node/root.go +++ b/internal/app/wwctl/node/root.go @@ -2,31 +2,23 @@ package node import ( "github.com/hpcng/warewulf/internal/app/wwctl/node/add" + "github.com/hpcng/warewulf/internal/app/wwctl/node/console" "github.com/hpcng/warewulf/internal/app/wwctl/node/delete" "github.com/hpcng/warewulf/internal/app/wwctl/node/list" - "github.com/hpcng/warewulf/internal/app/wwctl/node/poweron" - "github.com/hpcng/warewulf/internal/app/wwctl/node/poweroff" - "github.com/hpcng/warewulf/internal/app/wwctl/node/powercycle" - "github.com/hpcng/warewulf/internal/app/wwctl/node/powerstatus" "github.com/hpcng/warewulf/internal/app/wwctl/node/sensors" - "github.com/hpcng/warewulf/internal/app/wwctl/node/console" "github.com/hpcng/warewulf/internal/app/wwctl/node/set" "github.com/spf13/cobra" ) var ( baseCmd = &cobra.Command{ - Use: "node", - Short: "Node management", - Long: "Management of node settings and power management", + Use: "node", + Short: "Node management", + Long: "Management of node settings", } ) func init() { - baseCmd.AddCommand(poweron.GetCommand()) - baseCmd.AddCommand(poweroff.GetCommand()) - baseCmd.AddCommand(powercycle.GetCommand()) - baseCmd.AddCommand(powerstatus.GetCommand()) baseCmd.AddCommand(sensors.GetCommand()) baseCmd.AddCommand(list.GetCommand()) baseCmd.AddCommand(set.GetCommand()) diff --git a/internal/app/wwctl/node/sensors/root.go b/internal/app/wwctl/node/sensors/root.go index a64a37e3..ac28bd1a 100644 --- a/internal/app/wwctl/node/sensors/root.go +++ b/internal/app/wwctl/node/sensors/root.go @@ -6,16 +6,17 @@ import ( var ( powerCmd = &cobra.Command{ - Use: "sensors", - Short: "node sensor information", - Long: "Get Node Sensor Information", + Use: "sensors [flags] [node pattern]", + Short: "Show node's IPMI sensor information", + Long: "Show IPMI sensors for a single node.", + Args: cobra.MinimumNArgs(1), RunE: CobraRunE, } full bool ) func init() { - powerCmd.PersistentFlags().BoolVarP(&full, "full", "F", false, "show detailed output.") + powerCmd.PersistentFlags().BoolVarP(&full, "full", "F", false, "show detailed output.") } // GetRootCommand returns the root cobra.Command for the application. diff --git a/internal/app/wwctl/node/set/root.go b/internal/app/wwctl/node/set/root.go index 3aadc4c7..0dfb6c35 100644 --- a/internal/app/wwctl/node/set/root.go +++ b/internal/app/wwctl/node/set/root.go @@ -4,9 +4,10 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ - Use: "set", - Short: "Set node configurations", - Long: "Set node configurations ", + Use: "set [flags] [node pattern]...", + Short: "Configure node properties", + Long: "This command will allow you to set configuration properties for nodes.", + Args: cobra.MinimumNArgs(1), RunE: CobraRunE, } SetComment string diff --git a/internal/app/wwctl/overlay/build/root.go b/internal/app/wwctl/overlay/build/root.go index 93efc9a1..4da9af71 100644 --- a/internal/app/wwctl/overlay/build/root.go +++ b/internal/app/wwctl/overlay/build/root.go @@ -4,13 +4,14 @@ 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, + Use: "build [flags] ", + Short: "(Re)build an overlay", + Long: "This command will build a system or runtime overlay.", + Args: cobra.MinimumNArgs(1), + RunE: CobraRunE, } SystemOverlay bool - BuildAll bool + BuildAll bool ) func init() { diff --git a/internal/app/wwctl/overlay/chmod/root.go b/internal/app/wwctl/overlay/chmod/root.go index 1fa4abb1..baf03081 100644 --- a/internal/app/wwctl/overlay/chmod/root.go +++ b/internal/app/wwctl/overlay/chmod/root.go @@ -4,21 +4,20 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ - Use: "chmod [overlay name] [numeric mode] [file path]", - Short: "Change permissions within an overlay", - Long: "Change permissions within an overlay", - RunE: CobraRunE, - Args: cobra.ExactArgs(3), - + Use: "chmod [flags] ", + Short: "Change file permissions within an overlay", + Long: "This command will allow you to change the permissions of a file within an\n" + + "overlay.", + RunE: CobraRunE, + Args: cobra.ExactArgs(3), } - SystemOverlay bool + SystemOverlay bool NoOverlayUpdate bool ) func init() { baseCmd.PersistentFlags().BoolVarP(&SystemOverlay, "system", "s", false, "Show System Overlays as well") baseCmd.PersistentFlags().BoolVarP(&NoOverlayUpdate, "noupdate", "n", false, "Don't update overlays") - } // GetRootCommand returns the root cobra.Command for the application. diff --git a/internal/app/wwctl/overlay/create/root.go b/internal/app/wwctl/overlay/create/root.go index 619b5bff..e44baff4 100644 --- a/internal/app/wwctl/overlay/create/root.go +++ b/internal/app/wwctl/overlay/create/root.go @@ -6,14 +6,13 @@ import ( var ( baseCmd = &cobra.Command{ - Use: "create [overlay name]", - Short: "Initialize a new Overlay", - Long: "Create a new Warewulf provisioning overlay", - RunE: CobraRunE, - Args: cobra.ExactArgs(1), - + Use: "create [flags] ", + Short: "Initialize a new Overlay", + Long: "This command will create a new empty overlay.", + RunE: CobraRunE, + Args: cobra.ExactArgs(1), } - SystemOverlay bool + SystemOverlay bool NoOverlayUpdate bool ) diff --git a/internal/app/wwctl/overlay/delete/root.go b/internal/app/wwctl/overlay/delete/root.go index 18e96caf..49327554 100644 --- a/internal/app/wwctl/overlay/delete/root.go +++ b/internal/app/wwctl/overlay/delete/root.go @@ -6,16 +6,17 @@ import ( var ( baseCmd = &cobra.Command{ - Use: "delete [overlay name]", - Short: "Delete Warewulf Overlay files", - Long: "Warewulf Delete overlay files", - RunE: CobraRunE, - Args: cobra.MinimumNArgs(1), - Aliases: []string{"rm", "del"}, + Use: "delete [flags] [overlay file]", + Short: "Delete Warewulf Overlay or files", + Long: "This command will delete files within an overlay or an entire overlay if no\n" + + "files are given to remove (use with caution).", + RunE: CobraRunE, + Args: cobra.MinimumNArgs(1), + Aliases: []string{"rm", "del"}, } - SystemOverlay bool - Force bool - Parents bool + SystemOverlay bool + Force bool + Parents bool NoOverlayUpdate bool ) @@ -30,4 +31,3 @@ func init() { func GetCommand() *cobra.Command { return baseCmd } - diff --git a/internal/app/wwctl/overlay/edit/root.go b/internal/app/wwctl/overlay/edit/root.go index a02674e9..922f6f85 100644 --- a/internal/app/wwctl/overlay/edit/root.go +++ b/internal/app/wwctl/overlay/edit/root.go @@ -6,17 +6,18 @@ import ( var ( baseCmd = &cobra.Command{ - Use: "edit [overlay name] [file path]", - Short: "Edit Warewulf Overlay files", - Long: "Warewulf edit overlay files", - RunE: CobraRunE, - Args: cobra.ExactArgs(2), - + Use: "edit [flags] ", + Short: "Edit/Create a file within a Warewulf Overlay", + Long: "This command will allow you to edit or create a new file within a given\n" + + "overlay. Note: when creating files ending in a '.ww' suffix this will always be\n" + + "parsed as a Warewulf template file, and the suffix will be removed automatically.", + RunE: CobraRunE, + Args: cobra.ExactArgs(2), } - SystemOverlay bool - ListFiles bool - CreateDirs bool - PermMode int32 + SystemOverlay bool + ListFiles bool + CreateDirs bool + PermMode int32 NoOverlayUpdate bool ) @@ -32,5 +33,3 @@ func init() { func GetCommand() *cobra.Command { return baseCmd } - - diff --git a/internal/app/wwctl/overlay/imprt/root.go b/internal/app/wwctl/overlay/imprt/root.go index 709f1843..2cc223a0 100644 --- a/internal/app/wwctl/overlay/imprt/root.go +++ b/internal/app/wwctl/overlay/imprt/root.go @@ -4,15 +4,15 @@ 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"}, + Use: "import [flags] [dest location]", + Short: "Import a file into a Warewulf Overlay", + Long: "This command will import a file into a given Warewulf overlay.", + RunE: CobraRunE, + Args: cobra.RangeArgs(2, 3), + Aliases: []string{"cp"}, } - SystemOverlay bool - PermMode int32 + SystemOverlay bool + PermMode int32 NoOverlayUpdate bool ) diff --git a/internal/app/wwctl/overlay/list/root.go b/internal/app/wwctl/overlay/list/root.go index b70bcc2d..41b087d1 100644 --- a/internal/app/wwctl/overlay/list/root.go +++ b/internal/app/wwctl/overlay/list/root.go @@ -6,15 +6,16 @@ import ( var ( baseCmd = &cobra.Command{ - Use: "list", - Short: "List Warewulf Overlays", - Long: "Warewulf List overlay", - RunE: CobraRunE, - Aliases: []string{"ls"}, + Use: "list [flags] [overlay name]", + Short: "List Warewulf Overlays and files", + Long: "This command will show you information about Warewulf overlays and the\n" + + "files contained within.", + RunE: CobraRunE, + Aliases: []string{"ls"}, } SystemOverlay bool - ListContents bool - ListLong bool + ListContents bool + ListLong bool ) func init() { diff --git a/internal/app/wwctl/overlay/mkdir/root.go b/internal/app/wwctl/overlay/mkdir/root.go index 89190226..4f293d4e 100644 --- a/internal/app/wwctl/overlay/mkdir/root.go +++ b/internal/app/wwctl/overlay/mkdir/root.go @@ -6,14 +6,14 @@ import ( 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), + Use: "mkdir [flags] ", + Short: "Create a new directory within an Overlay", + Long: "This command will allow you to create a new file within a given Warewulf overlay.", + RunE: CobraRunE, + Args: cobra.MinimumNArgs(2), } - SystemOverlay bool - PermMode int32 + SystemOverlay bool + PermMode int32 NoOverlayUpdate bool ) diff --git a/internal/app/wwctl/overlay/root.go b/internal/app/wwctl/overlay/root.go index 87e3abb5..72e9e87d 100644 --- a/internal/app/wwctl/overlay/root.go +++ b/internal/app/wwctl/overlay/root.go @@ -15,16 +15,14 @@ import ( var ( baseCmd = &cobra.Command{ - Use: "overlay", - Short: "Warewulf Overlay Management", - Long: "Management interface for Warewulf overlays", + Use: "overlay", + Short: "Warewulf Overlay Management", + Long: "Management interface for Warewulf overlays", } test bool ) func init() { -// baseCmd.PersistentFlags().BoolVarP(&test, "test", "t", false, "Testing.") - baseCmd.AddCommand(list.GetCommand()) baseCmd.AddCommand(show.GetCommand()) baseCmd.AddCommand(create.GetCommand()) diff --git a/internal/app/wwctl/overlay/show/root.go b/internal/app/wwctl/overlay/show/root.go index ab13c82e..6d848a25 100644 --- a/internal/app/wwctl/overlay/show/root.go +++ b/internal/app/wwctl/overlay/show/root.go @@ -6,12 +6,13 @@ import ( var ( baseCmd = &cobra.Command{ - Use: "show", - Short: "Show Warewulf Overlay objects", - Long: "Warewulf show overlay objects", - RunE: CobraRunE, - Aliases: []string{"cat"}, - Args: cobra.ExactArgs(2), + Use: "show [flags] ", + Short: "Show (cat) a file within a Warewulf Overlay", + Long: "This command will output the contents of a file within a given\n" + + "Warewulf overlay.", + RunE: CobraRunE, + Aliases: []string{"cat"}, + Args: cobra.ExactArgs(2), } SystemOverlay bool ) @@ -23,4 +24,4 @@ func init() { // GetRootCommand returns the root cobra.Command for the application. func GetCommand() *cobra.Command { return baseCmd -} \ No newline at end of file +} diff --git a/internal/app/wwctl/node/powercycle/power.go b/internal/app/wwctl/power/cycle/power.go similarity index 100% rename from internal/app/wwctl/node/powercycle/power.go rename to internal/app/wwctl/power/cycle/power.go diff --git a/internal/app/wwctl/node/powercycle/root.go b/internal/app/wwctl/power/cycle/root.go similarity index 60% rename from internal/app/wwctl/node/powercycle/root.go rename to internal/app/wwctl/power/cycle/root.go index 0adfee71..e89899fc 100644 --- a/internal/app/wwctl/node/powercycle/root.go +++ b/internal/app/wwctl/power/cycle/root.go @@ -6,9 +6,9 @@ import ( var ( powerCmd = &cobra.Command{ - Use: "powercycle", - Short: "power cycle node(s)", - Long: "cycle power for one or more nodes", + Use: "cycle [flags] ...", + Short: "Power cycle the given node(s)", + Long: "This command will cycle the power for a given set of nodes.", RunE: CobraRunE, } ) diff --git a/internal/app/wwctl/node/poweroff/power.go b/internal/app/wwctl/power/off/power.go similarity index 100% rename from internal/app/wwctl/node/poweroff/power.go rename to internal/app/wwctl/power/off/power.go diff --git a/internal/app/wwctl/node/poweroff/root.go b/internal/app/wwctl/power/off/root.go similarity index 64% rename from internal/app/wwctl/node/poweroff/root.go rename to internal/app/wwctl/power/off/root.go index 3d6a0de1..520ba12a 100644 --- a/internal/app/wwctl/node/poweroff/root.go +++ b/internal/app/wwctl/power/off/root.go @@ -6,9 +6,9 @@ import ( var ( powerCmd = &cobra.Command{ - Use: "poweroff", - Short: "power off node(s)", - Long: "turn power off for one or more nodes", + Use: "off", + Short: "Power off the given node(s)", + Long: "This command will shutdown the power to a given set of nodes.", RunE: CobraRunE, } ) diff --git a/internal/app/wwctl/node/poweron/power.go b/internal/app/wwctl/power/on/power.go similarity index 100% rename from internal/app/wwctl/node/poweron/power.go rename to internal/app/wwctl/power/on/power.go diff --git a/internal/app/wwctl/node/poweron/root.go b/internal/app/wwctl/power/on/root.go similarity index 67% rename from internal/app/wwctl/node/poweron/root.go rename to internal/app/wwctl/power/on/root.go index 3ef9041e..4da9b3e5 100644 --- a/internal/app/wwctl/node/poweron/root.go +++ b/internal/app/wwctl/power/on/root.go @@ -6,9 +6,9 @@ import ( var ( powerCmd = &cobra.Command{ - Use: "poweron", - Short: "power on node(s)", - Long: "turn power on for one or more nodes", + Use: "on", + Short: "Power on the given node(s)", + Long: "This command will power on a given set of nodes.", RunE: CobraRunE, } ) diff --git a/internal/app/wwctl/power/root.go b/internal/app/wwctl/power/root.go new file mode 100644 index 00000000..7ef3dbde --- /dev/null +++ b/internal/app/wwctl/power/root.go @@ -0,0 +1,32 @@ +package power + +import ( + powercycle "github.com/hpcng/warewulf/internal/app/wwctl/power/cycle" + poweroff "github.com/hpcng/warewulf/internal/app/wwctl/power/off" + poweron "github.com/hpcng/warewulf/internal/app/wwctl/power/on" + powerstatus "github.com/hpcng/warewulf/internal/app/wwctl/power/status" + "github.com/spf13/cobra" +) + +var ( + baseCmd = &cobra.Command{ + Use: "power", + Short: "Warewulf node power management", + Long: "This command can control the power state of nodes.", + } + test bool +) + +func init() { + // baseCmd.PersistentFlags().BoolVarP(&test, "test", "t", false, "Testing.") + + baseCmd.AddCommand(powercycle.GetCommand()) + baseCmd.AddCommand(poweroff.GetCommand()) + baseCmd.AddCommand(poweron.GetCommand()) + baseCmd.AddCommand(powerstatus.GetCommand()) +} + +// GetRootCommand returns the root cobra.Command for the application. +func GetCommand() *cobra.Command { + return baseCmd +} diff --git a/internal/app/wwctl/node/powerstatus/power.go b/internal/app/wwctl/power/status/power.go similarity index 100% rename from internal/app/wwctl/node/powerstatus/power.go rename to internal/app/wwctl/power/status/power.go diff --git a/internal/app/wwctl/node/powerstatus/root.go b/internal/app/wwctl/power/status/root.go similarity index 62% rename from internal/app/wwctl/node/powerstatus/root.go rename to internal/app/wwctl/power/status/root.go index 4c4ade66..60eb2d20 100644 --- a/internal/app/wwctl/node/powerstatus/root.go +++ b/internal/app/wwctl/power/status/root.go @@ -6,9 +6,9 @@ import ( var ( powerCmd = &cobra.Command{ - Use: "powerstatus", - Short: "node power status", - Long: "Get Node Power Status", + Use: "status", + Short: "Show power status for the given node(s)", + Long: "This command will show the power status of a given set of nodes.", RunE: CobraRunE, } ) diff --git a/internal/app/wwctl/profile/add/root.go b/internal/app/wwctl/profile/add/root.go index 756e829f..2ca19008 100644 --- a/internal/app/wwctl/profile/add/root.go +++ b/internal/app/wwctl/profile/add/root.go @@ -4,16 +4,14 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ - Use: "add", - Short: "Add profiles", - Long: "Profile configurations ", - RunE: CobraRunE, + Use: "add [flags] ", + Short: "Add a new node profile", + Long: "This command will add a new node profile.", + RunE: CobraRunE, + Args: cobra.MinimumNArgs(1), } ) -func init() { -} - // GetRootCommand returns the root cobra.Command for the application. func GetCommand() *cobra.Command { return baseCmd diff --git a/internal/app/wwctl/profile/delete/root.go b/internal/app/wwctl/profile/delete/root.go index c2a0cccf..9a9c028b 100644 --- a/internal/app/wwctl/profile/delete/root.go +++ b/internal/app/wwctl/profile/delete/root.go @@ -4,16 +4,14 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ - Use: "delete", - Short: "Delete profiles", - Long: "Profile configurations ", - RunE: CobraRunE, + Use: "delete [flags] ", + Short: "Delete a node profile", + Long: "This command will delete a node profile.", + RunE: CobraRunE, + Args: cobra.MinimumNArgs(1), } ) -func init() { -} - // GetRootCommand returns the root cobra.Command for the application. func GetCommand() *cobra.Command { return baseCmd diff --git a/internal/app/wwctl/profile/list/root.go b/internal/app/wwctl/profile/list/root.go index 1d3a8b8a..5d055164 100644 --- a/internal/app/wwctl/profile/list/root.go +++ b/internal/app/wwctl/profile/list/root.go @@ -4,16 +4,14 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ - Use: "list", - Short: "List profiles", - Long: "Profile configurations ", - RunE: CobraRunE, + Use: "list [flags] [profile pattern]...", + Short: "List profiles and configurations", + Long: "This command will list and show the profile configurations.", + RunE: CobraRunE, + Aliases: []string{"ls"}, } ) -func init() { -} - // GetRootCommand returns the root cobra.Command for the application. func GetCommand() *cobra.Command { return baseCmd diff --git a/internal/app/wwctl/profile/root.go b/internal/app/wwctl/profile/root.go index 83922375..faa89044 100644 --- a/internal/app/wwctl/profile/root.go +++ b/internal/app/wwctl/profile/root.go @@ -10,11 +10,10 @@ import ( var ( baseCmd = &cobra.Command{ - Use: "profile", - Short: "Management of node configuration profiles", - Long: "Warewulf profiles...", + Use: "profile", + Short: "Node configuration profile management", + Long: "Management of node profile settings", } - test bool ) func init() { diff --git a/internal/app/wwctl/profile/set/root.go b/internal/app/wwctl/profile/set/root.go index 875fa3e8..d24533a6 100644 --- a/internal/app/wwctl/profile/set/root.go +++ b/internal/app/wwctl/profile/set/root.go @@ -4,9 +4,10 @@ import "github.com/spf13/cobra" var ( baseCmd = &cobra.Command{ - Use: "set", - Short: "Set profile configurations", - Long: "Profile configurations ", + Use: "set [flags] ...", + Short: "Configure node profile properties", + Long: "This command will allow you to set configuration properties for node profiles.", + Args: cobra.MinimumNArgs(1), RunE: CobraRunE, } SetAll bool diff --git a/internal/app/wwctl/ready/root.go b/internal/app/wwctl/ready/root.go index 221b6d65..b8c5bad6 100644 --- a/internal/app/wwctl/ready/root.go +++ b/internal/app/wwctl/ready/root.go @@ -8,14 +8,10 @@ var ( baseCmd = &cobra.Command{ Use: "ready", Short: "Warewulf Status Check", - Long: "Warewulf Status Check", RunE: CobraRunE, } ) -func init() { -} - // GetRootCommand returns the root cobra.Command for the application. func GetCommand() *cobra.Command { return baseCmd diff --git a/internal/app/wwctl/root.go b/internal/app/wwctl/root.go index e3bd91fe..430938bf 100644 --- a/internal/app/wwctl/root.go +++ b/internal/app/wwctl/root.go @@ -6,10 +6,10 @@ import ( "github.com/hpcng/warewulf/internal/app/wwctl/kernel" "github.com/hpcng/warewulf/internal/app/wwctl/node" "github.com/hpcng/warewulf/internal/app/wwctl/overlay" + "github.com/hpcng/warewulf/internal/app/wwctl/power" "github.com/hpcng/warewulf/internal/app/wwctl/profile" "github.com/hpcng/warewulf/internal/app/wwctl/ready" "github.com/hpcng/warewulf/internal/app/wwctl/server" - "github.com/hpcng/warewulf/internal/pkg/wwlog" "github.com/spf13/cobra" ) @@ -36,7 +36,7 @@ func init() { rootCmd.AddCommand(container.GetCommand()) rootCmd.AddCommand(node.GetCommand()) rootCmd.AddCommand(kernel.GetCommand()) - // rootCmd.AddCommand(group.GetCommand()) + rootCmd.AddCommand(power.GetCommand()) rootCmd.AddCommand(profile.GetCommand()) rootCmd.AddCommand(configure.GetCommand()) rootCmd.AddCommand(ready.GetCommand()) diff --git a/internal/app/wwctl/server/root.go b/internal/app/wwctl/server/root.go index b368ac4d..0ab1e49a 100644 --- a/internal/app/wwctl/server/root.go +++ b/internal/app/wwctl/server/root.go @@ -11,7 +11,7 @@ var ( baseCmd = &cobra.Command{ Use: "server", Short: "Warewulf server process commands", - Long: "Warewulf profiles...", + Long: "This command will allow you to control the Warewulf daemon process.", } test bool ) @@ -20,7 +20,6 @@ func init() { baseCmd.AddCommand(start.GetCommand()) baseCmd.AddCommand(status.GetCommand()) baseCmd.AddCommand(stop.GetCommand()) - } // GetRootCommand returns the root cobra.Command for the application. diff --git a/internal/app/wwctl/server/start/main.go b/internal/app/wwctl/server/start/main.go index b3c2b339..93a6d147 100644 --- a/internal/app/wwctl/server/start/main.go +++ b/internal/app/wwctl/server/start/main.go @@ -7,5 +7,9 @@ import ( func CobraRunE(cmd *cobra.Command, args []string) error { - return warewulfd.DaemonStart() + if SetForeground == true { + return warewulfd.RunServer() + } else { + return warewulfd.DaemonStart() + } } diff --git a/internal/app/wwctl/server/start/root.go b/internal/app/wwctl/server/start/root.go index 357e0169..2d4ca442 100644 --- a/internal/app/wwctl/server/start/root.go +++ b/internal/app/wwctl/server/start/root.go @@ -6,12 +6,13 @@ var ( baseCmd = &cobra.Command{ Use: "start", Short: "Start Warewulf server", - Long: "Warewulf Server ", RunE: CobraRunE, } + SetForeground bool ) func init() { + baseCmd.PersistentFlags().BoolVarP(&SetForeground, "foreground", "f", false, "Run daemon process in the foreground") } // GetRootCommand returns the root cobra.Command for the application. diff --git a/internal/app/wwctl/server/status/root.go b/internal/app/wwctl/server/status/root.go index 71805969..d7e6270a 100644 --- a/internal/app/wwctl/server/status/root.go +++ b/internal/app/wwctl/server/status/root.go @@ -6,14 +6,10 @@ var ( baseCmd = &cobra.Command{ Use: "status", Short: "Warewulf server status", - Long: "Warewulf Server ", RunE: CobraRunE, } ) -func init() { -} - // GetRootCommand returns the root cobra.Command for the application. func GetCommand() *cobra.Command { return baseCmd diff --git a/internal/app/wwctl/server/stop/root.go b/internal/app/wwctl/server/stop/root.go index fd331c56..23549d95 100644 --- a/internal/app/wwctl/server/stop/root.go +++ b/internal/app/wwctl/server/stop/root.go @@ -6,14 +6,10 @@ var ( baseCmd = &cobra.Command{ Use: "stop", Short: "Stop Warewulf server", - Long: "Warewulf Server ", RunE: CobraRunE, } ) -func init() { -} - // GetRootCommand returns the root cobra.Command for the application. func GetCommand() *cobra.Command { return baseCmd diff --git a/internal/pkg/overlay/overlay.go b/internal/pkg/overlay/overlay.go index 3bbe5bc0..153567e7 100644 --- a/internal/pkg/overlay/overlay.go +++ b/internal/pkg/overlay/overlay.go @@ -46,7 +46,7 @@ func FindSystemOverlays() ([]string, error) { } func FindRuntimeOverlays() ([]string, error) { - return findAllOverlays("system") + return findAllOverlays("runtime") } func SystemOverlayInit(name string) error {