set the primary network in NodeInfo not in NetDev
Prior the primary was a boolean attribute of NetDev, so several NetDevs could have been primay. Setting is as a sting in NodeConf assures that only one network could be primary. If no primary network is set, a valid altvalue will be set.
This commit is contained in:
@@ -134,13 +134,6 @@ func (config *NodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
|||||||
for _, netdev := range n.NetDevs {
|
for _, netdev := range n.NetDevs {
|
||||||
netdev.SetDefFrom(defConfNet)
|
netdev.SetDefFrom(defConfNet)
|
||||||
}
|
}
|
||||||
// set default/primary network is just one network exist
|
|
||||||
if len(n.NetDevs) == 1 {
|
|
||||||
// only way to get the key
|
|
||||||
for key := range node.NetDevs {
|
|
||||||
n.NetDevs[key].Primary.SetDefaultB(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// backward compatibility
|
// backward compatibility
|
||||||
n.Ipmi.Ipaddr.Set(node.IpmiIpaddr)
|
n.Ipmi.Ipaddr.Set(node.IpmiIpaddr)
|
||||||
n.Ipmi.Netmask.Set(node.IpmiNetmask)
|
n.Ipmi.Netmask.Set(node.IpmiNetmask)
|
||||||
@@ -178,6 +171,20 @@ func (config *NodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
|||||||
wwlog.Verbose("Merging profile into node: %s <- %s", nodename, profileName)
|
wwlog.Verbose("Merging profile into node: %s <- %s", nodename, profileName)
|
||||||
n.SetAltFrom(config.NodeProfiles[profileName], profileName)
|
n.SetAltFrom(config.NodeProfiles[profileName], profileName)
|
||||||
}
|
}
|
||||||
|
// set default/primary network is just one network exist
|
||||||
|
if len(n.NetDevs) >= 1 {
|
||||||
|
tmpNets := make([]string, 0, len(n.NetDevs))
|
||||||
|
for key := range node.NetDevs {
|
||||||
|
tmpNets = append(tmpNets, key)
|
||||||
|
}
|
||||||
|
sort.Strings(tmpNets)
|
||||||
|
// if a value is present in profile or node, default is not visible
|
||||||
|
wwlog.Debug("%s setting primary network device: %s", n.Id.Get(), tmpNets[0])
|
||||||
|
n.PrimaryNetDev.SetDefault(tmpNets[0])
|
||||||
|
}
|
||||||
|
if dev, ok := n.NetDevs[n.PrimaryNetDev.Get()]; ok {
|
||||||
|
dev.Primary.SetDefaultB(true)
|
||||||
|
}
|
||||||
ret = append(ret, n)
|
ret = append(ret, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ type NodeConf struct {
|
|||||||
Tags map[string]string `yaml:"tags,omitempty" lopt:"tagadd" comment:"base key"`
|
Tags map[string]string `yaml:"tags,omitempty" lopt:"tagadd" comment:"base key"`
|
||||||
TagsDel []string `yaml:"tagsdel,omitempty" lopt:"tagdel" comment:"remove this tags"` // should not go to disk only to wire
|
TagsDel []string `yaml:"tagsdel,omitempty" lopt:"tagdel" comment:"remove this tags"` // should not go to disk only to wire
|
||||||
Keys map[string]string `yaml:"keys,omitempty"` // Reverse compatibility
|
Keys map[string]string `yaml:"keys,omitempty"` // Reverse compatibility
|
||||||
|
PrimaryNetDev string `yaml:"primary network,omitempty" lopt:"primarynet" sopt:"p" comment:"Set the primary network interface"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type IpmiConf struct {
|
type IpmiConf struct {
|
||||||
@@ -80,8 +81,6 @@ type NetDevs struct {
|
|||||||
Netmask string `yaml:"netmask,omitempty" lopt:"netmask" sopt:"M" comment:"Set the networks netmask"`
|
Netmask string `yaml:"netmask,omitempty" lopt:"netmask" sopt:"M" comment:"Set the networks netmask"`
|
||||||
Gateway string `yaml:"gateway,omitempty" lopt:"gateway" sopt:"G" comment:"Set the node's network device gateway"`
|
Gateway string `yaml:"gateway,omitempty" lopt:"gateway" sopt:"G" comment:"Set the node's network device gateway"`
|
||||||
MTU string `yaml:"mtu,omitempty" lopt:"mtu" comment:"Set the mtu"`
|
MTU string `yaml:"mtu,omitempty" lopt:"mtu" comment:"Set the mtu"`
|
||||||
Primary string `yaml:"primary,omitempty" lopt:"primary" comment:"Enable/disable network device as primary (yes/no)"`
|
|
||||||
Default string `yaml:"default,omitempty"` /* backward compatibility */
|
|
||||||
Tags map[string]string `yaml:"tags,omitempty" lopt:"nettagadd" comment:"network tags"`
|
Tags map[string]string `yaml:"tags,omitempty" lopt:"nettagadd" comment:"network tags"`
|
||||||
TagsDel []string `yaml:"tagsdel,omitempty" lopt:"nettagdel" comment:"delete network tags"` // should not go to disk only to wire
|
TagsDel []string `yaml:"tagsdel,omitempty" lopt:"nettagdel" comment:"delete network tags"` // should not go to disk only to wire
|
||||||
}
|
}
|
||||||
@@ -122,6 +121,7 @@ type NodeInfo struct {
|
|||||||
Kernel *KernelEntry
|
Kernel *KernelEntry
|
||||||
Ipmi *IpmiEntry
|
Ipmi *IpmiEntry
|
||||||
Profiles Entry
|
Profiles Entry
|
||||||
|
PrimaryNetDev Entry
|
||||||
NetDevs map[string]*NetDevEntry
|
NetDevs map[string]*NetDevEntry
|
||||||
Tags map[string]*Entry
|
Tags map[string]*Entry
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user