diff options
author | Ed Tanous <edtanous@google.com> | 2022-05-19 19:39:07 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-10-04 21:05:08 +0300 |
commit | 22d268cb2c0bc00676d08c79f6ab8958bee74a25 (patch) | |
tree | b0256b1cccd28f8ba05e3e33813403a6ce4c62bc /redfish-core/lib/memory.hpp | |
parent | 7a3a8f7aa20017a1bdb4f22737f03a12d0930f19 (diff) | |
download | bmcweb-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/memory.hpp')
-rw-r--r-- | redfish-core/lib/memory.hpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/redfish-core/lib/memory.hpp b/redfish-core/lib/memory.hpp index 988a251c03..dd535f7ce7 100644 --- a/redfish-core/lib/memory.hpp +++ b/redfish-core/lib/memory.hpp @@ -769,15 +769,23 @@ inline void requestRoutesMemoryCollection(App& app) /** * Functions triggers appropriate requests on DBus */ - BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Memory/") + BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Memory/") .privileges(redfish::privileges::getMemoryCollection) .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"] = "#MemoryCollection.MemoryCollection"; asyncResp->res.jsonValue["Name"] = "Memory Module Collection"; @@ -795,16 +803,23 @@ inline void requestRoutesMemory(App& app) /** * Functions triggers appropriate requests on DBus */ - BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Memory/<str>/") + BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/Memory/<str>/") .privileges(redfish::privileges::getMemory) .methods(boost::beast::http::verb::get)( [&app](const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, - const std::string& dimmId) { + const std::string& systemName, const std::string& dimmId) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } + if (systemName != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", + systemName); + return; + } + getDimmData(asyncResp, dimmId); }); } |