Fix NIC port count handling and apply pending exporter updates
This commit is contained in:
@@ -2361,7 +2361,7 @@ func parseNIC(doc map[string]interface{}) models.NetworkAdapter {
|
||||
location = firstNonEmpty(location, redfishLocationLabel(ctrl["Location"]))
|
||||
firmware = asString(ctrl["FirmwarePackageVersion"])
|
||||
if caps, ok := ctrl["ControllerCapabilities"].(map[string]interface{}); ok {
|
||||
portCount = asInt(caps["NetworkPortCount"])
|
||||
portCount = sanitizeNetworkPortCount(asInt(caps["NetworkPortCount"]))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3406,6 +3406,8 @@ func mergeNetworkAdapterEntries(a, b models.NetworkAdapter) models.NetworkAdapte
|
||||
base, donor = donor, base
|
||||
}
|
||||
out := base
|
||||
out.PortCount = sanitizeNetworkPortCount(out.PortCount)
|
||||
donor.PortCount = sanitizeNetworkPortCount(donor.PortCount)
|
||||
if strings.TrimSpace(out.Slot) == "" && strings.TrimSpace(donor.Slot) != "" {
|
||||
out.Slot = donor.Slot
|
||||
}
|
||||
@@ -3452,6 +3454,15 @@ func mergeNetworkAdapterEntries(a, b models.NetworkAdapter) models.NetworkAdapte
|
||||
return out
|
||||
}
|
||||
|
||||
const maxReasonableNetworkPortCount = 256
|
||||
|
||||
func sanitizeNetworkPortCount(v int) int {
|
||||
if v <= 0 || v > maxReasonableNetworkPortCount {
|
||||
return 0
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func dedupePCIeDevices(items []models.PCIeDevice) []models.PCIeDevice {
|
||||
if len(items) <= 1 {
|
||||
return items
|
||||
|
||||
Reference in New Issue
Block a user