| #ifndef THIRD_PARTY_GBMCWEB_REDFISH_CORE_LIB_LOG_SERVICES_H_ | |
| #define THIRD_PARTY_GBMCWEB_REDFISH_CORE_LIB_LOG_SERVICES_H_ | |
| /* | |
| // Copyright (c) 2018 Intel Corporation | |
| // | |
| // Licensed under the Apache License, Version 2.0 (the "License"); | |
| // you may not use this file except in compliance with the License. | |
| // You may obtain a copy of the License at | |
| // | |
| // http://www.apache.org/licenses/LICENSE-2.0 | |
| // | |
| // Unless required by applicable law or agreed to in writing, software | |
| // distributed under the License is distributed on an "AS IS" BASIS, | |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| // See the License for the specific language governing permissions and | |
| // limitations under the License. | |
| */ | |
| #include <array> | |
| #include <cstddef> | |
| #include <cstdint> | |
| #include <filesystem> // NOLINT | |
| #include <fstream> | |
| #include <memory> | |
| #include <optional> | |
| #include <string> | |
| #include <string_view> | |
| #include <tuple> | |
| #include <unordered_map> | |
| #include <utility> | |
| #include <vector> | |
| #include "absl/strings/str_cat.h" | |
| #include "app.hpp" | |
| #include "app_singleton.hpp" | |
| #include "http_request.hpp" | |
| #include "async_resp.hpp" | |
| #include "query.hpp" | |
| #include <nlohmann/json.hpp> | |
| namespace redfish { | |
| std::optional<std::string> crashdumpFolderPathFromSystemName( | |
| std::string_view systemName, std::string_view basePathPrefix = ""); | |
| using BootTimeCheckpoint = std::tuple<std::string, int64_t, int64_t>; | |
| using BootTimeDuration = std::tuple<std::string, int64_t>; | |
| enum class DumpType : std::uint8_t { | |
| BMC_DUMP = 0, | |
| SYSTEM_DUMP, | |
| BMC_FAULT_LOG, | |
| SYSTEM_FAULT_LOG, | |
| }; | |
| enum class LogParseError : std::uint8_t { | |
| success, | |
| parseFailed, | |
| messageIdNotInRegistry, | |
| }; | |
| // The index of the string is the integer value of the DumpType enum | |
| constexpr std::array<std::string_view, 4> dumpTypeStrings{ | |
| {"BMC", "System", "FaultLog", "FaultLog"}}; | |
| constexpr std::array<std::string_view, 1> systemInventoryInterfaces{ | |
| {"xyz.openbmc_project.Inventory.Item.System"}}; | |
| struct Dump { | |
| DumpType type = DumpType::BMC_DUMP; | |
| std::optional<std::string> systemName = std::nullopt; | |
| }; | |
| enum class BootTimeDataType : std::uint8_t { CHECKPOINT, DURATION, STATISTIC }; | |
| constexpr std::array<std::string_view, 3> bootTimeDataTypeString{ | |
| {"Checkpoint", "Duration", "Statistic"}}; | |
| std::string dumpTypeToString(DumpType dumpType); | |
| inline std::string bootTimeDataTypeToString(BootTimeDataType dataType); | |
| namespace internal { | |
| void getDumpServiceInfo(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const Dump& dump); | |
| } // namespace internal | |
| void getDumpEntryCollection(App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const Dump& dump, | |
| const query_param::Query& delegatedQuery); | |
| inline void getDumpEntryCollection( | |
| const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const Dump& dump, | |
| const query_param::Query& delegatedQuery) { | |
| getDumpEntryCollection(*crow::globalBmcWebApp, req, asyncResp, dump, | |
| delegatedQuery); | |
| } | |
| void getDumpEntryById(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& entryID, const Dump& dump); | |
| void queryFaultCollection( | |
| App& app, const crow::Request& origReq, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& collectionUri, | |
| std::unordered_map<std::string, nlohmann::json::json_pointer>& | |
| faultLogEntries, | |
| nlohmann::json& originalMembers); | |
| inline void queryFaultCollection( | |
| const crow::Request& origReq, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& collectionUri, | |
| std::unordered_map<std::string, nlohmann::json::json_pointer>& | |
| faultLogEntries, | |
| nlohmann::json& originalMembers) { | |
| queryFaultCollection(*crow::globalBmcWebApp, origReq, asyncResp, | |
| collectionUri, faultLogEntries, originalMembers); | |
| } | |
| inline bool getHostLoggerEntries( | |
| const std::vector<std::filesystem::path>& hostLoggerFiles, uint64_t skip, | |
| uint64_t top, std::vector<std::string>& logEntries, size_t& logCount); | |
| void handleDeleteEventLogEntry( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName, const std::string& param); | |
| void handlePatchEventLogEntry( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName, const std::string& entryId); | |
| void handleLogServiceFaultLogEntriesGet( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName); | |
| void handleLogServicesRasManagerEntriesCollectionGet( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName); | |
| #ifdef HEALTH_POPULATE | |
| void handleHealthMonitorLogServiceGet( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName); | |
| void handleHealthMonitorLogEntryCollectionGet( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName); | |
| void handleHealthMonitorLogEntryGet( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName, const std::string& entryId); | |
| #endif /* HEALTH_POPULATE */ | |
| void requestRoutesSystemLogServiceCollection(App& app); | |
| void handleSystemLogServicesCollectionGet( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName); | |
| void requestRoutesEventLogService(App& app); | |
| void requestRoutesJournalEventLogClear(App& app); | |
| void requestRoutesJournalEventLogEntryCollection(App& app); | |
| void requestRoutesJournalEventLogEntry(App& app); | |
| void requestRoutesDBusEventLogEntryCollection(App& app); | |
| void requestRoutesDBusEventLogEntry(App& app); | |
| void requestRoutesDBusEventLogEntryDownload(App& app); | |
| void requestRoutesSystemHostLogger(App& app); | |
| void requestRoutesSystemHostLoggerCollection(App& app); | |
| void requestRoutesSystemHostLoggerLogEntry(App& app); | |
| void requestRoutesHealthMonitorLogService(App& app); | |
| void requestRoutesHealthMonitorLogEntryCollection(App& app); | |
| void requestRoutesHealthMonitorLogEntry(App& app); | |
| void requestRoutesBMCLogServiceCollection(App& app); | |
| void requestRoutesBMCJournalLogService(App& app); | |
| void requestRoutesBMCJournalLogEntryCollection(App& app); | |
| void requestRoutesBMCJournalLogEntry(App& app); | |
| void requestRoutesRasManagerLogService(App& app); | |
| void requestRoutesRasManagerLogEntryCollection(App& app); | |
| void requestRoutesRasManagerLogEntry(App& app); | |
| void requestRoutesRasManagerLogClear(App& app); | |
| void requestRoutesIliadLogService(App& app); | |
| void requestRoutesIliadLogEntryCollection(App& app); | |
| void requestRoutesIliadLogEntry(App& app); | |
| void requestRoutesBMCDumpService(App& app); | |
| void requestRoutesBMCDumpEntryCollection(App& app); | |
| void requestRoutesBMCDumpEntry(App& app); | |
| void requestRoutesBMCDumpEntryDownload(App& app); | |
| void requestRoutesBMCDumpCreate(App& app); | |
| void requestRoutesBMCDumpClear(App& app); | |
| void requestRoutesFaultLogDumpService(App& app); | |
| void requestRoutesFaultLogDumpEntryCollection(App& app); | |
| void requestRoutesFaultLogDumpEntry(App& app); | |
| void requestRoutesFaultLogDumpClear(App& app); | |
| void requestRoutesSystemDumpService(App& app); | |
| void requestRoutesSystemDumpEntryCollection(App& app); | |
| void requestRoutesSystemDumpEntry(App& app); | |
| void requestRoutesSystemDumpCreate(App& app); | |
| void requestRoutesSystemDumpClear(App& app); | |
| void requestRoutesCrashdumpService(App& app); | |
| void requestRoutesCrashdumpClear(App& app); | |
| void requestRoutesCrashdumpEntryCollection(App& app); | |
| void requestRoutesCrashdumpEntry(App& app); | |
| void requestRoutesCrashdumpFile(App& app); | |
| void requestRoutesCrashdumpCollect(App& app); | |
| void requestRoutesPPRService(App& app); | |
| void requestRoutesPPRStatus(App& app); | |
| void requestRoutesPPRFile(App& app); | |
| void requestRoutesPPRConfig(App& app); | |
| void requestRoutesDBusLogServiceActionsClear(App& app); | |
| void requestRoutesPostCodesLogService(App& app); | |
| void requestRoutesPostCodesClear(App& app); | |
| void requestRoutesPostCodesEntryCollection(App& app); | |
| void requestRoutesPostCodesEntryAdditionalData(App& app); | |
| void requestRoutesPostCodesEntry(App& app); | |
| void handleGetPostCodesLogService( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName); | |
| void handlePostPostCodesClear( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName); | |
| void handleGetPostCodesEntryCollection( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName); | |
| void handleGetPostCodesEntryAdditionalData( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName, const std::string& postCodeID); | |
| void handleGetPostCodesEntry( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName, const std::string& targetID); | |
| void handleGetCrashdumpService( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName); | |
| void handleGetCrashdumpEntryCollection( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName); | |
| void handleGetCrashdumpEntryCollection( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName, const std::string& basePathPrefix); | |
| void handleGetCrashdumpEntry( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName, const std::string& param); | |
| void handleGetCrashdumpEntry( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName, const std::string& param, | |
| const std::string& basePathPrefix); | |
| void handleSystemBootTimeLogServiceGet( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName); | |
| void handleManagerBootTimeLogServiceGet( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp); | |
| void handleSystemBootTimeLogsEntryCollectionGet( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName); | |
| void handleManagerBootTimeLogsEntryCollectionGet( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp); | |
| void requestRoutesBootTimeLogService(App& app); | |
| void requestRoutesBootTimeLogEntryCollection(App& app); | |
| void handleSystemBootTimeLogsEntryGet( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& systemName, const std::string& entryId); | |
| void handleManagerBootTimeLogsEntryGet( | |
| App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, | |
| const std::string& entryId); | |
| void requestRoutesBootTimeLogEntry(App& app); | |
| void handlePPRServiceGet(App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp); | |
| void getPostPackageRepairStatus( | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp); | |
| void handlePPRStatusGet(App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp); | |
| void setPostPackageRepairData( | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, uint16_t Index, | |
| uint16_t repairEntryNum, uint16_t repairType, uint16_t socNum, | |
| std::vector<uint16_t>& payload); | |
| void handlePPRFilePost(App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp); | |
| void getPostPackageRepairConfig( | |
| const std::shared_ptr<bmcweb::AsyncResp>& aResp); | |
| void setPostPackageRepairConfig( | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const uint16_t& flag, | |
| const bool& data); | |
| void handlePPRConfigGet(App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp); | |
| void handlePPRConfigPost(App& app, const crow::Request& req, | |
| const std::shared_ptr<bmcweb::AsyncResp>& asyncResp); | |
| } // namespace redfish | |
| #endif // THIRD_PARTY_GBMCWEB_REDFISH_CORE_LIB_LOG_SERVICES_H_ |