summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaire Weinan <cweinan@google.com>2022-04-28 09:05:12 +0300
committerEd Tanous <ed@tanous.net>2022-05-13 03:21:38 +0300
commit565dfb6f9a87e15fa707e6b2c89222c4419e7491 (patch)
tree9f4570f54f620d0189938b787daa67c79da7eaff
parent482c45a52e221882be5142a873cd828c380d7e54 (diff)
downloadbmcweb-565dfb6f9a87e15fa707e6b2c89222c4419e7491.tar.xz
LogService: Sort dump entries collection by Id
Ordering by ID (represented internally as the last part of the D-Bus object path, after the rightmost slash) is done for human readability, but please note that Redfish clients should not be written in a way that assumes a particular ordering of entries in a collection. Without this change, entries are presented in the collection in whatever order entries are returned by the D-Bus method GetManagedObjects(), called in getDumpEntryCollection(). The effect of this change is that entries are presented in chronological order (by ID) with the earliest entry appearing first. Testing: 1. Prerequisite: Fixed createDump() locally, similar to https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/38954 2. Created 12 BMC dump entries by repeatedly calling CollectDiagnosticData: curl -k -H "X-Auth-Token: $token" -X POST http://${bmc}/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData -d '{"DiagnosticDataType":"Manager", "OEMDiagnosticDataType":"BMC"}' 3. Retrieved BMC dump entries collection and verified that entries were sorted by ID (1,2,3,4,5,6,7,8,9,10,11,12): curl -k -H "X-Auth-Token: $token" -X GET http://${bmc}/redfish/v1/Managers/bmc/LogServices/Dump/Entries Signed-off-by: Claire Weinan <cweinan@google.com> Change-Id: I99f96dd6679163cea443353ad0e4c8c750cd4330
-rw-r--r--redfish-core/lib/log_services.hpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index d31602cd54..5980071ba9 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -363,6 +363,12 @@ inline void
std::string(boost::algorithm::to_lower_copy(dumpType)) +
"/entry/";
+ std::sort(resp.begin(), resp.end(),
+ [](const auto& l, const auto& r) {
+ return AlphanumLess<std::string>()(
+ l.first.filename(), r.first.filename());
+ });
+
for (auto& object : resp)
{
if (object.first.str.find(dumpEntryPath) == std::string::npos)