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