diff options
author | Gunnar Mills <gmills@us.ibm.com> | 2024-04-02 00:05:21 +0300 |
---|---|---|
committer | Gunnar Mills <gunnar@gmills.xyz> | 2024-04-04 22:53:09 +0300 |
commit | 7ac13cc939beaf9a2a7af870ba9b5650c98e409e (patch) | |
tree | 3626ff9647f62a93beb6f5da9dc8e612a65b2918 /redfish-core | |
parent | 3dfed536df173ea6d37ac93f428b9094b6a736d1 (diff) | |
download | bmcweb-7ac13cc939beaf9a2a7af870ba9b5650c98e409e.tar.xz |
Remove redfish-health-populate
The redfish-health-populate option was scheduled to be removed in 1Q
2024. It is now 2Q, so remove the option. No upstream layers enabled it
and did not find a downstream layer that did either.
This was always limited to a few resources. Overall this design was only
half done. A future "HealthRollup" can be proposed.
Some discord discussion:
[1]: https://discord.com/channels/775381525260664832/855566794994221117/1110728560819327069
Commit disabling this (merged 10 months ago):
[2]: https://github.com/openbmc/bmcweb/commit/6f8273e49cffdd347c223b9538558edfb05e818a
Tested: Code compiles
Change-Id: I4d33c1e674ecdb0fd256df62f3795073454ae7a1
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'redfish-core')
-rw-r--r-- | redfish-core/lib/chassis.hpp | 21 | ||||
-rw-r--r-- | redfish-core/lib/ethernet.hpp | 23 | ||||
-rw-r--r-- | redfish-core/lib/health.hpp | 258 | ||||
-rw-r--r-- | redfish-core/lib/managers.hpp | 7 | ||||
-rw-r--r-- | redfish-core/lib/memory.hpp | 8 | ||||
-rw-r--r-- | redfish-core/lib/processor.hpp | 1 | ||||
-rw-r--r-- | redfish-core/lib/storage.hpp | 28 | ||||
-rw-r--r-- | redfish-core/lib/systems.hpp | 25 | ||||
-rw-r--r-- | redfish-core/lib/task.hpp | 7 |
9 files changed, 3 insertions, 375 deletions
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp index 6038384201..4a79783fb4 100644 --- a/redfish-core/lib/chassis.hpp +++ b/redfish-core/lib/chassis.hpp @@ -15,11 +15,8 @@ */ #pragma once -#include "bmcweb_config.h" - #include "app.hpp" #include "dbus_utility.hpp" -#include "health.hpp" #include "led.hpp" #include "query.hpp" #include "redfish_util.hpp" @@ -472,24 +469,6 @@ inline void handleChassisGetSubTree( getChassisConnectivity(asyncResp, chassisId, path); - auto health = std::make_shared<HealthPopulate>(asyncResp); - - if constexpr (bmcwebEnableHealthPopulate) - { - dbus::utility::getAssociationEndPoints( - path + "/all_sensors", - [health](const boost::system::error_code& ec2, - const dbus::utility::MapperEndPoints& resp) { - if (ec2) - { - return; // no sensors = no failures - } - health->inventory = resp; - }); - - health->populate(); - } - if (connectionNames.empty()) { BMCWEB_LOG_ERROR("Got 0 Connection names"); diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp index ee84c14cd1..2d538d7f1f 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp @@ -15,13 +15,10 @@ */ #pragma once -#include "bmcweb_config.h" - #include "app.hpp" #include "dbus_singleton.hpp" #include "dbus_utility.hpp" #include "error_messages.hpp" -#include "health.hpp" #include "human_sort.hpp" #include "query.hpp" #include "registries/privilege_registry.hpp" @@ -1779,26 +1776,6 @@ inline void "/redfish/v1/Managers/bmc/EthernetInterfaces/{}", ifaceId); jsonResponse["InterfaceEnabled"] = ethData.nicEnabled; - if constexpr (bmcwebEnableHealthPopulate) - { - constexpr std::array<std::string_view, 1> inventoryForEthernet = { - "xyz.openbmc_project.Inventory.Item.Ethernet"}; - auto health = std::make_shared<HealthPopulate>(asyncResp); - dbus::utility::getSubTreePaths( - "/", 0, inventoryForEthernet, - [health](const boost::system::error_code& ec, - const dbus::utility::MapperGetSubTreePathsResponse& resp) { - if (ec) - { - return; - } - - health->inventory = resp; - }); - - health->populate(); - } - if (ethData.nicEnabled) { jsonResponse["LinkStatus"] = ethData.linkUp ? "LinkUp" : "LinkDown"; diff --git a/redfish-core/lib/health.hpp b/redfish-core/lib/health.hpp deleted file mode 100644 index 20ea0f6236..0000000000 --- a/redfish-core/lib/health.hpp +++ /dev/null @@ -1,258 +0,0 @@ -/* -// Copyright (c) 2019 Intel Corporation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -*/ -#pragma once - -#include "app.hpp" -#include "async_resp.hpp" -#include "dbus_singleton.hpp" -#include "dbus_utility.hpp" - -#include <nlohmann/json.hpp> - -#include <array> -#include <ranges> -#include <string_view> -#include <variant> - -namespace redfish -{ - -struct HealthPopulate : std::enable_shared_from_this<HealthPopulate> -{ - // By default populate status to "/Status" of |asyncResp->res.jsonValue|. - explicit HealthPopulate( - const std::shared_ptr<bmcweb::AsyncResp>& asyncRespIn) : - asyncResp(asyncRespIn), - statusPtr("/Status") - {} - - // Takes a JSON pointer rather than a reference. This is pretty useful when - // the address of the status JSON might change, for example, elements in an - // array. - HealthPopulate(const std::shared_ptr<bmcweb::AsyncResp>& asyncRespIn, - const nlohmann::json::json_pointer& ptr) : - asyncResp(asyncRespIn), - statusPtr(ptr) - {} - - HealthPopulate(const HealthPopulate&) = delete; - HealthPopulate(HealthPopulate&&) = delete; - HealthPopulate& operator=(const HealthPopulate&) = delete; - HealthPopulate& operator=(const HealthPopulate&&) = delete; - - ~HealthPopulate() - { - nlohmann::json& jsonStatus = asyncResp->res.jsonValue[statusPtr]; - nlohmann::json& health = jsonStatus["Health"]; - nlohmann::json& rollup = jsonStatus["HealthRollup"]; - - health = "OK"; - rollup = "OK"; - - for (const std::shared_ptr<HealthPopulate>& healthChild : children) - { - healthChild->globalInventoryPath = globalInventoryPath; - healthChild->statuses = statuses; - } - - for (const auto& [path, interfaces] : statuses) - { - bool isSelf = false; - if (selfPath) - { - if (path.str == *selfPath || - path.str.starts_with(*selfPath + "/")) - { - isSelf = true; - } - } - - // managers inventory is all the inventory, don't skip any - if (!isManagersHealth && !isSelf) - { - // We only want to look at this association if either the path - // of this association is an inventory item, or one of the - // endpoints in this association is a child - - bool isChild = false; - for (const std::string& child : inventory) - { - if (path.str.starts_with(child)) - { - isChild = true; - break; - } - } - if (!isChild) - { - for (const auto& [interface, association] : interfaces) - { - if (interface != "xyz.openbmc_project.Association") - { - continue; - } - for (const auto& [name, value] : association) - { - if (name != "endpoints") - { - continue; - } - - const std::vector<std::string>* endpoints = - std::get_if<std::vector<std::string>>(&value); - if (endpoints == nullptr) - { - BMCWEB_LOG_ERROR("Illegal association at {}", - path.str); - continue; - } - bool containsChild = false; - for (const std::string& endpoint : *endpoints) - { - if (std::ranges::find(inventory, endpoint) != - inventory.end()) - { - containsChild = true; - break; - } - } - if (!containsChild) - { - continue; - } - } - } - } - } - - if (path.str.starts_with(globalInventoryPath) && - path.str.ends_with("critical")) - { - health = "Critical"; - rollup = "Critical"; - return; - } - if (path.str.starts_with(globalInventoryPath) && - path.str.ends_with("warning")) - { - health = "Warning"; - if (rollup != "Critical") - { - rollup = "Warning"; - } - } - else if (path.str.ends_with("critical")) - { - rollup = "Critical"; - if (isSelf) - { - health = "Critical"; - return; - } - } - else if (path.str.ends_with("warning")) - { - if (rollup != "Critical") - { - rollup = "Warning"; - } - - if (isSelf) - { - health = "Warning"; - } - } - } - } - - // 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() - { - if (populated) - { - return; - } - populated = true; - getAllStatusAssociations(); - getGlobalPath(); - } - - void getGlobalPath() - { - constexpr std::array<std::string_view, 1> interfaces = { - "xyz.openbmc_project.Inventory.Item.Global"}; - std::shared_ptr<HealthPopulate> self = shared_from_this(); - dbus::utility::getSubTreePaths( - "/", 0, interfaces, - [self](const boost::system::error_code& ec, - const dbus::utility::MapperGetSubTreePathsResponse& resp) { - if (ec || resp.size() != 1) - { - // no global item, or too many - return; - } - self->globalInventoryPath = resp[0]; - }); - } - - void getAllStatusAssociations() - { - std::shared_ptr<HealthPopulate> self = shared_from_this(); - sdbusplus::message::object_path path("/"); - dbus::utility::getManagedObjects( - "xyz.openbmc_project.ObjectMapper", path, - [self](const boost::system::error_code& ec, - const dbus::utility::ManagedObjectType& resp) { - if (ec) - { - return; - } - self->statuses = resp; - for (auto it = self->statuses.begin(); it != self->statuses.end();) - { - if (it->first.str.ends_with("critical") || - it->first.str.ends_with("warning")) - { - it++; - continue; - } - it = self->statuses.erase(it); - } - }); - } - - std::shared_ptr<bmcweb::AsyncResp> asyncResp; - - // Will populate the health status into |asyncResp_json[statusPtr]| - nlohmann::json::json_pointer statusPtr; - - // 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; - - // self is used if health is for an individual items status, as this is the - // 'lowest most' item, the rollup will equal the health - std::optional<std::string> selfPath; - - std::vector<std::string> inventory; - bool isManagersHealth = false; - dbus::utility::ManagedObjectType statuses; - std::string globalInventoryPath = "-"; // default to illegal dbus path - bool populated = false; -}; -} // namespace redfish diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp index 2f50ca0f16..5b87cc54b3 100644 --- a/redfish-core/lib/managers.hpp +++ b/redfish-core/lib/managers.hpp @@ -19,7 +19,6 @@ #include "app.hpp" #include "dbus_utility.hpp" -#include "health.hpp" #include "query.hpp" #include "redfish_util.hpp" #include "registries/privilege_registry.hpp" @@ -2019,12 +2018,6 @@ inline void requestRoutesManager(App& app) asyncResp->res.jsonValue["Links"]["ManagerForServers"] = std::move(managerForServers); } - if constexpr (bmcwebEnableHealthPopulate) - { - auto health = std::make_shared<HealthPopulate>(asyncResp); - health->isManagersHealth = true; - health->populate(); - } sw_util::populateSoftwareInformation(asyncResp, sw_util::bmcPurpose, "FirmwareVersion", true); diff --git a/redfish-core/lib/memory.hpp b/redfish-core/lib/memory.hpp index 58d5178604..2882da0ea7 100644 --- a/redfish-core/lib/memory.hpp +++ b/redfish-core/lib/memory.hpp @@ -19,7 +19,6 @@ #include "app.hpp" #include "dbus_utility.hpp" -#include "health.hpp" #include "query.hpp" #include "registries/privilege_registry.hpp" #include "utils/collection.hpp" @@ -607,13 +606,6 @@ inline void getDimmDataByService(std::shared_ptr<bmcweb::AsyncResp> asyncResp, const std::string& service, const std::string& objPath) { - if constexpr (bmcwebEnableHealthPopulate) - { - auto health = std::make_shared<HealthPopulate>(asyncResp); - health->selfPath = objPath; - health->populate(); - } - BMCWEB_LOG_DEBUG("Get available system components."); sdbusplus::asio::getAllProperties( *crow::connections::systemBus, service, objPath, "", diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp index 34aa42fbf4..5c229f4f9f 100644 --- a/redfish-core/lib/processor.hpp +++ b/redfish-core/lib/processor.hpp @@ -20,7 +20,6 @@ #include "dbus_utility.hpp" #include "error_messages.hpp" #include "generated/enums/processor.hpp" -#include "health.hpp" #include "query.hpp" #include "registries/privilege_registry.hpp" #include "utils/collection.hpp" diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp index 3a38fce550..9438144c12 100644 --- a/redfish-core/lib/storage.hpp +++ b/redfish-core/lib/storage.hpp @@ -21,7 +21,6 @@ #include "dbus_utility.hpp" #include "generated/enums/drive.hpp" #include "generated/enums/protocol.hpp" -#include "health.hpp" #include "human_sort.hpp" #include "openbmc_dbus_rest.hpp" #include "query.hpp" @@ -104,7 +103,6 @@ inline void requestRoutesStorageCollection(App& app) inline void afterChassisDriveCollectionSubtree( const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, - const std::shared_ptr<HealthPopulate>& health, const boost::system::error_code& ec, const dbus::utility::MapperGetSubTreePathsResponse& driveList) { @@ -120,12 +118,6 @@ inline void afterChassisDriveCollectionSubtree( auto& count = asyncResp->res.jsonValue["Drives@odata.count"]; count = 0; - if constexpr (bmcwebEnableHealthPopulate) - { - health->inventory.insert(health->inventory.end(), driveList.begin(), - driveList.end()); - } - for (const std::string& drive : driveList) { sdbusplus::message::object_path object(drive); @@ -144,14 +136,13 @@ inline void afterChassisDriveCollectionSubtree( count = driveArray.size(); } -inline void getDrives(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, - const std::shared_ptr<HealthPopulate>& health) +inline void getDrives(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { const std::array<std::string_view, 1> interfaces = { "xyz.openbmc_project.Inventory.Item.Drive"}; dbus::utility::getSubTreePaths( "/xyz/openbmc_project/inventory", 0, interfaces, - std::bind_front(afterChassisDriveCollectionSubtree, asyncResp, health)); + std::bind_front(afterChassisDriveCollectionSubtree, asyncResp)); } inline void afterSystemsStorageGetSubtree( @@ -187,13 +178,7 @@ inline void afterSystemsStorageGetSubtree( asyncResp->res.jsonValue["Id"] = storageId; asyncResp->res.jsonValue["Status"]["State"] = "Enabled"; - auto health = std::make_shared<HealthPopulate>(asyncResp); - if constexpr (bmcwebEnableHealthPopulate) - { - health->populate(); - } - - getDrives(asyncResp, health); + getDrives(asyncResp); asyncResp->res.jsonValue["Controllers"]["@odata.id"] = boost::urls::format( "/redfish/v1/Systems/system/Storage/{}/Controllers", storageId); } @@ -692,13 +677,6 @@ inline void afterGetSubtreeSystemsStorageDrive( // default it to Enabled asyncResp->res.jsonValue["Status"]["State"] = "Enabled"; - if constexpr (bmcwebEnableHealthPopulate) - { - auto health = std::make_shared<HealthPopulate>(asyncResp); - health->inventory.emplace_back(path); - health->populate(); - } - addAllDriveInfo(asyncResp, connectionNames[0].first, path, connectionNames[0].second); } diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp index 272a24b65a..082af6439b 100644 --- a/redfish-core/lib/systems.hpp +++ b/redfish-core/lib/systems.hpp @@ -22,7 +22,6 @@ #include "dbus_utility.hpp" #include "generated/enums/computer_system.hpp" #include "generated/enums/resource.hpp" -#include "health.hpp" #include "hypervisor_system.hpp" #include "led.hpp" #include "query.hpp" @@ -3227,30 +3226,6 @@ inline void #endif // BMCWEB_ENABLE_KVM - auto health = std::make_shared<HealthPopulate>(asyncResp); - if constexpr (bmcwebEnableHealthPopulate) - { - constexpr std::array<std::string_view, 4> inventoryForSystems{ - "xyz.openbmc_project.Inventory.Item.Dimm", - "xyz.openbmc_project.Inventory.Item.Cpu", - "xyz.openbmc_project.Inventory.Item.Drive", - "xyz.openbmc_project.Inventory.Item.StorageController"}; - - dbus::utility::getSubTreePaths( - "/", 0, inventoryForSystems, - [health](const boost::system::error_code& ec, - const std::vector<std::string>& resp) { - if (ec) - { - // no inventory - return; - } - - health->inventory = resp; - }); - health->populate(); - } - getMainChassisId(asyncResp, [](const std::string& chassisId, const std::shared_ptr<bmcweb::AsyncResp>& aRsp) { diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp index 136412c369..a2959b8455 100644 --- a/redfish-core/lib/task.hpp +++ b/redfish-core/lib/task.hpp @@ -14,12 +14,10 @@ // limitations under the License. */ #pragma once -#include "bmcweb_config.h" #include "app.hpp" #include "dbus_utility.hpp" #include "event_service_manager.hpp" -#include "health.hpp" #include "http/parsing.hpp" #include "query.hpp" #include "registries/privilege_registry.hpp" @@ -492,11 +490,6 @@ inline void requestRoutesTaskService(App& app) asyncResp->res.jsonValue["LifeCycleEventOnTaskStateChange"] = true; - if constexpr (bmcwebEnableHealthPopulate) - { - auto health = std::make_shared<HealthPopulate>(asyncResp); - health->populate(); - } asyncResp->res.jsonValue["Status"]["State"] = "Enabled"; asyncResp->res.jsonValue["ServiceEnabled"] = true; asyncResp->res.jsonValue["Tasks"]["@odata.id"] = |