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