diff options
author | Gunnar Mills <gmills@us.ibm.com> | 2018-12-11 00:17:20 +0300 |
---|---|---|
committer | Ed Tanous <ed.tanous@intel.com> | 2018-12-14 07:58:38 +0300 |
commit | aceb7fc879578407879af2f456458d080e39ec2d (patch) | |
tree | 06f4d11652c5d8adeb1e16c340e24e042532585a /redfish-core/lib/cpudimm.hpp | |
parent | de81881fcac87628d44bd9896f3eea53d4c3d5dd (diff) | |
download | bmcweb-aceb7fc879578407879af2f456458d080e39ec2d.tar.xz |
bmcweb: Redfish make MemorySizeInKB optional
This commit makes Memory Size an optional parameter.
On X86 platforms, MemorySizeInKB is coming from the MDR daemon.
For other platforms it is undefined. Still some work to do here,
but this commit fixes the internal error in
/redfish/v1/Systems/{ComputerSystemId}/Memory/{MemoryId} on non-X86
systems.
Resolves: openbmc/bmcweb#19
curl -k -H "X-Auth-Token: $bmc_token" -X GET \
https://${bmc}/redfish/v1/Systems/motherboard/Memory/dimm9
{
"@odata.context": "/redfish/v1/$metadata#Memory.Memory",
"@odata.id": "/redfish/v1/Systems/motherboard/Memory/dimm9",
"@odata.type": "#Memory.v1_2_0.Memory",
"Id": "dimm9",
"Name": "DIMM Slot",
"Status": {
"Health": "OK",
"State": "Enabled"
}
}
Change-Id: Ib2b558ba2299674edab0132a21dc6109e4b81732
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'redfish-core/lib/cpudimm.hpp')
-rw-r--r-- | redfish-core/lib/cpudimm.hpp | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/redfish-core/lib/cpudimm.hpp b/redfish-core/lib/cpudimm.hpp index ca2f164b27..ada4332e7d 100644 --- a/redfish-core/lib/cpudimm.hpp +++ b/redfish-core/lib/cpudimm.hpp @@ -216,32 +216,28 @@ void getDimmDataByService(std::shared_ptr<AsyncResp> aResp, aResp->res.jsonValue["Name"] = "DIMM Slot"; const auto memorySizeProperty = properties.find("MemorySizeInKB"); - if (memorySizeProperty == properties.end()) + if (memorySizeProperty != properties.end()) { - // Important property not in result - messages::internalError(aResp->res); - - return; - } - const uint32_t *memorySize = - sdbusplus::message::variant_ns::get_if<uint32_t>( - &memorySizeProperty->second); - if (memorySize == nullptr) - { - // Important property not in desired type - messages::internalError(aResp->res); + const uint32_t *memorySize = + sdbusplus::message::variant_ns::get_if<uint32_t>( + &memorySizeProperty->second); + if (memorySize == nullptr) + { + // Important property not in desired type + messages::internalError(aResp->res); - return; - } - if (*memorySize == 0) - { - // Slot is not populated, set status end return - aResp->res.jsonValue["Status"]["State"] = "Absent"; - aResp->res.jsonValue["Status"]["Health"] = "OK"; - // HTTP Code will be set up automatically, just return - return; + return; + } + if (*memorySize == 0) + { + // Slot is not populated, set status end return + aResp->res.jsonValue["Status"]["State"] = "Absent"; + aResp->res.jsonValue["Status"]["Health"] = "OK"; + // HTTP Code will be set up automatically, just return + return; + } + aResp->res.jsonValue["CapacityMiB"] = (*memorySize >> 10); } - aResp->res.jsonValue["CapacityMiB"] = (*memorySize >> 10); aResp->res.jsonValue["Status"]["State"] = "Enabled"; aResp->res.jsonValue["Status"]["Health"] = "OK"; |