diff --git a/internal/app/wwctl/kernel/delete/main.go b/internal/app/wwctl/kernel/delete/main.go index c289a27d..ab2efe70 100644 --- a/internal/app/wwctl/kernel/delete/main.go +++ b/internal/app/wwctl/kernel/delete/main.go @@ -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 } diff --git a/internal/app/wwctl/kernel/delete/root.go b/internal/app/wwctl/kernel/delete/root.go index 5fc68bea..1ae1c8b9 100644 --- a/internal/app/wwctl/kernel/delete/root.go +++ b/internal/app/wwctl/kernel/delete/root.go @@ -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 diff --git a/internal/app/wwctl/kernel/imprt/main.go b/internal/app/wwctl/kernel/imprt/main.go index 97e3e219..d9513eff 100644 --- a/internal/app/wwctl/kernel/imprt/main.go +++ b/internal/app/wwctl/kernel/imprt/main.go @@ -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") diff --git a/internal/app/wwctl/kernel/list/main.go b/internal/app/wwctl/kernel/list/main.go index a3a8d4ad..628a63b3 100644 --- a/internal/app/wwctl/kernel/list/main.go +++ b/internal/app/wwctl/kernel/list/main.go @@ -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") diff --git a/internal/app/wwctl/kernel/list/root.go b/internal/app/wwctl/kernel/list/root.go index fba84101..08fdbd09 100644 --- a/internal/app/wwctl/kernel/list/root.go +++ b/internal/app/wwctl/kernel/list/root.go @@ -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"}, } ) diff --git a/internal/app/wwctl/kernel/root.go b/internal/app/wwctl/kernel/root.go index bb0cdb8d..3717a3b0 100644 --- a/internal/app/wwctl/kernel/root.go +++ b/internal/app/wwctl/kernel/root.go @@ -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", } ) diff --git a/internal/app/wwctl/node/list/main.go b/internal/app/wwctl/node/list/main.go index 0e6845c8..4fe66890 100644 --- a/internal/app/wwctl/node/list/main.go +++ b/internal/app/wwctl/node/list/main.go @@ -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 { diff --git a/internal/app/wwctl/node/set/main.go b/internal/app/wwctl/node/set/main.go index 59f3e7c5..66324ea9 100644 --- a/internal/app/wwctl/node/set/main.go +++ b/internal/app/wwctl/node/set/main.go @@ -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 != "" { diff --git a/internal/app/wwctl/node/set/root.go b/internal/app/wwctl/node/set/root.go index a3feec62..f405aebf 100644 --- a/internal/app/wwctl/node/set/root.go +++ b/internal/app/wwctl/node/set/root.go @@ -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 { diff --git a/internal/app/wwctl/profile/list/main.go b/internal/app/wwctl/profile/list/main.go index a419952e..03219706 100644 --- a/internal/app/wwctl/profile/list/main.go +++ b/internal/app/wwctl/profile/list/main.go @@ -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()) diff --git a/internal/app/wwctl/profile/set/main.go b/internal/app/wwctl/profile/set/main.go index 09d4c288..18158196 100644 --- a/internal/app/wwctl/profile/set/main.go +++ b/internal/app/wwctl/profile/set/main.go @@ -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 != "" { diff --git a/internal/app/wwctl/profile/set/root.go b/internal/app/wwctl/profile/set/root.go index d8b08dc6..48782e63 100644 --- a/internal/app/wwctl/profile/set/root.go +++ b/internal/app/wwctl/profile/set/root.go @@ -37,7 +37,7 @@ var ( SetForce bool SetComment string SetContainer string - SetKernel string + SetKernelOverride string SetKernelArgs string SetClusterName string SetIpxe string @@ -79,8 +79,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 { diff --git a/internal/pkg/node/constructors.go b/internal/pkg/node/constructors.go index ebf35397..ec8211be 100644 --- a/internal/pkg/node/constructors.go +++ b/internal/pkg/node/constructors.go @@ -72,7 +72,6 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) { n.Id.Set(nodename) n.Comment.Set(node.Comment) n.ContainerName.Set(node.ContainerName) - n.KernelVersion.Set(node.KernelVersion) n.KernelArgs.Set(node.KernelArgs) n.ClusterName.Set(node.ClusterName) n.Ipxe.Set(node.Ipxe) @@ -90,6 +89,12 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) { n.AssetKey.Set(node.AssetKey) n.Discoverable.Set(node.Discoverable) + if node.KernelOverride != "" { + n.KernelOverride.Set(node.KernelOverride) + } else if node.KernelVersion != "" { + n.KernelOverride.Set(node.KernelVersion) + } + for devname, netdev := range node.NetDevs { if _, ok := n.NetDevs[devname]; !ok { var netdev NetDevEntry @@ -134,7 +139,6 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) { n.Comment.SetAlt(config.NodeProfiles[p].Comment, p) n.ClusterName.SetAlt(config.NodeProfiles[p].ClusterName, p) n.ContainerName.SetAlt(config.NodeProfiles[p].ContainerName, p) - n.KernelVersion.SetAlt(config.NodeProfiles[p].KernelVersion, p) n.KernelArgs.SetAlt(config.NodeProfiles[p].KernelArgs, p) n.Ipxe.SetAlt(config.NodeProfiles[p].Ipxe, p) n.Init.SetAlt(config.NodeProfiles[p].Init, p) @@ -151,6 +155,12 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) { n.AssetKey.SetAlt(config.NodeProfiles[p].AssetKey, p) n.Discoverable.SetAlt(config.NodeProfiles[p].Discoverable, p) + if config.NodeProfiles[p].KernelOverride != "" { + n.KernelOverride.SetAlt(config.NodeProfiles[p].KernelOverride, p) + } else if config.NodeProfiles[p].KernelVersion != "" { + n.KernelOverride.SetAlt(config.NodeProfiles[p].KernelVersion, p) + } + for devname, netdev := range config.NodeProfiles[p].NetDevs { if _, ok := n.NetDevs[devname]; !ok { var netdev NetDevEntry @@ -218,7 +228,6 @@ func (config *nodeYaml) FindAllProfiles() ([]NodeInfo, error) { p.ContainerName.Set(profile.ContainerName) p.Ipxe.Set(profile.Ipxe) p.Init.Set(profile.Init) - p.KernelVersion.Set(profile.KernelVersion) p.KernelArgs.Set(profile.KernelArgs) p.IpmiNetmask.Set(profile.IpmiNetmask) p.IpmiPort.Set(profile.IpmiPort) @@ -232,6 +241,12 @@ func (config *nodeYaml) FindAllProfiles() ([]NodeInfo, error) { p.AssetKey.Set(profile.AssetKey) p.Discoverable.Set(profile.Discoverable) + if profile.KernelOverride != "" { + p.KernelOverride.Set(profile.KernelOverride) + } else if profile.KernelVersion != "" { + p.KernelOverride.Set(profile.KernelVersion) + } + for devname, netdev := range profile.NetDevs { if _, ok := p.NetDevs[devname]; !ok { var netdev NetDevEntry diff --git a/internal/pkg/node/datastructure.go b/internal/pkg/node/datastructure.go index 7b273f82..fed82f39 100644 --- a/internal/pkg/node/datastructure.go +++ b/internal/pkg/node/datastructure.go @@ -20,6 +20,7 @@ type NodeConf struct { ContainerName string `yaml:"container name,omitempty"` Ipxe string `yaml:"ipxe template,omitempty"` KernelVersion string `yaml:"kernel version,omitempty"` + KernelOverride string `yaml:"kernel override,omitempty"` KernelArgs string `yaml:"kernel args,omitempty"` IpmiUserName string `yaml:"ipmi username,omitempty"` IpmiPassword string `yaml:"ipmi password,omitempty"` @@ -71,7 +72,7 @@ type NodeInfo struct { ClusterName Entry ContainerName Entry Ipxe Entry - KernelVersion Entry + KernelOverride Entry KernelArgs Entry IpmiIpaddr Entry IpmiNetmask Entry diff --git a/internal/pkg/node/modifiers.go b/internal/pkg/node/modifiers.go index 6502be84..92628592 100644 --- a/internal/pkg/node/modifiers.go +++ b/internal/pkg/node/modifiers.go @@ -60,7 +60,7 @@ func (config *nodeYaml) NodeUpdate(node NodeInfo) error { config.Nodes[nodeID].ClusterName = node.ClusterName.GetReal() config.Nodes[nodeID].Ipxe = node.Ipxe.GetReal() config.Nodes[nodeID].Init = node.Init.GetReal() - config.Nodes[nodeID].KernelVersion = node.KernelVersion.GetReal() + config.Nodes[nodeID].KernelOverride = node.KernelOverride.GetReal() config.Nodes[nodeID].KernelArgs = node.KernelArgs.GetReal() config.Nodes[nodeID].IpmiIpaddr = node.IpmiIpaddr.GetReal() config.Nodes[nodeID].IpmiNetmask = node.IpmiNetmask.GetReal() @@ -148,7 +148,7 @@ func (config *nodeYaml) ProfileUpdate(profile NodeInfo) error { config.NodeProfiles[profileID].Ipxe = profile.Ipxe.GetReal() config.NodeProfiles[profileID].Init = profile.Init.GetReal() config.NodeProfiles[profileID].ClusterName = profile.ClusterName.GetReal() - config.NodeProfiles[profileID].KernelVersion = profile.KernelVersion.GetReal() + config.NodeProfiles[profileID].KernelOverride = profile.KernelOverride.GetReal() config.NodeProfiles[profileID].KernelArgs = profile.KernelArgs.GetReal() config.NodeProfiles[profileID].IpmiIpaddr = profile.IpmiIpaddr.GetReal() config.NodeProfiles[profileID].IpmiNetmask = profile.IpmiNetmask.GetReal() diff --git a/internal/pkg/overlay/overlay.go b/internal/pkg/overlay/overlay.go index 36083519..2a80ba97 100644 --- a/internal/pkg/overlay/overlay.go +++ b/internal/pkg/overlay/overlay.go @@ -25,6 +25,7 @@ type TemplateStruct struct { ClusterName string Container string KernelVersion string + KernelOverride string KernelArgs string Init string Root string @@ -174,7 +175,8 @@ func BuildOverlay(nodeInfo node.NodeInfo, overlayName string) error { tstruct.Hostname = nodeInfo.Id.Get() tstruct.ClusterName = nodeInfo.ClusterName.Get() tstruct.Container = nodeInfo.ContainerName.Get() - tstruct.KernelVersion = nodeInfo.KernelVersion.Get() + tstruct.KernelVersion = nodeInfo.KernelOverride.Get() + tstruct.KernelOverride = nodeInfo.KernelOverride.Get() tstruct.KernelArgs = nodeInfo.KernelArgs.Get() tstruct.Init = nodeInfo.Init.Get() tstruct.Root = nodeInfo.Root.Get() diff --git a/internal/pkg/warewulfd/ipxe.go b/internal/pkg/warewulfd/ipxe.go index 84c11808..e3fe9419 100644 --- a/internal/pkg/warewulfd/ipxe.go +++ b/internal/pkg/warewulfd/ipxe.go @@ -15,18 +15,18 @@ import ( ) type iPxeTemplate struct { - Message string - WaitTime string - Hostname string - Fqdn string - Id string - Cluster string - ContainerName string - Hwaddr string - Ipaddr string - Port string - KernelArgs string - KernelVersion string + Message string + WaitTime string + Hostname string + Fqdn string + Id string + Cluster string + ContainerName string + Hwaddr string + Ipaddr string + Port string + KernelArgs string + KernelOverride string } func IpxeSend(w http.ResponseWriter, req *http.Request) { @@ -140,7 +140,7 @@ func IpxeSend(w http.ResponseWriter, req *http.Request) { replace.Hwaddr = rinfo.hwaddr replace.ContainerName = node.ContainerName.Get() replace.KernelArgs = node.KernelArgs.Get() - replace.KernelVersion = node.KernelVersion.Get() + replace.KernelOverride = node.KernelOverride.Get() err = tmpl.Execute(w, replace) if err != nil { diff --git a/internal/pkg/warewulfd/kernel.go b/internal/pkg/warewulfd/kernel.go index 74286ee7..f386852d 100644 --- a/internal/pkg/warewulfd/kernel.go +++ b/internal/pkg/warewulfd/kernel.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/hpcng/warewulf/internal/pkg/container" + "github.com/hpcng/warewulf/internal/pkg/kernel" ) func KernelSend(w http.ResponseWriter, req *http.Request) { @@ -29,18 +30,25 @@ func KernelSend(w http.ResponseWriter, req *http.Request) { return } - if node.ContainerName.Defined() { - fileName := container.KernelFind(node.ContainerName.Get()) + var fileName string + if node.KernelOverride.Defined() { + fileName = kernel.KernelImage(node.KernelOverride.Get()) - updateStatus(node.Id.Get(), "KERNEL", path.Base(fileName), strings.Split(req.RemoteAddr, ":")[0]) - - err := sendFile(w, fileName, node.Id.Get()) - if err != nil { - daemonLogf("ERROR: %s\n", err) - } + } else if node.ContainerName.Defined() { + fileName = container.KernelFind(node.ContainerName.Get()) } else { w.WriteHeader(503) daemonLogf("WARNING: No 'kernel version' set for node %s\n", node.Id.Get()) + + return } + + updateStatus(node.Id.Get(), "KERNEL", path.Base(fileName), strings.Split(req.RemoteAddr, ":")[0]) + + err = sendFile(w, fileName, node.Id.Get()) + if err != nil { + daemonLogf("ERROR: %s\n", err) + } + } diff --git a/internal/pkg/warewulfd/kmods.go b/internal/pkg/warewulfd/kmods.go index 13ace42b..a8378699 100644 --- a/internal/pkg/warewulfd/kmods.go +++ b/internal/pkg/warewulfd/kmods.go @@ -28,18 +28,14 @@ func KmodsSend(w http.ResponseWriter, req *http.Request) { return } - if node.KernelVersion.Defined() { - fileName := kernel.KmodsImage(node.KernelVersion.Get()) + if node.KernelOverride.Defined() { + fileName := kernel.KmodsImage(node.KernelOverride.Get()) - updateStatus(node.Id.Get(), "KMODS_OVERLAY", node.KernelVersion.Get()+".img", strings.Split(req.RemoteAddr, ":")[0]) + updateStatus(node.Id.Get(), "KMODS_OVERLAY", node.KernelOverride.Get()+".img", strings.Split(req.RemoteAddr, ":")[0]) err := sendFile(w, fileName, node.Id.Get()) if err != nil { daemonLogf("ERROR: %s\n", err) } - - } else { - w.WriteHeader(503) - daemonLogf("WARNING: No 'kernel version' set for node %s\n", node.Id.Get()) } }