log_services: Initialize Members@odata.count as 0
Currently when Members array is initialized to an empty array, the
Members@odata.count is not present. Initialize it as 0.
The bug seems to have been introduced by:
https://gerrit.openbmc-project.xyz/50224
Tested: On QEMU -
Before change:
{
"@odata.id": "/redfish/v1/Systems/system/LogServices/Crashdump/Entries",
"@odata.type": "#LogEntryCollection.LogEntryCollection",
"Description": "Collection of Crashdump Entries",
"Members": [],
"Name": "Open BMC Crashdump Entries"
}
After change:
{
"@odata.id": "/redfish/v1/Systems/system/LogServices/Crashdump/Entries",
"@odata.type": "#LogEntryCollection.LogEntryCollection",
"Description": "Collection of Crashdump Entries",
"Members": [],
"Members@odata.count": 0,
"Name": "Open BMC Crashdump Entries"
}
{
"@odata.id": "/redfish/v1/Systems/system/LogServices/Crashdump/Entries",
"@odata.type": "#LogEntryCollection.LogEntryCollection",
"Description": "Collection of Crashdump Entries",
"Members": [
{
"@odata.id": "/redfish/v1/Systems/system/LogServices/Crashdump/Entries/OnDemand",
"@odata.type": "#LogEntry.v1_7_0.LogEntry",
"AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/Crashdump/Entries/OnDemand/crashdump_ondemand_1970-01-01T00:05:23Z.json",
"Created": "1970-01-01T00:05:23Z",
"DiagnosticDataType": "OEM",
"EntryType": "Oem",
"Id": "OnDemand",
"Name": "CPU Crashdump",
"OEMDiagnosticDataType": "PECICrashdump"
}
],
"Members@odata.count": 1,
"Name": "Open BMC Crashdump Entries"
}
Signed-off-by: Brandon Kim <brandonkim@google.com>
Change-Id: I5d17a8a62db23ad0da1c97113a4c6521bdec02cb
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 4b48873..08765f2 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -2723,6 +2723,7 @@
"Collection of Crashdump Entries";
asyncResp->res.jsonValue["Members"] =
nlohmann::json::array();
+ asyncResp->res.jsonValue["Members@odata.count"] = 0;
for (const std::string& path : resp)
{