Ed Tanous | 40e9b92 | 2024-09-10 13:50:16 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // SPDX-FileCopyrightText: Copyright OpenBMC Authors |
| 3 | // SPDX-FileCopyrightText: Copyright 2018 Intel Corporation |
Borawski.Lukasz | 9c310685 | 2018-02-09 15:24:22 +0100 | [diff] [blame] | 4 | #pragma once |
| 5 | |
Willy Tu | 13451e3 | 2023-05-24 16:08:18 -0700 | [diff] [blame] | 6 | #include "bmcweb_config.h" |
| 7 | |
Sui Chen | a51fc2d | 2022-07-14 17:21:53 -0700 | [diff] [blame] | 8 | #include "app.hpp" |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 9 | #include "async_resp.hpp" |
| 10 | #include "dbus_singleton.hpp" |
Sui Chen | a51fc2d | 2022-07-14 17:21:53 -0700 | [diff] [blame] | 11 | #include "dbus_utility.hpp" |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 12 | #include "error_messages.hpp" |
Ed Tanous | 539d8c6 | 2024-06-19 14:38:27 -0700 | [diff] [blame] | 13 | #include "generated/enums/action_info.hpp" |
| 14 | #include "generated/enums/manager.hpp" |
| 15 | #include "generated/enums/resource.hpp" |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 16 | #include "http_request.hpp" |
George Liu | 79f3b6a | 2021-05-13 18:08:44 +0800 | [diff] [blame^] | 17 | #include "led.hpp" |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 18 | #include "logging.hpp" |
| 19 | #include "persistent_data.hpp" |
Sui Chen | a51fc2d | 2022-07-14 17:21:53 -0700 | [diff] [blame] | 20 | #include "query.hpp" |
rohitpai | c1a75eb | 2025-01-03 19:13:36 +0530 | [diff] [blame] | 21 | #include "redfish.hpp" |
Jennifer Lee | c5d03ff | 2019-03-08 15:42:58 -0800 | [diff] [blame] | 22 | #include "redfish_util.hpp" |
Sui Chen | a51fc2d | 2022-07-14 17:21:53 -0700 | [diff] [blame] | 23 | #include "registries/privilege_registry.hpp" |
Krzysztof Grobelny | fac6e53 | 2022-08-04 12:42:45 +0200 | [diff] [blame] | 24 | #include "utils/dbus_utils.hpp" |
Ed Tanous | 3ccb3ad | 2023-01-13 17:40:03 -0800 | [diff] [blame] | 25 | #include "utils/json_utils.hpp" |
Sui Chen | a51fc2d | 2022-07-14 17:21:53 -0700 | [diff] [blame] | 26 | #include "utils/sw_utils.hpp" |
| 27 | #include "utils/systemd_utils.hpp" |
Ed Tanous | 2b82937 | 2022-08-03 14:22:34 -0700 | [diff] [blame] | 28 | #include "utils/time_utils.hpp" |
Borawski.Lukasz | 9c310685 | 2018-02-09 15:24:22 +0100 | [diff] [blame] | 29 | |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 30 | #include <systemd/sd-bus.h> |
| 31 | |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 32 | #include <boost/beast/http/status.hpp> |
| 33 | #include <boost/beast/http/verb.hpp> |
George Liu | e99073f | 2022-12-09 11:06:16 +0800 | [diff] [blame] | 34 | #include <boost/system/error_code.hpp> |
Ed Tanous | ef4c65b | 2023-04-24 15:28:50 -0700 | [diff] [blame] | 35 | #include <boost/url/format.hpp> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 36 | #include <boost/url/url.hpp> |
| 37 | #include <nlohmann/json.hpp> |
Krzysztof Grobelny | fac6e53 | 2022-08-04 12:42:45 +0200 | [diff] [blame] | 38 | #include <sdbusplus/asio/property.hpp> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 39 | #include <sdbusplus/message.hpp> |
| 40 | #include <sdbusplus/message/native_types.hpp> |
Krzysztof Grobelny | fac6e53 | 2022-08-04 12:42:45 +0200 | [diff] [blame] | 41 | #include <sdbusplus/unpack_properties.hpp> |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 42 | |
George Liu | e99073f | 2022-12-09 11:06:16 +0800 | [diff] [blame] | 43 | #include <array> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 44 | #include <cstddef> |
Gunnar Mills | 4bfefa7 | 2020-07-30 13:54:29 -0500 | [diff] [blame] | 45 | #include <cstdint> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 46 | #include <format> |
| 47 | #include <functional> |
| 48 | #include <map> |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 49 | #include <memory> |
Konstantin Aladyshev | 9970e93 | 2024-02-20 09:51:29 +0300 | [diff] [blame] | 50 | #include <optional> |
Ed Tanous | 3544d2a | 2023-08-06 18:12:20 -0700 | [diff] [blame] | 51 | #include <ranges> |
Konstantin Aladyshev | 9970e93 | 2024-02-20 09:51:29 +0300 | [diff] [blame] | 52 | #include <string> |
George Liu | e99073f | 2022-12-09 11:06:16 +0800 | [diff] [blame] | 53 | #include <string_view> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 54 | #include <utility> |
Ed Tanous | d785720 | 2025-01-28 15:32:26 -0800 | [diff] [blame] | 55 | #include <vector> |
James Feist | 5b4aa86 | 2018-08-16 14:07:01 -0700 | [diff] [blame] | 56 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 57 | namespace redfish |
| 58 | { |
Jennifer Lee | ed5befb | 2018-08-10 11:29:45 -0700 | [diff] [blame] | 59 | |
George Liu | 79f3b6a | 2021-05-13 18:08:44 +0800 | [diff] [blame^] | 60 | inline void handleSetLocationIndicatorActive( |
| 61 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 62 | bool locationIndicatorActive, const std::string& managerId, |
| 63 | const boost::system::error_code& ec, |
| 64 | const dbus::utility::MapperGetSubTreePathsResponse& subtreePaths) |
| 65 | { |
| 66 | if (ec) |
| 67 | { |
| 68 | if (ec == boost::system::errc::io_error) |
| 69 | { |
| 70 | // Not found |
| 71 | BMCWEB_LOG_WARNING("Manager {} not found", managerId); |
| 72 | messages::resourceNotFound(asyncResp->res, "Manager", managerId); |
| 73 | return; |
| 74 | } |
| 75 | BMCWEB_LOG_ERROR("D-Bus response error {}", ec.value()); |
| 76 | messages::internalError(asyncResp->res); |
| 77 | return; |
| 78 | } |
| 79 | if (subtreePaths.empty()) |
| 80 | { |
| 81 | BMCWEB_LOG_WARNING("Manager {} not found", managerId); |
| 82 | messages::resourceNotFound(asyncResp->res, "Manager", managerId); |
| 83 | return; |
| 84 | } |
| 85 | // Assume only 1 bmc D-Bus object |
| 86 | // Throw an error if there is more than 1 |
| 87 | if (subtreePaths.size() != 1) |
| 88 | { |
| 89 | BMCWEB_LOG_ERROR("Found {} Bmc D-Bus paths", subtreePaths.size()); |
| 90 | messages::internalError(asyncResp->res); |
| 91 | return; |
| 92 | } |
| 93 | |
| 94 | setLocationIndicatorActive(asyncResp, subtreePaths[0], |
| 95 | locationIndicatorActive); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Set the locationIndicatorActive. |
| 100 | * |
| 101 | * @param[in,out] asyncResp Async HTTP response. |
| 102 | * @param[in] locationIndicatorActive Value of the property |
| 103 | */ |
| 104 | inline void setLocationIndicatorActiveState( |
| 105 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 106 | bool locationIndicatorActive, const std::string& managerId) |
| 107 | { |
| 108 | // GetSubTree on all interfaces which provide info about a Manager |
| 109 | constexpr std::array<std::string_view, 1> interfaces = { |
| 110 | "xyz.openbmc_project.Inventory.Item.Bmc"}; |
| 111 | dbus::utility::getSubTreePaths( |
| 112 | "/xyz/openbmc_project/inventory", 0, interfaces, |
| 113 | std::bind_front(handleSetLocationIndicatorActive, asyncResp, |
| 114 | locationIndicatorActive, managerId)); |
| 115 | } |
| 116 | |
Jagpal Singh Gill | d27c31e | 2024-10-15 15:10:19 -0700 | [diff] [blame] | 117 | inline std::string getBMCUpdateServiceName() |
| 118 | { |
| 119 | if constexpr (BMCWEB_REDFISH_UPDATESERVICE_USE_DBUS) |
| 120 | { |
| 121 | return "xyz.openbmc_project.Software.Manager"; |
| 122 | } |
| 123 | return "xyz.openbmc_project.Software.BMC.Updater"; |
| 124 | } |
| 125 | |
| 126 | inline std::string getBMCUpdateServicePath() |
| 127 | { |
| 128 | if constexpr (BMCWEB_REDFISH_UPDATESERVICE_USE_DBUS) |
| 129 | { |
| 130 | return "/xyz/openbmc_project/software/bmc"; |
| 131 | } |
| 132 | return "/xyz/openbmc_project/software"; |
| 133 | } |
| 134 | |
Jennifer Lee | ed5befb | 2018-08-10 11:29:45 -0700 | [diff] [blame] | 135 | /** |
Gunnar Mills | 2a5c440 | 2020-05-19 09:07:24 -0500 | [diff] [blame] | 136 | * Function reboots the BMC. |
| 137 | * |
| 138 | * @param[in] asyncResp - Shared pointer for completing asynchronous calls |
Jennifer Lee | ed5befb | 2018-08-10 11:29:45 -0700 | [diff] [blame] | 139 | */ |
Patrick Williams | 504af5a | 2025-02-03 14:29:03 -0500 | [diff] [blame] | 140 | inline void doBMCGracefulRestart( |
| 141 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
Gunnar Mills | 2a5c440 | 2020-05-19 09:07:24 -0500 | [diff] [blame] | 142 | { |
| 143 | const char* processName = "xyz.openbmc_project.State.BMC"; |
| 144 | const char* objectPath = "/xyz/openbmc_project/state/bmc0"; |
| 145 | const char* interfaceName = "xyz.openbmc_project.State.BMC"; |
| 146 | const std::string& propertyValue = |
| 147 | "xyz.openbmc_project.State.BMC.Transition.Reboot"; |
| 148 | const char* destProperty = "RequestedBMCTransition"; |
| 149 | |
| 150 | // Create the D-Bus variant for D-Bus call. |
George Liu | 9ae226f | 2023-06-21 17:56:46 +0800 | [diff] [blame] | 151 | sdbusplus::asio::setProperty( |
| 152 | *crow::connections::systemBus, processName, objectPath, interfaceName, |
| 153 | destProperty, propertyValue, |
Ed Tanous | 5e7e2dc | 2023-02-16 10:37:01 -0800 | [diff] [blame] | 154 | [asyncResp](const boost::system::error_code& ec) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 155 | // Use "Set" method to set the property value. |
| 156 | if (ec) |
| 157 | { |
| 158 | BMCWEB_LOG_DEBUG("[Set] Bad D-Bus request error: {}", ec); |
| 159 | messages::internalError(asyncResp->res); |
| 160 | return; |
| 161 | } |
Gunnar Mills | 2a5c440 | 2020-05-19 09:07:24 -0500 | [diff] [blame] | 162 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 163 | messages::success(asyncResp->res); |
| 164 | }); |
Gunnar Mills | 2a5c440 | 2020-05-19 09:07:24 -0500 | [diff] [blame] | 165 | } |
| 166 | |
Patrick Williams | 504af5a | 2025-02-03 14:29:03 -0500 | [diff] [blame] | 167 | inline void doBMCForceRestart( |
| 168 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
Jayaprakash Mutyala | f92af38 | 2020-06-16 23:29:41 +0000 | [diff] [blame] | 169 | { |
| 170 | const char* processName = "xyz.openbmc_project.State.BMC"; |
| 171 | const char* objectPath = "/xyz/openbmc_project/state/bmc0"; |
| 172 | const char* interfaceName = "xyz.openbmc_project.State.BMC"; |
| 173 | const std::string& propertyValue = |
| 174 | "xyz.openbmc_project.State.BMC.Transition.HardReboot"; |
| 175 | const char* destProperty = "RequestedBMCTransition"; |
| 176 | |
| 177 | // Create the D-Bus variant for D-Bus call. |
George Liu | 9ae226f | 2023-06-21 17:56:46 +0800 | [diff] [blame] | 178 | sdbusplus::asio::setProperty( |
| 179 | *crow::connections::systemBus, processName, objectPath, interfaceName, |
| 180 | destProperty, propertyValue, |
Ed Tanous | 5e7e2dc | 2023-02-16 10:37:01 -0800 | [diff] [blame] | 181 | [asyncResp](const boost::system::error_code& ec) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 182 | // Use "Set" method to set the property value. |
| 183 | if (ec) |
| 184 | { |
| 185 | BMCWEB_LOG_DEBUG("[Set] Bad D-Bus request error: {}", ec); |
| 186 | messages::internalError(asyncResp->res); |
| 187 | return; |
| 188 | } |
Jayaprakash Mutyala | f92af38 | 2020-06-16 23:29:41 +0000 | [diff] [blame] | 189 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 190 | messages::success(asyncResp->res); |
| 191 | }); |
Jayaprakash Mutyala | f92af38 | 2020-06-16 23:29:41 +0000 | [diff] [blame] | 192 | } |
| 193 | |
Gunnar Mills | 2a5c440 | 2020-05-19 09:07:24 -0500 | [diff] [blame] | 194 | /** |
| 195 | * ManagerResetAction class supports the POST method for the Reset (reboot) |
| 196 | * action. |
| 197 | */ |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 198 | inline void requestRoutesManagerResetAction(App& app) |
Jennifer Lee | ed5befb | 2018-08-10 11:29:45 -0700 | [diff] [blame] | 199 | { |
Jennifer Lee | ed5befb | 2018-08-10 11:29:45 -0700 | [diff] [blame] | 200 | /** |
Jennifer Lee | ed5befb | 2018-08-10 11:29:45 -0700 | [diff] [blame] | 201 | * Function handles POST method request. |
Gunnar Mills | 2a5c440 | 2020-05-19 09:07:24 -0500 | [diff] [blame] | 202 | * Analyzes POST body before sending Reset (Reboot) request data to D-Bus. |
Jayaprakash Mutyala | f92af38 | 2020-06-16 23:29:41 +0000 | [diff] [blame] | 203 | * OpenBMC supports ResetType "GracefulRestart" and "ForceRestart". |
Jennifer Lee | ed5befb | 2018-08-10 11:29:45 -0700 | [diff] [blame] | 204 | */ |
Jennifer Lee | ed5befb | 2018-08-10 11:29:45 -0700 | [diff] [blame] | 205 | |
Ed Tanous | 253f11b | 2024-05-16 09:38:31 -0700 | [diff] [blame] | 206 | BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/Actions/Manager.Reset/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 207 | .privileges(redfish::privileges::postManager) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 208 | .methods(boost::beast::http::verb::post)( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 209 | [&app](const crow::Request& req, |
Ed Tanous | 253f11b | 2024-05-16 09:38:31 -0700 | [diff] [blame] | 210 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 211 | const std::string& managerId) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 212 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
| 213 | { |
| 214 | return; |
| 215 | } |
| 216 | if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME) |
| 217 | { |
| 218 | messages::resourceNotFound(asyncResp->res, "Manager", |
| 219 | managerId); |
| 220 | return; |
| 221 | } |
Ed Tanous | 253f11b | 2024-05-16 09:38:31 -0700 | [diff] [blame] | 222 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 223 | BMCWEB_LOG_DEBUG("Post Manager Reset."); |
Gunnar Mills | 2a5c440 | 2020-05-19 09:07:24 -0500 | [diff] [blame] | 224 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 225 | std::string resetType; |
Jennifer Lee | ed5befb | 2018-08-10 11:29:45 -0700 | [diff] [blame] | 226 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 227 | if (!json_util::readJsonAction(req, asyncResp->res, "ResetType", |
| 228 | resetType)) |
| 229 | { |
| 230 | return; |
| 231 | } |
Gunnar Mills | 2a5c440 | 2020-05-19 09:07:24 -0500 | [diff] [blame] | 232 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 233 | if (resetType == "GracefulRestart") |
| 234 | { |
| 235 | BMCWEB_LOG_DEBUG("Proceeding with {}", resetType); |
| 236 | doBMCGracefulRestart(asyncResp); |
| 237 | return; |
| 238 | } |
| 239 | if (resetType == "ForceRestart") |
| 240 | { |
| 241 | BMCWEB_LOG_DEBUG("Proceeding with {}", resetType); |
| 242 | doBMCForceRestart(asyncResp); |
| 243 | return; |
| 244 | } |
| 245 | BMCWEB_LOG_DEBUG("Invalid property value for ResetType: {}", |
| 246 | resetType); |
| 247 | messages::actionParameterNotSupported(asyncResp->res, resetType, |
| 248 | "ResetType"); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 249 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 250 | return; |
| 251 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 252 | } |
Jennifer Lee | ed5befb | 2018-08-10 11:29:45 -0700 | [diff] [blame] | 253 | |
Gunnar Mills | 3e40fc7 | 2020-05-19 19:18:17 -0500 | [diff] [blame] | 254 | /** |
| 255 | * ManagerResetToDefaultsAction class supports POST method for factory reset |
| 256 | * action. |
| 257 | */ |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 258 | inline void requestRoutesManagerResetToDefaultsAction(App& app) |
Gunnar Mills | 3e40fc7 | 2020-05-19 19:18:17 -0500 | [diff] [blame] | 259 | { |
Gunnar Mills | 3e40fc7 | 2020-05-19 19:18:17 -0500 | [diff] [blame] | 260 | /** |
| 261 | * Function handles ResetToDefaults POST method request. |
| 262 | * |
| 263 | * Analyzes POST body message and factory resets BMC by calling |
| 264 | * BMC code updater factory reset followed by a BMC reboot. |
| 265 | * |
| 266 | * BMC code updater factory reset wipes the whole BMC read-write |
| 267 | * filesystem which includes things like the network settings. |
| 268 | * |
Gunnar Mills | 18bf4bf | 2025-05-09 08:22:38 -0500 | [diff] [blame] | 269 | * OpenBMC only supports ResetType "ResetAll". |
Gunnar Mills | 3e40fc7 | 2020-05-19 19:18:17 -0500 | [diff] [blame] | 270 | */ |
Gunnar Mills | 3e40fc7 | 2020-05-19 19:18:17 -0500 | [diff] [blame] | 271 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 272 | BMCWEB_ROUTE(app, |
Ed Tanous | 253f11b | 2024-05-16 09:38:31 -0700 | [diff] [blame] | 273 | "/redfish/v1/Managers/<str>/Actions/Manager.ResetToDefaults/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 274 | .privileges(redfish::privileges::postManager) |
Gunnar Mills | 18bf4bf | 2025-05-09 08:22:38 -0500 | [diff] [blame] | 275 | .methods(boost::beast::http::verb::post)( |
| 276 | [&app](const crow::Request& req, |
| 277 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 278 | const std::string& managerId) { |
| 279 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
| 280 | { |
| 281 | return; |
| 282 | } |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 283 | |
Gunnar Mills | 18bf4bf | 2025-05-09 08:22:38 -0500 | [diff] [blame] | 284 | if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME) |
| 285 | { |
| 286 | messages::resourceNotFound(asyncResp->res, "Manager", |
| 287 | managerId); |
| 288 | return; |
| 289 | } |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 290 | |
Gunnar Mills | 18bf4bf | 2025-05-09 08:22:38 -0500 | [diff] [blame] | 291 | BMCWEB_LOG_DEBUG("Post ResetToDefaults."); |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 292 | |
Gunnar Mills | 18bf4bf | 2025-05-09 08:22:38 -0500 | [diff] [blame] | 293 | std::optional<std::string> resetType; |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 294 | |
Gunnar Mills | 18bf4bf | 2025-05-09 08:22:38 -0500 | [diff] [blame] | 295 | if (!json_util::readJsonAction( // |
| 296 | req, asyncResp->res, // |
| 297 | "ResetType", resetType // |
| 298 | )) |
| 299 | { |
| 300 | BMCWEB_LOG_DEBUG("Missing property ResetType."); |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 301 | |
Gunnar Mills | 18bf4bf | 2025-05-09 08:22:38 -0500 | [diff] [blame] | 302 | messages::actionParameterMissing( |
| 303 | asyncResp->res, "ResetToDefaults", "ResetType"); |
| 304 | return; |
| 305 | } |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 306 | |
Gunnar Mills | 18bf4bf | 2025-05-09 08:22:38 -0500 | [diff] [blame] | 307 | if (resetType != "ResetAll") |
| 308 | { |
| 309 | BMCWEB_LOG_DEBUG("Invalid property value for ResetType: {}", |
| 310 | *resetType); |
| 311 | messages::actionParameterNotSupported( |
| 312 | asyncResp->res, *resetType, "ResetType"); |
| 313 | return; |
| 314 | } |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 315 | |
Gunnar Mills | 18bf4bf | 2025-05-09 08:22:38 -0500 | [diff] [blame] | 316 | crow::connections::systemBus->async_method_call( |
| 317 | [asyncResp](const boost::system::error_code& ec) { |
| 318 | if (ec) |
| 319 | { |
| 320 | BMCWEB_LOG_DEBUG("Failed to ResetToDefaults: {}", |
| 321 | ec); |
| 322 | messages::internalError(asyncResp->res); |
| 323 | return; |
| 324 | } |
| 325 | // Factory Reset doesn't actually happen until a reboot |
| 326 | // Can't erase what the BMC is running on |
| 327 | doBMCGracefulRestart(asyncResp); |
| 328 | }, |
| 329 | getBMCUpdateServiceName(), getBMCUpdateServicePath(), |
| 330 | "xyz.openbmc_project.Common.FactoryReset", "Reset"); |
| 331 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 332 | } |
Gunnar Mills | 3e40fc7 | 2020-05-19 19:18:17 -0500 | [diff] [blame] | 333 | |
AppaRao Puli | 1cb1a9e | 2020-07-17 23:38:57 +0530 | [diff] [blame] | 334 | /** |
| 335 | * ManagerResetActionInfo derived class for delivering Manager |
| 336 | * ResetType AllowableValues using ResetInfo schema. |
| 337 | */ |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 338 | inline void requestRoutesManagerResetActionInfo(App& app) |
AppaRao Puli | 1cb1a9e | 2020-07-17 23:38:57 +0530 | [diff] [blame] | 339 | { |
AppaRao Puli | 1cb1a9e | 2020-07-17 23:38:57 +0530 | [diff] [blame] | 340 | /** |
| 341 | * Functions triggers appropriate requests on DBus |
| 342 | */ |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 343 | |
Ed Tanous | 253f11b | 2024-05-16 09:38:31 -0700 | [diff] [blame] | 344 | BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/ResetActionInfo/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 345 | .privileges(redfish::privileges::getActionInfo) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 346 | .methods(boost::beast::http::verb::get)( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 347 | [&app](const crow::Request& req, |
Ed Tanous | 253f11b | 2024-05-16 09:38:31 -0700 | [diff] [blame] | 348 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 349 | const std::string& managerId) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 350 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
| 351 | { |
| 352 | return; |
| 353 | } |
Ed Tanous | 1476687 | 2022-03-15 10:44:42 -0700 | [diff] [blame] | 354 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 355 | if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME) |
| 356 | { |
| 357 | messages::resourceNotFound(asyncResp->res, "Manager", |
| 358 | managerId); |
| 359 | return; |
| 360 | } |
Ed Tanous | 253f11b | 2024-05-16 09:38:31 -0700 | [diff] [blame] | 361 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 362 | asyncResp->res.jsonValue["@odata.type"] = |
| 363 | "#ActionInfo.v1_1_2.ActionInfo"; |
| 364 | asyncResp->res.jsonValue["@odata.id"] = boost::urls::format( |
| 365 | "/redfish/v1/Managers/{}/ResetActionInfo", |
| 366 | BMCWEB_REDFISH_MANAGER_URI_NAME); |
| 367 | asyncResp->res.jsonValue["Name"] = "Reset Action Info"; |
| 368 | asyncResp->res.jsonValue["Id"] = "ResetActionInfo"; |
| 369 | nlohmann::json::object_t parameter; |
| 370 | parameter["Name"] = "ResetType"; |
| 371 | parameter["Required"] = true; |
| 372 | parameter["DataType"] = action_info::ParameterTypes::String; |
Ed Tanous | 1476687 | 2022-03-15 10:44:42 -0700 | [diff] [blame] | 373 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 374 | nlohmann::json::array_t allowableValues; |
| 375 | allowableValues.emplace_back("GracefulRestart"); |
| 376 | allowableValues.emplace_back("ForceRestart"); |
| 377 | parameter["AllowableValues"] = std::move(allowableValues); |
Ed Tanous | 1476687 | 2022-03-15 10:44:42 -0700 | [diff] [blame] | 378 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 379 | nlohmann::json::array_t parameters; |
| 380 | parameters.emplace_back(std::move(parameter)); |
Ed Tanous | 1476687 | 2022-03-15 10:44:42 -0700 | [diff] [blame] | 381 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 382 | asyncResp->res.jsonValue["Parameters"] = std::move(parameters); |
| 383 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 384 | } |
AppaRao Puli | 1cb1a9e | 2020-07-17 23:38:57 +0530 | [diff] [blame] | 385 | |
SunnySrivastava1984 | 071d8fd | 2020-10-28 02:20:30 -0500 | [diff] [blame] | 386 | /** |
| 387 | * @brief Retrieves BMC manager location data over DBus |
| 388 | * |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 389 | * @param[in] asyncResp Shared pointer for completing asynchronous calls |
SunnySrivastava1984 | 071d8fd | 2020-10-28 02:20:30 -0500 | [diff] [blame] | 390 | * @param[in] connectionName - service name |
| 391 | * @param[in] path - object path |
| 392 | * @return none |
| 393 | */ |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 394 | inline void getLocation(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
SunnySrivastava1984 | 071d8fd | 2020-10-28 02:20:30 -0500 | [diff] [blame] | 395 | const std::string& connectionName, |
| 396 | const std::string& path) |
| 397 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 398 | BMCWEB_LOG_DEBUG("Get BMC manager Location data."); |
SunnySrivastava1984 | 071d8fd | 2020-10-28 02:20:30 -0500 | [diff] [blame] | 399 | |
Ed Tanous | deae6a7 | 2024-11-11 21:58:57 -0800 | [diff] [blame] | 400 | dbus::utility::getProperty<std::string>( |
| 401 | connectionName, path, |
Jonathan Doman | 1e1e598 | 2021-06-11 09:36:17 -0700 | [diff] [blame] | 402 | "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode", |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 403 | [asyncResp](const boost::system::error_code& ec, |
| 404 | const std::string& property) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 405 | if (ec) |
| 406 | { |
| 407 | BMCWEB_LOG_DEBUG("DBUS response error for " |
| 408 | "Location"); |
| 409 | messages::internalError(asyncResp->res); |
| 410 | return; |
| 411 | } |
SunnySrivastava1984 | 071d8fd | 2020-10-28 02:20:30 -0500 | [diff] [blame] | 412 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 413 | asyncResp->res |
| 414 | .jsonValue["Location"]["PartLocation"]["ServiceLabel"] = |
| 415 | property; |
| 416 | }); |
SunnySrivastava1984 | 071d8fd | 2020-10-28 02:20:30 -0500 | [diff] [blame] | 417 | } |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 418 | // avoid name collision systems.hpp |
Patrick Williams | 504af5a | 2025-02-03 14:29:03 -0500 | [diff] [blame] | 419 | inline void managerGetLastResetTime( |
| 420 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 421 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 422 | BMCWEB_LOG_DEBUG("Getting Manager Last Reset Time"); |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 423 | |
Ed Tanous | deae6a7 | 2024-11-11 21:58:57 -0800 | [diff] [blame] | 424 | dbus::utility::getProperty<uint64_t>( |
| 425 | "xyz.openbmc_project.State.BMC", "/xyz/openbmc_project/state/bmc0", |
| 426 | "xyz.openbmc_project.State.BMC", "LastRebootTime", |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 427 | [asyncResp](const boost::system::error_code& ec, |
| 428 | const uint64_t lastResetTime) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 429 | if (ec) |
| 430 | { |
| 431 | BMCWEB_LOG_DEBUG("D-BUS response error {}", ec); |
| 432 | return; |
| 433 | } |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 434 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 435 | // LastRebootTime is epoch time, in milliseconds |
| 436 | // https://github.com/openbmc/phosphor-dbus-interfaces/blob/7f9a128eb9296e926422ddc312c148b625890bb6/xyz/openbmc_project/State/BMC.interface.yaml#L19 |
| 437 | uint64_t lastResetTimeStamp = lastResetTime / 1000; |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 438 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 439 | // Convert to ISO 8601 standard |
| 440 | asyncResp->res.jsonValue["LastResetTime"] = |
| 441 | redfish::time_utils::getDateTimeUint(lastResetTimeStamp); |
| 442 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | /** |
| 446 | * @brief Set the running firmware image |
| 447 | * |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 448 | * @param[i,o] asyncResp - Async response object |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 449 | * @param[i] runningFirmwareTarget - Image to make the running image |
| 450 | * |
| 451 | * @return void |
| 452 | */ |
Patrick Williams | 504af5a | 2025-02-03 14:29:03 -0500 | [diff] [blame] | 453 | inline void setActiveFirmwareImage( |
| 454 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 455 | const std::string& runningFirmwareTarget) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 456 | { |
| 457 | // Get the Id from /redfish/v1/UpdateService/FirmwareInventory/<Id> |
| 458 | std::string::size_type idPos = runningFirmwareTarget.rfind('/'); |
| 459 | if (idPos == std::string::npos) |
| 460 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 461 | messages::propertyValueNotInList(asyncResp->res, runningFirmwareTarget, |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 462 | "@odata.id"); |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 463 | BMCWEB_LOG_DEBUG("Can't parse firmware ID!"); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 464 | return; |
| 465 | } |
| 466 | idPos++; |
| 467 | if (idPos >= runningFirmwareTarget.size()) |
| 468 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 469 | messages::propertyValueNotInList(asyncResp->res, runningFirmwareTarget, |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 470 | "@odata.id"); |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 471 | BMCWEB_LOG_DEBUG("Invalid firmware ID."); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 472 | return; |
| 473 | } |
| 474 | std::string firmwareId = runningFirmwareTarget.substr(idPos); |
| 475 | |
| 476 | // Make sure the image is valid before setting priority |
George Liu | 5eb468d | 2023-06-20 17:03:24 +0800 | [diff] [blame] | 477 | sdbusplus::message::object_path objPath("/xyz/openbmc_project/software"); |
| 478 | dbus::utility::getManagedObjects( |
Jagpal Singh Gill | d27c31e | 2024-10-15 15:10:19 -0700 | [diff] [blame] | 479 | getBMCUpdateServiceName(), objPath, |
George Liu | 5eb468d | 2023-06-20 17:03:24 +0800 | [diff] [blame] | 480 | [asyncResp, firmwareId, runningFirmwareTarget]( |
| 481 | const boost::system::error_code& ec, |
| 482 | const dbus::utility::ManagedObjectType& subtree) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 483 | if (ec) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 484 | { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 485 | BMCWEB_LOG_DEBUG("D-Bus response error getting objects."); |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 486 | messages::internalError(asyncResp->res); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 487 | return; |
| 488 | } |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 489 | |
| 490 | if (subtree.empty()) |
| 491 | { |
| 492 | BMCWEB_LOG_DEBUG("Can't find image!"); |
| 493 | messages::internalError(asyncResp->res); |
| 494 | return; |
| 495 | } |
| 496 | |
| 497 | bool foundImage = false; |
| 498 | for (const auto& object : subtree) |
| 499 | { |
| 500 | const std::string& path = |
| 501 | static_cast<const std::string&>(object.first); |
| 502 | std::size_t idPos2 = path.rfind('/'); |
| 503 | |
| 504 | if (idPos2 == std::string::npos) |
| 505 | { |
| 506 | continue; |
| 507 | } |
| 508 | |
| 509 | idPos2++; |
| 510 | if (idPos2 >= path.size()) |
| 511 | { |
| 512 | continue; |
| 513 | } |
| 514 | |
| 515 | if (path.substr(idPos2) == firmwareId) |
| 516 | { |
| 517 | foundImage = true; |
| 518 | break; |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | if (!foundImage) |
| 523 | { |
| 524 | messages::propertyValueNotInList( |
| 525 | asyncResp->res, runningFirmwareTarget, "@odata.id"); |
| 526 | BMCWEB_LOG_DEBUG("Invalid firmware ID."); |
| 527 | return; |
| 528 | } |
| 529 | |
| 530 | BMCWEB_LOG_DEBUG("Setting firmware version {} to priority 0.", |
| 531 | firmwareId); |
| 532 | |
| 533 | // Only support Immediate |
| 534 | // An addition could be a Redfish Setting like |
| 535 | // ActiveSoftwareImageApplyTime and support OnReset |
| 536 | sdbusplus::asio::setProperty( |
Jagpal Singh Gill | d27c31e | 2024-10-15 15:10:19 -0700 | [diff] [blame] | 537 | *crow::connections::systemBus, getBMCUpdateServiceName(), |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 538 | "/xyz/openbmc_project/software/" + firmwareId, |
| 539 | "xyz.openbmc_project.Software.RedundancyPriority", "Priority", |
| 540 | static_cast<uint8_t>(0), |
| 541 | [asyncResp](const boost::system::error_code& ec2) { |
| 542 | if (ec2) |
| 543 | { |
| 544 | BMCWEB_LOG_DEBUG("D-Bus response error setting."); |
| 545 | messages::internalError(asyncResp->res); |
| 546 | return; |
| 547 | } |
| 548 | doBMCGracefulRestart(asyncResp); |
| 549 | }); |
George Liu | 5eb468d | 2023-06-20 17:03:24 +0800 | [diff] [blame] | 550 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 551 | } |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 552 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 553 | inline void afterSetDateTime( |
| 554 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 555 | const boost::system::error_code& ec, const sdbusplus::message_t& msg) |
Ed Tanous | c51afd5 | 2024-03-07 10:13:14 -0800 | [diff] [blame] | 556 | { |
| 557 | if (ec) |
| 558 | { |
| 559 | BMCWEB_LOG_DEBUG("Failed to set elapsed time. DBUS response error {}", |
| 560 | ec); |
| 561 | const sd_bus_error* dbusError = msg.get_error(); |
| 562 | if (dbusError != nullptr) |
| 563 | { |
| 564 | std::string_view errorName(dbusError->name); |
| 565 | if (errorName == |
| 566 | "org.freedesktop.timedate1.AutomaticTimeSyncEnabled") |
| 567 | { |
| 568 | BMCWEB_LOG_DEBUG("Setting conflict"); |
| 569 | messages::propertyValueConflict( |
| 570 | asyncResp->res, "DateTime", |
| 571 | "Managers/NetworkProtocol/NTPProcotolEnabled"); |
| 572 | return; |
| 573 | } |
| 574 | } |
| 575 | messages::internalError(asyncResp->res); |
| 576 | return; |
| 577 | } |
| 578 | asyncResp->res.result(boost::beast::http::status::no_content); |
| 579 | } |
| 580 | |
| 581 | inline void setDateTime(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 582 | const std::string& datetime) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 583 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 584 | BMCWEB_LOG_DEBUG("Set date time: {}", datetime); |
Borawski.Lukasz | 9c310685 | 2018-02-09 15:24:22 +0100 | [diff] [blame] | 585 | |
Ed Tanous | c2e3200 | 2023-01-07 22:05:08 -0800 | [diff] [blame] | 586 | std::optional<redfish::time_utils::usSinceEpoch> us = |
| 587 | redfish::time_utils::dateStringToEpoch(datetime); |
| 588 | if (!us) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 589 | { |
Ed Tanous | ac106bf | 2023-06-07 09:24:59 -0700 | [diff] [blame] | 590 | messages::propertyValueFormatError(asyncResp->res, datetime, |
| 591 | "DateTime"); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 592 | return; |
| 593 | } |
Ed Tanous | c51afd5 | 2024-03-07 10:13:14 -0800 | [diff] [blame] | 594 | // Set the absolute datetime |
| 595 | bool relative = false; |
| 596 | bool interactive = false; |
| 597 | crow::connections::systemBus->async_method_call( |
| 598 | [asyncResp](const boost::system::error_code& ec, |
| 599 | const sdbusplus::message_t& msg) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 600 | afterSetDateTime(asyncResp, ec, msg); |
| 601 | }, |
Ed Tanous | c51afd5 | 2024-03-07 10:13:14 -0800 | [diff] [blame] | 602 | "org.freedesktop.timedate1", "/org/freedesktop/timedate1", |
| 603 | "org.freedesktop.timedate1", "SetTime", us->count(), relative, |
| 604 | interactive); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 605 | } |
| 606 | |
Patrick Williams | 504af5a | 2025-02-03 14:29:03 -0500 | [diff] [blame] | 607 | inline void checkForQuiesced( |
| 608 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
Ed Tanous | 75815e5 | 2022-10-05 17:21:13 -0700 | [diff] [blame] | 609 | { |
Ed Tanous | deae6a7 | 2024-11-11 21:58:57 -0800 | [diff] [blame] | 610 | dbus::utility::getProperty<std::string>( |
| 611 | "org.freedesktop.systemd1", |
Ed Tanous | 75815e5 | 2022-10-05 17:21:13 -0700 | [diff] [blame] | 612 | "/org/freedesktop/systemd1/unit/obmc-bmc-service-quiesce@0.target", |
| 613 | "org.freedesktop.systemd1.Unit", "ActiveState", |
| 614 | [asyncResp](const boost::system::error_code& ec, |
| 615 | const std::string& val) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 616 | if (!ec) |
Ed Tanous | 75815e5 | 2022-10-05 17:21:13 -0700 | [diff] [blame] | 617 | { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 618 | if (val == "active") |
| 619 | { |
| 620 | asyncResp->res.jsonValue["Status"]["Health"] = |
| 621 | resource::Health::Critical; |
| 622 | asyncResp->res.jsonValue["Status"]["State"] = |
| 623 | resource::State::Quiesced; |
| 624 | return; |
| 625 | } |
Ed Tanous | 75815e5 | 2022-10-05 17:21:13 -0700 | [diff] [blame] | 626 | } |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 627 | asyncResp->res.jsonValue["Status"]["Health"] = resource::Health::OK; |
| 628 | asyncResp->res.jsonValue["Status"]["State"] = |
| 629 | resource::State::Enabled; |
| 630 | }); |
Ed Tanous | 75815e5 | 2022-10-05 17:21:13 -0700 | [diff] [blame] | 631 | } |
| 632 | |
Janet Adkins | e2cdf06 | 2025-06-18 11:17:35 -0500 | [diff] [blame] | 633 | inline void getPhysicalAssets( |
| 634 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 635 | const boost::system::error_code& ec, |
| 636 | const dbus::utility::DBusPropertiesMap& propertiesList) |
| 637 | { |
| 638 | if (ec) |
| 639 | { |
| 640 | BMCWEB_LOG_DEBUG("Can't get bmc asset!"); |
| 641 | return; |
| 642 | } |
| 643 | |
| 644 | const std::string* partNumber = nullptr; |
| 645 | const std::string* serialNumber = nullptr; |
| 646 | const std::string* manufacturer = nullptr; |
| 647 | const std::string* model = nullptr; |
| 648 | const std::string* sparePartNumber = nullptr; |
| 649 | |
| 650 | const bool success = sdbusplus::unpackPropertiesNoThrow( |
| 651 | dbus_utils::UnpackErrorPrinter(), propertiesList, "PartNumber", |
| 652 | partNumber, "SerialNumber", serialNumber, "Manufacturer", manufacturer, |
| 653 | "Model", model, "SparePartNumber", sparePartNumber); |
| 654 | |
| 655 | if (!success) |
| 656 | { |
| 657 | messages::internalError(asyncResp->res); |
| 658 | return; |
| 659 | } |
| 660 | |
| 661 | if (partNumber != nullptr) |
| 662 | { |
| 663 | asyncResp->res.jsonValue["PartNumber"] = *partNumber; |
| 664 | } |
| 665 | |
| 666 | if (serialNumber != nullptr) |
| 667 | { |
| 668 | asyncResp->res.jsonValue["SerialNumber"] = *serialNumber; |
| 669 | } |
| 670 | |
| 671 | if (manufacturer != nullptr) |
| 672 | { |
| 673 | asyncResp->res.jsonValue["Manufacturer"] = *manufacturer; |
| 674 | } |
| 675 | |
| 676 | if (model != nullptr) |
| 677 | { |
| 678 | asyncResp->res.jsonValue["Model"] = *model; |
| 679 | } |
| 680 | |
| 681 | if (sparePartNumber != nullptr) |
| 682 | { |
| 683 | asyncResp->res.jsonValue["SparePartNumber"] = *sparePartNumber; |
| 684 | } |
| 685 | } |
| 686 | |
| 687 | inline void getManagerData(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 688 | const std::string& managerPath, |
| 689 | const dbus::utility::MapperServiceMap& serviceMap) |
| 690 | { |
| 691 | if (managerPath.empty() || serviceMap.size() != 1) |
| 692 | { |
| 693 | BMCWEB_LOG_DEBUG("Error getting bmc D-Bus object!"); |
| 694 | messages::internalError(asyncResp->res); |
| 695 | return; |
| 696 | } |
| 697 | |
| 698 | for (const auto& [connectionName, interfaces] : serviceMap) |
| 699 | { |
| 700 | for (const auto& interfaceName : interfaces) |
| 701 | { |
| 702 | if (interfaceName == |
| 703 | "xyz.openbmc_project.Inventory.Decorator.Asset") |
| 704 | { |
| 705 | dbus::utility::getAllProperties( |
| 706 | *crow::connections::systemBus, connectionName, managerPath, |
| 707 | "xyz.openbmc_project.Inventory.Decorator.Asset", |
| 708 | std::bind_front(getPhysicalAssets, asyncResp)); |
| 709 | } |
| 710 | else if (interfaceName == |
| 711 | "xyz.openbmc_project.Inventory.Decorator.LocationCode") |
| 712 | { |
| 713 | getLocation(asyncResp, connectionName, managerPath); |
| 714 | } |
George Liu | 79f3b6a | 2021-05-13 18:08:44 +0800 | [diff] [blame^] | 715 | else if (interfaceName == |
| 716 | "xyz.openbmc_project.Association.Definitions") |
| 717 | { |
| 718 | getLocationIndicatorActive(asyncResp, managerPath); |
| 719 | } |
Janet Adkins | e2cdf06 | 2025-06-18 11:17:35 -0500 | [diff] [blame] | 720 | } |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | inline void afterGetManagerObject( |
| 725 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 726 | const boost::system::error_code& ec, |
| 727 | const dbus::utility::MapperGetSubTreeResponse& subtree, |
| 728 | const std::function< |
| 729 | void(const std::string& managerPath, |
| 730 | const dbus::utility::MapperServiceMap& serviceMap)>& callback) |
| 731 | { |
| 732 | if (ec) |
| 733 | { |
| 734 | BMCWEB_LOG_DEBUG("D-Bus response error on GetSubTree {}", ec); |
| 735 | return; |
| 736 | } |
| 737 | if (subtree.empty()) |
| 738 | { |
| 739 | BMCWEB_LOG_DEBUG("Can't find bmc D-Bus object!"); |
| 740 | return; |
| 741 | } |
| 742 | // Assume only 1 bmc D-Bus object |
| 743 | // Throw an error if there is more than 1 |
| 744 | if (subtree.size() > 1) |
| 745 | { |
| 746 | BMCWEB_LOG_ERROR("Found more than 1 bmc D-Bus object!"); |
| 747 | messages::internalError(asyncResp->res); |
| 748 | return; |
| 749 | } |
| 750 | |
| 751 | callback(subtree[0].first, subtree[0].second); |
| 752 | } |
| 753 | |
| 754 | inline void getManagerObject( |
| 755 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 756 | const std::string& /* managerId */, |
| 757 | std::function<void(const std::string& managerPath, |
| 758 | const dbus::utility::MapperServiceMap& serviceMap)>&& |
| 759 | callback) |
| 760 | { |
| 761 | constexpr std::array<std::string_view, 1> interfaces = { |
| 762 | "xyz.openbmc_project.Inventory.Item.Bmc"}; |
| 763 | dbus::utility::getSubTree( |
| 764 | "/xyz/openbmc_project/inventory", 0, interfaces, |
| 765 | [asyncResp, callback{std::move(callback)}]( |
| 766 | const boost::system::error_code& ec, |
| 767 | const dbus::utility::MapperGetSubTreeResponse& subtree) { |
| 768 | afterGetManagerObject(asyncResp, ec, subtree, callback); |
| 769 | }); |
| 770 | } |
| 771 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 772 | inline void requestRoutesManager(App& app) |
| 773 | { |
| 774 | std::string uuid = persistent_data::getConfig().systemUuid; |
| 775 | |
Ed Tanous | 253f11b | 2024-05-16 09:38:31 -0700 | [diff] [blame] | 776 | BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 777 | .privileges(redfish::privileges::getManager) |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 778 | .methods( |
| 779 | boost::beast::http::verb:: |
| 780 | get)([&app, |
| 781 | uuid](const crow::Request& req, |
| 782 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 783 | const std::string& managerId) { |
| 784 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
| 785 | { |
| 786 | return; |
| 787 | } |
Ed Tanous | 253f11b | 2024-05-16 09:38:31 -0700 | [diff] [blame] | 788 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 789 | if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME) |
| 790 | { |
| 791 | messages::resourceNotFound(asyncResp->res, "Manager", |
| 792 | managerId); |
| 793 | return; |
| 794 | } |
Ed Tanous | 253f11b | 2024-05-16 09:38:31 -0700 | [diff] [blame] | 795 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 796 | asyncResp->res.jsonValue["@odata.id"] = boost::urls::format( |
| 797 | "/redfish/v1/Managers/{}", BMCWEB_REDFISH_MANAGER_URI_NAME); |
| 798 | asyncResp->res.jsonValue["@odata.type"] = |
| 799 | "#Manager.v1_14_0.Manager"; |
| 800 | asyncResp->res.jsonValue["Id"] = BMCWEB_REDFISH_MANAGER_URI_NAME; |
| 801 | asyncResp->res.jsonValue["Name"] = "OpenBmc Manager"; |
| 802 | asyncResp->res.jsonValue["Description"] = |
| 803 | "Baseboard Management Controller"; |
| 804 | asyncResp->res.jsonValue["PowerState"] = resource::PowerState::On; |
Ed Tanous | 1476687 | 2022-03-15 10:44:42 -0700 | [diff] [blame] | 805 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 806 | asyncResp->res.jsonValue["ManagerType"] = manager::ManagerType::BMC; |
| 807 | asyncResp->res.jsonValue["UUID"] = systemd_utils::getUuid(); |
| 808 | asyncResp->res.jsonValue["ServiceEntryPointUUID"] = uuid; |
| 809 | asyncResp->res.jsonValue["Model"] = |
| 810 | "OpenBmc"; // TODO(ed), get model |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 811 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 812 | asyncResp->res.jsonValue["LogServices"]["@odata.id"] = |
| 813 | boost::urls::format("/redfish/v1/Managers/{}/LogServices", |
Ed Tanous | 253f11b | 2024-05-16 09:38:31 -0700 | [diff] [blame] | 814 | BMCWEB_REDFISH_MANAGER_URI_NAME); |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 815 | asyncResp->res.jsonValue["NetworkProtocol"]["@odata.id"] = |
| 816 | boost::urls::format("/redfish/v1/Managers/{}/NetworkProtocol", |
| 817 | BMCWEB_REDFISH_MANAGER_URI_NAME); |
| 818 | asyncResp->res.jsonValue["EthernetInterfaces"]["@odata.id"] = |
| 819 | boost::urls::format( |
| 820 | "/redfish/v1/Managers/{}/EthernetInterfaces", |
| 821 | BMCWEB_REDFISH_MANAGER_URI_NAME); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 822 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 823 | if constexpr (BMCWEB_VM_NBDPROXY) |
Ed Tanous | 75815e5 | 2022-10-05 17:21:13 -0700 | [diff] [blame] | 824 | { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 825 | asyncResp->res.jsonValue["VirtualMedia"]["@odata.id"] = |
| 826 | boost::urls::format("/redfish/v1/Managers/{}/VirtualMedia", |
| 827 | BMCWEB_REDFISH_MANAGER_URI_NAME); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 828 | } |
| 829 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 830 | // Manager.Reset (an action) can be many values, OpenBMC only |
| 831 | // supports BMC reboot. |
| 832 | nlohmann::json& managerReset = |
| 833 | asyncResp->res.jsonValue["Actions"]["#Manager.Reset"]; |
| 834 | managerReset["target"] = boost::urls::format( |
| 835 | "/redfish/v1/Managers/{}/Actions/Manager.Reset", |
| 836 | BMCWEB_REDFISH_MANAGER_URI_NAME); |
| 837 | managerReset["@Redfish.ActionInfo"] = |
| 838 | boost::urls::format("/redfish/v1/Managers/{}/ResetActionInfo", |
| 839 | BMCWEB_REDFISH_MANAGER_URI_NAME); |
| 840 | |
| 841 | // ResetToDefaults (Factory Reset) has values like |
| 842 | // PreserveNetworkAndUsers and PreserveNetwork that aren't supported |
| 843 | // on OpenBMC |
| 844 | nlohmann::json& resetToDefaults = |
| 845 | asyncResp->res.jsonValue["Actions"]["#Manager.ResetToDefaults"]; |
| 846 | resetToDefaults["target"] = boost::urls::format( |
| 847 | "/redfish/v1/Managers/{}/Actions/Manager.ResetToDefaults", |
| 848 | BMCWEB_REDFISH_MANAGER_URI_NAME); |
| 849 | resetToDefaults["ResetType@Redfish.AllowableValues"] = |
| 850 | nlohmann::json::array_t({"ResetAll"}); |
| 851 | |
| 852 | std::pair<std::string, std::string> redfishDateTimeOffset = |
| 853 | redfish::time_utils::getDateTimeOffsetNow(); |
| 854 | |
| 855 | asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first; |
| 856 | asyncResp->res.jsonValue["DateTimeLocalOffset"] = |
| 857 | redfishDateTimeOffset.second; |
| 858 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 859 | if constexpr (BMCWEB_KVM) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 860 | { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 861 | // Fill in GraphicalConsole info |
| 862 | asyncResp->res.jsonValue["GraphicalConsole"]["ServiceEnabled"] = |
| 863 | true; |
| 864 | asyncResp->res |
| 865 | .jsonValue["GraphicalConsole"]["MaxConcurrentSessions"] = 4; |
| 866 | asyncResp->res |
| 867 | .jsonValue["GraphicalConsole"]["ConnectTypesSupported"] = |
| 868 | nlohmann::json::array_t({"KVMIP"}); |
| 869 | } |
| 870 | if constexpr (!BMCWEB_EXPERIMENTAL_REDFISH_MULTI_COMPUTER_SYSTEM) |
| 871 | { |
| 872 | asyncResp->res |
| 873 | .jsonValue["Links"]["ManagerForServers@odata.count"] = 1; |
| 874 | |
| 875 | nlohmann::json::array_t managerForServers; |
| 876 | nlohmann::json::object_t manager; |
| 877 | manager["@odata.id"] = std::format( |
| 878 | "/redfish/v1/Systems/{}", BMCWEB_REDFISH_SYSTEM_URI_NAME); |
| 879 | managerForServers.emplace_back(std::move(manager)); |
| 880 | |
| 881 | asyncResp->res.jsonValue["Links"]["ManagerForServers"] = |
| 882 | std::move(managerForServers); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 883 | } |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 884 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 885 | sw_util::populateSoftwareInformation(asyncResp, sw_util::bmcPurpose, |
| 886 | "FirmwareVersion", true); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 887 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 888 | managerGetLastResetTime(asyncResp); |
| 889 | |
| 890 | // ManagerDiagnosticData is added for all BMCs. |
| 891 | nlohmann::json& managerDiagnosticData = |
| 892 | asyncResp->res.jsonValue["ManagerDiagnosticData"]; |
| 893 | managerDiagnosticData["@odata.id"] = boost::urls::format( |
| 894 | "/redfish/v1/Managers/{}/ManagerDiagnosticData", |
| 895 | BMCWEB_REDFISH_MANAGER_URI_NAME); |
| 896 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 897 | getMainChassisId(asyncResp, [](const std::string& chassisId, |
| 898 | const std::shared_ptr< |
| 899 | bmcweb::AsyncResp>& aRsp) { |
| 900 | aRsp->res.jsonValue["Links"]["ManagerForChassis@odata.count"] = |
| 901 | 1; |
| 902 | nlohmann::json::array_t managerForChassis; |
| 903 | nlohmann::json::object_t managerObj; |
| 904 | boost::urls::url chassiUrl = |
| 905 | boost::urls::format("/redfish/v1/Chassis/{}", chassisId); |
| 906 | managerObj["@odata.id"] = chassiUrl; |
| 907 | managerForChassis.emplace_back(std::move(managerObj)); |
| 908 | aRsp->res.jsonValue["Links"]["ManagerForChassis"] = |
| 909 | std::move(managerForChassis); |
| 910 | aRsp->res.jsonValue["Links"]["ManagerInChassis"]["@odata.id"] = |
| 911 | chassiUrl; |
| 912 | }); |
| 913 | |
Ed Tanous | deae6a7 | 2024-11-11 21:58:57 -0800 | [diff] [blame] | 914 | dbus::utility::getProperty<double>( |
| 915 | "org.freedesktop.systemd1", "/org/freedesktop/systemd1", |
| 916 | "org.freedesktop.systemd1.Manager", "Progress", |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 917 | [asyncResp](const boost::system::error_code& ec, double val) { |
| 918 | if (ec) |
| 919 | { |
| 920 | BMCWEB_LOG_ERROR("Error while getting progress"); |
| 921 | messages::internalError(asyncResp->res); |
| 922 | return; |
| 923 | } |
| 924 | if (val < 1.0) |
| 925 | { |
| 926 | asyncResp->res.jsonValue["Status"]["Health"] = |
| 927 | resource::Health::OK; |
| 928 | asyncResp->res.jsonValue["Status"]["State"] = |
| 929 | resource::State::Starting; |
| 930 | return; |
| 931 | } |
| 932 | checkForQuiesced(asyncResp); |
| 933 | }); |
| 934 | |
Janet Adkins | e2cdf06 | 2025-06-18 11:17:35 -0500 | [diff] [blame] | 935 | getManagerObject(asyncResp, managerId, |
| 936 | std::bind_front(getManagerData, asyncResp)); |
rohitpai | c1a75eb | 2025-01-03 19:13:36 +0530 | [diff] [blame] | 937 | |
| 938 | RedfishService::getInstance(app).handleSubRoute(req, asyncResp); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 939 | }); |
| 940 | |
Ed Tanous | 253f11b | 2024-05-16 09:38:31 -0700 | [diff] [blame] | 941 | BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 942 | .privileges(redfish::privileges::patchManager) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 943 | .methods(boost::beast::http::verb::patch)( |
| 944 | [&app](const crow::Request& req, |
Ed Tanous | 253f11b | 2024-05-16 09:38:31 -0700 | [diff] [blame] | 945 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 946 | const std::string& managerId) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 947 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
| 948 | { |
| 949 | return; |
| 950 | } |
Ed Tanous | 253f11b | 2024-05-16 09:38:31 -0700 | [diff] [blame] | 951 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 952 | if (managerId != BMCWEB_REDFISH_MANAGER_URI_NAME) |
| 953 | { |
| 954 | messages::resourceNotFound(asyncResp->res, "Manager", |
| 955 | managerId); |
| 956 | return; |
| 957 | } |
Ed Tanous | 253f11b | 2024-05-16 09:38:31 -0700 | [diff] [blame] | 958 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 959 | std::optional<std::string> activeSoftwareImageOdataId; |
| 960 | std::optional<std::string> datetime; |
George Liu | 79f3b6a | 2021-05-13 18:08:44 +0800 | [diff] [blame^] | 961 | std::optional<bool> locationIndicatorActive; |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 962 | std::optional<nlohmann::json::object_t> pidControllers; |
| 963 | std::optional<nlohmann::json::object_t> fanControllers; |
| 964 | std::optional<nlohmann::json::object_t> fanZones; |
| 965 | std::optional<nlohmann::json::object_t> stepwiseControllers; |
| 966 | std::optional<std::string> profile; |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 967 | |
Patrick Williams | 504af5a | 2025-02-03 14:29:03 -0500 | [diff] [blame] | 968 | if (!json_util::readJsonPatch( // |
| 969 | req, asyncResp->res, // |
| 970 | "DateTime", datetime, // |
Myung Bae | afc474a | 2024-10-09 00:53:29 -0700 | [diff] [blame] | 971 | "Links/ActiveSoftwareImage/@odata.id", |
Patrick Williams | 504af5a | 2025-02-03 14:29:03 -0500 | [diff] [blame] | 972 | activeSoftwareImageOdataId, // |
George Liu | 79f3b6a | 2021-05-13 18:08:44 +0800 | [diff] [blame^] | 973 | "LocationIndicatorActive", |
| 974 | locationIndicatorActive, // |
Myung Bae | afc474a | 2024-10-09 00:53:29 -0700 | [diff] [blame] | 975 | "Oem/OpenBmc/Fan/FanControllers", fanControllers, // |
Patrick Williams | 504af5a | 2025-02-03 14:29:03 -0500 | [diff] [blame] | 976 | "Oem/OpenBmc/Fan/FanZones", fanZones, // |
Myung Bae | afc474a | 2024-10-09 00:53:29 -0700 | [diff] [blame] | 977 | "Oem/OpenBmc/Fan/PidControllers", pidControllers, // |
Patrick Williams | 504af5a | 2025-02-03 14:29:03 -0500 | [diff] [blame] | 978 | "Oem/OpenBmc/Fan/Profile", profile, // |
Myung Bae | afc474a | 2024-10-09 00:53:29 -0700 | [diff] [blame] | 979 | "Oem/OpenBmc/Fan/StepwiseControllers", |
Patrick Williams | 504af5a | 2025-02-03 14:29:03 -0500 | [diff] [blame] | 980 | stepwiseControllers // |
Myung Bae | afc474a | 2024-10-09 00:53:29 -0700 | [diff] [blame] | 981 | )) |
| 982 | { |
| 983 | return; |
| 984 | } |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 985 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 986 | if (activeSoftwareImageOdataId) |
| 987 | { |
| 988 | setActiveFirmwareImage(asyncResp, |
| 989 | *activeSoftwareImageOdataId); |
| 990 | } |
Ed Tanous | 9e9b604 | 2024-03-06 14:18:28 -0800 | [diff] [blame] | 991 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 992 | if (datetime) |
| 993 | { |
| 994 | setDateTime(asyncResp, *datetime); |
| 995 | } |
rohitpai | 84aad24 | 2025-01-28 09:23:53 +0530 | [diff] [blame] | 996 | |
George Liu | 79f3b6a | 2021-05-13 18:08:44 +0800 | [diff] [blame^] | 997 | if (locationIndicatorActive) |
| 998 | { |
| 999 | setLocationIndicatorActiveState( |
| 1000 | asyncResp, *locationIndicatorActive, managerId); |
| 1001 | } |
| 1002 | |
rohitpai | 84aad24 | 2025-01-28 09:23:53 +0530 | [diff] [blame] | 1003 | RedfishService::getInstance(app).handleSubRoute(req, asyncResp); |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 1004 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1005 | } |
| 1006 | |
| 1007 | inline void requestRoutesManagerCollection(App& app) |
| 1008 | { |
| 1009 | BMCWEB_ROUTE(app, "/redfish/v1/Managers/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 1010 | .privileges(redfish::privileges::getManagerCollection) |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1011 | .methods(boost::beast::http::verb::get)( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 1012 | [&app](const crow::Request& req, |
| 1013 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 1014 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
| 1015 | { |
| 1016 | return; |
| 1017 | } |
| 1018 | // Collections don't include the static data added by SubRoute |
| 1019 | // because it has a duplicate entry for members |
| 1020 | asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Managers"; |
| 1021 | asyncResp->res.jsonValue["@odata.type"] = |
| 1022 | "#ManagerCollection.ManagerCollection"; |
| 1023 | asyncResp->res.jsonValue["Name"] = "Manager Collection"; |
| 1024 | asyncResp->res.jsonValue["Members@odata.count"] = 1; |
| 1025 | nlohmann::json::array_t members; |
| 1026 | nlohmann::json& bmc = members.emplace_back(); |
| 1027 | bmc["@odata.id"] = boost::urls::format( |
| 1028 | "/redfish/v1/Managers/{}", BMCWEB_REDFISH_MANAGER_URI_NAME); |
| 1029 | asyncResp->res.jsonValue["Members"] = std::move(members); |
| 1030 | }); |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 1031 | } |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 1032 | } // namespace redfish |