Implement Modified Event log property
Refer to https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-dbus-interfaces/+/29734
and implement Modified Event log property
Tested:
curl -k -H "X-Auth-Token: $token" https://${bmc}/redfish/v1/Systems/system/LogServices/EventLog/Entries/1
{
"@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
"@odata.type": "#LogEntry.v1_6_0.LogEntry",
"Created": "1970-01-01T00:01:35+00:00",
"EntryType": "Event",
"Id": "1",
"Message": "xyz.openbmc_project.Common.Device.Error.ReadFailure",
"Modified": "1970-01-01T00:01:35+00:00",
"Name": "System Event Log Entry",
"Severity": "Critical"
}
Passed the validator:
VERBO - ServiceRoot -> Systems.Systems -> Members.ComputerSystem#0 ->
LogServices.LogServices -> Members.LogService#0 -> Entries.Entries ->
Members.LogEntry#0, LogEntry.v1_6_1, LogEntry
VERBO - @odata.id PASS
VERBO - @odata.type PASS
VERBO - Created PASS
VERBO - EntryType PASS
VERBO - Id PASS
VERBO - Message PASS
VERBO - Modified PASS
VERBO - Name PASS
VERBO - Severity PASS
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I5a59a298e95e78acaad11a99558f9046675820d3
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 6a23e6e..7be934e 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1440,8 +1440,10 @@
nlohmann::json& thisEntry = entriesArray.back();
uint32_t* id = nullptr;
std::time_t timestamp{};
+ std::time_t updateTimestamp{};
std::string* severity = nullptr;
std::string* message = nullptr;
+
for (auto& propertyMap : interfaceMap.second)
{
if (propertyMap.first == "Id")
@@ -1459,16 +1461,20 @@
if (millisTimeStamp == nullptr)
{
messages::internalError(asyncResp->res);
- continue;
}
- // Retrieve Created property with format:
- // yyyy-mm-ddThh:mm:ss
- std::chrono::milliseconds chronoTimeStamp(
+ timestamp = crow::utility::getTimestamp(
*millisTimeStamp);
- timestamp = std::chrono::duration_cast<
- std::chrono::duration<int>>(
- chronoTimeStamp)
- .count();
+ }
+ else if (propertyMap.first == "UpdateTimestamp")
+ {
+ const uint64_t* millisTimeStamp =
+ std::get_if<uint64_t>(&propertyMap.second);
+ if (millisTimeStamp == nullptr)
+ {
+ messages::internalError(asyncResp->res);
+ }
+ updateTimestamp = crow::utility::getTimestamp(
+ *millisTimeStamp);
}
else if (propertyMap.first == "Severity")
{
@@ -1490,7 +1496,7 @@
}
}
thisEntry = {
- {"@odata.type", "#LogEntry.v1_4_0.LogEntry"},
+ {"@odata.type", "#LogEntry.v1_6_0.LogEntry"},
{"@odata.id",
"/redfish/v1/Systems/system/LogServices/EventLog/"
"Entries/" +
@@ -1501,7 +1507,9 @@
{"EntryType", "Event"},
{"Severity",
translateSeverityDbusToRedfish(*severity)},
- {"Created", crow::utility::getDateTime(timestamp)}};
+ {"Created", crow::utility::getDateTime(timestamp)},
+ {"Modified",
+ crow::utility::getDateTime(updateTimestamp)}};
}
}
std::sort(entriesArray.begin(), entriesArray.end(),
@@ -1560,8 +1568,10 @@
}
uint32_t* id = nullptr;
std::time_t timestamp{};
+ std::time_t updateTimestamp{};
std::string* severity = nullptr;
std::string* message = nullptr;
+
for (auto& propertyMap : resp)
{
if (propertyMap.first == "Id")
@@ -1579,16 +1589,20 @@
if (millisTimeStamp == nullptr)
{
messages::internalError(asyncResp->res);
- continue;
}
- // Retrieve Created property with format:
- // yyyy-mm-ddThh:mm:ss
- std::chrono::milliseconds chronoTimeStamp(
- *millisTimeStamp);
timestamp =
- std::chrono::duration_cast<
- std::chrono::duration<int>>(chronoTimeStamp)
- .count();
+ crow::utility::getTimestamp(*millisTimeStamp);
+ }
+ else if (propertyMap.first == "UpdateTimestamp")
+ {
+ const uint64_t* millisTimeStamp =
+ std::get_if<uint64_t>(&propertyMap.second);
+ if (millisTimeStamp == nullptr)
+ {
+ messages::internalError(asyncResp->res);
+ }
+ updateTimestamp =
+ crow::utility::getTimestamp(*millisTimeStamp);
}
else if (propertyMap.first == "Severity")
{
@@ -1613,7 +1627,7 @@
return;
}
asyncResp->res.jsonValue = {
- {"@odata.type", "#LogEntry.v1_4_0.LogEntry"},
+ {"@odata.type", "#LogEntry.v1_6_0.LogEntry"},
{"@odata.id",
"/redfish/v1/Systems/system/LogServices/EventLog/"
"Entries/" +
@@ -1623,7 +1637,8 @@
{"Message", *message},
{"EntryType", "Event"},
{"Severity", translateSeverityDbusToRedfish(*severity)},
- {"Created", crow::utility::getDateTime(timestamp)}};
+ {"Created", crow::utility::getDateTime(timestamp)},
+ {"Modified", crow::utility::getDateTime(updateTimestamp)}};
},
"xyz.openbmc_project.Logging",
"/xyz/openbmc_project/logging/entry/" + entryID,