summaryrefslogtreecommitdiff
path: root/redfish-core/lib/pcie.hpp
diff options
context:
space:
mode:
authorLakshmi Yadlapati <lakshmiy@us.ibm.com>2023-06-08 12:37:18 +0300
committerEd Tanous <ed@tanous.net>2023-12-18 23:06:24 +0300
commit70c4d545817d83819f7f0cd571e0160bacb51d11 (patch)
tree3a513d1af3e29aa908c4d85fd161a87e0622d5b4 /redfish-core/lib/pcie.hpp
parent75e8e218cbf9539144ee8f6aea01e158d0a9e190 (diff)
downloadbmcweb-70c4d545817d83819f7f0cd571e0160bacb51d11.tar.xz
Refactor PCIeDeviceList to use getCollectionMembers
This commit refactors the code in the PCIeDeviceList function to use the getCollectionMembers function for retrieving collection members. Additionally, a new function getCollectionToKey() is added to handle the retrieval of collection members with custom key name. Tested: Validator passed ''' Test1: Redfish query of PCI devices on a system that does not have any PCIe devices curl -k https://$bmc/redfish/v1/Systems/system/PCIeDevices { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices", "@odata.type": "#PCIeDeviceCollection.PCIeDeviceCollection", "Description": "Collection of PCIe Devices", "Members": [], "Members@odata.count": 0, "Name": "PCIe Device Collection" } Test2: Redfish query of PCIe devices on a system that has PCIe devices curl -k https://$bmc/redfish/v1/Systems/system/PCIeDevices { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices", "@odata.type": "#PCIeDeviceCollection.PCIeDeviceCollection", "Description": "Collection of PCIe Devices", "Members": [ { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/drive0" }, ....... { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card1" }, { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card2" }, ....... { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card12" } ], "Members@odata.count": 22, "Name": "PCIe Device Collection" } Test3: Redfish query of system with PCIe devices curl -k https://$bmc/redfish/v1/Systems/system { "@odata.id": "/redfish/v1/Systems/system", "@odata.type": "#ComputerSystem.v1_16_0.ComputerSystem", "Actions": { "#ComputerSystem.Reset": { "@Redfish.ActionInfo": "/redfish/v1/Systems/system/ResetActionInfo", "target": "/redfish/v1/Systems/system/Actions/ComputerSystem.Reset" } }, ...... "PCIeDevices": [ { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/drive0" }, ....... { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card1" }, .... ], "PCIeDevices@odata.count": 22, "PartNumber": "", .... "SubModel": "S0", "SystemType": "Physical" } ''' Change-Id: Icb38945a2c7bc5219ff3917fbbc8a9986c9c6155 Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
Diffstat (limited to 'redfish-core/lib/pcie.hpp')
-rw-r--r--redfish-core/lib/pcie.hpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index 6bd74f9188..e8da2195a8 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -131,10 +131,9 @@ static inline void handlePCIeDeviceCollectionGet(
"/redfish/v1/Systems/system/PCIeDevices";
asyncResp->res.jsonValue["Name"] = "PCIe Device Collection";
asyncResp->res.jsonValue["Description"] = "Collection of PCIe Devices";
- asyncResp->res.jsonValue["Members"] = nlohmann::json::array();
- asyncResp->res.jsonValue["Members@odata.count"] = 0;
- pcie_util::getPCIeDeviceList(asyncResp, "Members");
+ pcie_util::getPCIeDeviceList(asyncResp,
+ nlohmann::json::json_pointer("/Members"));
}
inline void requestRoutesSystemPCIeDeviceCollection(App& app)