summaryrefslogtreecommitdiff
path: root/redfish-core/lib
diff options
context:
space:
mode:
authorCheng C Yang <cheng.c.yang@linux.intel.com>2019-11-28 10:58:08 +0300
committerCheng C Yang <cheng.c.yang@linux.intel.com>2019-12-03 06:04:32 +0300
commit5fd7ba65ac0e49dff95e4a0b334c9a314e870918 (patch)
tree7ff3172fc53ff70b854406df21485293a2f7e642 /redfish-core/lib
parent3e0414fd3f3b8b08ef3960f66fa056d8376e3544 (diff)
downloadbmcweb-5fd7ba65ac0e49dff95e4a0b334c9a314e870918.tar.xz
Fix No Total Memory Size Issue
Total Memory in redfish is always 0, fix the problem. Tested: After DC cycle the system. TotalSystemMemoryGiB in Redfish system page should not be zero. "MemorySummary": { "Status": { "State": "Enabled" }, "TotalSystemMemoryGiB": 16 }, Signed-off-by: Cheng C Yang <cheng.c.yang@linux.intel.com> Change-Id: I89ad8ed1cf5f9ca9589db444740167645dab9a6e
Diffstat (limited to 'redfish-core/lib')
-rw-r--r--redfish-core/lib/chassis.hpp2
-rw-r--r--redfish-core/lib/systems.hpp57
2 files changed, 39 insertions, 20 deletions
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index d8bc8f5d53..84acc58ca3 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -75,7 +75,7 @@ void getChassisState(std::shared_ptr<AsyncResp> aResp)
// Note, this is not a very useful Variant, but because it isn't used to get
// values, it should be as simple as possible
// TODO(ed) invent a nullvariant type
-using VariantType = std::variant<bool, std::string, uint64_t>;
+using VariantType = std::variant<bool, std::string, uint64_t, uint32_t>;
using ManagedObjectsType = std::vector<std::pair<
sdbusplus::message::object_path,
std::vector<std::pair<std::string,
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 0e6cb09412..ce12ed74aa 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -215,26 +215,45 @@ void getComputerSystem(std::shared_ptr<AsyncResp> aResp,
VariantType>
&property : properties)
{
- if (property.first ==
- "MemorySizeInKb")
+ if (property.first !=
+ "MemorySizeInKB")
{
- const uint64_t *value =
- sdbusplus::message::
- variant_ns::get_if<
- uint64_t>(
- &property.second);
- if (value != nullptr)
- {
- aResp->res.jsonValue
- ["TotalSystemMemoryGi"
- "B"] +=
- *value / (1024 * 1024);
- aResp->res.jsonValue
- ["MemorySummary"]
- ["Status"]["State"] =
- "Enabled";
- }
+ continue;
+ }
+ const uint32_t *value =
+ sdbusplus::message::variant_ns::
+ get_if<uint32_t>(
+ &property.second);
+ if (value == nullptr)
+ {
+ BMCWEB_LOG_DEBUG
+ << "Find incorrect type of "
+ "MemorySize";
+ continue;
+ }
+ nlohmann::json &totalMemory =
+ aResp->res
+ .jsonValue["MemorySummar"
+ "y"]
+ ["TotalSystemMe"
+ "moryGiB"];
+ uint64_t *preValue =
+ totalMemory
+ .get_ptr<uint64_t *>();
+ if (preValue == nullptr)
+ {
+ continue;
}
+ aResp->res
+ .jsonValue["MemorySummary"]
+ ["TotalSystemMemoryGi"
+ "B"] =
+ *value / (1024 * 1024) +
+ *preValue;
+ aResp->res
+ .jsonValue["MemorySummary"]
+ ["Status"]["State"] =
+ "Enabled";
}
}
else
@@ -1669,7 +1688,7 @@ class Systems : public Node
res.jsonValue["Description"] = "Computer System";
res.jsonValue["ProcessorSummary"]["Count"] = 0;
res.jsonValue["ProcessorSummary"]["Status"]["State"] = "Disabled";
- res.jsonValue["MemorySummary"]["TotalSystemMemoryGiB"] = int(0);
+ res.jsonValue["MemorySummary"]["TotalSystemMemoryGiB"] = uint64_t(0);
res.jsonValue["MemorySummary"]["Status"]["State"] = "Disabled";
res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system";