summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--redfish-core/lib/health.hpp29
-rw-r--r--redfish-core/lib/systems.hpp20
2 files changed, 42 insertions, 7 deletions
diff --git a/redfish-core/lib/health.hpp b/redfish-core/lib/health.hpp
index 930eaee38f..91279304e5 100644
--- a/redfish-core/lib/health.hpp
+++ b/redfish-core/lib/health.hpp
@@ -28,19 +28,31 @@ namespace redfish
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 @@ struct HealthPopulate : std::enable_shared_from_this<HealthPopulate>
}
}
+ // 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 @@ struct HealthPopulate : std::enable_shared_from_this<HealthPopulate>
}
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 0724c85cd2..b91296f18b 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -136,12 +136,13 @@ void modifyCpuFunctionalState(std::shared_ptr<AsyncResp> aResp,
*
* @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 @@ void getComputerSystem(std::shared_ptr<AsyncResp> aResp)
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 @@ void getComputerSystem(std::shared_ptr<AsyncResp> aResp)
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 @@ void getComputerSystem(std::shared_ptr<AsyncResp> aResp)
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 @@ class Systems : public Node
aRsp->res.jsonValue["IndicatorLED"] = "Off";
}
});
- getComputerSystem(asyncResp);
+ getComputerSystem(asyncResp, health);
getHostState(asyncResp);
getBootProperties(asyncResp);
getPCIeDeviceList(asyncResp);