summaryrefslogtreecommitdiff
path: root/redfish-core/lib/pcie.hpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-05-19 19:39:07 +0300
committerEd Tanous <ed@tanous.net>2022-10-04 21:05:08 +0300
commit22d268cb2c0bc00676d08c79f6ab8958bee74a25 (patch)
treeb0256b1cccd28f8ba05e3e33813403a6ce4c62bc /redfish-core/lib/pcie.hpp
parent7a3a8f7aa20017a1bdb4f22737f03a12d0930f19 (diff)
downloadbmcweb-22d268cb2c0bc00676d08c79f6ab8958bee74a25.tar.xz
Make routes start matching Redfish
This is preliminary patch to set up the route handling such that it's ready for the addition of multiple hosts, multiple managers in the future. Routes previously took the form of /redfish/v1/Systems/system which essentially hardcoded the name "system" into a number of places. As the stack evolves to support multiple systems, this needs to change. This patchset changes all the ComputerSystem resources to the form: /redfish/v1/Systems/<str> and adds 404 checks to each route such that they will be handled properly still. This means that as we evolve our multi-host support, each individual route can be moved one at a time to support multi-host. In the future, moving these to redfish-spec-defined routing would likely mean that we could generate this code in the future at some point, which reduces the likelihood that people do it incorrectly. This patch currently sets the resource id and resource type in the resourceNotFound message to empty string (""). This handling is still arguably more correct than what we had before, which just returned 404 with an empty payload, although this will be corrected in the future. Tested: None yet. RFC to see if this is a pattern we'd like to propogate Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: If9c07ad69f5287bb054645f460d7e370d433dc27
Diffstat (limited to 'redfish-core/lib/pcie.hpp')
-rw-r--r--redfish-core/lib/pcie.hpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index 47c5c91bac..13d5ab93eb 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -82,15 +82,22 @@ inline void requestRoutesSystemPCIeDeviceCollection(App& app)
/**
* Functions triggers appropriate requests on DBus
*/
- BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/PCIeDevices/")
+ BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/PCIeDevices/")
.privileges(redfish::privileges::getPCIeDeviceCollection)
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& systemName) {
if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
return;
}
+ if (systemName != "system")
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#PCIeDeviceCollection.PCIeDeviceCollection";
@@ -145,16 +152,23 @@ inline std::optional<std::string>
inline void requestRoutesSystemPCIeDevice(App& app)
{
- BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/PCIeDevices/<str>/")
+ BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/PCIeDevices/<str>/")
.privileges(redfish::privileges::getPCIeDevice)
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& device) {
+ const std::string& systemName, const std::string& device) {
if (!redfish::setUpRedfishRoute(app, req, asyncResp))
{
return;
}
+ if (systemName != "system")
+ {
+ messages::resourceNotFound(asyncResp->res, "ComputerSystem",
+ systemName);
+ return;
+ }
+
auto getPCIeDeviceCallback =
[asyncResp, device](
const boost::system::error_code ec,