diff options
Diffstat (limited to 'redfish-core/lib/health.hpp')
-rw-r--r-- | redfish-core/lib/health.hpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/redfish-core/lib/health.hpp b/redfish-core/lib/health.hpp index b9f2e38635..59c8a27a5c 100644 --- a/redfish-core/lib/health.hpp +++ b/redfish-core/lib/health.hpp @@ -20,6 +20,7 @@ #include <boost/algorithm/string/predicate.hpp> #include <boost/container/flat_set.hpp> #include <dbus_singleton.hpp> + #include <variant> namespace redfish @@ -27,33 +28,31 @@ namespace redfish struct HealthPopulate : std::enable_shared_from_this<HealthPopulate> { - HealthPopulate(const std::shared_ptr<AsyncResp> &asyncResp) : + HealthPopulate(const std::shared_ptr<AsyncResp>& asyncResp) : asyncResp(asyncResp), jsonStatus(asyncResp->res.jsonValue["Status"]) - { - } + {} - HealthPopulate(const std::shared_ptr<AsyncResp> &asyncResp, - nlohmann::json &status) : + HealthPopulate(const std::shared_ptr<AsyncResp>& asyncResp, + nlohmann::json& status) : asyncResp(asyncResp), jsonStatus(status) - { - } + {} ~HealthPopulate() { - nlohmann::json &health = jsonStatus["Health"]; - nlohmann::json &rollup = jsonStatus["HealthRollup"]; + nlohmann::json& health = jsonStatus["Health"]; + nlohmann::json& rollup = jsonStatus["HealthRollup"]; health = "OK"; rollup = "OK"; - for (const std::shared_ptr<HealthPopulate> &health : children) + for (const std::shared_ptr<HealthPopulate>& health : children) { health->globalInventoryPath = globalInventoryPath; health->statuses = statuses; } - for (const auto &[path, interfaces] : statuses) + for (const auto& [path, interfaces] : statuses) { bool isChild = false; bool isSelf = @@ -67,7 +66,7 @@ struct HealthPopulate : std::enable_shared_from_this<HealthPopulate> // of this association is an inventory item, or one of the // endpoints in this association is a child - for (const std::string &child : inventory) + for (const std::string& child : inventory) { if (boost::starts_with(path.str, child)) { @@ -90,7 +89,7 @@ struct HealthPopulate : std::enable_shared_from_this<HealthPopulate> << path.str; continue; } - const std::vector<std::string> *endpoints = + const std::vector<std::string>* endpoints = std::get_if<std::vector<std::string>>( &endpointsIt->second); if (endpoints == nullptr) @@ -100,7 +99,7 @@ struct HealthPopulate : std::enable_shared_from_this<HealthPopulate> continue; } bool containsChild = false; - for (const std::string &endpoint : *endpoints) + for (const std::string& endpoint : *endpoints) { if (std::find(inventory.begin(), inventory.end(), endpoint) != inventory.end()) @@ -174,7 +173,7 @@ struct HealthPopulate : std::enable_shared_from_this<HealthPopulate> std::shared_ptr<HealthPopulate> self = shared_from_this(); crow::connections::systemBus->async_method_call( [self](const boost::system::error_code ec, - std::vector<std::string> &resp) { + std::vector<std::string>& resp) { if (ec || resp.size() != 1) { // no global item, or too many @@ -185,7 +184,7 @@ struct HealthPopulate : std::enable_shared_from_this<HealthPopulate> "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", "/", 0, - std::array<const char *, 1>{ + std::array<const char*, 1>{ "xyz.openbmc_project.Inventory.Item.Global"}); } @@ -194,7 +193,7 @@ struct HealthPopulate : std::enable_shared_from_this<HealthPopulate> std::shared_ptr<HealthPopulate> self = shared_from_this(); crow::connections::systemBus->async_method_call( [self](const boost::system::error_code ec, - dbus::utility::ManagedObjectType &resp) { + dbus::utility::ManagedObjectType& resp) { if (ec) { return; @@ -216,7 +215,7 @@ struct HealthPopulate : std::enable_shared_from_this<HealthPopulate> } std::shared_ptr<AsyncResp> asyncResp; - nlohmann::json &jsonStatus; + 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 |