Initial redfish logging support
This was imported from a fork:
https://github.com/ampere-openbmc/bmcweb/commits/ampere-next/redfish-core/lib/logservices.hpp
Which had a series of commits from TungVuX and hyche
The initial patch is that code verbatim.
Follow up patches on top of this make the necessary changes
for current bmcweb:
- Move to sdbusplus
- C++ naming convention changes
- Clang format
- Some refactoring
Tested:
Verified new services work correctly when queried
e.g. curl -k -H "X-Auth-Token: $bmc_token" -X GET \
https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries
displays the entries properly.
RedfishServiceValidator results:
/redfish/v1/Systems/system/LogServices
pass: 3
passGet: 1
skipOptional: 1
/redfish/v1/Systems/system/LogServices/EventLog
pass: 5
passGet: 1
skipOptional: 8
/redfish/v1/Systems/system/LogServices/EventLog/Entries
pass: 3
passGet: 1
skipOptional: 1
/redfish/v1/Systems/system/LogServices/EventLog/<str>
pass: 6
passGet: 1
skipOptional: 16
Sample Output: curl -k -H "X-Auth-Token: $bmc_token" -X GET https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries
{
"@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection",
"@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
"@odata.type": "#LogEntryCollection.LogEntryCollection",
"Description": "Collection of System Event Log Entries",
"Members": [
{
"@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
"@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
"@odata.type": "#LogEntry.v1_4_0.LogEntry",
"Created": "2019-02-22T17:11:00+00:00",
"EntryType": "Event",
"Id": "1",
"Message": "example.xyz.openbmc_project.Example.Elog.AutoTestSimple",
"Name": "System DBus Event Log Entry",
"Severity": "Critical"
}
],
"Members@odata.count": 1,
"Name": "System Event Log Entries"
}
Change-Id: I422b0d0ec577ea734fecfb6f49101ec5ff45a556
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Signed-off-by: Anthony Wilson <wilsonan@us.ibm.com>
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 3cde0ef..e6e80a8 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -971,7 +971,7 @@
manager_reset["ResetType@Redfish.AllowableValues"] = {
"GracefulRestart"};
- res.jsonValue["DateTime"] = getDateTime();
+ res.jsonValue["DateTime"] = crow::utility::dateTimeNow();
res.jsonValue["Links"]["ManagerForServers@odata.count"] = 1;
res.jsonValue["Links"]["ManagerForServers"] = {
{{"@odata.id", "/redfish/v1/Systems/system"}}};
@@ -1268,23 +1268,6 @@
}
}
- std::string getDateTime() const
- {
- std::array<char, 128> dateTime;
- std::string redfishDateTime("0000-00-00T00:00:00Z00:00");
- std::time_t time = std::time(nullptr);
-
- if (std::strftime(dateTime.begin(), dateTime.size(), "%FT%T%z",
- std::localtime(&time)))
- {
- // insert the colon required by the ISO 8601 standard
- redfishDateTime = std::string(dateTime.data());
- redfishDateTime.insert(redfishDateTime.end() - 2, ':');
- }
-
- return redfishDateTime;
- }
-
std::string uuid;
};