Merge branch 'main' of github.com:hpcng/warewulf into jcsiadal-loops
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/container"
|
||||
"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"
|
||||
)
|
||||
@@ -27,14 +26,15 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
nodemap[n.ContainerName.Get()]++
|
||||
}
|
||||
|
||||
fmt.Printf("%-35s %-6s %-6s\n", "CONTAINER NAME", "BUILT", "NODES")
|
||||
fmt.Printf("%-25s %-6s %-6s\n", "CONTAINER NAME", "NODES", "KERNEL VERSION")
|
||||
for _, source := range sources {
|
||||
image := container.ImageFile(source)
|
||||
|
||||
if nodemap[source] == 0 {
|
||||
nodemap[source] = 0
|
||||
}
|
||||
fmt.Printf("%-35s %-6t %-6d\n", source, util.IsFile(image), nodemap[source])
|
||||
|
||||
wwlog.Printf(wwlog.DEBUG, "Finding kernel version for: %s\n", source)
|
||||
kernelVersion := container.KernelVersion(source)
|
||||
fmt.Printf("%-25s %-6d %s\n", source, nodemap[source], kernelVersion)
|
||||
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -23,7 +23,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
ARG_LOOP:
|
||||
for _, arg := range args {
|
||||
for _, n := range nodes {
|
||||
if n.KernelVersion.Get() == arg {
|
||||
if n.KernelOverride.Get() == arg {
|
||||
wwlog.Printf(wwlog.ERROR, "Kernel is configured for nodes, skipping: %s\n", arg)
|
||||
continue ARG_LOOP
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
DisableFlagsInUseLine: true,
|
||||
Use: "delete [OPTIONS] KERNEL [...]",
|
||||
Short: "Delete imported kernels",
|
||||
Long: "This command will delete KERNEL versions that have been imported into Warewulf.",
|
||||
RunE: CobraRunE,
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
Use: "delete [OPTIONS] KERNEL [...]",
|
||||
Short: "Delete imported kernels",
|
||||
Long: "This command will delete KERNEL versions that have been imported into Warewulf.",
|
||||
RunE: CobraRunE,
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
if len(args) != 0 {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
|
||||
@@ -70,7 +70,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
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])
|
||||
profile.KernelOverride.Set(args[0])
|
||||
err := nodeDB.ProfileUpdate(profile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to update node profile")
|
||||
|
||||
@@ -23,7 +23,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
nodemap := make(map[string]int)
|
||||
|
||||
for _, n := range nodes {
|
||||
nodemap[n.KernelVersion.Get()]++
|
||||
nodemap[n.KernelOverride.Get()]++
|
||||
}
|
||||
|
||||
fmt.Printf("%-35s %-25s %-6s\n", "KERNEL NAME", "KERNEL VERSION", "NODES")
|
||||
|
||||
@@ -5,12 +5,12 @@ import "github.com/spf13/cobra"
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
DisableFlagsInUseLine: true,
|
||||
Use: "list [OPTIONS]",
|
||||
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"},
|
||||
Use: "list [OPTIONS]",
|
||||
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"},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
DisableFlagsInUseLine: true,
|
||||
Use: "kernel COMMAND [OPTIONS]",
|
||||
Short: "Kernel Image Management",
|
||||
Long: "This command manages Warewulf Kernels used for bootstrapping nodes",
|
||||
Use: "kernel COMMAND [OPTIONS]",
|
||||
Short: "Kernel Image Management",
|
||||
Long: "This command manages Warewulf Kernels used for bootstrapping nodes",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
fmt.Printf("%-20s %-18s %-12s %t\n", node.Id.Get(), "Discoverable", node.Discoverable.Source(), node.Discoverable.PrintB())
|
||||
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Container", node.ContainerName.Source(), node.ContainerName.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "Kernel", node.KernelVersion.Source(), node.KernelVersion.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "KernelOverride", node.KernelOverride.Source(), node.KernelOverride.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "KernelArgs", node.KernelArgs.Source(), node.KernelArgs.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "SystemOverlay", node.SystemOverlay.Source(), node.SystemOverlay.Print())
|
||||
fmt.Printf("%-20s %-18s %-12s %s\n", node.Id.Get(), "RuntimeOverlay", node.RuntimeOverlay.Source(), node.RuntimeOverlay.Print())
|
||||
@@ -97,11 +97,11 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
} else if ShowLong {
|
||||
fmt.Printf("%-22s %-26s %-35s %s\n", "NODE NAME", "KERNEL", "CONTAINER", "OVERLAYS (S/R)")
|
||||
fmt.Printf("%-22s %-26s %-35s %s\n", "NODE NAME", "KERNEL OVERRIDE", "CONTAINER", "OVERLAYS (S/R)")
|
||||
fmt.Println(strings.Repeat("=", 120))
|
||||
|
||||
for _, node := range node.FilterByName(nodes, args) {
|
||||
fmt.Printf("%-22s %-26s %-35s %s\n", node.Id.Get(), node.KernelVersion.Print(), node.ContainerName.Print(), node.SystemOverlay.Print()+"/"+node.RuntimeOverlay.Print())
|
||||
fmt.Printf("%-22s %-26s %-35s %s\n", node.Id.Get(), node.KernelOverride.Print(), node.ContainerName.Print(), node.SystemOverlay.Print()+"/"+node.RuntimeOverlay.Print())
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@@ -70,9 +70,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
n.AssetKey.Set(SetAssetKey)
|
||||
}
|
||||
|
||||
if SetKernel != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting kernel to: %s\n", n.Id.Get(), SetKernel)
|
||||
n.KernelVersion.Set(SetKernel)
|
||||
if SetKernelOverride != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Node: %s, Setting kernel override to: %s\n", n.Id.Get(), SetKernelOverride)
|
||||
n.KernelOverride.Set(SetKernelOverride)
|
||||
}
|
||||
|
||||
if SetKernelArgs != "" {
|
||||
|
||||
@@ -34,7 +34,7 @@ var (
|
||||
}
|
||||
SetComment string
|
||||
SetContainer string
|
||||
SetKernel string
|
||||
SetKernelOverride string
|
||||
SetKernelArgs string
|
||||
SetNetName string
|
||||
SetNetDev string
|
||||
@@ -82,8 +82,8 @@ func init() {
|
||||
}); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
baseCmd.PersistentFlags().StringVarP(&SetKernel, "kernel", "K", "", "Set Kernel version for nodes")
|
||||
if err := baseCmd.RegisterFlagCompletionFunc("kernel", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
baseCmd.PersistentFlags().StringVarP(&SetKernelOverride, "kerneloverride", "K", "", "Set kernel override version for nodes")
|
||||
if err := baseCmd.RegisterFlagCompletionFunc("kerneloverride", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
list, _ := kernel.ListKernels()
|
||||
return list, cobra.ShellCompDirectiveNoFileComp
|
||||
}); err != nil {
|
||||
|
||||
@@ -33,7 +33,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "Cluster", profile.ClusterName.Print())
|
||||
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "Container", profile.ContainerName.Print())
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "Kernel", profile.KernelVersion.Print())
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "KernelOverride", profile.KernelOverride.Print())
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "KernelArgs", profile.KernelArgs.Print())
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "Init", profile.Init.Print())
|
||||
fmt.Printf("%-20s %-18s %s\n", profile.Id.Get(), "Root", profile.Root.Print())
|
||||
|
||||
@@ -75,9 +75,9 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
p.AssetKey.Set(SetAssetKey)
|
||||
}
|
||||
|
||||
if SetKernel != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting Kernel to: %s\n", p.Id.Get(), SetKernel)
|
||||
p.KernelVersion.Set(SetKernel)
|
||||
if SetKernelOverride != "" {
|
||||
wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting Kernel override version to: %s\n", p.Id.Get(), SetKernelOverride)
|
||||
p.KernelOverride.Set(SetKernelOverride)
|
||||
}
|
||||
|
||||
if SetKernelArgs != "" {
|
||||
|
||||
@@ -37,7 +37,7 @@ var (
|
||||
SetForce bool
|
||||
SetComment string
|
||||
SetContainer string
|
||||
SetKernel string
|
||||
SetKernelOverride string
|
||||
SetKernelArgs string
|
||||
SetClusterName string
|
||||
SetIpxe string
|
||||
@@ -77,8 +77,8 @@ func init() {
|
||||
}); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
baseCmd.PersistentFlags().StringVarP(&SetKernel, "kernel", "K", "", "Set Kernel version for nodes")
|
||||
if err := baseCmd.RegisterFlagCompletionFunc("kernel", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
baseCmd.PersistentFlags().StringVarP(&SetKernelOverride, "kerneloverride", "K", "", "Set kernel override version for nodes")
|
||||
if err := baseCmd.RegisterFlagCompletionFunc("kerneloverride", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
list, _ := kernel.ListKernels()
|
||||
return list, cobra.ShellCompDirectiveNoFileComp
|
||||
}); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user