Merge branch 'main' of github.com:gmkurtzer/warewulf into netdev_refactor

This commit is contained in:
Gregory Kurtzer
2021-12-28 15:17:21 -08:00
80 changed files with 735 additions and 232 deletions

View File

@@ -4,9 +4,10 @@ import "github.com/spf13/cobra"
var (
baseCmd = &cobra.Command{
Use: "add [flags] [node pattern]",
DisableFlagsInUseLine: true,
Use: "add [OPTIONS] NODENAME",
Short: "Add new node to Warewulf",
Long: "This command will add a new node to Warewulf.",
Long: "This command will add a new node named NODENAME to Warewulf.",
RunE: CobraRunE,
Args: cobra.MinimumNArgs(1),
}

View File

@@ -49,11 +49,13 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
ipmiCmd := power.IPMI{
NodeName: node.Id.Get(),
HostName: node.IpmiIpaddr.Get(),
User: node.IpmiUserName.Get(),
Password: node.IpmiPassword.Get(),
AuthType: "MD5",
NodeName: node.Id.Get(),
HostName: node.IpmiIpaddr.Get(),
Port: node.IpmiPort.Get(),
User: node.IpmiUserName.Get(),
Password: node.IpmiPassword.Get(),
AuthType: "MD5",
Interface: node.IpmiInterface.Get(),
}
err := ipmiCmd.Console()

View File

@@ -6,9 +6,10 @@ import (
var (
powerCmd = &cobra.Command{
Use: "console [flags] [node pattern]",
DisableFlagsInUseLine: true,
Use: "console [OPTIONS] NODENAME",
Short: "Connect to IPMI console",
Long: "Start IPMI console for a singe node.",
Long: "Start a new IPMI console for NODENAME.",
Args: cobra.MinimumNArgs(1),
RunE: CobraRunE,
}

View File

@@ -7,9 +7,10 @@ import (
var (
baseCmd = &cobra.Command{
Use: "delete [flags] [exact node name]...",
DisableFlagsInUseLine: true,
Use: "delete [OPTIONS] NODE [NODE ...]",
Short: "Delete a node from Warewulf",
Long: "This command will remove a node from the Warewulf node configuration.",
Long: "This command will remove NODE(s) from the Warewulf node configuration.",
Args: cobra.MinimumNArgs(1),
RunE: CobraRunE,
Aliases: []string{"rm", "del"},

View File

@@ -85,11 +85,11 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
} else if ShowIpmi {
fmt.Printf("%-22s %-16s %-5s %-20s %-20s %-20s\n", "NODE NAME", "IPMI IPADDR", "IPMI PORT", "IPMI USERNAME", "IPMI PASSWORD", "IPMI INTERFACE")
fmt.Println(strings.Repeat("=", 80))
fmt.Printf("%-22s %-16s %-10s %-20s %-20s %-14s\n", "NODE NAME", "IPMI IPADDR", "IPMI PORT", "IPMI USERNAME", "IPMI PASSWORD", "IPMI INTERFACE")
fmt.Println(strings.Repeat("=", 108))
for _, node := range node.FilterByName(nodes, args) {
fmt.Printf("%-22s %-16s %-5s %-20s %-20s %-20s\n", node.Id.Get(), node.IpmiIpaddr.Print(), node.IpmiPort.Print(), node.IpmiUserName.Print(), node.IpmiPassword.Print(), node.IpmiInterface.Print())
fmt.Printf("%-22s %-16s %-10s %-20s %-20s %-14s\n", node.Id.Get(), node.IpmiIpaddr.Print(), node.IpmiPort.Print(), node.IpmiUserName.Print(), node.IpmiPassword.Print(), node.IpmiInterface.Print())
}
} else if ShowLong {

View File

@@ -1,14 +1,32 @@
package list
import "github.com/spf13/cobra"
import (
"github.com/hpcng/warewulf/internal/pkg/node"
"github.com/spf13/cobra"
)
var (
baseCmd = &cobra.Command{
Use: "list [flags] (node pattern)",
Short: "List nodes matching pattern",
Long: "This command will show you configured nodes.",
DisableFlagsInUseLine: true,
Use: "list [OPTIONS] [PATTERN]",
Short: "List nodes",
Long: "This command lists all configured nodes. Optionally, it will list only\n" +
"nodes matching a glob PATTERN.",
RunE: CobraRunE,
Aliases: []string{"ls"},
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
return nil, cobra.ShellCompDirectiveNoFileComp
}
nodeDB, _ := node.New()
nodes, _ := nodeDB.FindAllNodes()
var node_names []string
for _, node := range nodes {
node_names = append(node_names, node.Id.Get())
}
return node_names, cobra.ShellCompDirectiveNoFileComp
},
}
ShowNet bool
ShowIpmi bool

View File

@@ -7,8 +7,10 @@ import (
var (
baseCmd = &cobra.Command{
Use: "ready",
Short: "Warewulf Status Check",
DisableFlagsInUseLine: true,
Use: "ready [OPTIONS]",
Short: "Warewulf status check",
Long: "Provides the current status of all Warewulf nodes.",
RunE: CobraRunE,
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {

View File

@@ -13,7 +13,8 @@ import (
var (
baseCmd = &cobra.Command{
Use: "node",
DisableFlagsInUseLine: true,
Use: "node COMMAND [OPTONS]",
Short: "Node management",
Long: "Management of node settings. All node ranges can use brackets to identify\n" +
"node ranges. For example: n00[00-4].cluster[0-1] will identify the first 5 nodes\n" +

View File

@@ -7,9 +7,10 @@ import (
var (
powerCmd = &cobra.Command{
Use: "sensors [flags] [node pattern]",
Short: "Show node's IPMI sensor information",
Long: "Show IPMI sensors for a single node.",
DisableFlagsInUseLine: true,
Use: "sensors [OPTIONS] PATTERN",
Short: "Show node IPMI sensor information",
Long: "Show IPMI sensor information for nodes matching PATTERN.",
Args: cobra.MinimumNArgs(1),
RunE: CobraRunE,
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {

View File

@@ -12,9 +12,10 @@ import (
var (
baseCmd = &cobra.Command{
Use: "set [flags] [node pattern]...",
DisableFlagsInUseLine: true,
Use: "set [OPTIONS] PATTERN [PATTERN ...]",
Short: "Configure node properties",
Long: "This command will allow you to set configuration properties for nodes.\n\n" +
Long: "This command sets configuration properties for nodes matching PATTERN.\n\n" +
"Note: use the string 'UNSET' to remove a configuration",
Args: cobra.MinimumNArgs(1),
RunE: CobraRunE,