feat(models): resolve CPU serial from source PPIN as common fallback
Centralize CPU identity in models.ResolveCPUSerialNumber: an explicit source serial wins, otherwise a valid source PPIN is used, placeholders rejected. Dell, H3C and Redfish apply it while parsing; canonical-device and Reanimator conversion apply it again at the output boundary. No identity is synthesized from socket/model/board serial. See ADL-058. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
9d701885da
commit
07c270cda2
@@ -3311,6 +3311,7 @@ func parseCPUs(docs []map[string]interface{}) []models.CPU {
|
||||
if serial == "" && publicSerial == "" {
|
||||
serial = findFirstNormalizedStringByKeys(doc, "SerialNumber")
|
||||
}
|
||||
ppin := firstNonEmpty(findFirstNormalizedStringByKeys(doc, "PPIN", "ProtectedIdentificationNumber"), publicSerial)
|
||||
cpus = append(cpus, models.CPU{
|
||||
Socket: socket,
|
||||
Model: firstNonEmpty(asString(doc["Model"]), asString(doc["Name"])),
|
||||
@@ -3318,8 +3319,8 @@ func parseCPUs(docs []map[string]interface{}) []models.CPU {
|
||||
Threads: asInt(doc["TotalThreads"]),
|
||||
FrequencyMHz: int(redfishFirstNumeric(doc, "OperatingSpeedMHz", "CurrentSpeedMHz", "FrequencyMHz")),
|
||||
MaxFreqMHz: int(redfishFirstNumeric(doc, "MaxSpeedMHz", "TurboEnableMaxSpeedMHz", "TurboDisableMaxSpeedMHz")),
|
||||
PPIN: firstNonEmpty(findFirstNormalizedStringByKeys(doc, "PPIN", "ProtectedIdentificationNumber"), publicSerial),
|
||||
SerialNumber: serial,
|
||||
PPIN: ppin,
|
||||
SerialNumber: models.ResolveCPUSerialNumber(serial, ppin),
|
||||
L1CacheKB: l1,
|
||||
L2CacheKB: l2,
|
||||
L3CacheKB: l3,
|
||||
|
||||
@@ -1557,8 +1557,8 @@ func TestParseCPU_UsesPublicSerialAsPPINAndCurrentSpeedMHz(t *testing.T) {
|
||||
if cpus[0].PPIN != "6FB5241E81CECDFD" {
|
||||
t.Fatalf("expected PPIN from Oem.Public.SerialNumber, got %+v", cpus[0])
|
||||
}
|
||||
if cpus[0].SerialNumber != "" {
|
||||
t.Fatalf("expected empty CPU serial number when only Public serial exists, got %+v", cpus[0])
|
||||
if cpus[0].SerialNumber != "6FB5241E81CECDFD" {
|
||||
t.Fatalf("expected CPU serial number to fall back to PPIN, got %+v", cpus[0])
|
||||
}
|
||||
if cpus[0].FrequencyMHz != 2700 {
|
||||
t.Fatalf("expected CPU frequency from Oem.Public.CurrentSpeedMHz, got %+v", cpus[0])
|
||||
|
||||
Reference in New Issue
Block a user