Add Health to Memory and Processor Summary
These fields were missing Health. Add health objects
to get the health associated with these items. Also update
the health object to be able to add more than the 'main'
health for a url, by allowing passing a json reference.
Also, add a 'children' vector of more shared_ptr<HealthPopulate>
so we don't double up on d-bus calls.
Tested:
"MemorySummary": {
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Disabled"
},
"TotalSystemMemoryGiB": 0
},
"Model": "S2600WFT",
"Name": "system",
"PartNumber": "..........",
"PowerState": "On",
"ProcessorSummary": {
"Count": 2,
"Model": "Intel Xeon processor",
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
}
},
Change-Id: I06f802da93a44cfbac40b63d507e3b9faf0c999a
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/redfish-core/lib/health.hpp b/redfish-core/lib/health.hpp
index 930eaee..9127930 100644
--- a/redfish-core/lib/health.hpp
+++ b/redfish-core/lib/health.hpp
@@ -28,19 +28,31 @@
struct HealthPopulate : std::enable_shared_from_this<HealthPopulate>
{
HealthPopulate(const std::shared_ptr<AsyncResp> &asyncResp) :
- asyncResp(asyncResp)
+ asyncResp(asyncResp), jsonStatus(asyncResp->res.jsonValue["Status"])
+ {
+ }
+
+ HealthPopulate(const std::shared_ptr<AsyncResp> &asyncResp,
+ nlohmann::json &status) :
+ asyncResp(asyncResp),
+ jsonStatus(status)
{
}
~HealthPopulate()
{
- nlohmann::json &health = asyncResp->res.jsonValue["Status"]["Health"];
- nlohmann::json &rollup =
- asyncResp->res.jsonValue["Status"]["HealthRollup"];
+ nlohmann::json &health = jsonStatus["Health"];
+ nlohmann::json &rollup = jsonStatus["HealthRollup"];
health = "OK";
rollup = "OK";
+ for (const std::shared_ptr<HealthPopulate> &health : children)
+ {
+ health->globalInventoryPath = globalInventoryPath;
+ health->statuses = statuses;
+ }
+
for (const auto &[path, interfaces] : statuses)
{
bool isChild = false;
@@ -132,6 +144,8 @@
}
}
+ // this should only be called once per url, others should get updated by
+ // being added as children to the 'main' health object for the page
void populate()
{
getAllStatusAssociations();
@@ -185,6 +199,13 @@
}
std::shared_ptr<AsyncResp> asyncResp;
+ nlohmann::json &jsonStatus;
+
+ // we store pointers to other HealthPopulate items so we can update their
+ // members and reduce dbus calls. As we hold a shared_ptr to them, they get
+ // destroyed last, and they need not call populate()
+ std::vector<std::shared_ptr<HealthPopulate>> children;
+
std::vector<std::string> inventory;
bool isManagersHealth = false;
dbus::utility::ManagedObjectType statuses;
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 0724c85..b91296f 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -136,12 +136,13 @@
*
* @return None.
*/
-void getComputerSystem(std::shared_ptr<AsyncResp> aResp)
+void getComputerSystem(std::shared_ptr<AsyncResp> aResp,
+ std::shared_ptr<HealthPopulate> systemHealth)
{
BMCWEB_LOG_DEBUG << "Get available system components.";
crow::connections::systemBus->async_method_call(
- [aResp](
+ [aResp, systemHealth](
const boost::system::error_code ec,
const std::vector<std::pair<
std::string,
@@ -169,6 +170,15 @@
continue;
}
+ auto memoryHealth = std::make_shared<HealthPopulate>(
+ aResp, aResp->res.jsonValue["MemorySummary"]["Status"]);
+
+ auto cpuHealth = std::make_shared<HealthPopulate>(
+ aResp, aResp->res.jsonValue["ProcessorSummary"]["Status"]);
+
+ systemHealth->children.emplace_back(memoryHealth);
+ systemHealth->children.emplace_back(cpuHealth);
+
// This is not system, so check if it's cpu, dimm, UUID or
// BiosVer
for (const auto &connection : connectionNames)
@@ -261,6 +271,8 @@
connection.first, path,
"org.freedesktop.DBus.Properties", "GetAll",
"xyz.openbmc_project.Inventory.Item.Dimm");
+
+ memoryHealth->inventory.emplace_back(path);
}
else if (interfaceName ==
"xyz.openbmc_project.Inventory.Item.Cpu")
@@ -391,6 +403,8 @@
connection.first, path,
"org.freedesktop.DBus.Properties", "GetAll",
"xyz.openbmc_project.Inventory.Item.Cpu");
+
+ cpuHealth->inventory.emplace_back(path);
}
else if (interfaceName ==
"xyz.openbmc_project.Common.UUID")
@@ -1454,7 +1468,7 @@
aRsp->res.jsonValue["IndicatorLED"] = "Off";
}
});
- getComputerSystem(asyncResp);
+ getComputerSystem(asyncResp, health);
getHostState(asyncResp);
getBootProperties(asyncResp);
getPCIeDeviceList(asyncResp);