Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [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 | |
Ed Tanous | 3ccb3ad | 2023-01-13 17:40:03 -0800 | [diff] [blame] | 18 | #include "account_service.hpp" |
| 19 | #include "app.hpp" |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 20 | #include "async_resp.hpp" |
George Liu | 2b73119 | 2023-01-11 16:27:13 +0800 | [diff] [blame] | 21 | #include "dbus_utility.hpp" |
Ed Tanous | 739b87e | 2023-02-24 13:13:33 -0800 | [diff] [blame] | 22 | #include "generated/enums/virtual_media.hpp" |
Ed Tanous | 3ccb3ad | 2023-01-13 17:40:03 -0800 | [diff] [blame] | 23 | #include "query.hpp" |
| 24 | #include "registries/privilege_registry.hpp" |
| 25 | #include "utils/json_utils.hpp" |
| 26 | |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 27 | #include <boost/process/async_pipe.hpp> |
Anna Platash | 9e319cf | 2020-11-17 10:18:31 +0100 | [diff] [blame] | 28 | #include <boost/url/url_view.hpp> |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 29 | |
George Liu | 2b73119 | 2023-01-11 16:27:13 +0800 | [diff] [blame] | 30 | #include <array> |
| 31 | #include <string_view> |
| 32 | |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 33 | namespace redfish |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 34 | { |
Ed Tanous | 365a73f | 2023-02-24 12:16:49 -0800 | [diff] [blame] | 35 | |
| 36 | enum class VmMode |
| 37 | { |
| 38 | Invalid, |
| 39 | Legacy, |
| 40 | Proxy |
| 41 | }; |
| 42 | |
| 43 | inline VmMode |
| 44 | parseObjectPathAndGetMode(const sdbusplus::message::object_path& itemPath, |
| 45 | const std::string& resName) |
| 46 | { |
| 47 | std::string thisPath = itemPath.filename(); |
| 48 | BMCWEB_LOG_DEBUG << "Filename: " << itemPath.str |
| 49 | << ", ThisPath: " << thisPath; |
| 50 | |
| 51 | if (thisPath.empty()) |
| 52 | { |
| 53 | return VmMode::Invalid; |
| 54 | } |
| 55 | |
| 56 | if (thisPath != resName) |
| 57 | { |
| 58 | return VmMode::Invalid; |
| 59 | } |
| 60 | |
| 61 | auto mode = itemPath.parent_path(); |
| 62 | auto type = mode.parent_path(); |
| 63 | |
| 64 | if (mode.filename().empty() || type.filename().empty()) |
| 65 | { |
| 66 | return VmMode::Invalid; |
| 67 | } |
| 68 | |
| 69 | if (type.filename() != "VirtualMedia") |
| 70 | { |
| 71 | return VmMode::Invalid; |
| 72 | } |
| 73 | std::string modeStr = mode.filename(); |
| 74 | if (modeStr == "Legacy") |
| 75 | { |
| 76 | return VmMode::Legacy; |
| 77 | } |
| 78 | if (modeStr == "Proxy") |
| 79 | { |
| 80 | return VmMode::Proxy; |
| 81 | } |
| 82 | return VmMode::Invalid; |
| 83 | } |
| 84 | |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 85 | using CheckItemHandler = |
| 86 | std::function<void(const std::string& service, const std::string& resName, |
| 87 | const std::shared_ptr<bmcweb::AsyncResp>&, |
George Liu | 70cbdf5 | 2023-03-04 12:07:25 +0800 | [diff] [blame] | 88 | const std::pair<sdbusplus::message::object_path, |
| 89 | dbus::utility::DBusInteracesMap>&)>; |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 90 | |
| 91 | inline void findAndParseObject(const std::string& service, |
| 92 | const std::string& resName, |
| 93 | const std::shared_ptr<bmcweb::AsyncResp>& aResp, |
| 94 | CheckItemHandler&& handler) |
| 95 | { |
| 96 | crow::connections::systemBus->async_method_call( |
| 97 | [service, resName, aResp, |
Lakshmi Yadlapati | 746c5b8 | 2023-03-06 16:07:28 -0600 | [diff] [blame] | 98 | handler](const boost::system::error_code& ec, |
George Liu | 70cbdf5 | 2023-03-04 12:07:25 +0800 | [diff] [blame] | 99 | const dbus::utility::ManagedObjectType& subtree) { |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 100 | if (ec) |
| 101 | { |
| 102 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 103 | |
| 104 | return; |
| 105 | } |
| 106 | |
George Liu | 70cbdf5 | 2023-03-04 12:07:25 +0800 | [diff] [blame] | 107 | for (const auto& item : subtree) |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 108 | { |
| 109 | VmMode mode = parseObjectPathAndGetMode(item.first, resName); |
| 110 | if (mode != VmMode::Invalid) |
| 111 | { |
| 112 | handler(service, resName, aResp, item); |
| 113 | return; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | BMCWEB_LOG_DEBUG << "Parent item not found"; |
| 118 | aResp->res.result(boost::beast::http::status::not_found); |
| 119 | }, |
| 120 | service, "/xyz/openbmc_project/VirtualMedia", |
| 121 | "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); |
| 122 | } |
| 123 | |
Anna Platash | 9e319cf | 2020-11-17 10:18:31 +0100 | [diff] [blame] | 124 | /** |
| 125 | * @brief Function extracts transfer protocol name from URI. |
| 126 | */ |
Ed Tanous | 67df073 | 2021-10-26 11:23:56 -0700 | [diff] [blame] | 127 | inline std::string getTransferProtocolTypeFromUri(const std::string& imageUri) |
| 128 | { |
| 129 | boost::urls::result<boost::urls::url_view> url = |
Ed Tanous | 079360a | 2022-06-29 10:05:19 -0700 | [diff] [blame] | 130 | boost::urls::parse_uri(imageUri); |
Ed Tanous | 67df073 | 2021-10-26 11:23:56 -0700 | [diff] [blame] | 131 | if (!url) |
| 132 | { |
| 133 | return "None"; |
| 134 | } |
Ed Tanous | 079360a | 2022-06-29 10:05:19 -0700 | [diff] [blame] | 135 | std::string_view scheme = url->scheme(); |
Ed Tanous | 67df073 | 2021-10-26 11:23:56 -0700 | [diff] [blame] | 136 | if (scheme == "smb") |
| 137 | { |
| 138 | return "CIFS"; |
| 139 | } |
| 140 | if (scheme == "https") |
| 141 | { |
| 142 | return "HTTPS"; |
| 143 | } |
| 144 | |
| 145 | return "None"; |
| 146 | } |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 147 | |
| 148 | /** |
| 149 | * @brief Read all known properties from VM object interfaces |
| 150 | */ |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 151 | inline void |
Ed Tanous | 8a59281 | 2022-06-04 09:06:59 -0700 | [diff] [blame] | 152 | vmParseInterfaceObject(const dbus::utility::DBusInteracesMap& interfaces, |
zhanghch05 | 8d1b46d | 2021-04-01 11:18:24 +0800 | [diff] [blame] | 153 | const std::shared_ptr<bmcweb::AsyncResp>& aResp) |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 154 | { |
Ed Tanous | 8a59281 | 2022-06-04 09:06:59 -0700 | [diff] [blame] | 155 | for (const auto& [interface, values] : interfaces) |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 156 | { |
Ed Tanous | 711ac7a | 2021-12-20 09:34:41 -0800 | [diff] [blame] | 157 | if (interface == "xyz.openbmc_project.VirtualMedia.MountPoint") |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 158 | { |
Ed Tanous | 711ac7a | 2021-12-20 09:34:41 -0800 | [diff] [blame] | 159 | for (const auto& [property, value] : values) |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 160 | { |
Ed Tanous | 711ac7a | 2021-12-20 09:34:41 -0800 | [diff] [blame] | 161 | if (property == "EndpointId") |
| 162 | { |
| 163 | const std::string* endpointIdValue = |
| 164 | std::get_if<std::string>(&value); |
| 165 | if (endpointIdValue == nullptr) |
| 166 | { |
| 167 | continue; |
| 168 | } |
| 169 | if (!endpointIdValue->empty()) |
| 170 | { |
| 171 | // Proxy mode |
| 172 | aResp->res |
| 173 | .jsonValue["Oem"]["OpenBMC"]["WebSocketEndpoint"] = |
| 174 | *endpointIdValue; |
| 175 | aResp->res.jsonValue["TransferProtocolType"] = "OEM"; |
| 176 | } |
| 177 | } |
| 178 | if (property == "ImageURL") |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 179 | { |
Anna Platash | 9e319cf | 2020-11-17 10:18:31 +0100 | [diff] [blame] | 180 | const std::string* imageUrlValue = |
Ed Tanous | 711ac7a | 2021-12-20 09:34:41 -0800 | [diff] [blame] | 181 | std::get_if<std::string>(&value); |
Ed Tanous | 26f6976 | 2022-01-25 09:49:11 -0800 | [diff] [blame] | 182 | if (imageUrlValue != nullptr && !imageUrlValue->empty()) |
Przemyslaw Czarnowski | da4784d | 2020-11-06 09:58:25 +0100 | [diff] [blame] | 183 | { |
Anna Platash | 9e319cf | 2020-11-17 10:18:31 +0100 | [diff] [blame] | 184 | std::filesystem::path filePath = *imageUrlValue; |
| 185 | if (!filePath.has_filename()) |
| 186 | { |
| 187 | // this will handle https share, which not |
| 188 | // necessarily has to have filename given. |
| 189 | aResp->res.jsonValue["ImageName"] = ""; |
| 190 | } |
| 191 | else |
| 192 | { |
| 193 | aResp->res.jsonValue["ImageName"] = |
| 194 | filePath.filename(); |
| 195 | } |
Przemyslaw Czarnowski | da4784d | 2020-11-06 09:58:25 +0100 | [diff] [blame] | 196 | |
Anna Platash | 9e319cf | 2020-11-17 10:18:31 +0100 | [diff] [blame] | 197 | aResp->res.jsonValue["Image"] = *imageUrlValue; |
Anna Platash | 9e319cf | 2020-11-17 10:18:31 +0100 | [diff] [blame] | 198 | aResp->res.jsonValue["TransferProtocolType"] = |
| 199 | getTransferProtocolTypeFromUri(*imageUrlValue); |
| 200 | |
Ed Tanous | 739b87e | 2023-02-24 13:13:33 -0800 | [diff] [blame] | 201 | aResp->res.jsonValue["ConnectedVia"] = |
| 202 | virtual_media::ConnectedVia::URI; |
Anna Platash | 9e319cf | 2020-11-17 10:18:31 +0100 | [diff] [blame] | 203 | } |
| 204 | } |
Ed Tanous | 711ac7a | 2021-12-20 09:34:41 -0800 | [diff] [blame] | 205 | if (property == "WriteProtected") |
Anna Platash | 9e319cf | 2020-11-17 10:18:31 +0100 | [diff] [blame] | 206 | { |
Ed Tanous | 711ac7a | 2021-12-20 09:34:41 -0800 | [diff] [blame] | 207 | const bool* writeProtectedValue = std::get_if<bool>(&value); |
Ed Tanous | e662eae | 2022-01-25 10:39:19 -0800 | [diff] [blame] | 208 | if (writeProtectedValue != nullptr) |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 209 | { |
Anna Platash | 9e319cf | 2020-11-17 10:18:31 +0100 | [diff] [blame] | 210 | aResp->res.jsonValue["WriteProtected"] = |
| 211 | *writeProtectedValue; |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 212 | } |
| 213 | } |
| 214 | } |
| 215 | } |
Ed Tanous | 711ac7a | 2021-12-20 09:34:41 -0800 | [diff] [blame] | 216 | if (interface == "xyz.openbmc_project.VirtualMedia.Process") |
| 217 | { |
| 218 | for (const auto& [property, value] : values) |
| 219 | { |
| 220 | if (property == "Active") |
| 221 | { |
| 222 | const bool* activeValue = std::get_if<bool>(&value); |
Ed Tanous | e662eae | 2022-01-25 10:39:19 -0800 | [diff] [blame] | 223 | if (activeValue == nullptr) |
Ed Tanous | 711ac7a | 2021-12-20 09:34:41 -0800 | [diff] [blame] | 224 | { |
| 225 | BMCWEB_LOG_DEBUG << "Value Active not found"; |
| 226 | return; |
| 227 | } |
| 228 | aResp->res.jsonValue["Inserted"] = *activeValue; |
| 229 | |
Ed Tanous | e05aec5 | 2022-01-25 10:28:56 -0800 | [diff] [blame] | 230 | if (*activeValue) |
Ed Tanous | 711ac7a | 2021-12-20 09:34:41 -0800 | [diff] [blame] | 231 | { |
Ed Tanous | 739b87e | 2023-02-24 13:13:33 -0800 | [diff] [blame] | 232 | aResp->res.jsonValue["ConnectedVia"] = |
| 233 | virtual_media::ConnectedVia::Applet; |
Ed Tanous | 711ac7a | 2021-12-20 09:34:41 -0800 | [diff] [blame] | 234 | } |
| 235 | } |
| 236 | } |
| 237 | } |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 238 | } |
| 239 | } |
| 240 | |
| 241 | /** |
| 242 | * @brief Fill template for Virtual Media Item. |
| 243 | */ |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 244 | inline nlohmann::json vmItemTemplate(const std::string& name, |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 245 | const std::string& resName) |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 246 | { |
| 247 | nlohmann::json item; |
Ed Tanous | fdb2034 | 2022-06-03 09:56:52 -0700 | [diff] [blame] | 248 | item["@odata.id"] = crow::utility::urlFromPieces( |
| 249 | "redfish", "v1", "Managers", name, "VirtualMedia", resName); |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 250 | |
Przemyslaw Czarnowski | d04ba32 | 2020-01-21 12:41:56 +0100 | [diff] [blame] | 251 | item["@odata.type"] = "#VirtualMedia.v1_3_0.VirtualMedia"; |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 252 | item["Name"] = "Virtual Removable Media"; |
| 253 | item["Id"] = resName; |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 254 | item["WriteProtected"] = true; |
Ed Tanous | 739b87e | 2023-02-24 13:13:33 -0800 | [diff] [blame] | 255 | item["ConnectedVia"] = virtual_media::ConnectedVia::NotConnected; |
Ed Tanous | 613dabe | 2022-07-09 11:17:36 -0700 | [diff] [blame] | 256 | item["MediaTypes"] = nlohmann::json::array_t({"CD", "USBStick"}); |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 257 | item["TransferMethod"] = "Stream"; |
Przemyslaw Czarnowski | d04ba32 | 2020-01-21 12:41:56 +0100 | [diff] [blame] | 258 | item["Oem"]["OpenBMC"]["@odata.type"] = |
| 259 | "#OemVirtualMedia.v1_0_0.VirtualMedia"; |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 260 | |
| 261 | return item; |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * @brief Fills collection data |
| 266 | */ |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 267 | inline void getVmResourceList(std::shared_ptr<bmcweb::AsyncResp> aResp, |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 268 | const std::string& service, |
| 269 | const std::string& name) |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 270 | { |
| 271 | BMCWEB_LOG_DEBUG << "Get available Virtual Media resources."; |
| 272 | crow::connections::systemBus->async_method_call( |
Ed Tanous | 02cad96 | 2022-06-30 16:50:15 -0700 | [diff] [blame] | 273 | [name, aResp{std::move(aResp)}]( |
Ed Tanous | 5e7e2dc | 2023-02-16 10:37:01 -0800 | [diff] [blame] | 274 | const boost::system::error_code& ec, |
Ed Tanous | 02cad96 | 2022-06-30 16:50:15 -0700 | [diff] [blame] | 275 | const dbus::utility::ManagedObjectType& subtree) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 276 | if (ec) |
| 277 | { |
| 278 | BMCWEB_LOG_DEBUG << "DBUS response error"; |
| 279 | return; |
| 280 | } |
| 281 | nlohmann::json& members = aResp->res.jsonValue["Members"]; |
| 282 | members = nlohmann::json::array(); |
| 283 | |
| 284 | for (const auto& object : subtree) |
| 285 | { |
| 286 | nlohmann::json item; |
| 287 | std::string path = object.first.filename(); |
| 288 | if (path.empty()) |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 289 | { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 290 | continue; |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 291 | } |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 292 | |
Ed Tanous | fdb2034 | 2022-06-03 09:56:52 -0700 | [diff] [blame] | 293 | item["@odata.id"] = crow::utility::urlFromPieces( |
| 294 | "redfish", "v1", "Managers", name, "VirtualMedia", path); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 295 | members.emplace_back(std::move(item)); |
| 296 | } |
| 297 | aResp->res.jsonValue["Members@odata.count"] = members.size(); |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 298 | }, |
| 299 | service, "/xyz/openbmc_project/VirtualMedia", |
| 300 | "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); |
| 301 | } |
| 302 | |
George Liu | 70cbdf5 | 2023-03-04 12:07:25 +0800 | [diff] [blame] | 303 | inline void |
| 304 | afterGetVmData(const std::string& name, const std::string& /*service*/, |
| 305 | const std::string& resName, |
| 306 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 307 | const std::pair<sdbusplus::message::object_path, |
| 308 | dbus::utility::DBusInteracesMap>& item) |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 309 | { |
| 310 | VmMode mode = parseObjectPathAndGetMode(item.first, resName); |
| 311 | if (mode == VmMode::Invalid) |
| 312 | { |
| 313 | return; |
| 314 | } |
| 315 | |
| 316 | asyncResp->res.jsonValue = vmItemTemplate(name, resName); |
| 317 | |
| 318 | // Check if dbus path is Legacy type |
| 319 | if (mode == VmMode::Legacy) |
| 320 | { |
| 321 | asyncResp->res |
| 322 | .jsonValue["Actions"]["#VirtualMedia.InsertMedia"]["target"] = |
| 323 | crow::utility::urlFromPieces("redfish", "v1", "Managers", name, |
| 324 | "VirtualMedia", resName, "Actions", |
| 325 | "VirtualMedia.InsertMedia"); |
| 326 | } |
| 327 | |
| 328 | vmParseInterfaceObject(item.second, asyncResp); |
| 329 | |
| 330 | asyncResp->res.jsonValue["Actions"]["#VirtualMedia.EjectMedia"]["target"] = |
| 331 | crow::utility::urlFromPieces("redfish", "v1", "Managers", name, |
| 332 | "VirtualMedia", resName, "Actions", |
| 333 | "VirtualMedia.EjectMedia"); |
| 334 | } |
| 335 | |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 336 | /** |
| 337 | * @brief Fills data for specific resource |
| 338 | */ |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 339 | inline void getVmData(const std::shared_ptr<bmcweb::AsyncResp>& aResp, |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 340 | const std::string& service, const std::string& name, |
| 341 | const std::string& resName) |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 342 | { |
| 343 | BMCWEB_LOG_DEBUG << "Get Virtual Media resource data."; |
| 344 | |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 345 | findAndParseObject(service, resName, aResp, |
George Liu | 70cbdf5 | 2023-03-04 12:07:25 +0800 | [diff] [blame] | 346 | std::bind_front(afterGetVmData, name)); |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 347 | } |
| 348 | |
Przemyslaw Czarnowski | e13c276 | 2019-09-02 17:32:43 +0200 | [diff] [blame] | 349 | /** |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 350 | * @brief Transfer protocols supported for InsertMedia action. |
| 351 | * |
Przemyslaw Czarnowski | e13c276 | 2019-09-02 17:32:43 +0200 | [diff] [blame] | 352 | */ |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 353 | enum class TransferProtocol |
Przemyslaw Czarnowski | e13c276 | 2019-09-02 17:32:43 +0200 | [diff] [blame] | 354 | { |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 355 | https, |
| 356 | smb, |
| 357 | invalid |
| 358 | }; |
| 359 | |
| 360 | /** |
| 361 | * @brief Function extracts transfer protocol type from URI. |
| 362 | * |
| 363 | */ |
Ed Tanous | 67df073 | 2021-10-26 11:23:56 -0700 | [diff] [blame] | 364 | inline std::optional<TransferProtocol> |
Ed Tanous | ace85d6 | 2021-10-26 12:45:59 -0700 | [diff] [blame] | 365 | getTransferProtocolFromUri(const boost::urls::url_view& imageUri) |
Ed Tanous | 67df073 | 2021-10-26 11:23:56 -0700 | [diff] [blame] | 366 | { |
Ed Tanous | 079360a | 2022-06-29 10:05:19 -0700 | [diff] [blame] | 367 | std::string_view scheme = imageUri.scheme(); |
Ed Tanous | 67df073 | 2021-10-26 11:23:56 -0700 | [diff] [blame] | 368 | if (scheme == "smb") |
| 369 | { |
| 370 | return TransferProtocol::smb; |
| 371 | } |
| 372 | if (scheme == "https") |
| 373 | { |
| 374 | return TransferProtocol::https; |
| 375 | } |
| 376 | if (!scheme.empty()) |
| 377 | { |
| 378 | return TransferProtocol::invalid; |
| 379 | } |
| 380 | |
| 381 | return {}; |
| 382 | } |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 383 | |
| 384 | /** |
| 385 | * @brief Function convert transfer protocol from string param. |
| 386 | * |
| 387 | */ |
| 388 | inline std::optional<TransferProtocol> getTransferProtocolFromParam( |
| 389 | const std::optional<std::string>& transferProtocolType) |
| 390 | { |
| 391 | if (transferProtocolType == std::nullopt) |
Agata Olender | c6f4e01 | 2020-03-11 15:19:07 +0100 | [diff] [blame] | 392 | { |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 393 | return {}; |
Agata Olender | c6f4e01 | 2020-03-11 15:19:07 +0100 | [diff] [blame] | 394 | } |
| 395 | |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 396 | if (*transferProtocolType == "CIFS") |
Przemyslaw Czarnowski | e13c276 | 2019-09-02 17:32:43 +0200 | [diff] [blame] | 397 | { |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 398 | return TransferProtocol::smb; |
Przemyslaw Czarnowski | e13c276 | 2019-09-02 17:32:43 +0200 | [diff] [blame] | 399 | } |
| 400 | |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 401 | if (*transferProtocolType == "HTTPS") |
| 402 | { |
| 403 | return TransferProtocol::https; |
| 404 | } |
| 405 | |
| 406 | return TransferProtocol::invalid; |
| 407 | } |
| 408 | |
| 409 | /** |
| 410 | * @brief Function extends URI with transfer protocol type. |
| 411 | * |
| 412 | */ |
| 413 | inline std::string |
| 414 | getUriWithTransferProtocol(const std::string& imageUri, |
| 415 | const TransferProtocol& transferProtocol) |
| 416 | { |
| 417 | if (transferProtocol == TransferProtocol::smb) |
| 418 | { |
| 419 | return "smb://" + imageUri; |
| 420 | } |
| 421 | |
| 422 | if (transferProtocol == TransferProtocol::https) |
| 423 | { |
| 424 | return "https://" + imageUri; |
| 425 | } |
| 426 | |
| 427 | return imageUri; |
| 428 | } |
| 429 | |
Przemyslaw Czarnowski | 1f2a40c | 2022-06-24 13:47:08 +0200 | [diff] [blame] | 430 | struct InsertMediaActionParams |
| 431 | { |
Przemyslaw Czarnowski | 120fa86 | 2022-06-24 15:10:48 +0200 | [diff] [blame] | 432 | std::optional<std::string> imageUrl; |
Przemyslaw Czarnowski | 1f2a40c | 2022-06-24 13:47:08 +0200 | [diff] [blame] | 433 | std::optional<std::string> userName; |
| 434 | std::optional<std::string> password; |
| 435 | std::optional<std::string> transferMethod; |
| 436 | std::optional<std::string> transferProtocolType; |
| 437 | std::optional<bool> writeProtected = true; |
| 438 | std::optional<bool> inserted; |
| 439 | }; |
| 440 | |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 441 | template <typename T> |
| 442 | static void secureCleanup(T& value) |
| 443 | { |
Ed Tanous | 4ecc618 | 2022-01-07 09:36:26 -0800 | [diff] [blame] | 444 | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 445 | auto raw = const_cast<typename T::value_type*>(value.data()); |
| 446 | explicit_bzero(raw, value.size() * sizeof(*raw)); |
| 447 | } |
| 448 | |
| 449 | class Credentials |
| 450 | { |
| 451 | public: |
| 452 | Credentials(std::string&& user, std::string&& password) : |
| 453 | userBuf(std::move(user)), passBuf(std::move(password)) |
| 454 | {} |
| 455 | |
| 456 | ~Credentials() |
| 457 | { |
| 458 | secureCleanup(userBuf); |
| 459 | secureCleanup(passBuf); |
| 460 | } |
| 461 | |
| 462 | const std::string& user() |
| 463 | { |
| 464 | return userBuf; |
| 465 | } |
| 466 | |
| 467 | const std::string& password() |
| 468 | { |
| 469 | return passBuf; |
| 470 | } |
| 471 | |
| 472 | Credentials() = delete; |
| 473 | Credentials(const Credentials&) = delete; |
| 474 | Credentials& operator=(const Credentials&) = delete; |
Ed Tanous | ecd6a3a | 2022-01-07 09:18:40 -0800 | [diff] [blame] | 475 | Credentials(Credentials&&) = delete; |
| 476 | Credentials& operator=(Credentials&&) = delete; |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 477 | |
| 478 | private: |
| 479 | std::string userBuf; |
| 480 | std::string passBuf; |
| 481 | }; |
| 482 | |
| 483 | class CredentialsProvider |
| 484 | { |
| 485 | public: |
Gunnar Mills | 1214b7e | 2020-06-04 10:11:30 -0500 | [diff] [blame] | 486 | template <typename T> |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 487 | struct Deleter |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 488 | { |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 489 | void operator()(T* buff) const |
| 490 | { |
| 491 | if (buff) |
| 492 | { |
| 493 | secureCleanup(*buff); |
| 494 | delete buff; |
| 495 | } |
| 496 | } |
| 497 | }; |
| 498 | |
| 499 | using Buffer = std::vector<char>; |
| 500 | using SecureBuffer = std::unique_ptr<Buffer, Deleter<Buffer>>; |
| 501 | // Using explicit definition instead of std::function to avoid implicit |
| 502 | // conversions eg. stack copy instead of reference |
| 503 | using FormatterFunc = void(const std::string& username, |
| 504 | const std::string& password, Buffer& dest); |
| 505 | |
| 506 | CredentialsProvider(std::string&& user, std::string&& password) : |
| 507 | credentials(std::move(user), std::move(password)) |
| 508 | {} |
| 509 | |
| 510 | const std::string& user() |
| 511 | { |
| 512 | return credentials.user(); |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 513 | } |
| 514 | |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 515 | const std::string& password() |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 516 | { |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 517 | return credentials.password(); |
| 518 | } |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 519 | |
Ed Tanous | 1917ee9 | 2022-06-30 22:30:50 -0700 | [diff] [blame] | 520 | SecureBuffer pack(FormatterFunc* formatter) |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 521 | { |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 522 | SecureBuffer packed{new Buffer{}}; |
Ed Tanous | e662eae | 2022-01-25 10:39:19 -0800 | [diff] [blame] | 523 | if (formatter != nullptr) |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 524 | { |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 525 | formatter(credentials.user(), credentials.password(), *packed); |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 526 | } |
| 527 | |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 528 | return packed; |
| 529 | } |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 530 | |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 531 | private: |
| 532 | Credentials credentials; |
| 533 | }; |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 534 | |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 535 | // Wrapper for boost::async_pipe ensuring proper pipe cleanup |
Ed Tanous | 0a48306 | 2022-07-11 10:18:50 -0700 | [diff] [blame] | 536 | class SecurePipe |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 537 | { |
| 538 | public: |
| 539 | using unix_fd = sdbusplus::message::unix_fd; |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 540 | |
Ed Tanous | 0a48306 | 2022-07-11 10:18:50 -0700 | [diff] [blame] | 541 | SecurePipe(boost::asio::io_context& io, |
| 542 | CredentialsProvider::SecureBuffer&& bufferIn) : |
| 543 | impl(io), |
| 544 | buffer{std::move(bufferIn)} |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 545 | {} |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 546 | |
Ed Tanous | 0a48306 | 2022-07-11 10:18:50 -0700 | [diff] [blame] | 547 | ~SecurePipe() |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 548 | { |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 549 | // Named pipe needs to be explicitly removed |
| 550 | impl.close(); |
| 551 | } |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 552 | |
Ed Tanous | 0a48306 | 2022-07-11 10:18:50 -0700 | [diff] [blame] | 553 | SecurePipe(const SecurePipe&) = delete; |
| 554 | SecurePipe(SecurePipe&&) = delete; |
| 555 | SecurePipe& operator=(const SecurePipe&) = delete; |
| 556 | SecurePipe& operator=(SecurePipe&&) = delete; |
Ed Tanous | ecd6a3a | 2022-01-07 09:18:40 -0800 | [diff] [blame] | 557 | |
Ed Tanous | 0a48306 | 2022-07-11 10:18:50 -0700 | [diff] [blame] | 558 | unix_fd fd() const |
Przemyslaw Czarnowski | e13c276 | 2019-09-02 17:32:43 +0200 | [diff] [blame] | 559 | { |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 560 | return unix_fd{impl.native_source()}; |
| 561 | } |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 562 | |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 563 | template <typename WriteHandler> |
| 564 | void asyncWrite(WriteHandler&& handler) |
| 565 | { |
Ed Tanous | 0a48306 | 2022-07-11 10:18:50 -0700 | [diff] [blame] | 566 | impl.async_write_some(boost::asio::buffer(*buffer), |
| 567 | std::forward<WriteHandler>(handler)); |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | const std::string name; |
| 571 | boost::process::async_pipe impl; |
Ed Tanous | 0a48306 | 2022-07-11 10:18:50 -0700 | [diff] [blame] | 572 | CredentialsProvider::SecureBuffer buffer; |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 573 | }; |
| 574 | |
| 575 | /** |
| 576 | * @brief Function transceives data with dbus directly. |
| 577 | * |
| 578 | * All BMC state properties will be retrieved before sending reset request. |
| 579 | */ |
| 580 | inline void doMountVmLegacy(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 581 | const std::string& service, const std::string& name, |
| 582 | const std::string& imageUrl, const bool rw, |
| 583 | std::string&& userName, std::string&& password) |
| 584 | { |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 585 | constexpr const size_t secretLimit = 1024; |
| 586 | |
| 587 | std::shared_ptr<SecurePipe> secretPipe; |
Ed Tanous | 168e20c | 2021-12-13 14:39:53 -0800 | [diff] [blame] | 588 | dbus::utility::DbusVariantType unixFd = -1; |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 589 | |
| 590 | if (!userName.empty() || !password.empty()) |
| 591 | { |
| 592 | // Encapsulate in safe buffer |
| 593 | CredentialsProvider credentials(std::move(userName), |
| 594 | std::move(password)); |
| 595 | |
| 596 | // Payload must contain data + NULL delimiters |
| 597 | if (credentials.user().size() + credentials.password().size() + 2 > |
| 598 | secretLimit) |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 599 | { |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 600 | BMCWEB_LOG_ERROR << "Credentials too long to handle"; |
| 601 | messages::unrecognizedRequestBody(asyncResp->res); |
| 602 | return; |
| 603 | } |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 604 | |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 605 | // Pack secret |
| 606 | auto secret = credentials.pack( |
| 607 | [](const auto& user, const auto& pass, auto& buff) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 608 | std::copy(user.begin(), user.end(), std::back_inserter(buff)); |
| 609 | buff.push_back('\0'); |
| 610 | std::copy(pass.begin(), pass.end(), std::back_inserter(buff)); |
| 611 | buff.push_back('\0'); |
| 612 | }); |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 613 | |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 614 | // Open pipe |
| 615 | secretPipe = std::make_shared<SecurePipe>( |
| 616 | crow::connections::systemBus->get_io_context(), std::move(secret)); |
| 617 | unixFd = secretPipe->fd(); |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 618 | |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 619 | // Pass secret over pipe |
| 620 | secretPipe->asyncWrite( |
| 621 | [asyncResp](const boost::system::error_code& ec, std::size_t) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 622 | if (ec) |
| 623 | { |
| 624 | BMCWEB_LOG_ERROR << "Failed to pass secret: " << ec; |
| 625 | messages::internalError(asyncResp->res); |
| 626 | } |
| 627 | }); |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 628 | } |
Adrian Ambrożewicz | 988fb7b | 2020-01-13 18:52:46 +0100 | [diff] [blame] | 629 | |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 630 | crow::connections::systemBus->async_method_call( |
Ed Tanous | 5e7e2dc | 2023-02-16 10:37:01 -0800 | [diff] [blame] | 631 | [asyncResp, secretPipe](const boost::system::error_code& ec, |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 632 | bool success) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 633 | if (ec) |
| 634 | { |
| 635 | BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec; |
| 636 | messages::internalError(asyncResp->res); |
| 637 | } |
| 638 | else if (!success) |
| 639 | { |
| 640 | BMCWEB_LOG_ERROR << "Service responded with error"; |
| 641 | messages::generalError(asyncResp->res); |
| 642 | } |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 643 | }, |
| 644 | service, "/xyz/openbmc_project/VirtualMedia/Legacy/" + name, |
| 645 | "xyz.openbmc_project.VirtualMedia.Legacy", "Mount", imageUrl, rw, |
| 646 | unixFd); |
| 647 | } |
| 648 | |
| 649 | /** |
Przemyslaw Czarnowski | 120fa86 | 2022-06-24 15:10:48 +0200 | [diff] [blame] | 650 | * @brief Function validate parameters of insert media request. |
| 651 | * |
| 652 | */ |
| 653 | inline void validateParams(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 654 | const std::string& service, |
| 655 | const std::string& resName, |
| 656 | InsertMediaActionParams& actionParams) |
| 657 | { |
| 658 | BMCWEB_LOG_DEBUG << "Validation started"; |
| 659 | // required param imageUrl must not be empty |
| 660 | if (!actionParams.imageUrl) |
| 661 | { |
| 662 | BMCWEB_LOG_ERROR << "Request action parameter Image is empty."; |
| 663 | |
| 664 | messages::propertyValueFormatError(asyncResp->res, "<empty>", "Image"); |
| 665 | |
| 666 | return; |
| 667 | } |
| 668 | |
| 669 | // optional param inserted must be true |
| 670 | if ((actionParams.inserted != std::nullopt) && !*actionParams.inserted) |
| 671 | { |
| 672 | BMCWEB_LOG_ERROR |
| 673 | << "Request action optional parameter Inserted must be true."; |
| 674 | |
| 675 | messages::actionParameterNotSupported(asyncResp->res, "Inserted", |
| 676 | "InsertMedia"); |
| 677 | |
| 678 | return; |
| 679 | } |
| 680 | |
| 681 | // optional param transferMethod must be stream |
| 682 | if ((actionParams.transferMethod != std::nullopt) && |
| 683 | (*actionParams.transferMethod != "Stream")) |
| 684 | { |
| 685 | BMCWEB_LOG_ERROR << "Request action optional parameter " |
| 686 | "TransferMethod must be Stream."; |
| 687 | |
| 688 | messages::actionParameterNotSupported(asyncResp->res, "TransferMethod", |
| 689 | "InsertMedia"); |
| 690 | |
| 691 | return; |
| 692 | } |
| 693 | boost::urls::result<boost::urls::url_view> url = |
| 694 | boost::urls::parse_uri(*actionParams.imageUrl); |
| 695 | if (!url) |
| 696 | { |
| 697 | messages::actionParameterValueFormatError( |
| 698 | asyncResp->res, *actionParams.imageUrl, "Image", "InsertMedia"); |
| 699 | return; |
| 700 | } |
| 701 | std::optional<TransferProtocol> uriTransferProtocolType = |
| 702 | getTransferProtocolFromUri(*url); |
| 703 | |
| 704 | std::optional<TransferProtocol> paramTransferProtocolType = |
| 705 | getTransferProtocolFromParam(actionParams.transferProtocolType); |
| 706 | |
| 707 | // ImageUrl does not contain valid protocol type |
| 708 | if (*uriTransferProtocolType == TransferProtocol::invalid) |
| 709 | { |
| 710 | BMCWEB_LOG_ERROR << "Request action parameter ImageUrl must " |
| 711 | "contain specified protocol type from list: " |
| 712 | "(smb, https)."; |
| 713 | |
| 714 | messages::resourceAtUriInUnknownFormat(asyncResp->res, *url); |
| 715 | |
| 716 | return; |
| 717 | } |
| 718 | |
| 719 | // transferProtocolType should contain value from list |
| 720 | if (*paramTransferProtocolType == TransferProtocol::invalid) |
| 721 | { |
| 722 | BMCWEB_LOG_ERROR << "Request action parameter TransferProtocolType " |
| 723 | "must be provided with value from list: " |
| 724 | "(CIFS, HTTPS)."; |
| 725 | |
| 726 | messages::propertyValueNotInList(asyncResp->res, |
| 727 | *actionParams.transferProtocolType, |
| 728 | "TransferProtocolType"); |
| 729 | return; |
| 730 | } |
| 731 | |
| 732 | // valid transfer protocol not provided either with URI nor param |
| 733 | if ((uriTransferProtocolType == std::nullopt) && |
| 734 | (paramTransferProtocolType == std::nullopt)) |
| 735 | { |
| 736 | BMCWEB_LOG_ERROR << "Request action parameter ImageUrl must " |
| 737 | "contain specified protocol type or param " |
| 738 | "TransferProtocolType must be provided."; |
| 739 | |
| 740 | messages::resourceAtUriInUnknownFormat(asyncResp->res, *url); |
| 741 | |
| 742 | return; |
| 743 | } |
| 744 | |
| 745 | // valid transfer protocol provided both with URI and param |
| 746 | if ((paramTransferProtocolType != std::nullopt) && |
| 747 | (uriTransferProtocolType != std::nullopt)) |
| 748 | { |
| 749 | // check if protocol is the same for URI and param |
| 750 | if (*paramTransferProtocolType != *uriTransferProtocolType) |
| 751 | { |
| 752 | BMCWEB_LOG_ERROR << "Request action parameter " |
| 753 | "TransferProtocolType must contain the " |
| 754 | "same protocol type as protocol type " |
| 755 | "provided with param imageUrl."; |
| 756 | |
| 757 | messages::actionParameterValueTypeError( |
| 758 | asyncResp->res, *actionParams.transferProtocolType, |
| 759 | "TransferProtocolType", "InsertMedia"); |
| 760 | |
| 761 | return; |
| 762 | } |
| 763 | } |
| 764 | |
| 765 | // validation passed, add protocol to URI if needed |
| 766 | if (uriTransferProtocolType == std::nullopt) |
| 767 | { |
| 768 | actionParams.imageUrl = getUriWithTransferProtocol( |
| 769 | *actionParams.imageUrl, *paramTransferProtocolType); |
| 770 | } |
| 771 | |
| 772 | doMountVmLegacy(asyncResp, service, resName, *actionParams.imageUrl, |
| 773 | !(*actionParams.writeProtected), |
| 774 | std::move(*actionParams.userName), |
| 775 | std::move(*actionParams.password)); |
| 776 | } |
| 777 | |
| 778 | /** |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 779 | * @brief Function transceives data with dbus directly. |
| 780 | * |
| 781 | * All BMC state properties will be retrieved before sending reset request. |
| 782 | */ |
Ed Tanous | 24e740a | 2023-02-24 12:08:58 -0800 | [diff] [blame] | 783 | inline void doEjectAction(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 784 | const std::string& service, const std::string& name, |
| 785 | bool legacy) |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 786 | { |
| 787 | |
| 788 | // Legacy mount requires parameter with image |
| 789 | if (legacy) |
| 790 | { |
Adrian Ambrożewicz | d6da5be | 2020-01-13 18:31:01 +0100 | [diff] [blame] | 791 | crow::connections::systemBus->async_method_call( |
Ed Tanous | 5e7e2dc | 2023-02-16 10:37:01 -0800 | [diff] [blame] | 792 | [asyncResp](const boost::system::error_code& ec) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 793 | if (ec) |
| 794 | { |
| 795 | BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec; |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 796 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 797 | messages::internalError(asyncResp->res); |
| 798 | return; |
| 799 | } |
Adrian Ambrożewicz | d6da5be | 2020-01-13 18:31:01 +0100 | [diff] [blame] | 800 | }, |
| 801 | service, "/xyz/openbmc_project/VirtualMedia/Legacy/" + name, |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 802 | "xyz.openbmc_project.VirtualMedia.Legacy", "Unmount"); |
Przemyslaw Czarnowski | e13c276 | 2019-09-02 17:32:43 +0200 | [diff] [blame] | 803 | } |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 804 | else // proxy |
Przemyslaw Czarnowski | e13c276 | 2019-09-02 17:32:43 +0200 | [diff] [blame] | 805 | { |
Przemyslaw Czarnowski | e13c276 | 2019-09-02 17:32:43 +0200 | [diff] [blame] | 806 | crow::connections::systemBus->async_method_call( |
Ed Tanous | 5e7e2dc | 2023-02-16 10:37:01 -0800 | [diff] [blame] | 807 | [asyncResp](const boost::system::error_code& ec) { |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 808 | if (ec) |
| 809 | { |
| 810 | BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec; |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 811 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 812 | messages::internalError(asyncResp->res); |
| 813 | return; |
| 814 | } |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 815 | }, |
| 816 | service, "/xyz/openbmc_project/VirtualMedia/Proxy/" + name, |
| 817 | "xyz.openbmc_project.VirtualMedia.Proxy", "Unmount"); |
| 818 | } |
| 819 | } |
| 820 | |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 821 | inline void handleManagersVirtualMediaActionInsertPost( |
| 822 | crow::App& app, const crow::Request& req, |
| 823 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 824 | const std::string& name, const std::string& resName) |
| 825 | { |
| 826 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
| 827 | { |
| 828 | return; |
| 829 | } |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 830 | |
| 831 | constexpr std::string_view action = "VirtualMedia.InsertMedia"; |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 832 | if (name != "bmc") |
| 833 | { |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 834 | messages::resourceNotFound(asyncResp->res, action, resName); |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 835 | |
| 836 | return; |
| 837 | } |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 838 | InsertMediaActionParams actionParams; |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 839 | |
Przemyslaw Czarnowski | 120fa86 | 2022-06-24 15:10:48 +0200 | [diff] [blame] | 840 | // Read obligatory parameters (url of image) |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 841 | if (!json_util::readJsonAction( |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 842 | req, asyncResp->res, "Image", actionParams.imageUrl, |
| 843 | "WriteProtected", actionParams.writeProtected, "UserName", |
| 844 | actionParams.userName, "Password", actionParams.password, |
| 845 | "Inserted", actionParams.inserted, "TransferMethod", |
| 846 | actionParams.transferMethod, "TransferProtocolType", |
| 847 | actionParams.transferProtocolType)) |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 848 | { |
| 849 | return; |
| 850 | } |
| 851 | |
George Liu | 2b73119 | 2023-01-11 16:27:13 +0800 | [diff] [blame] | 852 | dbus::utility::getDbusObject( |
| 853 | "/xyz/openbmc_project/VirtualMedia", {}, |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 854 | [asyncResp, action, actionParams, |
George Liu | 2b73119 | 2023-01-11 16:27:13 +0800 | [diff] [blame] | 855 | resName](const boost::system::error_code& ec, |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 856 | const dbus::utility::MapperGetObject& getObjectType) mutable { |
| 857 | if (ec) |
| 858 | { |
| 859 | BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec; |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 860 | messages::resourceNotFound(asyncResp->res, action, resName); |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 861 | |
| 862 | return; |
| 863 | } |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 864 | |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 865 | std::string service = getObjectType.begin()->first; |
| 866 | BMCWEB_LOG_DEBUG << "GetObjectType: " << service; |
| 867 | |
| 868 | crow::connections::systemBus->async_method_call( |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 869 | [service, resName, action, actionParams, |
Ed Tanous | 5e7e2dc | 2023-02-16 10:37:01 -0800 | [diff] [blame] | 870 | asyncResp](const boost::system::error_code& ec2, |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 871 | dbus::utility::ManagedObjectType& subtree) mutable { |
Ed Tanous | 8a59281 | 2022-06-04 09:06:59 -0700 | [diff] [blame] | 872 | if (ec2) |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 873 | { |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 874 | // Not possible in proxy mode |
| 875 | BMCWEB_LOG_DEBUG << "InsertMedia not " |
| 876 | "allowed in proxy mode"; |
| 877 | messages::resourceNotFound(asyncResp->res, action, resName); |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 878 | |
| 879 | return; |
| 880 | } |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 881 | for (const auto& object : subtree) |
| 882 | { |
Ed Tanous | 365a73f | 2023-02-24 12:16:49 -0800 | [diff] [blame] | 883 | VmMode mode = parseObjectPathAndGetMode(object.first, resName); |
| 884 | if (mode == VmMode::Proxy) |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 885 | { |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 886 | validateParams(asyncResp, service, resName, actionParams); |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 887 | |
| 888 | return; |
| 889 | } |
| 890 | } |
| 891 | BMCWEB_LOG_DEBUG << "Parent item not found"; |
| 892 | messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName); |
| 893 | }, |
| 894 | service, "/xyz/openbmc_project/VirtualMedia", |
| 895 | "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); |
George Liu | 2b73119 | 2023-01-11 16:27:13 +0800 | [diff] [blame] | 896 | }); |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 897 | } |
| 898 | |
| 899 | inline void handleManagersVirtualMediaActionEject( |
| 900 | crow::App& app, const crow::Request& req, |
| 901 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 902 | const std::string& managerName, const std::string& resName) |
| 903 | { |
| 904 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
| 905 | { |
| 906 | return; |
| 907 | } |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 908 | |
| 909 | constexpr std::string_view action = "VirtualMedia.EjectMedia"; |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 910 | if (managerName != "bmc") |
| 911 | { |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 912 | messages::resourceNotFound(asyncResp->res, action, resName); |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 913 | |
| 914 | return; |
| 915 | } |
| 916 | |
George Liu | 2b73119 | 2023-01-11 16:27:13 +0800 | [diff] [blame] | 917 | dbus::utility::getDbusObject( |
| 918 | "/xyz/openbmc_project/VirtualMedia", {}, |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 919 | [asyncResp, action, |
George Liu | 2b73119 | 2023-01-11 16:27:13 +0800 | [diff] [blame] | 920 | resName](const boost::system::error_code& ec2, |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 921 | const dbus::utility::MapperGetObject& getObjectType) { |
Ed Tanous | 8a59281 | 2022-06-04 09:06:59 -0700 | [diff] [blame] | 922 | if (ec2) |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 923 | { |
Ed Tanous | 8a59281 | 2022-06-04 09:06:59 -0700 | [diff] [blame] | 924 | BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec2; |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 925 | messages::internalError(asyncResp->res); |
| 926 | |
| 927 | return; |
| 928 | } |
| 929 | std::string service = getObjectType.begin()->first; |
| 930 | BMCWEB_LOG_DEBUG << "GetObjectType: " << service; |
| 931 | |
| 932 | crow::connections::systemBus->async_method_call( |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 933 | [resName, service, action, |
| 934 | asyncResp](const boost::system::error_code& ec, |
| 935 | const dbus::utility::ManagedObjectType& subtree) { |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 936 | if (ec) |
| 937 | { |
Przemyslaw Czarnowski | 79fdf63 | 2022-06-28 18:11:59 +0200 | [diff] [blame] | 938 | BMCWEB_LOG_ERROR << "ObjectMapper : No Service found"; |
| 939 | messages::resourceNotFound(asyncResp->res, action, resName); |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 940 | return; |
| 941 | } |
| 942 | |
| 943 | for (const auto& object : subtree) |
| 944 | { |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 945 | |
Ed Tanous | 365a73f | 2023-02-24 12:16:49 -0800 | [diff] [blame] | 946 | VmMode mode = parseObjectPathAndGetMode(object.first, resName); |
| 947 | if (mode != VmMode::Invalid) |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 948 | { |
Ed Tanous | 365a73f | 2023-02-24 12:16:49 -0800 | [diff] [blame] | 949 | doEjectAction(asyncResp, service, resName, |
| 950 | mode == VmMode::Legacy); |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 951 | } |
| 952 | } |
| 953 | BMCWEB_LOG_DEBUG << "Parent item not found"; |
| 954 | messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName); |
| 955 | }, |
| 956 | service, "/xyz/openbmc_project/VirtualMedia", |
| 957 | "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); |
George Liu | 2b73119 | 2023-01-11 16:27:13 +0800 | [diff] [blame] | 958 | }); |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 959 | } |
| 960 | |
| 961 | inline void handleManagersVirtualMediaCollectionGet( |
| 962 | crow::App& app, const crow::Request& req, |
| 963 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 964 | const std::string& name) |
| 965 | { |
| 966 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
| 967 | { |
| 968 | return; |
| 969 | } |
| 970 | if (name != "bmc") |
| 971 | { |
| 972 | messages::resourceNotFound(asyncResp->res, "VirtualMedia", name); |
| 973 | |
| 974 | return; |
| 975 | } |
| 976 | |
| 977 | asyncResp->res.jsonValue["@odata.type"] = |
| 978 | "#VirtualMediaCollection.VirtualMediaCollection"; |
| 979 | asyncResp->res.jsonValue["Name"] = "Virtual Media Services"; |
Ed Tanous | fdb2034 | 2022-06-03 09:56:52 -0700 | [diff] [blame] | 980 | asyncResp->res.jsonValue["@odata.id"] = crow::utility::urlFromPieces( |
| 981 | "redfish", "v1", "Managers", name, "VirtualMedia"); |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 982 | |
George Liu | 2b73119 | 2023-01-11 16:27:13 +0800 | [diff] [blame] | 983 | dbus::utility::getDbusObject( |
| 984 | "/xyz/openbmc_project/VirtualMedia", {}, |
| 985 | [asyncResp, name](const boost::system::error_code& ec, |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 986 | const dbus::utility::MapperGetObject& getObjectType) { |
| 987 | if (ec) |
| 988 | { |
| 989 | BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec; |
| 990 | messages::internalError(asyncResp->res); |
| 991 | |
| 992 | return; |
| 993 | } |
| 994 | std::string service = getObjectType.begin()->first; |
| 995 | BMCWEB_LOG_DEBUG << "GetObjectType: " << service; |
| 996 | |
| 997 | getVmResourceList(asyncResp, service, name); |
George Liu | 2b73119 | 2023-01-11 16:27:13 +0800 | [diff] [blame] | 998 | }); |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 999 | } |
| 1000 | |
| 1001 | inline void |
| 1002 | handleVirtualMediaGet(crow::App& app, const crow::Request& req, |
| 1003 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 1004 | const std::string& name, const std::string& resName) |
| 1005 | { |
| 1006 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
| 1007 | { |
| 1008 | return; |
| 1009 | } |
| 1010 | if (name != "bmc") |
| 1011 | { |
| 1012 | messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName); |
| 1013 | |
| 1014 | return; |
| 1015 | } |
| 1016 | |
George Liu | 2b73119 | 2023-01-11 16:27:13 +0800 | [diff] [blame] | 1017 | dbus::utility::getDbusObject( |
| 1018 | "/xyz/openbmc_project/VirtualMedia", {}, |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 1019 | [asyncResp, name, |
George Liu | 2b73119 | 2023-01-11 16:27:13 +0800 | [diff] [blame] | 1020 | resName](const boost::system::error_code& ec, |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 1021 | const dbus::utility::MapperGetObject& getObjectType) { |
| 1022 | if (ec) |
| 1023 | { |
| 1024 | BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec; |
| 1025 | messages::internalError(asyncResp->res); |
| 1026 | |
| 1027 | return; |
| 1028 | } |
| 1029 | std::string service = getObjectType.begin()->first; |
| 1030 | BMCWEB_LOG_DEBUG << "GetObjectType: " << service; |
| 1031 | |
| 1032 | getVmData(asyncResp, service, name, resName); |
George Liu | 2b73119 | 2023-01-11 16:27:13 +0800 | [diff] [blame] | 1033 | }); |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 1034 | } |
| 1035 | |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 1036 | inline void requestNBDVirtualMediaRoutes(App& app) |
| 1037 | { |
George Liu | 0fda0f1 | 2021-11-16 10:06:17 +0800 | [diff] [blame] | 1038 | BMCWEB_ROUTE( |
| 1039 | app, |
| 1040 | "/redfish/v1/Managers/<str>/VirtualMedia/<str>/Actions/VirtualMedia.InsertMedia") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 1041 | .privileges(redfish::privileges::postVirtualMedia) |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 1042 | .methods(boost::beast::http::verb::post)(std::bind_front( |
| 1043 | handleManagersVirtualMediaActionInsertPost, std::ref(app))); |
Przemyslaw Czarnowski | e13c276 | 2019-09-02 17:32:43 +0200 | [diff] [blame] | 1044 | |
George Liu | 0fda0f1 | 2021-11-16 10:06:17 +0800 | [diff] [blame] | 1045 | BMCWEB_ROUTE( |
| 1046 | app, |
| 1047 | "/redfish/v1/Managers/<str>/VirtualMedia/<str>/Actions/VirtualMedia.EjectMedia") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 1048 | .privileges(redfish::privileges::postVirtualMedia) |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 1049 | .methods(boost::beast::http::verb::post)(std::bind_front( |
| 1050 | handleManagersVirtualMediaActionEject, std::ref(app))); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 1051 | |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 1052 | BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/VirtualMedia/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 1053 | .privileges(redfish::privileges::getVirtualMediaCollection) |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 1054 | .methods(boost::beast::http::verb::get)(std::bind_front( |
| 1055 | handleManagersVirtualMediaCollectionGet, std::ref(app))); |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 1056 | |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 1057 | BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/VirtualMedia/<str>/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 1058 | .privileges(redfish::privileges::getVirtualMedia) |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 1059 | .methods(boost::beast::http::verb::get)( |
Ed Tanous | 96825be | 2022-06-03 09:43:38 -0700 | [diff] [blame] | 1060 | std::bind_front(handleVirtualMediaGet, std::ref(app))); |
Ed Tanous | 22db172 | 2021-06-09 10:53:51 -0700 | [diff] [blame] | 1061 | } |
Przemyslaw Czarnowski | 107077d | 2019-07-11 10:16:43 +0200 | [diff] [blame] | 1062 | |
| 1063 | } // namespace redfish |