Fix NIC port count handling and apply pending exporter updates

This commit is contained in:
2026-02-28 18:42:01 +03:00
parent 612058ed16
commit fe5da1dbd7
7 changed files with 362 additions and 4 deletions

View File

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