summaryrefslogtreecommitdiff
path: root/redfish-core/lib/pcie.hpp
diff options
context:
space:
mode:
authorWilly Tu <wltu@google.com>2022-09-26 19:46:38 +0300
committerEd Tanous <ed@tanous.net>2023-02-23 20:53:12 +0300
commiteddfc437edfc871b469199552bdeb0d65ee2dcf3 (patch)
tree3900183f1dc64c2cdcc20eebbc6d8de84e78a557 /redfish-core/lib/pcie.hpp
parent66d90c2cb505d899373f17be468e730e88fe2345 (diff)
downloadbmcweb-eddfc437edfc871b469199552bdeb0d65ee2dcf3.tar.xz
Update most resources to use urlFromPieces
Only id in event_service and account_service have not been updated due to the risk of it breaking the username/id. It will require further testing to verify. Use urlFromPieces wherever that is needed to insert a variable in the URI. Don't use urlFromPieces when it is hardcoded values. This allow us to control all resource URIs that is dynamically added and to sync with the current recommanded method for `@odata.id`. The goal is to have a common place to manage the url created from dbus-paths in order to manage/update it easily when needed. Tested: RedfishValidtor Passed for all resource including the sensors with the fragments. Change-Id: I95cdfaaee58fc7f21c95f5944e1e5c813b3215f2 Signed-off-by: Willy Tu <wltu@google.com> Signed-off-by: Ed Tanous <edtanous@google.com>
Diffstat (limited to 'redfish-core/lib/pcie.hpp')
-rw-r--r--redfish-core/lib/pcie.hpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index 77afd0acd6..5332a391ef 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -67,8 +67,8 @@ static inline void
continue;
}
nlohmann::json::object_t pcieDevice;
- pcieDevice["@odata.id"] =
- "/redfish/v1/Systems/system/PCIeDevices/" + devName;
+ pcieDevice["@odata.id"] = crow::utility::urlFromPieces(
+ "redfish", "v1", "Systems", "system", "PCIeDevices", devName);
pcieDeviceList.push_back(std::move(pcieDevice));
}
asyncResp->res.jsonValue[name + "@odata.count"] = pcieDeviceList.size();
@@ -242,13 +242,15 @@ inline void requestRoutesSystemPCIeDevice(App& app)
asyncResp->res.jsonValue["@odata.type"] =
"#PCIeDevice.v1_4_0.PCIeDevice";
asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Systems/system/PCIeDevices/" + device;
+ crow::utility::urlFromPieces("redfish", "v1", "Systems",
+ "system", "PCIeDevices", device);
asyncResp->res.jsonValue["Name"] = "PCIe Device";
asyncResp->res.jsonValue["Id"] = device;
asyncResp->res.jsonValue["PCIeFunctions"]["@odata.id"] =
- "/redfish/v1/Systems/system/PCIeDevices/" + device +
- "/PCIeFunctions";
+ crow::utility::urlFromPieces("redfish", "v1", "Systems",
+ "system", "PCIeDevices", device,
+ "PCIeFunctions");
};
std::string escapedPath = std::string(pciePath) + "/" + device;
dbus::utility::escapePathForDbus(escapedPath);
@@ -277,9 +279,9 @@ inline void requestRoutesSystemPCIeFunctionCollection(App& app)
asyncResp->res.jsonValue["@odata.type"] =
"#PCIeFunctionCollection.PCIeFunctionCollection";
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Systems/system/PCIeDevices/" + device +
- "/PCIeFunctions";
+ asyncResp->res.jsonValue["@odata.id"] = crow::utility::urlFromPieces(
+ "redfish", "v1", "Systems", "system", "PCIeDevices", device,
+ "PCIeFunctions");
asyncResp->res.jsonValue["Name"] = "PCIe Function Collection";
asyncResp->res.jsonValue["Description"] =
"Collection of PCIe Functions for PCIe Device " + device;
@@ -330,9 +332,9 @@ inline void requestRoutesSystemPCIeFunctionCollection(App& app)
continue;
}
nlohmann::json::object_t pcieFunction;
- pcieFunction["@odata.id"] =
- "/redfish/v1/Systems/system/PCIeDevices/" + device +
- "/PCIeFunctions/" + std::to_string(functionNum);
+ pcieFunction["@odata.id"] = crow::utility::urlFromPieces(
+ "redfish", "v1", "Systems", "system", "PCIeDevices", device,
+ "PCIeFunctions", std::to_string(functionNum));
pcieFunctionList.push_back(std::move(pcieFunction));
}
asyncResp->res.jsonValue["Members@odata.count"] =
@@ -406,13 +408,15 @@ inline void requestRoutesSystemPCIeFunction(App& app)
asyncResp->res.jsonValue["@odata.type"] =
"#PCIeFunction.v1_2_0.PCIeFunction";
asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Systems/system/PCIeDevices/" + device +
- "/PCIeFunctions/" + function;
+ crow::utility::urlFromPieces("redfish", "v1", "Systems",
+ "system", "PCIeDevices", device,
+ "PCIeFunctions", function);
asyncResp->res.jsonValue["Name"] = "PCIe Function";
asyncResp->res.jsonValue["Id"] = function;
asyncResp->res.jsonValue["FunctionId"] = std::stoi(function);
asyncResp->res.jsonValue["Links"]["PCIeDevice"]["@odata.id"] =
- "/redfish/v1/Systems/system/PCIeDevices/" + device;
+ crow::utility::urlFromPieces("redfish", "v1", "Systems",
+ "system", "PCIeDevices", device);
for (const auto& property : pcieDevProperties)
{