// SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright OpenBMC Authors // SPDX-FileCopyrightText: Copyright 2018 Intel Corporation #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/eventlog_utils.hpp" #include #include #include #include #include #include #include #include #include #include namespace redfish { inline void handleSystemsDBusEventLogEntryCollection( 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; } eventlog_utils::dBusEventLogEntryCollection( asyncResp, eventlog_utils::LogServiceParent::Systems); } inline void handleSystemsDBusEventLogEntryGet( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& systemName, const std::string& entryId) { 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; } eventlog_utils::dBusEventLogEntryGet( asyncResp, eventlog_utils::LogServiceParent::Systems, entryId); } inline void handleSystemsDBusEventLogEntryPatch( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& systemName, const std::string& entryId) { 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; } eventlog_utils::dBusEventLogEntryPatch(req, asyncResp, entryId); } inline void handleSystemsDBusEventLogEntryDelete( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& systemName, const std::string& entryId) { 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; } eventlog_utils::dBusEventLogEntryDelete(asyncResp, entryId); } inline void handleSystemsDBusLogServiceActionsClear( 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; } eventlog_utils::dBusLogServiceActionsClear(asyncResp); } inline void handleSystemsDBusEventLogEntryDownloadGet( crow::App& app, const crow::Request& req, const std::shared_ptr& asyncResp, const std::string& systemName, const std::string& entryId) { if (!redfish::setUpRedfishRoute(app, req, asyncResp)) { return; } if (!http_helpers::isContentTypeAllowed( req.getHeaderValue("Accept"), http_helpers::ContentType::OctetStream, true)) { asyncResp->res.result(boost::beast::http::status::bad_request); 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; } eventlog_utils::downloadEventLogEntry(asyncResp, entryId, "System"); } inline void requestRoutesSystemsDBusEventLog(App& app) { BMCWEB_ROUTE(app, "/redfish/v1/Systems//LogServices/EventLog/Entries/") .privileges(redfish::privileges::getLogEntryCollection) .methods(boost::beast::http::verb::get)(std::bind_front( handleSystemsDBusEventLogEntryCollection, std::ref(app))); BMCWEB_ROUTE( app, "/redfish/v1/Systems//LogServices/EventLog/Entries//") .privileges(redfish::privileges::getLogEntry) .methods(boost::beast::http::verb::get)( std::bind_front(handleSystemsDBusEventLogEntryGet, std::ref(app))); BMCWEB_ROUTE( app, "/redfish/v1/Systems//LogServices/EventLog/Entries//") .privileges(redfish::privileges::patchLogEntry) .methods(boost::beast::http::verb::patch)(std::bind_front( handleSystemsDBusEventLogEntryPatch, std::ref(app))); BMCWEB_ROUTE( app, "/redfish/v1/Systems//LogServices/EventLog/Entries//") .privileges( redfish::privileges:: deleteLogEntrySubOverComputerSystemLogServiceCollectionLogServiceLogEntryCollection) .methods(boost::beast::http::verb::delete_)(std::bind_front( handleSystemsDBusEventLogEntryDelete, std::ref(app))); BMCWEB_ROUTE( app, "/redfish/v1/Systems//LogServices/EventLog/Actions/LogService.ClearLog/") .privileges(redfish::privileges:: postLogServiceSubOverComputerSystemLogServiceCollection) .methods(boost::beast::http::verb::post)(std::bind_front( handleSystemsDBusLogServiceActionsClear, std::ref(app))); BMCWEB_ROUTE( app, "/redfish/v1/Systems//LogServices/EventLog/Entries//attachment/") .privileges(redfish::privileges::getLogEntry) .methods(boost::beast::http::verb::get)(std::bind_front( handleSystemsDBusEventLogEntryDownloadGet, std::ref(app))); } } // namespace redfish