diff options
| author | Jason M. Bills <jason.m.bills@linux.intel.com> | 2019-07-29 17:05:30 -0700 |
|---|---|---|
| committer | Ed Tanous <ed.tanous@intel.com> | 2019-08-02 17:13:01 +0000 |
| commit | 897967def41b35ec39069bee365eeee8a1111bd9 (patch) | |
| tree | 59696264254634b64d55168d49f224c668d1db4d | |
| parent | e85d6b167dcce7ea0c4adee5ea7113f7b6135319 (diff) | |
| download | bmcweb-897967def41b35ec39069bee365eeee8a1111bd9.tar.gz bmcweb-897967def41b35ec39069bee365eeee8a1111bd9.zip | |
Add support to request a single Journal Event Log Entry
This change adds back support to request a single Journal Event
Log Entry.
Tested:
Requested a single valid entry and got it.
Requested an invalid entry and got the correct error message.
Passed the Redfish Service Validator.
Change-Id: Ibd2defee04510c1b52fe010cf3e2c6aced94537f
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
| -rw-r--r-- | redfish-core/include/redfish.hpp | 1 | ||||
| -rw-r--r-- | redfish-core/lib/log_services.hpp | 79 |
2 files changed, 79 insertions, 1 deletions
diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp index 21d6500..6f68611 100644 --- a/redfish-core/include/redfish.hpp +++ b/redfish-core/include/redfish.hpp @@ -86,6 +86,7 @@ class RedfishService #ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES nodes.emplace_back( std::make_unique<JournalEventLogEntryCollection>(app)); + nodes.emplace_back(std::make_unique<JournalEventLogEntry>(app)); #endif nodes.emplace_back(std::make_unique<BMCLogServiceCollection>(app)); diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index 94496a1..a9356ae 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -651,7 +651,7 @@ static int fillEventLogEntryJson(const std::string &logEntryID, {"@odata.type", "#LogEntry.v1_4_0.LogEntry"}, {"@odata.context", "/redfish/v1/$metadata#LogEntry.LogEntry"}, {"@odata.id", - "/redfish/v1/Systems/system/LogServices/EventLog/Entries/#" + + "/redfish/v1/Systems/system/LogServices/EventLog/Entries/" + logEntryID}, {"Name", "System Event Log Entry"}, {"Id", logEntryID}, @@ -768,6 +768,83 @@ class JournalEventLogEntryCollection : public Node } }; +class JournalEventLogEntry : public Node +{ + public: + JournalEventLogEntry(CrowApp &app) : + Node(app, + "/redfish/v1/Systems/system/LogServices/EventLog/Entries/<str>/", + std::string()) + { + entityPrivileges = { + {boost::beast::http::verb::get, {{"Login"}}}, + {boost::beast::http::verb::head, {{"Login"}}}, + {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, + {boost::beast::http::verb::put, {{"ConfigureManager"}}}, + {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, + {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; + } + + private: + void doGet(crow::Response &res, const crow::Request &req, + const std::vector<std::string> ¶ms) override + { + std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res); + if (params.size() != 1) + { + messages::internalError(asyncResp->res); + return; + } + const std::string &targetID = params[0]; + + // Go through the log files and check the unique ID for each entry to + // find the target entry + std::vector<std::filesystem::path> redfishLogFiles; + getRedfishLogFiles(redfishLogFiles); + std::string logEntry; + + // Oldest logs are in the last file, so start there and loop backwards + for (auto it = redfishLogFiles.rbegin(); it < redfishLogFiles.rend(); + it++) + { + std::ifstream logStream(*it); + if (!logStream.is_open()) + { + continue; + } + + // Reset the unique ID on the first entry + bool firstEntry = true; + while (std::getline(logStream, logEntry)) + { + std::string idStr; + if (!getUniqueEntryID(logEntry, idStr, firstEntry)) + { + continue; + } + + if (firstEntry) + { + firstEntry = false; + } + + if (idStr == targetID) + { + if (fillEventLogEntryJson(idStr, logEntry, + asyncResp->res.jsonValue) != 0) + { + messages::internalError(asyncResp->res); + return; + } + return; + } + } + } + // Requested ID was not found + messages::resourceMissingAtURI(asyncResp->res, targetID); + } +}; + class DBusEventLogEntryCollection : public Node { public: |

