// SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright OpenBMC Authors #pragma once #include "bmcweb_config.h" #include "app.hpp" #include "async_resp.hpp" #include "error_messages.hpp" #include "http_request.hpp" #include "query.hpp" #include "registries/privilege_registry.hpp" #include "utils/dump_utils.hpp" #include #include #include #include namespace redfish { inline void handleSystemsLogServicesDumpServiceGet( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& systemName) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME) { messages::resourceNotFound(asyncResp->res, "ComputerSystem", systemName); return; } dump_utils::getDumpServiceInfo(asyncResp, "System"); } inline void handleSystemsLogServicesDumpEntriesCollectionGet( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& systemName) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME) { messages::resourceNotFound(asyncResp->res, "ComputerSystem", systemName); return; } dump_utils::getDumpEntryCollection(asyncResp, "System"); } inline void handleSystemsLogServicesDumpEntryGet( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& systemName, const std::string& dumpId) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME) { messages::resourceNotFound(asyncResp->res, "ComputerSystem", systemName); return; } dump_utils::getDumpEntryById(asyncResp, dumpId, "System"); } inline void handleSystemsLogServicesDumpEntryDelete( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& systemName, const std::string& dumpId) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME) { messages::resourceNotFound(asyncResp->res, "ComputerSystem", systemName); return; } dump_utils::deleteDumpEntry(asyncResp, dumpId, "System"); } inline void handleSystemsLogServicesDumpEntryDownloadGet( crow::App& app, const std::string& dumpType, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& systemName, const std::string& dumpId) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM) { // Option currently returns no systems. TBD messages::resourceNotFound(asyncResp->res, "ComputerSystem", systemName); return; } if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME) { messages::resourceNotFound(asyncResp->res, "ComputerSystem", systemName); return; } dump_utils::downloadDumpEntry(asyncResp, dumpId, dumpType); } inline void handleSystemsLogServicesDumpCollectDiagnosticDataPost( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& systemName) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM) { // Option currently returns no systems. TBD messages::resourceNotFound(asyncResp->res, "ComputerSystem", systemName); return; } if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME) { messages::resourceNotFound(asyncResp->res, "ComputerSystem", systemName); return; } dump_utils::createDump(asyncResp, req, "System"); } inline void handleSystemsLogServicesDumpClearLogPost( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& systemName) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } if constexpr (BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM) { // Option currently returns no systems. TBD messages::resourceNotFound(asyncResp->res, "ComputerSystem", systemName); return; } if (systemName != BMCWEB_REDFISH_SYSTEM_URI_NAME) { messages::resourceNotFound(asyncResp->res, "ComputerSystem", systemName); return; } dump_utils::clearDump(asyncResp, "System"); } inline void requestRoutesSystemsLogServicesDump(App& app) { BMCWEB_ROUTE(app, "/redfish/v1/Systems//LogServices/Dump/") .privileges(redfish::privileges::getLogService) .methods(boost::beast::http::verb::get)(std::bind_front( handleSystemsLogServicesDumpServiceGet, std::ref(app))); BMCWEB_ROUTE(app, "/redfish/v1/Systems//LogServices/Dump/Entries/") .privileges(redfish::privileges::getLogEntryCollection) .methods(boost::beast::http::verb::get)(std::bind_front( handleSystemsLogServicesDumpEntriesCollectionGet, std::ref(app))); BMCWEB_ROUTE(app, "/redfish/v1/Systems//LogServices/Dump/Entries//") .privileges(redfish::privileges::getLogEntry) .methods(boost::beast::http::verb::get)(std::bind_front( handleSystemsLogServicesDumpEntryGet, std::ref(app))); BMCWEB_ROUTE(app, "/redfish/v1/Systems//LogServices/Dump/Entries//") .privileges(redfish::privileges::deleteLogEntry) .methods(boost::beast::http::verb::delete_)(std::bind_front( handleSystemsLogServicesDumpEntryDelete, std::ref(app))); BMCWEB_ROUTE( app, "/redfish/v1/Systems//LogServices/Dump/Entries//attachment/") .privileges(redfish::privileges::getLogEntry) .methods(boost::beast::http::verb::get)( std::bind_front(handleSystemsLogServicesDumpEntryDownloadGet, std::ref(app), "System")); BMCWEB_ROUTE( app, "/redfish/v1/Systems//LogServices/Dump/Actions/LogService.CollectDiagnosticData/") .privileges(redfish::privileges:: postLogServiceSubOverComputerSystemLogServiceCollection) .methods(boost::beast::http::verb::post)(std::bind_front( handleSystemsLogServicesDumpCollectDiagnosticDataPost, std::ref(app))); BMCWEB_ROUTE( app, "/redfish/v1/Systems//LogServices/Dump/Actions/LogService.ClearLog/") .privileges(redfish::privileges:: postLogServiceSubOverComputerSystemLogServiceCollection) .methods(boost::beast::http::verb::post)(std::bind_front( handleSystemsLogServicesDumpClearLogPost, std::ref(app))); } } // namespace redfish