return the primary network interface for discoverd

close #775

Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
Christian Goll
2023-04-13 11:06:37 +02:00
committed by Jonathon Anderson
parent 03d94322cd
commit 84d2389aaf
2 changed files with 12 additions and 0 deletions

View File

@@ -309,6 +309,14 @@ func (config *NodeYaml) ListAllProfiles() []string {
return ret
}
/*
FindDiscoverableNode returns the first discoverable node and an
interface to associate with the discovered interface. If the node has
a primary interface, it is returned; otherwise, the first interface
without a hardware address is returned.
If no unconfigured nodes are found, an error is returned.
*/
func (config *NodeYaml) FindDiscoverableNode() (NodeInfo, string, error) {
var ret NodeInfo
@@ -318,6 +326,9 @@ func (config *NodeYaml) FindDiscoverableNode() (NodeInfo, string, error) {
if !node.Discoverable.GetB() {
continue
}
if _, ok := node.NetDevs[node.PrimaryNetDev.Get()]; ok {
return node, node.PrimaryNetDev.Get(), nil
}
for netdev, dev := range node.NetDevs {
if !dev.Hwaddr.Defined() {
return node, netdev, nil