From cb1455bd8be4caed64327f0b11418cc1764c93f0 Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Fri, 1 Oct 2021 00:05:41 -0700 Subject: [PATCH] Allow `--discoverable` option to be set via profiles (ref: #159) --- internal/app/wwctl/profile/set/main.go | 10 ++++++++++ internal/app/wwctl/profile/set/root.go | 4 ++++ internal/pkg/node/constructors.go | 3 +++ 3 files changed, 17 insertions(+) diff --git a/internal/app/wwctl/profile/set/main.go b/internal/app/wwctl/profile/set/main.go index 246b7b15..667111f7 100644 --- a/internal/app/wwctl/profile/set/main.go +++ b/internal/app/wwctl/profile/set/main.go @@ -120,6 +120,16 @@ func CobraRunE(cmd *cobra.Command, args []string) error { p.IpmiInterface.Set(SetIpmiInterface) } + if SetDiscoverable { + wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting all nodes to discoverable\n", p.Id.Get()) + p.Discoverable.SetB(true) + } + + if SetUndiscoverable { + wwlog.Printf(wwlog.VERBOSE, "Profile: %s, Setting all nodes to undiscoverable\n", p.Id.Get()) + p.Discoverable.SetB(false) + } + if SetNetDevDel { if SetNetDev == "" { wwlog.Printf(wwlog.ERROR, "You must include the '--netdev' option\n") diff --git a/internal/app/wwctl/profile/set/root.go b/internal/app/wwctl/profile/set/root.go index 14b57b6d..cb0b765a 100644 --- a/internal/app/wwctl/profile/set/root.go +++ b/internal/app/wwctl/profile/set/root.go @@ -56,6 +56,8 @@ var ( SetType string SetNetDevDel bool SetNetDevDefault bool + SetDiscoverable bool + SetUndiscoverable bool SetInit string SetRoot string SetKey string @@ -123,6 +125,8 @@ func init() { baseCmd.PersistentFlags().BoolVarP(&SetAll, "all", "a", false, "Set all profiles") baseCmd.PersistentFlags().BoolVarP(&SetForce, "force", "f", false, "Force configuration (even on error)") baseCmd.PersistentFlags().BoolVarP(&SetYes, "yes", "y", false, "Set 'yes' to all questions asked") + baseCmd.PersistentFlags().BoolVar(&SetDiscoverable, "discoverable", false, "Make this node discoverable") + baseCmd.PersistentFlags().BoolVar(&SetUndiscoverable, "undiscoverable", false, "Remove the discoverable flag") } // GetRootCommand returns the root cobra.Command for the application. diff --git a/internal/pkg/node/constructors.go b/internal/pkg/node/constructors.go index 7dd55277..596a6b43 100644 --- a/internal/pkg/node/constructors.go +++ b/internal/pkg/node/constructors.go @@ -130,6 +130,9 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) { n.IpmiInterface.SetAlt(config.NodeProfiles[p].IpmiInterface, p) n.SystemOverlay.SetAlt(config.NodeProfiles[p].SystemOverlay, p) n.RuntimeOverlay.SetAlt(config.NodeProfiles[p].RuntimeOverlay, p) + + n.Discoverable.SetAltB(config.NodeProfiles[p].Discoverable, p) + n.Root.SetAlt(config.NodeProfiles[p].Root, p) for devname, netdev := range config.NodeProfiles[p].NetDevs {