diff options
Diffstat (limited to 'redfish-core/lib/log_services.hpp')
-rw-r--r-- | redfish-core/lib/log_services.hpp | 423 |
1 files changed, 355 insertions, 68 deletions
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index d4ef1f19df..ecd5d59684 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -910,15 +910,23 @@ inline void requestRoutesSystemLogServiceCollection(App& app) /** * Functions triggers appropriate requests on DBus */ - BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/LogServices/") + BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/") .privileges(redfish::privileges::getLogServiceCollection) .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; + } + // Collections don't include the static data added by SubRoute // because it has a duplicate entry for members asyncResp->res.jsonValue["@odata.type"] = @@ -993,15 +1001,22 @@ inline void requestRoutesSystemLogServiceCollection(App& app) inline void requestRoutesEventLogService(App& app) { - BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/LogServices/EventLog/") + BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/EventLog/") .privileges(redfish::privileges::getLogService) .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.id"] = "/redfish/v1/Systems/system/LogServices/EventLog"; asyncResp->res.jsonValue["@odata.type"] = @@ -1031,15 +1046,22 @@ inline void requestRoutesJournalEventLogClear(App& app) { BMCWEB_ROUTE( app, - "/redfish/v1/Systems/system/LogServices/EventLog/Actions/LogService.ClearLog/") + "/redfish/v1/Systems/<str>/LogServices/EventLog/Actions/LogService.ClearLog/") .privileges({{"ConfigureComponents"}}) .methods(boost::beast::http::verb::post)( [&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; + } // Clear the EventLog by deleting the log files std::vector<std::filesystem::path> redfishLogFiles; if (getRedfishLogFiles(redfishLogFiles)) @@ -1173,12 +1195,12 @@ static LogParseError inline void requestRoutesJournalEventLogEntryCollection(App& app) { - BMCWEB_ROUTE(app, - "/redfish/v1/Systems/system/LogServices/EventLog/Entries/") + BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/EventLog/Entries/") .privileges(redfish::privileges::getLogEntryCollection) .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) { query_param::QueryCapabilities capabilities = { .canDelegateTop = true, .canDelegateSkip = true, @@ -1189,6 +1211,13 @@ inline void requestRoutesJournalEventLogEntryCollection(App& app) { return; } + if (systemName != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", + systemName); + return; + } + size_t top = delegatedQuery.top.value_or(query_param::Query::maxTop); size_t skip = delegatedQuery.skip.value_or(0); @@ -1270,16 +1299,24 @@ inline void requestRoutesJournalEventLogEntryCollection(App& app) inline void requestRoutesJournalEventLogEntry(App& app) { BMCWEB_ROUTE( - app, "/redfish/v1/Systems/system/LogServices/EventLog/Entries/<str>/") + app, "/redfish/v1/Systems/<str>/LogServices/EventLog/Entries/<str>/") .privileges(redfish::privileges::getLogEntry) .methods(boost::beast::http::verb::get)( [&app](const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, - const std::string& param) { + const std::string& systemName, const std::string& param) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } + + if (systemName != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", + systemName); + return; + } + const std::string& targetID = param; // Go through the log files and check the unique ID for each @@ -1333,16 +1370,23 @@ inline void requestRoutesJournalEventLogEntry(App& app) inline void requestRoutesDBusEventLogEntryCollection(App& app) { - BMCWEB_ROUTE(app, - "/redfish/v1/Systems/system/LogServices/EventLog/Entries/") + BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/EventLog/Entries/") .privileges(redfish::privileges::getLogEntryCollection) .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; + } + // Collections don't include the static data added by SubRoute // because it has a duplicate entry for members asyncResp->res.jsonValue["@odata.type"] = @@ -1499,16 +1543,23 @@ inline void requestRoutesDBusEventLogEntryCollection(App& app) inline void requestRoutesDBusEventLogEntry(App& app) { BMCWEB_ROUTE( - app, "/redfish/v1/Systems/system/LogServices/EventLog/Entries/<str>/") + app, "/redfish/v1/Systems/<str>/LogServices/EventLog/Entries/<str>/") .privileges(redfish::privileges::getLogEntry) .methods(boost::beast::http::verb::get)( [&app](const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, - const std::string& param) { + const std::string& systemName, const std::string& param) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } + if (systemName != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", + systemName); + return; + } + std::string entryID = param; dbus::utility::escapePathForDbus(entryID); @@ -1589,16 +1640,22 @@ inline void requestRoutesDBusEventLogEntry(App& app) }); BMCWEB_ROUTE( - app, "/redfish/v1/Systems/system/LogServices/EventLog/Entries/<str>/") + app, "/redfish/v1/Systems/<str>/LogServices/EventLog/Entries/<str>/") .privileges(redfish::privileges::patchLogEntry) .methods(boost::beast::http::verb::patch)( [&app](const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, - const std::string& entryId) { + const std::string& systemName, const std::string& entryId) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } + if (systemName != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", + systemName); + return; + } std::optional<bool> resolved; if (!json_util::readJsonPatch(req, asyncResp->res, "Resolved", @@ -1625,17 +1682,23 @@ inline void requestRoutesDBusEventLogEntry(App& app) }); BMCWEB_ROUTE( - app, "/redfish/v1/Systems/system/LogServices/EventLog/Entries/<str>/") + app, "/redfish/v1/Systems/<str>/LogServices/EventLog/Entries/<str>/") .privileges(redfish::privileges::deleteLogEntry) .methods(boost::beast::http::verb::delete_)( [&app](const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, - const std::string& param) { + const std::string& systemName, const std::string& param) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } + if (systemName != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", + systemName); + return; + } BMCWEB_LOG_DEBUG << "Do delete single event entries."; std::string entryID = param; @@ -1678,12 +1741,12 @@ inline void requestRoutesDBusEventLogEntryDownload(App& app) { BMCWEB_ROUTE( app, - "/redfish/v1/Systems/system/LogServices/EventLog/Entries/<str>/attachment") + "/redfish/v1/Systems/<str>/LogServices/EventLog/Entries/<str>/attachment") .privileges(redfish::privileges::getLogEntry) .methods(boost::beast::http::verb::get)( [&app](const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, - const std::string& param) { + const std::string& systemName, const std::string& param) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; @@ -1695,6 +1758,12 @@ inline void requestRoutesDBusEventLogEntryDownload(App& app) asyncResp->res.result(boost::beast::http::status::bad_request); return; } + if (systemName != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", + systemName); + return; + } std::string entryID = param; dbus::utility::escapePathForDbus(entryID); @@ -1848,15 +1917,22 @@ inline void fillHostLoggerEntryJson(const std::string& logEntryID, inline void requestRoutesSystemHostLogger(App& app) { - BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/LogServices/HostLogger/") + BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/HostLogger/") .privileges(redfish::privileges::getLogService) .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.id"] = "/redfish/v1/Systems/system/LogServices/HostLogger"; asyncResp->res.jsonValue["@odata.type"] = @@ -1872,11 +1948,12 @@ inline void requestRoutesSystemHostLogger(App& app) inline void requestRoutesSystemHostLoggerCollection(App& app) { BMCWEB_ROUTE(app, - "/redfish/v1/Systems/system/LogServices/HostLogger/Entries/") + "/redfish/v1/Systems/<str>/LogServices/HostLogger/Entries/") .privileges(redfish::privileges::getLogEntry) .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) { query_param::QueryCapabilities capabilities = { .canDelegateTop = true, .canDelegateSkip = true, @@ -1887,6 +1964,12 @@ inline void requestRoutesSystemHostLoggerCollection(App& app) { return; } + if (systemName != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", + systemName); + return; + } asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/LogServices/HostLogger/Entries"; asyncResp->res.jsonValue["@odata.type"] = @@ -1948,16 +2031,22 @@ inline void requestRoutesSystemHostLoggerCollection(App& app) inline void requestRoutesSystemHostLoggerLogEntry(App& app) { BMCWEB_ROUTE( - app, "/redfish/v1/Systems/system/LogServices/HostLogger/Entries/<str>/") + app, "/redfish/v1/Systems/<str>/LogServices/HostLogger/Entries/<str>/") .privileges(redfish::privileges::getLogEntry) .methods(boost::beast::http::verb::get)( [&app](const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, - const std::string& param) { + const std::string& systemName, const std::string& param) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } + if (systemName != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", + systemName); + return; + } const std::string& targetID = param; uint64_t idInt = 0; @@ -2417,6 +2506,23 @@ inline void handleLogServicesDumpServiceGet( getDumpServiceInfo(asyncResp, dumpType); } +inline void handleLogServicesDumpServiceComputerSystemGet( + crow::App& app, const crow::Request& req, + const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& chassisId) +{ + if (!redfish::setUpRedfishRoute(app, req, asyncResp)) + { + return; + } + if (chassisId != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", chassisId); + return; + } + getDumpServiceInfo(asyncResp, "System"); +} + inline void handleLogServicesDumpEntriesCollectionGet( crow::App& app, const std::string& dumpType, const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) @@ -2428,6 +2534,23 @@ inline void handleLogServicesDumpEntriesCollectionGet( getDumpEntryCollection(asyncResp, dumpType); } +inline void handleLogServicesDumpEntriesCollectionComputerSystemGet( + crow::App& app, const crow::Request& req, + const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& chassisId) +{ + if (!redfish::setUpRedfishRoute(app, req, asyncResp)) + { + return; + } + if (chassisId != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", chassisId); + return; + } + getDumpEntryCollection(asyncResp, "System"); +} + inline void handleLogServicesDumpEntryGet( crow::App& app, const std::string& dumpType, const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, @@ -2439,6 +2562,22 @@ inline void handleLogServicesDumpEntryGet( } getDumpEntryById(asyncResp, dumpId, dumpType); } +inline void handleLogServicesDumpEntryComputerSystemGet( + crow::App& app, const crow::Request& req, + const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& chassisId, const std::string& dumpId) +{ + if (!redfish::setUpRedfishRoute(app, req, asyncResp)) + { + return; + } + if (chassisId != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", chassisId); + return; + } + getDumpEntryById(asyncResp, dumpId, "System"); +} inline void handleLogServicesDumpEntryDelete( crow::App& app, const std::string& dumpType, const crow::Request& req, @@ -2452,6 +2591,23 @@ inline void handleLogServicesDumpEntryDelete( deleteDumpEntry(asyncResp, dumpId, dumpType); } +inline void handleLogServicesDumpEntryComputerSystemDelete( + crow::App& app, const crow::Request& req, + const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& chassisId, const std::string& dumpId) +{ + if (!redfish::setUpRedfishRoute(app, req, asyncResp)) + { + return; + } + if (chassisId != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", chassisId); + return; + } + deleteDumpEntry(asyncResp, dumpId, "System"); +} + inline void handleLogServicesDumpCollectDiagnosticDataPost( crow::App& app, const std::string& dumpType, const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) @@ -2463,6 +2619,23 @@ inline void handleLogServicesDumpCollectDiagnosticDataPost( createDump(asyncResp, req, dumpType); } +inline void handleLogServicesDumpCollectDiagnosticDataComputerSystemPost( + crow::App& app, const crow::Request& req, + const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& chassisId) +{ + if (!redfish::setUpRedfishRoute(app, req, asyncResp)) + { + return; + } + if (chassisId != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", chassisId); + return; + } + createDump(asyncResp, req, "System"); +} + inline void handleLogServicesDumpClearLogPost( crow::App& app, const std::string& dumpType, const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) @@ -2474,6 +2647,23 @@ inline void handleLogServicesDumpClearLogPost( clearDump(asyncResp, dumpType); } +inline void handleLogServicesDumpClearLogComputerSystemPost( + crow::App& app, const crow::Request& req, + const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& chassisId) +{ + if (!redfish::setUpRedfishRoute(app, req, asyncResp)) + { + return; + } + if (chassisId != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", chassisId); + return; + } + clearDump(asyncResp, "System"); +} + inline void requestRoutesBMCDumpService(App& app) { BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/LogServices/Dump/") @@ -2570,55 +2760,55 @@ inline void requestRoutesFaultLogDumpClear(App& app) inline void requestRoutesSystemDumpService(App& app) { - BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/LogServices/Dump/") + BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/Dump/") .privileges(redfish::privileges::getLogService) .methods(boost::beast::http::verb::get)(std::bind_front( - handleLogServicesDumpServiceGet, std::ref(app), "System")); + handleLogServicesDumpServiceComputerSystemGet, std::ref(app))); } inline void requestRoutesSystemDumpEntryCollection(App& app) { - BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/LogServices/Dump/Entries/") + BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/Dump/Entries/") .privileges(redfish::privileges::getLogEntryCollection) - .methods(boost::beast::http::verb::get)( - std::bind_front(handleLogServicesDumpEntriesCollectionGet, - std::ref(app), "System")); + .methods(boost::beast::http::verb::get)(std::bind_front( + handleLogServicesDumpEntriesCollectionComputerSystemGet, + std::ref(app))); } inline void requestRoutesSystemDumpEntry(App& app) { BMCWEB_ROUTE(app, - "/redfish/v1/Systems/system/LogServices/Dump/Entries/<str>/") + "/redfish/v1/Systems/<str>/LogServices/Dump/Entries/<str>/") .privileges(redfish::privileges::getLogEntry) .methods(boost::beast::http::verb::get)(std::bind_front( - handleLogServicesDumpEntryGet, std::ref(app), "System")); + handleLogServicesDumpEntryComputerSystemGet, std::ref(app))); BMCWEB_ROUTE(app, - "/redfish/v1/Systems/system/LogServices/Dump/Entries/<str>/") + "/redfish/v1/Systems/<str>/LogServices/Dump/Entries/<str>/") .privileges(redfish::privileges::deleteLogEntry) .methods(boost::beast::http::verb::delete_)(std::bind_front( - handleLogServicesDumpEntryDelete, std::ref(app), "System")); + handleLogServicesDumpEntryComputerSystemDelete, std::ref(app))); } inline void requestRoutesSystemDumpCreate(App& app) { BMCWEB_ROUTE( app, - "/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.CollectDiagnosticData/") + "/redfish/v1/Systems/<str>/LogServices/Dump/Actions/LogService.CollectDiagnosticData/") .privileges(redfish::privileges::postLogService) - .methods(boost::beast::http::verb::post)( - std::bind_front(handleLogServicesDumpCollectDiagnosticDataPost, - std::ref(app), "System")); + .methods(boost::beast::http::verb::post)(std::bind_front( + handleLogServicesDumpCollectDiagnosticDataComputerSystemPost, + std::ref(app))); } inline void requestRoutesSystemDumpClear(App& app) { BMCWEB_ROUTE( app, - "/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.ClearLog/") + "/redfish/v1/Systems/<str>/LogServices/Dump/Actions/LogService.ClearLog/") .privileges(redfish::privileges::postLogService) .methods(boost::beast::http::verb::post)(std::bind_front( - handleLogServicesDumpClearLogPost, std::ref(app), "System")); + handleLogServicesDumpClearLogComputerSystemPost, std::ref(app))); } inline void requestRoutesCrashdumpService(App& app) @@ -2628,17 +2818,25 @@ inline void requestRoutesCrashdumpService(App& app) /** * Functions triggers appropriate requests on DBus */ - BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/LogServices/Crashdump/") + BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/Crashdump/") // This is incorrect, should be: //.privileges(redfish::privileges::getLogService) .privileges({{"ConfigureManager"}}) .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; + } + // Copy over the static data to include the entries added by // SubRoute asyncResp->res.jsonValue["@odata.id"] = @@ -2671,17 +2869,24 @@ void inline requestRoutesCrashdumpClear(App& app) { BMCWEB_ROUTE( app, - "/redfish/v1/Systems/system/LogServices/Crashdump/Actions/LogService.ClearLog/") + "/redfish/v1/Systems/<str>/LogServices/Crashdump/Actions/LogService.ClearLog/") // This is incorrect, should be: //.privileges(redfish::privileges::postLogService) .privileges({{"ConfigureComponents"}}) .methods(boost::beast::http::verb::post)( [&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; + } crow::connections::systemBus->async_method_call( [asyncResp](const boost::system::error_code ec, const std::string&) { @@ -2774,17 +2979,25 @@ inline void requestRoutesCrashdumpEntryCollection(App& app) * Functions triggers appropriate requests on DBus */ BMCWEB_ROUTE(app, - "/redfish/v1/Systems/system/LogServices/Crashdump/Entries/") + "/redfish/v1/Systems/<str>/LogServices/Crashdump/Entries/") // This is incorrect, should be. //.privileges(redfish::privileges::postLogEntryCollection) .privileges({{"ConfigureComponents"}}) .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; + } + crow::connections::systemBus->async_method_call( [asyncResp](const boost::system::error_code ec, const std::vector<std::string>& resp) { @@ -2836,18 +3049,25 @@ inline void requestRoutesCrashdumpEntry(App& app) // method for security reasons. BMCWEB_ROUTE( - app, "/redfish/v1/Systems/system/LogServices/Crashdump/Entries/<str>/") + app, "/redfish/v1/Systems/<str>/LogServices/Crashdump/Entries/<str>/") // this is incorrect, should be // .privileges(redfish::privileges::getLogEntry) .privileges({{"ConfigureComponents"}}) .methods(boost::beast::http::verb::get)( [&app](const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, - const std::string& param) { + const std::string& systemName, const std::string& param) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } + if (systemName != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", + systemName); + ; + return; + } const std::string& logID = param; logCrashdumpEntry(asyncResp, logID, asyncResp->res.jsonValue); }); @@ -2859,14 +3079,24 @@ inline void requestRoutesCrashdumpFile(App& app) // method for security reasons. BMCWEB_ROUTE( app, - "/redfish/v1/Systems/system/LogServices/Crashdump/Entries/<str>/<str>/") + "/redfish/v1/Systems/<str>/LogServices/Crashdump/Entries/<str>/<str>/") .privileges(redfish::privileges::getLogEntry) .methods(boost::beast::http::verb::get)( [](const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, - const std::string& logID, const std::string& fileName) { + const std::string& systemName, const std::string& logID, + const std::string& fileName) { // Do not call getRedfishRoute here since the crashdump file is not a // Redfish resource. + + if (systemName != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", + systemName); + ; + return; + } + auto getStoredLogCallback = [asyncResp, logID, fileName, url(boost::urls::url(req.urlView))]( const boost::system::error_code ec, @@ -2950,17 +3180,27 @@ inline void requestRoutesCrashdumpCollect(App& app) // method for security reasons. BMCWEB_ROUTE( app, - "/redfish/v1/Systems/system/LogServices/Crashdump/Actions/LogService.CollectDiagnosticData/") + "/redfish/v1/Systems/<str>/LogServices/Crashdump/Actions/LogService.CollectDiagnosticData/") // The below is incorrect; Should be ConfigureManager //.privileges(redfish::privileges::postLogService) .privileges({{"ConfigureComponents"}}) .methods(boost::beast::http::verb::post)( [&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; + } + std::string diagnosticDataType; std::string oemDiagnosticDataType; if (!redfish::json_util::readJsonAction( @@ -3073,15 +3313,23 @@ inline void requestRoutesDBusLogServiceActionsClear(App& app) BMCWEB_ROUTE( app, - "/redfish/v1/Systems/system/LogServices/EventLog/Actions/LogService.ClearLog/") + "/redfish/v1/Systems/<str>/LogServices/EventLog/Actions/LogService.ClearLog/") .privileges(redfish::privileges::postLogService) .methods(boost::beast::http::verb::post)( [&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; + } BMCWEB_LOG_DEBUG << "Do delete all entries."; // Process response from Logging service. @@ -3113,16 +3361,23 @@ inline void requestRoutesDBusLogServiceActionsClear(App& app) ******************************************************/ inline void requestRoutesPostCodesLogService(App& app) { - BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/LogServices/PostCodes/") + BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/PostCodes/") .privileges(redfish::privileges::getLogService) .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.id"] = "/redfish/v1/Systems/system/LogServices/PostCodes"; asyncResp->res.jsonValue["@odata.type"] = @@ -3150,17 +3405,25 @@ inline void requestRoutesPostCodesClear(App& app) { BMCWEB_ROUTE( app, - "/redfish/v1/Systems/system/LogServices/PostCodes/Actions/LogService.ClearLog/") + "/redfish/v1/Systems/<str>/LogServices/PostCodes/Actions/LogService.ClearLog/") // The following privilege is incorrect; It should be ConfigureManager //.privileges(redfish::privileges::postLogService) .privileges({{"ConfigureComponents"}}) .methods(boost::beast::http::verb::post)( [&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; + } BMCWEB_LOG_DEBUG << "Do delete all postcodes entries."; // Make call to post-code service to request clear all @@ -3424,11 +3687,12 @@ static void inline void requestRoutesPostCodesEntryCollection(App& app) { BMCWEB_ROUTE(app, - "/redfish/v1/Systems/system/LogServices/PostCodes/Entries/") + "/redfish/v1/Systems/<str>/LogServices/PostCodes/Entries/") .privileges(redfish::privileges::getLogEntryCollection) .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) { query_param::QueryCapabilities capabilities = { .canDelegateTop = true, .canDelegateSkip = true, @@ -3439,6 +3703,14 @@ inline void requestRoutesPostCodesEntryCollection(App& app) { return; } + + if (systemName != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", + systemName); + ; + return; + } asyncResp->res.jsonValue["@odata.type"] = "#LogEntryCollection.LogEntryCollection"; asyncResp->res.jsonValue["@odata.id"] = @@ -3498,11 +3770,12 @@ inline void requestRoutesPostCodesEntryAdditionalData(App& app) { BMCWEB_ROUTE( app, - "/redfish/v1/Systems/system/LogServices/PostCodes/Entries/<str>/attachment/") + "/redfish/v1/Systems/<str>/LogServices/PostCodes/Entries/<str>/attachment/") .privileges(redfish::privileges::getLogEntry) .methods(boost::beast::http::verb::get)( [&app](const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& systemName, const std::string& postCodeID) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { @@ -3515,6 +3788,13 @@ inline void requestRoutesPostCodesEntryAdditionalData(App& app) asyncResp->res.result(boost::beast::http::status::bad_request); return; } + if (systemName != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", + systemName); + ; + return; + } uint64_t currentValue = 0; uint16_t index = 0; @@ -3578,16 +3858,23 @@ inline void requestRoutesPostCodesEntryAdditionalData(App& app) inline void requestRoutesPostCodesEntry(App& app) { BMCWEB_ROUTE( - app, "/redfish/v1/Systems/system/LogServices/PostCodes/Entries/<str>/") + app, "/redfish/v1/Systems/<str>/LogServices/PostCodes/Entries/<str>/") .privileges(redfish::privileges::getLogEntry) .methods(boost::beast::http::verb::get)( [&app](const crow::Request& req, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, - const std::string& targetID) { + const std::string& systemName, const std::string& targetID) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } + if (systemName != "system") + { + messages::resourceNotFound(asyncResp->res, "ComputerSystem", + systemName); + return; + } + uint16_t bootIndex = 0; uint64_t codeIndex = 0; if (!parsePostCode(targetID, codeIndex, bootIndex)) |