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
@@ -57,7 +57,7 @@ func BuildHardwareDevices(hw *models.HardwareConfig) []models.HardwareDevice {
|
||||
Source: "cpus",
|
||||
Slot: fmt.Sprintf("CPU%d", cpu.Socket),
|
||||
Model: cpu.Model,
|
||||
SerialNumber: cpu.SerialNumber,
|
||||
SerialNumber: models.ResolveCPUSerialNumber(cpu.SerialNumber, cpu.PPIN),
|
||||
Cores: cpu.Cores,
|
||||
Threads: cpu.Threads,
|
||||
FrequencyMHz: cpu.FrequencyMHz,
|
||||
|
||||
@@ -315,3 +315,18 @@ func TestHandleGetConfig_ReturnsCanonicalHardware(t *testing.T) {
|
||||
t.Fatalf("did not expect legacy hardware.cpus in config response")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildHardwareDevices_CPUUsesPPINAsSerialFallback(t *testing.T) {
|
||||
hw := &models.HardwareConfig{CPUs: []models.CPU{{Socket: 0, Model: "Intel Xeon", PPIN: "D46E5D6B1D3E40E1"}}}
|
||||
|
||||
devices := BuildHardwareDevices(hw)
|
||||
for _, device := range devices {
|
||||
if device.Kind == models.DeviceKindCPU {
|
||||
if device.SerialNumber != "D46E5D6B1D3E40E1" {
|
||||
t.Fatalf("expected CPU serial fallback from PPIN, got %q", device.SerialNumber)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
t.Fatal("CPU device was not built")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user