pcie: Fixed return nothing when get PCIeDeviceId
GET /redfish/v1/Systems/system/PCIeDevices/<str> nothing will be
returned if their 'generationInUse' is Unknown.
The original intention is that if it is Unknown, there is no need to
display '"PCIeType"'. But the others still have to show.
After fix:
PCIeType is not Unknown:
GET http://${bmc}/redfish/v1/Systems/system/PCIeDevices/<str>
{
"@odata.id": "/redfish/v1/Systems/system/PCIeDevices/<str>.",
"@odata.type": "#PCIeDevice.v1_4_0.PCIeDevice",
"DeviceType": "SingleFunction",
"Id": "<str>",
"Manufacturer": "Intel Corporation",
"Name": "PCIe Device",
"PCIeFunctions": {
"@odata.id":
"/redfish/v1/Systems/system/PCIeDevices/<str>/PCIeFunctions"
},
"PCIeInterface": {
"PCIeType": "Gen1"
}
}
PCIeType is Unknown:
GET http://${bmc}/redfish/v1/Systems/system/PCIeDevices/<str>
{
"@odata.id": "/redfish/v1/Systems/system/PCIeDevices/<str>",
"@odata.type": "#PCIeDevice.v1_4_0.PCIeDevice",
"DeviceType": "SingleFunction",
"Id": "<str>",
"Manufacturer": "Intel Corporation",
"Name": "PCIe Device",
"PCIeFunctions": {
"@odata.id":
"/redfish/v1/Systems/system/PCIeDevices/<str>/PCIeFunctions"
}
}
Signed-off-by: Tony Lee <tony.lee@quantatw.com>
Change-Id: I85a97e0370a5789e4526964272381a557ce942a0
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index 327e79e..64fe70e 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -215,13 +215,11 @@
messages::internalError(asyncResp->res);
return;
}
- if (redfishGenerationInUse->empty())
+ if (!redfishGenerationInUse->empty())
{
- // unknown, no need to handle
- return;
+ asyncResp->res.jsonValue["PCIeInterface"]["PCIeType"] =
+ *redfishGenerationInUse;
}
- asyncResp->res.jsonValue["PCIeInterface"]["PCIeType"] =
- *redfishGenerationInUse;
}
if (manufacturer != nullptr)