fix(region,baremetal): choose candidate network not according by types

This commit is contained in:
Zexi Li
2020-12-21 20:42:38 +08:00
parent 2c7f8d93f6
commit e2201a80f3
+17 -1
View File
@@ -804,12 +804,28 @@ func chooseNetworkByAddressCount(nets []*SNetwork) (*SNetwork, *SNetwork) {
}
func ChooseCandidateNetworks(nets []SNetwork, isExit bool, serverTypes []string) *SNetwork {
matchingNets := make([]*SNetwork, 0)
notMatchingNets := make([]*SNetwork, 0)
for _, s := range serverTypes {
net := chooseCandidateNetworksByNetworkType(nets, isExit, s)
if net != nil {
return net
if utils.IsInStringArray(net.ServerType, serverTypes) {
matchingNets = append(matchingNets, net)
} else {
notMatchingNets = append(notMatchingNets, net)
}
}
}
if len(matchingNets) >= 1 {
return matchingNets[0]
}
if len(notMatchingNets) >= 1 {
return notMatchingNets[0]
}
return nil
}