Merge pull request #297 from gmkurtzer/discoverable-fix

Discoverable and network fixes
This commit is contained in:
Gregory M. Kurtzer
2022-02-11 19:23:46 -08:00
committed by GitHub
5 changed files with 26 additions and 31 deletions

View File

@@ -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 != "" {

View File

@@ -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)
}
}
}

View File

@@ -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 {

View File

@@ -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"`
}
/******

View File

@@ -104,10 +104,10 @@ func (ent *Entry) Get() string {
}
func (ent *Entry) GetB() bool {
if ent.value == "false" || ent.value == "no" {
if ent.value == "false" || ent.value == "no" || ent.value == "" {
if ent.altvalue == "false" || ent.altvalue == "no" || ent.altvalue == "" {
return false
}
if ent.altvalue == "false" || ent.altvalue == "no" || ent.altvalue == "" {
return false
}
return true