fix(redfish): recover MSI NIC serials from PCIe functions
This commit is contained in:
@@ -1197,6 +1197,8 @@ func TestEnrichNICFromPCIeFunctions(t *testing.T) {
|
||||
"FunctionId": "0000:17:00.0",
|
||||
"VendorId": "0x15b3",
|
||||
"DeviceId": "0x1021",
|
||||
"SerialNumber": "MT-SN-0001",
|
||||
"PartNumber": "MCX623106AC-CDAT",
|
||||
"CurrentLinkWidth": 16,
|
||||
"CurrentLinkSpeedGTs": "32 GT/s",
|
||||
"MaxLinkWidth": 16,
|
||||
@@ -1214,6 +1216,12 @@ func TestEnrichNICFromPCIeFunctions(t *testing.T) {
|
||||
if nic.BDF != "0000:17:00.0" {
|
||||
t.Fatalf("unexpected NIC BDF: %q", nic.BDF)
|
||||
}
|
||||
if nic.SerialNumber != "NIC-SN-1" {
|
||||
t.Fatalf("expected existing NIC serial to be preserved, got %q", nic.SerialNumber)
|
||||
}
|
||||
if nic.PartNumber != "MCX623106AC-CDAT" {
|
||||
t.Fatalf("expected NIC part number from PCIe function, got %q", nic.PartNumber)
|
||||
}
|
||||
if nic.LinkWidth != 16 || nic.MaxLinkWidth != 16 {
|
||||
t.Fatalf("unexpected NIC link width state: current=%d max=%d", nic.LinkWidth, nic.MaxLinkWidth)
|
||||
}
|
||||
@@ -1222,6 +1230,63 @@ func TestEnrichNICFromPCIeFunctions(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnrichNICFromPCIeFunctions_FillsMissingIdentityFromFunctionDoc(t *testing.T) {
|
||||
nic := parseNIC(map[string]interface{}{
|
||||
"Id": "DevType7_NIC1",
|
||||
"Controllers": []interface{}{
|
||||
map[string]interface{}{
|
||||
"ControllerCapabilities": map[string]interface{}{
|
||||
"NetworkPortCount": 1,
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"ControllerCapabilities": map[string]interface{}{
|
||||
"NetworkPortCount": 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
pcieDoc := map[string]interface{}{
|
||||
"Slot": map[string]interface{}{
|
||||
"Location": map[string]interface{}{
|
||||
"PartLocation": map[string]interface{}{
|
||||
"ServiceLabel": "RISER4",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
functionDocs := []map[string]interface{}{
|
||||
{
|
||||
"FunctionId": "0000:0f:00.0",
|
||||
"VendorId": "0x15b3",
|
||||
"DeviceId": "0x101f",
|
||||
"SerialNumber": "MT2412X00001",
|
||||
"PartNumber": "MCX623432AC-GDA_Ax",
|
||||
},
|
||||
}
|
||||
|
||||
enrichNICFromPCIe(&nic, pcieDoc, functionDocs, nil)
|
||||
if nic.Slot != "RISER4" {
|
||||
t.Fatalf("expected slot from PCIe slot label, got %q", nic.Slot)
|
||||
}
|
||||
if nic.Location != "RISER4" {
|
||||
t.Fatalf("expected location from PCIe slot label, got %q", nic.Location)
|
||||
}
|
||||
if nic.PortCount != 2 {
|
||||
t.Fatalf("expected combined port count from controllers, got %d", nic.PortCount)
|
||||
}
|
||||
if nic.SerialNumber != "MT2412X00001" {
|
||||
t.Fatalf("expected serial from PCIe function, got %q", nic.SerialNumber)
|
||||
}
|
||||
if nic.PartNumber != "MCX623432AC-GDA_Ax" {
|
||||
t.Fatalf("expected part number from PCIe function, got %q", nic.PartNumber)
|
||||
}
|
||||
if nic.BDF != "0000:0f:00.0" {
|
||||
t.Fatalf("expected BDF from PCIe function, got %q", nic.BDF)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseNIC_PortCountFromControllerCapabilities(t *testing.T) {
|
||||
nic := parseNIC(map[string]interface{}{
|
||||
"Id": "1",
|
||||
@@ -3462,8 +3527,8 @@ func TestShouldCrawlPath_MemoryAndProcessorMetricsAreAllowed(t *testing.T) {
|
||||
if !shouldCrawlPath("/redfish/v1/Systems/1/Processors/CPU0/ProcessorMetrics") {
|
||||
t.Fatalf("expected CPU metrics subresource to be crawlable")
|
||||
}
|
||||
if shouldCrawlPath("/redfish/v1/Chassis/1/PCIeDevices/0/PCIeFunctions/1") {
|
||||
t.Fatalf("expected noisy chassis pciefunctions branch to be skipped")
|
||||
if !shouldCrawlPath("/redfish/v1/Chassis/1/PCIeDevices/0/PCIeFunctions/1") {
|
||||
t.Fatalf("expected chassis pciefunctions resource to be crawlable for NIC/GPU identity recovery")
|
||||
}
|
||||
if !shouldCrawlPath("/redfish/v1/Fabrics/HGX_NVLinkFabric_0/Switches/NVSwitch_0") {
|
||||
t.Fatalf("expected NVSwitch fabric resource to be crawlable")
|
||||
|
||||
Reference in New Issue
Block a user