summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Wilson <wilsonan@us.ibm.com>2019-04-12 08:23:05 -0500
committerEd Tanous <ed.tanous@intel.com>2019-07-03 16:48:58 +0000
commit08a4e4b592e582c8534f59dc73320763a07a3bbb (patch)
treea544573d922f98a7f7265033e3d1a0feb403abf2
parentd1d50814d1756a33755dd9de5c62124223cedc98 (diff)
downloadbmcweb-08a4e4b592e582c8534f59dc73320763a07a3bbb.tar.gz
bmcweb-08a4e4b592e582c8534f59dc73320763a07a3bbb.zip
redfish: Give DBus event logging its own classes
Since the DBus implementation of event logging is completely different than the journal implementation, moved it to its own class to be consistent. Tested: Verified both implementations work the same as before the class split. Change-Id: I95e3b837f9d99b78034695545ab5791386d94a13 Signed-off-by: Anthony Wilson <wilsonan@us.ibm.com>
-rw-r--r--redfish-core/include/redfish.hpp5
-rw-r--r--redfish-core/lib/log_services.hpp61
2 files changed, 49 insertions, 17 deletions
diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp
index 8cb9e01..718b082 100644
--- a/redfish-core/include/redfish.hpp
+++ b/redfish-core/include/redfish.hpp
@@ -82,8 +82,9 @@ class RedfishService
nodes.emplace_back(std::make_unique<SystemLogServiceCollection>(app));
nodes.emplace_back(std::make_unique<EventLogService>(app));
nodes.emplace_back(std::make_unique<EventLogClear>(app));
+#ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
nodes.emplace_back(std::make_unique<EventLogEntryCollection>(app));
- nodes.emplace_back(std::make_unique<EventLogEntry>(app));
+#endif
nodes.emplace_back(std::make_unique<BMCLogServiceCollection>(app));
#ifdef BMCWEB_ENABLE_REDFISH_BMC_JOURNAL
@@ -112,6 +113,8 @@ class RedfishService
nodes.emplace_back(std::make_unique<SystemActionsReset>(app));
#ifdef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
nodes.emplace_back(std::make_unique<DBusLogServiceActionsClear>(app));
+ nodes.emplace_back(std::make_unique<DBusEventLogEntryCollection>(app));
+ nodes.emplace_back(std::make_unique<DBusEventLogEntry>(app));
#endif
nodes.emplace_back(
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 9e3b2f0..063a34c 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -453,8 +453,8 @@ class SystemLogServiceCollection : public Node
{{"@odata.id", "/redfish/v1/Systems/system/LogServices/EventLog"}});
#ifdef BMCWEB_ENABLE_REDFISH_CPU_LOG
logServiceArray.push_back(
- {{ "@odata.id",
- "/redfish/v1/Systems/system/LogServices/Crashdump" }});
+ {{"@odata.id",
+ "/redfish/v1/Systems/system/LogServices/Crashdump"}});
#endif
asyncResp->res.jsonValue["Members@odata.count"] =
logServiceArray.size();
@@ -695,7 +695,6 @@ class EventLogEntryCollection : public Node
asyncResp->res.jsonValue["Description"] =
"Collection of System Event Log Entries";
-#ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
nlohmann::json &logEntryArray = asyncResp->res.jsonValue["Members"];
logEntryArray = nlohmann::json::array();
// Go through the log files and create a unique ID for each entry
@@ -747,7 +746,43 @@ class EventLogEntryCollection : public Node
"Entries?$skip=" +
std::to_string(skip + top);
}
-#else
+ }
+};
+
+class DBusEventLogEntryCollection : public Node
+{
+ public:
+ template <typename CrowApp>
+ DBusEventLogEntryCollection(CrowApp &app) :
+ Node(app, "/redfish/v1/Systems/system/LogServices/EventLog/Entries/")
+ {
+ 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> &params) override
+ {
+ std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res);
+
+ // Collections don't include the static data added by SubRoute because
+ // it has a duplicate entry for members
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogEntryCollection.LogEntryCollection";
+ asyncResp->res.jsonValue["@odata.context"] =
+ "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/EventLog/Entries";
+ asyncResp->res.jsonValue["Name"] = "System Event Log Entries";
+ asyncResp->res.jsonValue["Description"] =
+ "Collection of System Event Log Entries";
+
// DBus implementation of EventLog/Entries
// Make call to Logging Service to find all log entry objects
crow::connections::systemBus->async_method_call(
@@ -860,14 +895,13 @@ class EventLogEntryCollection : public Node
},
"xyz.openbmc_project.Logging", "/xyz/openbmc_project/logging",
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
-#endif
}
};
-class EventLogEntry : public Node
+class DBusEventLogEntry : public Node
{
public:
- EventLogEntry(CrowApp &app) :
+ DBusEventLogEntry(CrowApp &app) :
Node(app,
"/redfish/v1/Systems/system/LogServices/EventLog/Entries/<str>/",
std::string())
@@ -893,7 +927,6 @@ class EventLogEntry : public Node
}
const std::string &entryID = params[0];
-#ifdef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
// DBus implementation of EventLog/Entries
// Make call to Logging Service to find all log entry objects
crow::connections::systemBus->async_method_call(
@@ -971,14 +1004,12 @@ class EventLogEntry : public Node
{"Message", *message},
{"EntryType", "Event"},
{"Severity", translateSeverityDbusToRedfish(*severity)},
- { "Created",
- crow::utility::getDateTime(timestamp) }};
+ {"Created", crow::utility::getDateTime(timestamp)}};
},
"xyz.openbmc_project.Logging",
"/xyz/openbmc_project/logging/entry/" + entryID,
"org.freedesktop.DBus.Properties", "GetAll",
"xyz.openbmc_project.Logging.Entry");
-#endif
}
};
@@ -1021,8 +1052,7 @@ class BMCLogServiceCollection : public Node
logServiceArray = nlohmann::json::array();
#ifdef BMCWEB_ENABLE_REDFISH_BMC_JOURNAL
logServiceArray.push_back(
- {{ "@odata.id",
- "/redfish/v1/Managers/bmc/LogServices/Journal" }});
+ {{"@odata.id", "/redfish/v1/Managers/bmc/LogServices/Journal"}});
#endif
asyncResp->res.jsonValue["Members@odata.count"] =
logServiceArray.size();
@@ -1331,9 +1361,8 @@ class CrashdumpService : public Node
#ifdef BMCWEB_ENABLE_REDFISH_RAW_PECI
asyncResp->res.jsonValue["Actions"]["Oem"].push_back(
{"#Crashdump.SendRawPeci",
- { { "target",
- "/redfish/v1/Systems/system/LogServices/Crashdump/"
- "Actions/Oem/Crashdump.SendRawPeci" } }});
+ {{"target", "/redfish/v1/Systems/system/LogServices/Crashdump/"
+ "Actions/Oem/Crashdump.SendRawPeci"}}});
#endif
}
};
OpenPOWER on IntegriCloud