From b1b893861edef1e82ae501da239544f94c3f3ddf Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Sat, 12 Feb 2022 01:53:18 +0000 Subject: [PATCH 1/3] Fix for faulty boolean logic (ref #292) --- internal/pkg/node/constructors.go | 3 --- internal/pkg/node/methods.go | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/internal/pkg/node/constructors.go b/internal/pkg/node/constructors.go index 3e12c133..ebf35397 100644 --- a/internal/pkg/node/constructors.go +++ b/internal/pkg/node/constructors.go @@ -88,7 +88,6 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) { n.RuntimeOverlay.Set(node.RuntimeOverlay) n.Root.Set(node.Root) n.AssetKey.Set(node.AssetKey) - n.Discoverable.Set(node.Discoverable) for devname, netdev := range node.NetDevs { @@ -150,7 +149,6 @@ func (config *nodeYaml) FindAllNodes() ([]NodeInfo, error) { n.RuntimeOverlay.SetAlt(config.NodeProfiles[p].RuntimeOverlay, p) n.Root.SetAlt(config.NodeProfiles[p].Root, p) n.AssetKey.SetAlt(config.NodeProfiles[p].AssetKey, p) - n.Discoverable.SetAlt(config.NodeProfiles[p].Discoverable, p) for devname, netdev := range config.NodeProfiles[p].NetDevs { @@ -232,7 +230,6 @@ func (config *nodeYaml) FindAllProfiles() ([]NodeInfo, error) { p.SystemOverlay.Set(profile.SystemOverlay) p.Root.Set(profile.Root) p.AssetKey.Set(profile.AssetKey) - p.Discoverable.Set(profile.Discoverable) for devname, netdev := range profile.NetDevs { diff --git a/internal/pkg/node/methods.go b/internal/pkg/node/methods.go index 58a457b6..a97fa895 100644 --- a/internal/pkg/node/methods.go +++ b/internal/pkg/node/methods.go @@ -104,10 +104,10 @@ func (ent *Entry) Get() string { } func (ent *Entry) GetB() bool { - if ent.value == "false" || ent.value == "no" { - return false - } - if ent.altvalue == "false" || ent.altvalue == "no" || ent.altvalue == "" { + if ent.value == "false" || ent.value == "no" || ent.value == "" { + if ent.altvalue == "false" || ent.altvalue == "no" || ent.altvalue == "" { + return false + } return false } return true From e6a3810d207bec91cef6f007ff7c15d119395631 Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Sat, 12 Feb 2022 03:08:33 +0000 Subject: [PATCH 2/3] Fixing oddball network configuration parameters --- internal/app/wwctl/node/set/main.go | 4 ---- internal/app/wwctl/profile/set/main.go | 10 ---------- internal/pkg/node/datastructure.go | 16 ++++++++-------- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/internal/app/wwctl/node/set/main.go b/internal/app/wwctl/node/set/main.go index dfa7fd89..2522c087 100644 --- a/internal/app/wwctl/node/set/main.go +++ b/internal/app/wwctl/node/set/main.go @@ -181,10 +181,6 @@ func CobraRunE(cmd *cobra.Command, args []string) error { } n.NetDevs[SetNetName] = &nd - - if SetNetDev == "" { - n.NetDevs[SetNetName].Device.Set(SetNetName) - } } } diff --git a/internal/app/wwctl/profile/set/main.go b/internal/app/wwctl/profile/set/main.go index 7b4f958c..82fa2db1 100644 --- a/internal/app/wwctl/profile/set/main.go +++ b/internal/app/wwctl/profile/set/main.go @@ -145,17 +145,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error { if _, ok := p.NetDevs[SetNetName]; !ok { var nd node.NetDevEntry - SetNetOnBoot = "yes" - - if len(p.NetDevs) == 0 { - SetNetDefault = "yes" - } - p.NetDevs[SetNetName] = &nd - - if SetNetDev == "" { - p.NetDevs[SetNetName].Device.Set(SetNetName) - } } } diff --git a/internal/pkg/node/datastructure.go b/internal/pkg/node/datastructure.go index a66f96a0..7b273f82 100644 --- a/internal/pkg/node/datastructure.go +++ b/internal/pkg/node/datastructure.go @@ -41,16 +41,16 @@ type NodeConf struct { } type NetDevs struct { - Type string - OnBoot string - Device string - Hwaddr string - Ipaddr string + Type string `yaml:"type,omitempty"` + OnBoot string `yaml:"onboot,omitempty"` + Device string `yaml:"device,omitempty"` + Hwaddr string `yaml:"hwaddr,omitempty"` + Ipaddr string `yaml:"ipaddr,omitempty"` IpCIDR string `yaml:"ipcidr,omitempty"` Prefix string `yaml:"prefix,omitempty"` - Netmask string - Gateway string `yaml:"gateway"` - Default string + Netmask string `yaml:"netmask,omitempty"` + Gateway string `yaml:"gateway,omitempty"` + Default string `yaml:"default,omitempty"` } /****** From 1a48bc6ee52df354675797d73c4ea1f6e574b754 Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Sat, 12 Feb 2022 03:21:31 +0000 Subject: [PATCH 3/3] Fixed default network device logic --- internal/app/wwctl/node/set/main.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/internal/app/wwctl/node/set/main.go b/internal/app/wwctl/node/set/main.go index 2522c087..1c0312e6 100644 --- a/internal/app/wwctl/node/set/main.go +++ b/internal/app/wwctl/node/set/main.go @@ -174,14 +174,26 @@ func CobraRunE(cmd *cobra.Command, args []string) error { if _, ok := n.NetDevs[SetNetName]; !ok { var nd node.NetDevEntry - SetNetOnBoot = "yes" - - if len(n.NetDevs) == 0 { - SetNetDefault = "yes" - } - n.NetDevs[SetNetName] = &nd + + if SetNetDev == "" { + n.NetDevs[SetNetName].Device.Set(SetNetName) + } } + var def bool = true + + SetNetOnBoot = "yes" + + for _, n := range n.NetDevs { + if n.Default.GetB() { + def = false + } + } + + if def { + SetNetDefault = "yes" + } + } if SetNetDev != "" {