diff options
author | Lakshmi Yadlapati <lakshmiy@us.ibm.com> | 2023-03-22 17:57:05 +0300 |
---|---|---|
committer | Lakshmi Yadlapati <lakshmiy@us.ibm.com> | 2023-06-02 18:20:51 +0300 |
commit | 472bd202da308ea7ba6c9f5606e025367b52fccc (patch) | |
tree | 2e825be08a79c3336c6c35353ee6984cbdc77262 /redfish-core/lib/pcie.hpp | |
parent | c1c7b94bf8327a20ccce4f628c9b43c75db2023a (diff) | |
download | bmcweb-472bd202da308ea7ba6c9f5606e025367b52fccc.tar.xz |
Move getPCIeDeviceList to pcie_util
Currently, getPCIeDeviceList is only used by systems.hpp to obtain the
list of PCIe devices. However, there are plans to use this function in
other parts of the PCIe code as well. To better organize our code and
make the function more reusable, this commit moves getPCIeDeviceList to
pcie_util.hpp, a common location for PCIe-related utilities.
Tested:
'''
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/dp0_drive2"
},
{
"@odata.id": "/redfish/v1/Systems/system/PCIeDevices/dp0_drive3"
},
.....
.....
{
"@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card0"
},
{
"@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card1"
},
{
"@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card10"
},
.....
{
"@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card9"
}
],
"PCIeDevices@odata.count": 20,
.....
.....
'''
Change-Id: I3aaa5b55e8574929154ffd743db53da6fbaeb75d
Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
Diffstat (limited to 'redfish-core/lib/pcie.hpp')
-rw-r--r-- | redfish-core/lib/pcie.hpp | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp index 93b15c3abe..f98d6c8797 100644 --- a/redfish-core/lib/pcie.hpp +++ b/redfish-core/lib/pcie.hpp @@ -96,46 +96,6 @@ static inline void getValidPCIeDevicePath( }); } -static inline void - getPCIeDeviceList(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, - const std::string& name) -{ - dbus::utility::getSubTreePaths( - inventoryPath, 0, pcieDeviceInterface, - [asyncResp, name](const boost::system::error_code& ec, - const dbus::utility::MapperGetSubTreePathsResponse& - pcieDevicePaths) { - if (ec) - { - BMCWEB_LOG_DEBUG << "no PCIe device paths found ec: " - << ec.message(); - // Not an error, system just doesn't have PCIe info - return; - } - nlohmann::json& pcieDeviceList = asyncResp->res.jsonValue[name]; - pcieDeviceList = nlohmann::json::array(); - for (const std::string& pcieDevicePath : pcieDevicePaths) - { - size_t devStart = pcieDevicePath.rfind('/'); - if (devStart == std::string::npos) - { - continue; - } - - std::string devName = pcieDevicePath.substr(devStart + 1); - if (devName.empty()) - { - continue; - } - nlohmann::json::object_t pcieDevice; - pcieDevice["@odata.id"] = boost::urls::format( - "/redfish/v1/Systems/system/PCIeDevices/{}", devName); - pcieDeviceList.emplace_back(std::move(pcieDevice)); - } - asyncResp->res.jsonValue[name + "@odata.count"] = pcieDeviceList.size(); - }); -} - static inline void handlePCIeDeviceCollectionGet( crow::App& app, const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& aResp, |