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