diff --git a/internal/app/wwctl/node/set/main.go b/internal/app/wwctl/node/set/main.go index 512d8943..59f3e7c5 100644 --- a/internal/app/wwctl/node/set/main.go +++ b/internal/app/wwctl/node/set/main.go @@ -169,18 +169,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 != "" { diff --git a/internal/app/wwctl/profile/set/main.go b/internal/app/wwctl/profile/set/main.go index d8b4553f..09d4c288 100644 --- a/internal/app/wwctl/profile/set/main.go +++ b/internal/app/wwctl/profile/set/main.go @@ -144,17 +144,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/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/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"` } /****** 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