Jennifer Lee | 729dae7 | 2018-04-24 15:59:34 -0700 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2018 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | #pragma once |
| 17 | |
| 18 | #include "node.hpp" |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 19 | |
Jennifer Lee | 729dae7 | 2018-04-24 15:59:34 -0700 | [diff] [blame] | 20 | #include <boost/container/flat_map.hpp> |
Andrew Geissler | 87d8472 | 2019-02-28 14:28:39 -0600 | [diff] [blame] | 21 | #include <utils/fw_utils.hpp> |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 22 | |
Ed Tanous | abf2add | 2019-01-22 16:40:12 -0800 | [diff] [blame] | 23 | #include <variant> |
Jennifer Lee | 729dae7 | 2018-04-24 15:59:34 -0700 | [diff] [blame] | 24 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 25 | namespace redfish |
| 26 | { |
Ed Tanous | 27826b5 | 2018-10-29 11:40:58 -0700 | [diff] [blame] | 27 | |
Andrew Geissler | 0e7de46 | 2019-03-04 19:11:54 -0600 | [diff] [blame] | 28 | // Match signals added on software path |
Jennifer Lee | acb7cfb | 2018-06-07 16:08:15 -0700 | [diff] [blame] | 29 | static std::unique_ptr<sdbusplus::bus::match::match> fwUpdateMatcher; |
James Feist | 4cde5d9 | 2020-06-11 10:39:55 -0700 | [diff] [blame] | 30 | static std::unique_ptr<sdbusplus::bus::match::match> fwUpdateErrorMatcher; |
Andrew Geissler | 0e7de46 | 2019-03-04 19:11:54 -0600 | [diff] [blame] | 31 | // Only allow one update at a time |
| 32 | static bool fwUpdateInProgress = false; |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 33 | // Timer for software available |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 34 | static std::unique_ptr<boost::asio::steady_timer> fwAvailableTimer; |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 35 | |
| 36 | static void cleanUp() |
| 37 | { |
| 38 | fwUpdateInProgress = false; |
| 39 | fwUpdateMatcher = nullptr; |
James Feist | 4cde5d9 | 2020-06-11 10:39:55 -0700 | [diff] [blame] | 40 | fwUpdateErrorMatcher = nullptr; |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 41 | } |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 42 | static void activateImage(const std::string& objPath, |
| 43 | const std::string& service) |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 44 | { |
| 45 | BMCWEB_LOG_DEBUG << "Activate image for " << objPath << " " << service; |
| 46 | crow::connections::systemBus->async_method_call( |
Ed Tanous | 81ce609 | 2020-12-17 16:54:55 +0000 | [diff] [blame] | 47 | [](const boost::system::error_code errorCode) { |
| 48 | if (errorCode) |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 49 | { |
Ed Tanous | 81ce609 | 2020-12-17 16:54:55 +0000 | [diff] [blame] | 50 | BMCWEB_LOG_DEBUG << "error_code = " << errorCode; |
| 51 | BMCWEB_LOG_DEBUG << "error msg = " << errorCode.message(); |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 52 | } |
| 53 | }, |
| 54 | service, objPath, "org.freedesktop.DBus.Properties", "Set", |
| 55 | "xyz.openbmc_project.Software.Activation", "RequestedActivation", |
| 56 | std::variant<std::string>( |
| 57 | "xyz.openbmc_project.Software.Activation.RequestedActivations." |
| 58 | "Active")); |
| 59 | } |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 60 | |
| 61 | // Note that asyncResp can be either a valid pointer or nullptr. If nullptr |
| 62 | // then no asyncResp updates will occur |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 63 | static void |
| 64 | softwareInterfaceAdded(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 65 | sdbusplus::message::message& m, |
| 66 | const crow::Request& req) |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 67 | { |
| 68 | std::vector<std::pair< |
| 69 | std::string, |
| 70 | std::vector<std::pair<std::string, std::variant<std::string>>>>> |
| 71 | interfacesProperties; |
| 72 | |
| 73 | sdbusplus::message::object_path objPath; |
| 74 | |
| 75 | m.read(objPath, interfacesProperties); |
| 76 | |
| 77 | BMCWEB_LOG_DEBUG << "obj path = " << objPath.str; |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 78 | for (auto& interface : interfacesProperties) |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 79 | { |
| 80 | BMCWEB_LOG_DEBUG << "interface = " << interface.first; |
| 81 | |
| 82 | if (interface.first == "xyz.openbmc_project.Software.Activation") |
| 83 | { |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 84 | // Retrieve service and activate |
| 85 | crow::connections::systemBus->async_method_call( |
James Feist | fe30672 | 2020-03-12 16:32:08 -0700 | [diff] [blame] | 86 | [objPath, asyncResp, |
Ed Tanous | 81ce609 | 2020-12-17 16:54:55 +0000 | [diff] [blame] | 87 | req](const boost::system::error_code errorCode, |
James Feist | fe30672 | 2020-03-12 16:32:08 -0700 | [diff] [blame] | 88 | const std::vector<std::pair< |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 89 | std::string, std::vector<std::string>>>& objInfo) { |
Ed Tanous | 81ce609 | 2020-12-17 16:54:55 +0000 | [diff] [blame] | 90 | if (errorCode) |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 91 | { |
Ed Tanous | 81ce609 | 2020-12-17 16:54:55 +0000 | [diff] [blame] | 92 | BMCWEB_LOG_DEBUG << "error_code = " << errorCode; |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 93 | BMCWEB_LOG_DEBUG << "error msg = " |
Ed Tanous | 81ce609 | 2020-12-17 16:54:55 +0000 | [diff] [blame] | 94 | << errorCode.message(); |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 95 | if (asyncResp) |
| 96 | { |
| 97 | messages::internalError(asyncResp->res); |
| 98 | } |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 99 | cleanUp(); |
| 100 | return; |
| 101 | } |
| 102 | // Ensure we only got one service back |
| 103 | if (objInfo.size() != 1) |
| 104 | { |
| 105 | BMCWEB_LOG_ERROR << "Invalid Object Size " |
| 106 | << objInfo.size(); |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 107 | if (asyncResp) |
| 108 | { |
| 109 | messages::internalError(asyncResp->res); |
| 110 | } |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 111 | cleanUp(); |
| 112 | return; |
| 113 | } |
| 114 | // cancel timer only when |
| 115 | // xyz.openbmc_project.Software.Activation interface |
| 116 | // is added |
| 117 | fwAvailableTimer = nullptr; |
| 118 | |
| 119 | activateImage(objPath.str, objInfo[0].first); |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 120 | if (asyncResp) |
| 121 | { |
James Feist | 32898ce | 2020-03-10 16:16:52 -0700 | [diff] [blame] | 122 | std::shared_ptr<task::TaskData> task = |
| 123 | task::TaskData::createTask( |
| 124 | [](boost::system::error_code ec, |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 125 | sdbusplus::message::message& msg, |
| 126 | const std::shared_ptr<task::TaskData>& |
| 127 | taskData) { |
James Feist | 32898ce | 2020-03-10 16:16:52 -0700 | [diff] [blame] | 128 | if (ec) |
| 129 | { |
| 130 | return task::completed; |
| 131 | } |
| 132 | |
| 133 | std::string iface; |
| 134 | boost::container::flat_map< |
James Feist | fd9ab9e | 2020-05-19 13:48:07 -0700 | [diff] [blame] | 135 | std::string, |
| 136 | std::variant<std::string, uint8_t>> |
James Feist | 32898ce | 2020-03-10 16:16:52 -0700 | [diff] [blame] | 137 | values; |
James Feist | 32898ce | 2020-03-10 16:16:52 -0700 | [diff] [blame] | 138 | |
James Feist | e5d5006 | 2020-05-11 17:29:00 -0700 | [diff] [blame] | 139 | std::string index = |
| 140 | std::to_string(taskData->index); |
James Feist | fd9ab9e | 2020-05-19 13:48:07 -0700 | [diff] [blame] | 141 | msg.read(iface, values); |
James Feist | e5d5006 | 2020-05-11 17:29:00 -0700 | [diff] [blame] | 142 | |
James Feist | fd9ab9e | 2020-05-19 13:48:07 -0700 | [diff] [blame] | 143 | if (iface == "xyz.openbmc_project.Software." |
| 144 | "Activation") |
James Feist | 32898ce | 2020-03-10 16:16:52 -0700 | [diff] [blame] | 145 | { |
James Feist | fd9ab9e | 2020-05-19 13:48:07 -0700 | [diff] [blame] | 146 | auto findActivation = |
| 147 | values.find("Activation"); |
| 148 | if (findActivation == values.end()) |
| 149 | { |
| 150 | return !task::completed; |
| 151 | } |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 152 | std::string* state = |
James Feist | fd9ab9e | 2020-05-19 13:48:07 -0700 | [diff] [blame] | 153 | std::get_if<std::string>( |
| 154 | &(findActivation->second)); |
| 155 | |
| 156 | if (state == nullptr) |
| 157 | { |
| 158 | taskData->messages.emplace_back( |
| 159 | messages::internalError()); |
| 160 | return task::completed; |
| 161 | } |
| 162 | |
| 163 | if (boost::ends_with(*state, |
| 164 | "Invalid") || |
| 165 | boost::ends_with(*state, "Failed")) |
| 166 | { |
| 167 | taskData->state = "Exception"; |
| 168 | taskData->status = "Warning"; |
| 169 | taskData->messages.emplace_back( |
| 170 | messages::taskAborted(index)); |
| 171 | return task::completed; |
| 172 | } |
| 173 | |
| 174 | if (boost::ends_with(*state, "Staged")) |
| 175 | { |
| 176 | taskData->state = "Stopping"; |
| 177 | taskData->messages.emplace_back( |
| 178 | messages::taskPaused(index)); |
| 179 | |
| 180 | // its staged, set a long timer to |
| 181 | // allow them time to complete the |
| 182 | // update (probably cycle the |
| 183 | // system) if this expires then |
| 184 | // task will be cancelled |
| 185 | taskData->extendTimer( |
| 186 | std::chrono::hours(5)); |
| 187 | return !task::completed; |
| 188 | } |
| 189 | |
| 190 | if (boost::ends_with(*state, "Active")) |
| 191 | { |
| 192 | taskData->messages.emplace_back( |
| 193 | messages::taskCompletedOK( |
| 194 | index)); |
| 195 | taskData->state = "Completed"; |
| 196 | return task::completed; |
| 197 | } |
James Feist | 32898ce | 2020-03-10 16:16:52 -0700 | [diff] [blame] | 198 | } |
James Feist | fd9ab9e | 2020-05-19 13:48:07 -0700 | [diff] [blame] | 199 | else if (iface == |
| 200 | "xyz.openbmc_project.Software." |
| 201 | "ActivationProgress") |
James Feist | 32898ce | 2020-03-10 16:16:52 -0700 | [diff] [blame] | 202 | { |
James Feist | fd9ab9e | 2020-05-19 13:48:07 -0700 | [diff] [blame] | 203 | auto findProgress = |
| 204 | values.find("Progress"); |
| 205 | if (findProgress == values.end()) |
| 206 | { |
| 207 | return !task::completed; |
| 208 | } |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 209 | uint8_t* progress = |
James Feist | fd9ab9e | 2020-05-19 13:48:07 -0700 | [diff] [blame] | 210 | std::get_if<uint8_t>( |
| 211 | &(findProgress->second)); |
James Feist | 32898ce | 2020-03-10 16:16:52 -0700 | [diff] [blame] | 212 | |
James Feist | fd9ab9e | 2020-05-19 13:48:07 -0700 | [diff] [blame] | 213 | if (progress == nullptr) |
| 214 | { |
| 215 | taskData->messages.emplace_back( |
| 216 | messages::internalError()); |
| 217 | return task::completed; |
| 218 | } |
George Liu | 6868ff5 | 2021-01-02 11:37:41 +0800 | [diff] [blame] | 219 | taskData->percentComplete = |
| 220 | static_cast<int>(*progress); |
James Feist | 32898ce | 2020-03-10 16:16:52 -0700 | [diff] [blame] | 221 | taskData->messages.emplace_back( |
James Feist | fd9ab9e | 2020-05-19 13:48:07 -0700 | [diff] [blame] | 222 | messages::taskProgressChanged( |
| 223 | index, static_cast<size_t>( |
| 224 | *progress))); |
| 225 | |
| 226 | // if we're getting status updates it's |
| 227 | // still alive, update timer |
| 228 | taskData->extendTimer( |
| 229 | std::chrono::minutes(5)); |
James Feist | 32898ce | 2020-03-10 16:16:52 -0700 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | // as firmware update often results in a |
| 233 | // reboot, the task may never "complete" |
| 234 | // unless it is an error |
| 235 | |
| 236 | return !task::completed; |
| 237 | }, |
| 238 | "type='signal',interface='org.freedesktop.DBus." |
| 239 | "Properties'," |
James Feist | fd9ab9e | 2020-05-19 13:48:07 -0700 | [diff] [blame] | 240 | "member='PropertiesChanged',path='" + |
James Feist | 32898ce | 2020-03-10 16:16:52 -0700 | [diff] [blame] | 241 | objPath.str + "'"); |
| 242 | task->startTimer(std::chrono::minutes(5)); |
| 243 | task->populateResp(asyncResp->res); |
James Feist | fe30672 | 2020-03-12 16:32:08 -0700 | [diff] [blame] | 244 | task->payload.emplace(req); |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 245 | } |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 246 | fwUpdateInProgress = false; |
| 247 | }, |
| 248 | "xyz.openbmc_project.ObjectMapper", |
| 249 | "/xyz/openbmc_project/object_mapper", |
| 250 | "xyz.openbmc_project.ObjectMapper", "GetObject", objPath.str, |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 251 | std::array<const char*, 1>{ |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 252 | "xyz.openbmc_project.Software.Activation"}); |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 257 | // Note that asyncResp can be either a valid pointer or nullptr. If nullptr |
| 258 | // then no asyncResp updates will occur |
Ed Tanous | b5a7693 | 2020-09-29 16:16:58 -0700 | [diff] [blame] | 259 | static void monitorForSoftwareAvailable( |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 260 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 261 | const crow::Request& req, const std::string& url, |
| 262 | int timeoutTimeSeconds = 10) |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 263 | { |
| 264 | // Only allow one FW update at a time |
| 265 | if (fwUpdateInProgress != false) |
| 266 | { |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 267 | if (asyncResp) |
| 268 | { |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 269 | messages::serviceTemporarilyUnavailable(asyncResp->res, "30"); |
| 270 | } |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 271 | return; |
| 272 | } |
| 273 | |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 274 | fwAvailableTimer = |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 275 | std::make_unique<boost::asio::steady_timer>(*req.ioService); |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 276 | |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 277 | fwAvailableTimer->expires_after(std::chrono::seconds(timeoutTimeSeconds)); |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 278 | |
| 279 | fwAvailableTimer->async_wait( |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 280 | [asyncResp](const boost::system::error_code& ec) { |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 281 | cleanUp(); |
| 282 | if (ec == boost::asio::error::operation_aborted) |
| 283 | { |
| 284 | // expected, we were canceled before the timer completed. |
| 285 | return; |
| 286 | } |
| 287 | BMCWEB_LOG_ERROR |
| 288 | << "Timed out waiting for firmware object being created"; |
| 289 | BMCWEB_LOG_ERROR |
| 290 | << "FW image may has already been uploaded to server"; |
| 291 | if (ec) |
| 292 | { |
| 293 | BMCWEB_LOG_ERROR << "Async_wait failed" << ec; |
| 294 | return; |
| 295 | } |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 296 | if (asyncResp) |
| 297 | { |
| 298 | redfish::messages::internalError(asyncResp->res); |
| 299 | } |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 300 | }); |
| 301 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 302 | auto callback = [asyncResp, req](sdbusplus::message::message& m) { |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 303 | BMCWEB_LOG_DEBUG << "Match fired"; |
James Feist | fe30672 | 2020-03-12 16:32:08 -0700 | [diff] [blame] | 304 | softwareInterfaceAdded(asyncResp, m, req); |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 305 | }; |
| 306 | |
| 307 | fwUpdateInProgress = true; |
| 308 | |
| 309 | fwUpdateMatcher = std::make_unique<sdbusplus::bus::match::match>( |
| 310 | *crow::connections::systemBus, |
| 311 | "interface='org.freedesktop.DBus.ObjectManager',type='signal'," |
| 312 | "member='InterfacesAdded',path='/xyz/openbmc_project/software'", |
| 313 | callback); |
James Feist | 4cde5d9 | 2020-06-11 10:39:55 -0700 | [diff] [blame] | 314 | |
| 315 | fwUpdateErrorMatcher = std::make_unique<sdbusplus::bus::match::match>( |
| 316 | *crow::connections::systemBus, |
| 317 | "type='signal',member='PropertiesChanged',path_namespace='/xyz/" |
| 318 | "openbmc_project/logging/entry'," |
| 319 | "arg0='xyz.openbmc_project.Logging.Entry'", |
| 320 | [asyncResp, url](sdbusplus::message::message& m) { |
| 321 | BMCWEB_LOG_DEBUG << "Error Match fired"; |
| 322 | boost::container::flat_map<std::string, std::variant<std::string>> |
| 323 | values; |
| 324 | std::string objName; |
| 325 | m.read(objName, values); |
| 326 | auto find = values.find("Message"); |
| 327 | if (find == values.end()) |
| 328 | { |
| 329 | return; |
| 330 | } |
| 331 | std::string* type = std::get_if<std::string>(&(find->second)); |
| 332 | if (type == nullptr) |
| 333 | { |
| 334 | return; // if this was our message, timeout will cover it |
| 335 | } |
Gunnar Mills | 88b3dd1 | 2020-11-20 14:26:04 -0600 | [diff] [blame] | 336 | if (!boost::starts_with(*type, "xyz.openbmc_project.Software")) |
James Feist | 4cde5d9 | 2020-06-11 10:39:55 -0700 | [diff] [blame] | 337 | { |
| 338 | return; |
| 339 | } |
| 340 | if (*type == |
| 341 | "xyz.openbmc_project.Software.Image.Error.UnTarFailure") |
| 342 | { |
| 343 | redfish::messages::invalidUpload(asyncResp->res, url, |
| 344 | "Invalid archive"); |
| 345 | } |
| 346 | else if (*type == "xyz.openbmc_project.Software.Image.Error." |
| 347 | "ManifestFileFailure") |
| 348 | { |
| 349 | redfish::messages::invalidUpload(asyncResp->res, url, |
| 350 | "Invalid manifest"); |
| 351 | } |
| 352 | else if (*type == |
| 353 | "xyz.openbmc_project.Software.Image.Error.ImageFailure") |
| 354 | { |
| 355 | redfish::messages::invalidUpload(asyncResp->res, url, |
| 356 | "Invalid image format"); |
| 357 | } |
Gunnar Mills | 88b3dd1 | 2020-11-20 14:26:04 -0600 | [diff] [blame] | 358 | else if (*type == "xyz.openbmc_project.Software.Version.Error." |
| 359 | "AlreadyExists") |
| 360 | { |
| 361 | |
| 362 | redfish::messages::invalidUpload( |
| 363 | asyncResp->res, url, "Image version already exists"); |
| 364 | |
| 365 | redfish::messages::resourceAlreadyExists( |
| 366 | asyncResp->res, "UpdateService.v1_4_0.UpdateService", |
| 367 | "Version", "uploaded version"); |
| 368 | } |
James Feist | 4cde5d9 | 2020-06-11 10:39:55 -0700 | [diff] [blame] | 369 | else if (*type == |
| 370 | "xyz.openbmc_project.Software.Image.Error.BusyFailure") |
| 371 | { |
| 372 | redfish::messages::resourceExhaustion(asyncResp->res, url); |
| 373 | } |
| 374 | else |
| 375 | { |
| 376 | redfish::messages::internalError(asyncResp->res); |
| 377 | } |
| 378 | fwAvailableTimer = nullptr; |
| 379 | }); |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 380 | } |
Jennifer Lee | 729dae7 | 2018-04-24 15:59:34 -0700 | [diff] [blame] | 381 | |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 382 | /** |
| 383 | * UpdateServiceActionsSimpleUpdate class supports handle POST method for |
| 384 | * SimpleUpdate action. |
| 385 | */ |
| 386 | class UpdateServiceActionsSimpleUpdate : public Node |
| 387 | { |
| 388 | public: |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 389 | UpdateServiceActionsSimpleUpdate(App& app) : |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 390 | Node(app, |
| 391 | "/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate/") |
| 392 | { |
| 393 | entityPrivileges = { |
| 394 | {boost::beast::http::verb::get, {{"Login"}}}, |
| 395 | {boost::beast::http::verb::head, {{"Login"}}}, |
| 396 | {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, |
| 397 | {boost::beast::http::verb::put, {{"ConfigureComponents"}}}, |
| 398 | {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}}, |
| 399 | {boost::beast::http::verb::post, {{"ConfigureComponents"}}}}; |
| 400 | } |
| 401 | |
| 402 | private: |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 403 | void doPost(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 404 | const crow::Request& req, |
Ed Tanous | cb13a39 | 2020-07-25 19:02:03 +0000 | [diff] [blame] | 405 | const std::vector<std::string>&) override |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 406 | { |
| 407 | std::optional<std::string> transferProtocol; |
| 408 | std::string imageURI; |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 409 | |
| 410 | BMCWEB_LOG_DEBUG << "Enter UpdateService.SimpleUpdate doPost"; |
| 411 | |
| 412 | // User can pass in both TransferProtocol and ImageURI parameters or |
Gunnar Mills | 4e0453b | 2020-07-08 14:00:30 -0500 | [diff] [blame] | 413 | // they can pass in just the ImageURI with the transfer protocol |
| 414 | // embedded within it. |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 415 | // 1) TransferProtocol:TFTP ImageURI:1.1.1.1/myfile.bin |
| 416 | // 2) ImageURI:tftp://1.1.1.1/myfile.bin |
| 417 | |
| 418 | if (!json_util::readJson(req, asyncResp->res, "TransferProtocol", |
| 419 | transferProtocol, "ImageURI", imageURI)) |
| 420 | { |
| 421 | BMCWEB_LOG_DEBUG |
| 422 | << "Missing TransferProtocol or ImageURI parameter"; |
| 423 | return; |
| 424 | } |
| 425 | if (!transferProtocol) |
| 426 | { |
| 427 | // Must be option 2 |
| 428 | // Verify ImageURI has transfer protocol in it |
Ed Tanous | f23b729 | 2020-10-15 09:41:17 -0700 | [diff] [blame] | 429 | size_t separator = imageURI.find(':'); |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 430 | if ((separator == std::string::npos) || |
| 431 | ((separator + 1) > imageURI.size())) |
| 432 | { |
| 433 | messages::actionParameterValueTypeError( |
| 434 | asyncResp->res, imageURI, "ImageURI", |
| 435 | "UpdateService.SimpleUpdate"); |
| 436 | BMCWEB_LOG_ERROR << "ImageURI missing transfer protocol: " |
| 437 | << imageURI; |
| 438 | return; |
| 439 | } |
| 440 | transferProtocol = imageURI.substr(0, separator); |
| 441 | // Ensure protocol is upper case for a common comparison path below |
| 442 | boost::to_upper(*transferProtocol); |
| 443 | BMCWEB_LOG_DEBUG << "Encoded transfer protocol " |
| 444 | << *transferProtocol; |
| 445 | |
| 446 | // Adjust imageURI to not have the protocol on it for parsing |
| 447 | // below |
| 448 | // ex. tftp://1.1.1.1/myfile.bin -> 1.1.1.1/myfile.bin |
| 449 | imageURI = imageURI.substr(separator + 3); |
| 450 | BMCWEB_LOG_DEBUG << "Adjusted imageUri " << imageURI; |
| 451 | } |
| 452 | |
| 453 | // OpenBMC currently only supports TFTP |
| 454 | if (*transferProtocol != "TFTP") |
| 455 | { |
| 456 | messages::actionParameterNotSupported(asyncResp->res, |
| 457 | "TransferProtocol", |
| 458 | "UpdateService.SimpleUpdate"); |
| 459 | BMCWEB_LOG_ERROR << "Request incorrect protocol parameter: " |
| 460 | << *transferProtocol; |
| 461 | return; |
| 462 | } |
| 463 | |
| 464 | // Format should be <IP or Hostname>/<file> for imageURI |
Ed Tanous | f23b729 | 2020-10-15 09:41:17 -0700 | [diff] [blame] | 465 | size_t separator = imageURI.find('/'); |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 466 | if ((separator == std::string::npos) || |
| 467 | ((separator + 1) > imageURI.size())) |
| 468 | { |
| 469 | messages::actionParameterValueTypeError( |
| 470 | asyncResp->res, imageURI, "ImageURI", |
| 471 | "UpdateService.SimpleUpdate"); |
| 472 | BMCWEB_LOG_ERROR << "Invalid ImageURI: " << imageURI; |
| 473 | return; |
| 474 | } |
| 475 | |
| 476 | std::string tftpServer = imageURI.substr(0, separator); |
| 477 | std::string fwFile = imageURI.substr(separator + 1); |
| 478 | BMCWEB_LOG_DEBUG << "Server: " << tftpServer + " File: " << fwFile; |
| 479 | |
| 480 | // Setup callback for when new software detected |
Gunnar Mills | 2618d5e | 2020-08-18 13:04:27 -0500 | [diff] [blame] | 481 | // Give TFTP 10 minutes to complete |
James Feist | 4cde5d9 | 2020-06-11 10:39:55 -0700 | [diff] [blame] | 482 | monitorForSoftwareAvailable( |
Albert Zhang | d7a596b | 2021-01-20 16:39:12 +0800 | [diff] [blame] | 483 | asyncResp, req, |
James Feist | 4cde5d9 | 2020-06-11 10:39:55 -0700 | [diff] [blame] | 484 | "/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate", |
Gunnar Mills | 2618d5e | 2020-08-18 13:04:27 -0500 | [diff] [blame] | 485 | 600); |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 486 | |
Gunnar Mills | 2618d5e | 2020-08-18 13:04:27 -0500 | [diff] [blame] | 487 | // TFTP can take up to 10 minutes depending on image size and |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 488 | // connection speed. Return to caller as soon as the TFTP operation |
| 489 | // has been started. The callback above will ensure the activate |
| 490 | // is started once the download has completed |
| 491 | redfish::messages::success(asyncResp->res); |
| 492 | |
| 493 | // Call TFTP service |
| 494 | crow::connections::systemBus->async_method_call( |
| 495 | [](const boost::system::error_code ec) { |
| 496 | if (ec) |
| 497 | { |
| 498 | // messages::internalError(asyncResp->res); |
| 499 | cleanUp(); |
| 500 | BMCWEB_LOG_DEBUG << "error_code = " << ec; |
| 501 | BMCWEB_LOG_DEBUG << "error msg = " << ec.message(); |
| 502 | } |
| 503 | else |
| 504 | { |
| 505 | BMCWEB_LOG_DEBUG << "Call to DownloaViaTFTP Success"; |
| 506 | } |
| 507 | }, |
| 508 | "xyz.openbmc_project.Software.Download", |
| 509 | "/xyz/openbmc_project/software", "xyz.openbmc_project.Common.TFTP", |
| 510 | "DownloadViaTFTP", fwFile, tftpServer); |
| 511 | |
| 512 | BMCWEB_LOG_DEBUG << "Exit UpdateService.SimpleUpdate doPost"; |
| 513 | } |
| 514 | }; |
| 515 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 516 | class UpdateService : public Node |
| 517 | { |
| 518 | public: |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 519 | UpdateService(App& app) : Node(app, "/redfish/v1/UpdateService/") |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 520 | { |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 521 | entityPrivileges = { |
| 522 | {boost::beast::http::verb::get, {{"Login"}}}, |
| 523 | {boost::beast::http::verb::head, {{"Login"}}}, |
| 524 | {boost::beast::http::verb::patch, {{"ConfigureComponents"}}}, |
| 525 | {boost::beast::http::verb::put, {{"ConfigureComponents"}}}, |
| 526 | {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}}, |
| 527 | {boost::beast::http::verb::post, {{"ConfigureComponents"}}}}; |
Jennifer Lee | acb7cfb | 2018-06-07 16:08:15 -0700 | [diff] [blame] | 528 | } |
Jennifer Lee | acb7cfb | 2018-06-07 16:08:15 -0700 | [diff] [blame] | 529 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 530 | private: |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 531 | void doGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 532 | const crow::Request&, const std::vector<std::string>&) override |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 533 | { |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 534 | asyncResp->res.jsonValue["@odata.type"] = |
| 535 | "#UpdateService.v1_4_0.UpdateService"; |
| 536 | asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/UpdateService"; |
| 537 | asyncResp->res.jsonValue["Id"] = "UpdateService"; |
| 538 | asyncResp->res.jsonValue["Description"] = "Service for Software Update"; |
| 539 | asyncResp->res.jsonValue["Name"] = "Update Service"; |
| 540 | asyncResp->res.jsonValue["HttpPushUri"] = "/redfish/v1/UpdateService"; |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 541 | // UpdateService cannot be disabled |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 542 | asyncResp->res.jsonValue["ServiceEnabled"] = true; |
| 543 | asyncResp->res.jsonValue["FirmwareInventory"] = { |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 544 | {"@odata.id", "/redfish/v1/UpdateService/FirmwareInventory"}}; |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 545 | #ifdef BMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE |
| 546 | // Update Actions object. |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 547 | nlohmann::json& updateSvcSimpleUpdate = |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 548 | asyncResp->res.jsonValue["Actions"]["#UpdateService.SimpleUpdate"]; |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 549 | updateSvcSimpleUpdate["target"] = |
| 550 | "/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate"; |
| 551 | updateSvcSimpleUpdate["TransferProtocol@Redfish.AllowableValues"] = { |
| 552 | "TFTP"}; |
| 553 | #endif |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 554 | // Get the current ApplyTime value |
| 555 | crow::connections::systemBus->async_method_call( |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 556 | [asyncResp](const boost::system::error_code ec, |
| 557 | const std::variant<std::string>& applyTime) { |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 558 | if (ec) |
| 559 | { |
| 560 | BMCWEB_LOG_DEBUG << "DBUS response error " << ec; |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 561 | messages::internalError(asyncResp->res); |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 562 | return; |
| 563 | } |
| 564 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 565 | const std::string* s = std::get_if<std::string>(&applyTime); |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 566 | if (s == nullptr) |
| 567 | { |
| 568 | return; |
| 569 | } |
| 570 | // Store the ApplyTime Value |
| 571 | if (*s == "xyz.openbmc_project.Software.ApplyTime." |
| 572 | "RequestedApplyTimes.Immediate") |
| 573 | { |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 574 | asyncResp->res |
| 575 | .jsonValue["HttpPushUriOptions"]["HttpPushUriApplyTime"] |
| 576 | ["ApplyTime"] = "Immediate"; |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 577 | } |
| 578 | else if (*s == "xyz.openbmc_project.Software.ApplyTime." |
| 579 | "RequestedApplyTimes.OnReset") |
| 580 | { |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 581 | asyncResp->res |
| 582 | .jsonValue["HttpPushUriOptions"]["HttpPushUriApplyTime"] |
| 583 | ["ApplyTime"] = "OnReset"; |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 584 | } |
| 585 | }, |
| 586 | "xyz.openbmc_project.Settings", |
| 587 | "/xyz/openbmc_project/software/apply_time", |
| 588 | "org.freedesktop.DBus.Properties", "Get", |
| 589 | "xyz.openbmc_project.Software.ApplyTime", "RequestedApplyTime"); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 590 | } |
Andrew Geissler | 0e7de46 | 2019-03-04 19:11:54 -0600 | [diff] [blame] | 591 | |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 592 | void doPatch(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 593 | const crow::Request& req, |
Ed Tanous | cb13a39 | 2020-07-25 19:02:03 +0000 | [diff] [blame] | 594 | const std::vector<std::string>&) override |
Jayashankar Padath | fa1a5a3 | 2019-05-28 23:54:37 +0530 | [diff] [blame] | 595 | { |
| 596 | BMCWEB_LOG_DEBUG << "doPatch..."; |
| 597 | |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 598 | std::optional<nlohmann::json> pushUriOptions; |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 599 | if (!json_util::readJson(req, asyncResp->res, "HttpPushUriOptions", |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 600 | pushUriOptions)) |
Jayashankar Padath | fa1a5a3 | 2019-05-28 23:54:37 +0530 | [diff] [blame] | 601 | { |
| 602 | return; |
| 603 | } |
| 604 | |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 605 | if (pushUriOptions) |
Jayashankar Padath | fa1a5a3 | 2019-05-28 23:54:37 +0530 | [diff] [blame] | 606 | { |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 607 | std::optional<nlohmann::json> pushUriApplyTime; |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 608 | if (!json_util::readJson(*pushUriOptions, asyncResp->res, |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 609 | "HttpPushUriApplyTime", pushUriApplyTime)) |
Jayashankar Padath | fa1a5a3 | 2019-05-28 23:54:37 +0530 | [diff] [blame] | 610 | { |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 611 | return; |
Jayashankar Padath | fa1a5a3 | 2019-05-28 23:54:37 +0530 | [diff] [blame] | 612 | } |
| 613 | |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 614 | if (pushUriApplyTime) |
| 615 | { |
| 616 | std::optional<std::string> applyTime; |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 617 | if (!json_util::readJson(*pushUriApplyTime, asyncResp->res, |
| 618 | "ApplyTime", applyTime)) |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 619 | { |
| 620 | return; |
| 621 | } |
| 622 | |
| 623 | if (applyTime) |
| 624 | { |
| 625 | std::string applyTimeNewVal; |
| 626 | if (applyTime == "Immediate") |
Jayashankar Padath | fa1a5a3 | 2019-05-28 23:54:37 +0530 | [diff] [blame] | 627 | { |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 628 | applyTimeNewVal = |
| 629 | "xyz.openbmc_project.Software.ApplyTime." |
| 630 | "RequestedApplyTimes.Immediate"; |
| 631 | } |
| 632 | else if (applyTime == "OnReset") |
| 633 | { |
| 634 | applyTimeNewVal = |
| 635 | "xyz.openbmc_project.Software.ApplyTime." |
| 636 | "RequestedApplyTimes.OnReset"; |
| 637 | } |
| 638 | else |
| 639 | { |
| 640 | BMCWEB_LOG_INFO |
| 641 | << "ApplyTime value is not in the list of " |
| 642 | "acceptable values"; |
| 643 | messages::propertyValueNotInList( |
| 644 | asyncResp->res, *applyTime, "ApplyTime"); |
Jayashankar Padath | fa1a5a3 | 2019-05-28 23:54:37 +0530 | [diff] [blame] | 645 | return; |
| 646 | } |
Jayashankar Padath | 274dfe6 | 2019-08-23 12:30:57 +0530 | [diff] [blame] | 647 | |
| 648 | // Set the requested image apply time value |
| 649 | crow::connections::systemBus->async_method_call( |
| 650 | [asyncResp](const boost::system::error_code ec) { |
| 651 | if (ec) |
| 652 | { |
| 653 | BMCWEB_LOG_ERROR << "D-Bus responses error: " |
| 654 | << ec; |
| 655 | messages::internalError(asyncResp->res); |
| 656 | return; |
| 657 | } |
| 658 | messages::success(asyncResp->res); |
| 659 | }, |
| 660 | "xyz.openbmc_project.Settings", |
| 661 | "/xyz/openbmc_project/software/apply_time", |
| 662 | "org.freedesktop.DBus.Properties", "Set", |
| 663 | "xyz.openbmc_project.Software.ApplyTime", |
| 664 | "RequestedApplyTime", |
| 665 | std::variant<std::string>{applyTimeNewVal}); |
| 666 | } |
| 667 | } |
Jayashankar Padath | fa1a5a3 | 2019-05-28 23:54:37 +0530 | [diff] [blame] | 668 | } |
| 669 | } |
| 670 | |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 671 | void doPost(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 672 | const crow::Request& req, |
Ed Tanous | cb13a39 | 2020-07-25 19:02:03 +0000 | [diff] [blame] | 673 | const std::vector<std::string>&) override |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 674 | { |
| 675 | BMCWEB_LOG_DEBUG << "doPost..."; |
Jennifer Lee | acb7cfb | 2018-06-07 16:08:15 -0700 | [diff] [blame] | 676 | |
Andrew Geissler | 86adcd6 | 2019-04-18 10:58:05 -0500 | [diff] [blame] | 677 | // Setup callback for when new software detected |
James Feist | 4cde5d9 | 2020-06-11 10:39:55 -0700 | [diff] [blame] | 678 | monitorForSoftwareAvailable(asyncResp, req, |
| 679 | "/redfish/v1/UpdateService"); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 680 | |
| 681 | std::string filepath( |
| 682 | "/tmp/images/" + |
| 683 | boost::uuids::to_string(boost::uuids::random_generator()())); |
| 684 | BMCWEB_LOG_DEBUG << "Writing file to " << filepath; |
| 685 | std::ofstream out(filepath, std::ofstream::out | std::ofstream::binary | |
| 686 | std::ofstream::trunc); |
| 687 | out << req.body; |
| 688 | out.close(); |
| 689 | BMCWEB_LOG_DEBUG << "file upload complete!!"; |
| 690 | } |
Jennifer Lee | 729dae7 | 2018-04-24 15:59:34 -0700 | [diff] [blame] | 691 | }; |
Ed Tanous | c711bf8 | 2018-07-30 16:31:33 -0700 | [diff] [blame] | 692 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 693 | class SoftwareInventoryCollection : public Node |
| 694 | { |
| 695 | public: |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 696 | SoftwareInventoryCollection(App& app) : |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 697 | Node(app, "/redfish/v1/UpdateService/FirmwareInventory/") |
| 698 | { |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 699 | entityPrivileges = { |
| 700 | {boost::beast::http::verb::get, {{"Login"}}}, |
| 701 | {boost::beast::http::verb::head, {{"Login"}}}, |
| 702 | {boost::beast::http::verb::patch, {{"ConfigureComponents"}}}, |
| 703 | {boost::beast::http::verb::put, {{"ConfigureComponents"}}}, |
| 704 | {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}}, |
| 705 | {boost::beast::http::verb::post, {{"ConfigureComponents"}}}}; |
Jennifer Lee | 729dae7 | 2018-04-24 15:59:34 -0700 | [diff] [blame] | 706 | } |
Jennifer Lee | 729dae7 | 2018-04-24 15:59:34 -0700 | [diff] [blame] | 707 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 708 | private: |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 709 | void doGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 710 | const crow::Request&, const std::vector<std::string>&) override |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 711 | { |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 712 | asyncResp->res.jsonValue["@odata.type"] = |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 713 | "#SoftwareInventoryCollection.SoftwareInventoryCollection"; |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 714 | asyncResp->res.jsonValue["@odata.id"] = |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 715 | "/redfish/v1/UpdateService/FirmwareInventory"; |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 716 | asyncResp->res.jsonValue["Name"] = "Software Inventory Collection"; |
Ed Tanous | c711bf8 | 2018-07-30 16:31:33 -0700 | [diff] [blame] | 717 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 718 | crow::connections::systemBus->async_method_call( |
| 719 | [asyncResp]( |
| 720 | const boost::system::error_code ec, |
| 721 | const std::vector<std::pair< |
| 722 | std::string, std::vector<std::pair< |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 723 | std::string, std::vector<std::string>>>>>& |
| 724 | subtree) { |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 725 | if (ec) |
| 726 | { |
Jason M. Bills | f12894f | 2018-10-09 12:45:45 -0700 | [diff] [blame] | 727 | messages::internalError(asyncResp->res); |
Ed Tanous | c711bf8 | 2018-07-30 16:31:33 -0700 | [diff] [blame] | 728 | return; |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 729 | } |
| 730 | asyncResp->res.jsonValue["Members"] = nlohmann::json::array(); |
| 731 | asyncResp->res.jsonValue["Members@odata.count"] = 0; |
Jennifer Lee | 6c4eb9d | 2018-05-22 10:58:31 -0700 | [diff] [blame] | 732 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 733 | for (auto& obj : subtree) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 734 | { |
Ed Tanous | 2dfd18e | 2020-12-18 00:41:31 +0000 | [diff] [blame] | 735 | sdbusplus::message::object_path path(obj.first); |
| 736 | std::string swId = path.filename(); |
| 737 | if (swId.empty()) |
Jennifer Lee | f4b65ab | 2018-09-18 12:00:13 -0700 | [diff] [blame] | 738 | { |
Jason M. Bills | f12894f | 2018-10-09 12:45:45 -0700 | [diff] [blame] | 739 | messages::internalError(asyncResp->res); |
Jennifer Lee | f4b65ab | 2018-09-18 12:00:13 -0700 | [diff] [blame] | 740 | BMCWEB_LOG_DEBUG << "Can't parse firmware ID!!"; |
| 741 | return; |
| 742 | } |
Jennifer Lee | f4b65ab | 2018-09-18 12:00:13 -0700 | [diff] [blame] | 743 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 744 | nlohmann::json& members = |
Andrew Geissler | e0dd805 | 2019-06-18 16:05:10 -0500 | [diff] [blame] | 745 | asyncResp->res.jsonValue["Members"]; |
| 746 | members.push_back( |
| 747 | {{"@odata.id", "/redfish/v1/UpdateService/" |
| 748 | "FirmwareInventory/" + |
| 749 | swId}}); |
| 750 | asyncResp->res.jsonValue["Members@odata.count"] = |
| 751 | members.size(); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 752 | } |
| 753 | }, |
Andrew Geissler | 2830a9c | 2020-01-06 10:18:11 -0600 | [diff] [blame] | 754 | // Note that only firmware levels associated with a device are |
| 755 | // stored under /xyz/openbmc_project/software therefore to ensure |
| 756 | // only real FirmwareInventory items are returned, this full object |
| 757 | // path must be used here as input to mapper |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 758 | "xyz.openbmc_project.ObjectMapper", |
| 759 | "/xyz/openbmc_project/object_mapper", |
Andrew Geissler | 2830a9c | 2020-01-06 10:18:11 -0600 | [diff] [blame] | 760 | "xyz.openbmc_project.ObjectMapper", "GetSubTree", |
| 761 | "/xyz/openbmc_project/software", static_cast<int32_t>(0), |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 762 | std::array<const char*, 1>{"xyz.openbmc_project.Software.Version"}); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 763 | } |
Jennifer Lee | 729dae7 | 2018-04-24 15:59:34 -0700 | [diff] [blame] | 764 | }; |
| 765 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 766 | class SoftwareInventory : public Node |
| 767 | { |
| 768 | public: |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 769 | SoftwareInventory(App& app) : |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 770 | Node(app, "/redfish/v1/UpdateService/FirmwareInventory/<str>/", |
| 771 | std::string()) |
| 772 | { |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 773 | entityPrivileges = { |
| 774 | {boost::beast::http::verb::get, {{"Login"}}}, |
| 775 | {boost::beast::http::verb::head, {{"Login"}}}, |
| 776 | {boost::beast::http::verb::patch, {{"ConfigureComponents"}}}, |
| 777 | {boost::beast::http::verb::put, {{"ConfigureComponents"}}}, |
| 778 | {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}}, |
| 779 | {boost::beast::http::verb::post, {{"ConfigureComponents"}}}}; |
| 780 | } |
| 781 | |
| 782 | private: |
Andrew Geissler | 87d8472 | 2019-02-28 14:28:39 -0600 | [diff] [blame] | 783 | /* Fill related item links (i.e. bmc, bios) in for inventory */ |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 784 | static void getRelatedItems(const std::shared_ptr<bmcweb::AsyncResp>& aResp, |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 785 | const std::string& purpose) |
Andrew Geissler | 87d8472 | 2019-02-28 14:28:39 -0600 | [diff] [blame] | 786 | { |
| 787 | if (purpose == fw_util::bmcPurpose) |
| 788 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 789 | nlohmann::json& members = aResp->res.jsonValue["RelatedItem"]; |
Andrew Geissler | 87d8472 | 2019-02-28 14:28:39 -0600 | [diff] [blame] | 790 | members.push_back({{"@odata.id", "/redfish/v1/Managers/bmc"}}); |
| 791 | aResp->res.jsonValue["Members@odata.count"] = members.size(); |
| 792 | } |
| 793 | else if (purpose == fw_util::biosPurpose) |
| 794 | { |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 795 | nlohmann::json& members = aResp->res.jsonValue["RelatedItem"]; |
Gunnar Mills | f723d73 | 2020-02-26 11:20:49 -0600 | [diff] [blame] | 796 | members.push_back( |
| 797 | {{"@odata.id", "/redfish/v1/Systems/system/Bios"}}); |
| 798 | aResp->res.jsonValue["Members@odata.count"] = members.size(); |
Andrew Geissler | 87d8472 | 2019-02-28 14:28:39 -0600 | [diff] [blame] | 799 | } |
| 800 | else |
| 801 | { |
| 802 | BMCWEB_LOG_ERROR << "Unknown software purpose " << purpose; |
| 803 | } |
| 804 | } |
| 805 | |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 806 | void doGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 807 | const crow::Request&, |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 808 | const std::vector<std::string>& params) override |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 809 | { |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 810 | if (params.size() != 1) |
| 811 | { |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 812 | messages::internalError(asyncResp->res); |
| 813 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 814 | return; |
| 815 | } |
| 816 | |
Ed Tanous | 3ae837c | 2018-08-07 14:41:19 -0700 | [diff] [blame] | 817 | std::shared_ptr<std::string> swId = |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 818 | std::make_shared<std::string>(params[0]); |
| 819 | |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame^] | 820 | asyncResp->res.jsonValue["@odata.id"] = |
Ed Tanous | 3ae837c | 2018-08-07 14:41:19 -0700 | [diff] [blame] | 821 | "/redfish/v1/UpdateService/FirmwareInventory/" + *swId; |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 822 | |
| 823 | crow::connections::systemBus->async_method_call( |
Ed Tanous | 3ae837c | 2018-08-07 14:41:19 -0700 | [diff] [blame] | 824 | [asyncResp, swId]( |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 825 | const boost::system::error_code ec, |
| 826 | const std::vector<std::pair< |
| 827 | std::string, std::vector<std::pair< |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 828 | std::string, std::vector<std::string>>>>>& |
| 829 | subtree) { |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 830 | BMCWEB_LOG_DEBUG << "doGet callback..."; |
| 831 | if (ec) |
| 832 | { |
Jason M. Bills | f12894f | 2018-10-09 12:45:45 -0700 | [diff] [blame] | 833 | messages::internalError(asyncResp->res); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 834 | return; |
| 835 | } |
| 836 | |
Andrew Geissler | 6913228 | 2019-07-01 11:00:35 -0500 | [diff] [blame] | 837 | // Ensure we find our input swId, otherwise return an error |
| 838 | bool found = false; |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 839 | for (const std::pair< |
| 840 | std::string, |
| 841 | std::vector< |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 842 | std::pair<std::string, std::vector<std::string>>>>& |
| 843 | obj : subtree) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 844 | { |
Ed Tanous | 3ae837c | 2018-08-07 14:41:19 -0700 | [diff] [blame] | 845 | if (boost::ends_with(obj.first, *swId) != true) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 846 | { |
| 847 | continue; |
| 848 | } |
| 849 | |
Jennifer Lee | f4b65ab | 2018-09-18 12:00:13 -0700 | [diff] [blame] | 850 | if (obj.second.size() < 1) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 851 | { |
| 852 | continue; |
| 853 | } |
| 854 | |
Andrew Geissler | 6913228 | 2019-07-01 11:00:35 -0500 | [diff] [blame] | 855 | found = true; |
Andrew Geissler | e0dd805 | 2019-06-18 16:05:10 -0500 | [diff] [blame] | 856 | fw_util::getFwStatus(asyncResp, swId, obj.second[0].first); |
| 857 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 858 | crow::connections::systemBus->async_method_call( |
| 859 | [asyncResp, |
Ed Tanous | 81ce609 | 2020-12-17 16:54:55 +0000 | [diff] [blame] | 860 | swId](const boost::system::error_code errorCode, |
Ed Tanous | 3ae837c | 2018-08-07 14:41:19 -0700 | [diff] [blame] | 861 | const boost::container::flat_map< |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 862 | std::string, VariantType>& propertiesList) { |
Ed Tanous | 81ce609 | 2020-12-17 16:54:55 +0000 | [diff] [blame] | 863 | if (errorCode) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 864 | { |
Jason M. Bills | f12894f | 2018-10-09 12:45:45 -0700 | [diff] [blame] | 865 | messages::internalError(asyncResp->res); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 866 | return; |
| 867 | } |
| 868 | boost::container::flat_map< |
| 869 | std::string, VariantType>::const_iterator it = |
| 870 | propertiesList.find("Purpose"); |
| 871 | if (it == propertiesList.end()) |
| 872 | { |
| 873 | BMCWEB_LOG_DEBUG |
| 874 | << "Can't find property \"Purpose\"!"; |
Jason M. Bills | f12894f | 2018-10-09 12:45:45 -0700 | [diff] [blame] | 875 | messages::propertyMissing(asyncResp->res, |
| 876 | "Purpose"); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 877 | return; |
| 878 | } |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 879 | const std::string* swInvPurpose = |
Ed Tanous | abf2add | 2019-01-22 16:40:12 -0800 | [diff] [blame] | 880 | std::get_if<std::string>(&it->second); |
Ed Tanous | 3ae837c | 2018-08-07 14:41:19 -0700 | [diff] [blame] | 881 | if (swInvPurpose == nullptr) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 882 | { |
| 883 | BMCWEB_LOG_DEBUG |
| 884 | << "wrong types for property\"Purpose\"!"; |
Jason M. Bills | f12894f | 2018-10-09 12:45:45 -0700 | [diff] [blame] | 885 | messages::propertyValueTypeError(asyncResp->res, |
| 886 | "", "Purpose"); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 887 | return; |
| 888 | } |
| 889 | |
Ed Tanous | 3ae837c | 2018-08-07 14:41:19 -0700 | [diff] [blame] | 890 | BMCWEB_LOG_DEBUG << "swInvPurpose = " |
| 891 | << *swInvPurpose; |
Jennifer Lee | f4b65ab | 2018-09-18 12:00:13 -0700 | [diff] [blame] | 892 | it = propertiesList.find("Version"); |
| 893 | if (it == propertiesList.end()) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 894 | { |
Jennifer Lee | f4b65ab | 2018-09-18 12:00:13 -0700 | [diff] [blame] | 895 | BMCWEB_LOG_DEBUG |
| 896 | << "Can't find property \"Version\"!"; |
Jason M. Bills | f12894f | 2018-10-09 12:45:45 -0700 | [diff] [blame] | 897 | messages::propertyMissing(asyncResp->res, |
| 898 | "Version"); |
Jennifer Lee | f4b65ab | 2018-09-18 12:00:13 -0700 | [diff] [blame] | 899 | return; |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 900 | } |
Jennifer Lee | f4b65ab | 2018-09-18 12:00:13 -0700 | [diff] [blame] | 901 | |
| 902 | BMCWEB_LOG_DEBUG << "Version found!"; |
| 903 | |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 904 | const std::string* version = |
Ed Tanous | abf2add | 2019-01-22 16:40:12 -0800 | [diff] [blame] | 905 | std::get_if<std::string>(&it->second); |
Jennifer Lee | f4b65ab | 2018-09-18 12:00:13 -0700 | [diff] [blame] | 906 | |
| 907 | if (version == nullptr) |
| 908 | { |
| 909 | BMCWEB_LOG_DEBUG |
| 910 | << "Can't find property \"Version\"!"; |
Jason M. Bills | f12894f | 2018-10-09 12:45:45 -0700 | [diff] [blame] | 911 | |
| 912 | messages::propertyValueTypeError(asyncResp->res, |
| 913 | "", "Version"); |
Jennifer Lee | f4b65ab | 2018-09-18 12:00:13 -0700 | [diff] [blame] | 914 | return; |
| 915 | } |
| 916 | asyncResp->res.jsonValue["Version"] = *version; |
| 917 | asyncResp->res.jsonValue["Id"] = *swId; |
Andrew Geissler | 54daabe | 2019-02-13 13:54:15 -0600 | [diff] [blame] | 918 | |
| 919 | // swInvPurpose is of format: |
| 920 | // xyz.openbmc_project.Software.Version.VersionPurpose.ABC |
James Feist | e2e9677 | 2019-10-03 10:51:43 -0700 | [diff] [blame] | 921 | // Translate this to "ABC image" |
Ed Tanous | f23b729 | 2020-10-15 09:41:17 -0700 | [diff] [blame] | 922 | size_t endDesc = swInvPurpose->rfind('.'); |
Andrew Geissler | 54daabe | 2019-02-13 13:54:15 -0600 | [diff] [blame] | 923 | if (endDesc == std::string::npos) |
| 924 | { |
| 925 | messages::internalError(asyncResp->res); |
| 926 | return; |
| 927 | } |
| 928 | endDesc++; |
| 929 | if (endDesc >= swInvPurpose->size()) |
| 930 | { |
| 931 | messages::internalError(asyncResp->res); |
| 932 | return; |
| 933 | } |
| 934 | |
| 935 | std::string formatDesc = |
| 936 | swInvPurpose->substr(endDesc); |
| 937 | asyncResp->res.jsonValue["Description"] = |
James Feist | e2e9677 | 2019-10-03 10:51:43 -0700 | [diff] [blame] | 938 | formatDesc + " image"; |
Andrew Geissler | 87d8472 | 2019-02-28 14:28:39 -0600 | [diff] [blame] | 939 | getRelatedItems(asyncResp, *swInvPurpose); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 940 | }, |
| 941 | obj.second[0].first, obj.first, |
| 942 | "org.freedesktop.DBus.Properties", "GetAll", |
| 943 | "xyz.openbmc_project.Software.Version"); |
| 944 | } |
Andrew Geissler | 6913228 | 2019-07-01 11:00:35 -0500 | [diff] [blame] | 945 | if (!found) |
| 946 | { |
| 947 | BMCWEB_LOG_ERROR << "Input swID " + *swId + " not found!"; |
| 948 | messages::resourceMissingAtURI( |
| 949 | asyncResp->res, |
| 950 | "/redfish/v1/UpdateService/FirmwareInventory/" + *swId); |
| 951 | return; |
| 952 | } |
Ayushi Smriti | 4e68c45 | 2019-09-04 14:37:55 +0530 | [diff] [blame] | 953 | asyncResp->res.jsonValue["@odata.type"] = |
| 954 | "#SoftwareInventory.v1_1_0.SoftwareInventory"; |
Ayushi Smriti | 4e68c45 | 2019-09-04 14:37:55 +0530 | [diff] [blame] | 955 | asyncResp->res.jsonValue["Name"] = "Software Inventory"; |
Ayushi Smriti | 4e68c45 | 2019-09-04 14:37:55 +0530 | [diff] [blame] | 956 | asyncResp->res.jsonValue["Status"]["HealthRollup"] = "OK"; |
AppaRao Puli | 3f8a743 | 2020-01-29 02:36:32 +0530 | [diff] [blame] | 957 | |
| 958 | asyncResp->res.jsonValue["Updateable"] = false; |
| 959 | fw_util::getFwUpdateableStatus(asyncResp, swId); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 960 | }, |
| 961 | "xyz.openbmc_project.ObjectMapper", |
| 962 | "/xyz/openbmc_project/object_mapper", |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 963 | "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", |
| 964 | static_cast<int32_t>(0), |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 965 | std::array<const char*, 1>{"xyz.openbmc_project.Software.Version"}); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 966 | } |
| 967 | }; |
| 968 | |
| 969 | } // namespace redfish |