systems: fix Members@odata.count is incorrect even Members have contents
Issue symptom:
Run automation test "Verify_Systems_Defaults" then we got ERROR as below.
Verify Systems Defaults :: Verify systems defaults. | FAIL |
**ERROR** Invalid variable value: systems['Members@odata.count']: 0 <int>
Root cause:
In Systems, doGet() didn't calculate count after ifaceArray.push_back({{"@odata.id", "/redfish/v1/Systems/system"}})
Solution:
Increase count by ifaceArray.size() after ifaceArray.push_back() in Systems
Tested:
1. Verified
robot -t Verify_Systems_Defaults redfish/service_root/test_sessions_management.robot
Verify Systems Defaults :: Verify systems defaults. | PASS |
2. Verified system detail from Redfish.
Get https://<BMC-IP>/redfish/v1/Systems
Response:
{
"@odata.id": "/redfish/v1/Systems",
"@odata.type": "#ComputerSystemCollection.ComputerSystemCollection",
"Members": [
{
"@odata.id": "/redfish/v1/Systems/system"
}
],
"Members@odata.count": 1,
"Name": "Computer System Collection"
}
Signed-off-by: Tim Lee <timlee660101@gmail.com>
Change-Id: I9cdb5dac9e16851112085048bc674808511a4845
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index ef178ed..89a8ad5 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -1769,9 +1769,9 @@
asyncResp->res.jsonValue["Members"];
ifaceArray = nlohmann::json::array();
auto& count = asyncResp->res.jsonValue["Members@odata.count"];
- count = 0;
ifaceArray.push_back(
{{"@odata.id", "/redfish/v1/Systems/system"}});
+ count = ifaceArray.size();
if (!ec)
{
BMCWEB_LOG_DEBUG << "Hypervisor is available";