1107077deSPrzemyslaw Czarnowski /* 2107077deSPrzemyslaw Czarnowski // Copyright (c) 2018 Intel Corporation 3107077deSPrzemyslaw Czarnowski // 4107077deSPrzemyslaw Czarnowski // Licensed under the Apache License, Version 2.0 (the "License"); 5107077deSPrzemyslaw Czarnowski // you may not use this file except in compliance with the License. 6107077deSPrzemyslaw Czarnowski // You may obtain a copy of the License at 7107077deSPrzemyslaw Czarnowski // 8107077deSPrzemyslaw Czarnowski // http://www.apache.org/licenses/LICENSE-2.0 9107077deSPrzemyslaw Czarnowski // 10107077deSPrzemyslaw Czarnowski // Unless required by applicable law or agreed to in writing, software 11107077deSPrzemyslaw Czarnowski // distributed under the License is distributed on an "AS IS" BASIS, 12107077deSPrzemyslaw Czarnowski // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13107077deSPrzemyslaw Czarnowski // See the License for the specific language governing permissions and 14107077deSPrzemyslaw Czarnowski // limitations under the License. 15107077deSPrzemyslaw Czarnowski */ 16107077deSPrzemyslaw Czarnowski #pragma once 17107077deSPrzemyslaw Czarnowski 183ccb3adbSEd Tanous #include "account_service.hpp" 193ccb3adbSEd Tanous #include "app.hpp" 2079fdf63eSPrzemyslaw Czarnowski #include "async_resp.hpp" 212b73119cSGeorge Liu #include "dbus_utility.hpp" 22739b87efSEd Tanous #include "generated/enums/virtual_media.hpp" 233ccb3adbSEd Tanous #include "query.hpp" 243ccb3adbSEd Tanous #include "registries/privilege_registry.hpp" 253ccb3adbSEd Tanous #include "utils/json_utils.hpp" 263ccb3adbSEd Tanous 27988fb7b2SAdrian Ambrożewicz #include <boost/process/async_pipe.hpp> 28ef4c65b7SEd Tanous #include <boost/url/format.hpp> 299e319cf0SAnna Platash #include <boost/url/url_view.hpp> 30107077deSPrzemyslaw Czarnowski 312b73119cSGeorge Liu #include <array> 322b73119cSGeorge Liu #include <string_view> 332b73119cSGeorge Liu 34107077deSPrzemyslaw Czarnowski namespace redfish 35107077deSPrzemyslaw Czarnowski { 36365a73f4SEd Tanous 37365a73f4SEd Tanous enum class VmMode 38365a73f4SEd Tanous { 39365a73f4SEd Tanous Invalid, 40365a73f4SEd Tanous Legacy, 41365a73f4SEd Tanous Proxy 42365a73f4SEd Tanous }; 43365a73f4SEd Tanous 44365a73f4SEd Tanous inline VmMode 45365a73f4SEd Tanous parseObjectPathAndGetMode(const sdbusplus::message::object_path& itemPath, 46365a73f4SEd Tanous const std::string& resName) 47365a73f4SEd Tanous { 48365a73f4SEd Tanous std::string thisPath = itemPath.filename(); 49365a73f4SEd Tanous BMCWEB_LOG_DEBUG << "Filename: " << itemPath.str 50365a73f4SEd Tanous << ", ThisPath: " << thisPath; 51365a73f4SEd Tanous 52365a73f4SEd Tanous if (thisPath.empty()) 53365a73f4SEd Tanous { 54365a73f4SEd Tanous return VmMode::Invalid; 55365a73f4SEd Tanous } 56365a73f4SEd Tanous 57365a73f4SEd Tanous if (thisPath != resName) 58365a73f4SEd Tanous { 59365a73f4SEd Tanous return VmMode::Invalid; 60365a73f4SEd Tanous } 61365a73f4SEd Tanous 62365a73f4SEd Tanous auto mode = itemPath.parent_path(); 63365a73f4SEd Tanous auto type = mode.parent_path(); 64365a73f4SEd Tanous 65365a73f4SEd Tanous if (mode.filename().empty() || type.filename().empty()) 66365a73f4SEd Tanous { 67365a73f4SEd Tanous return VmMode::Invalid; 68365a73f4SEd Tanous } 69365a73f4SEd Tanous 70365a73f4SEd Tanous if (type.filename() != "VirtualMedia") 71365a73f4SEd Tanous { 72365a73f4SEd Tanous return VmMode::Invalid; 73365a73f4SEd Tanous } 74365a73f4SEd Tanous std::string modeStr = mode.filename(); 75365a73f4SEd Tanous if (modeStr == "Legacy") 76365a73f4SEd Tanous { 77365a73f4SEd Tanous return VmMode::Legacy; 78365a73f4SEd Tanous } 79365a73f4SEd Tanous if (modeStr == "Proxy") 80365a73f4SEd Tanous { 81365a73f4SEd Tanous return VmMode::Proxy; 82365a73f4SEd Tanous } 83365a73f4SEd Tanous return VmMode::Invalid; 84365a73f4SEd Tanous } 85365a73f4SEd Tanous 8679fdf63eSPrzemyslaw Czarnowski using CheckItemHandler = 8779fdf63eSPrzemyslaw Czarnowski std::function<void(const std::string& service, const std::string& resName, 8879fdf63eSPrzemyslaw Czarnowski const std::shared_ptr<bmcweb::AsyncResp>&, 8970cbdf53SGeorge Liu const std::pair<sdbusplus::message::object_path, 9079fdf63eSPrzemyslaw Czarnowski dbus::utility::DBusInteracesMap>&)>; 9179fdf63eSPrzemyslaw Czarnowski 92*ac106bf6SEd Tanous inline void 93*ac106bf6SEd Tanous findAndParseObject(const std::string& service, const std::string& resName, 94*ac106bf6SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 9579fdf63eSPrzemyslaw Czarnowski CheckItemHandler&& handler) 9679fdf63eSPrzemyslaw Czarnowski { 9779fdf63eSPrzemyslaw Czarnowski crow::connections::systemBus->async_method_call( 98*ac106bf6SEd Tanous [service, resName, asyncResp, 99746c5b8aSLakshmi Yadlapati handler](const boost::system::error_code& ec, 10070cbdf53SGeorge Liu const dbus::utility::ManagedObjectType& subtree) { 10179fdf63eSPrzemyslaw Czarnowski if (ec) 10279fdf63eSPrzemyslaw Czarnowski { 10379fdf63eSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "DBUS response error"; 10479fdf63eSPrzemyslaw Czarnowski 10579fdf63eSPrzemyslaw Czarnowski return; 10679fdf63eSPrzemyslaw Czarnowski } 10779fdf63eSPrzemyslaw Czarnowski 10870cbdf53SGeorge Liu for (const auto& item : subtree) 10979fdf63eSPrzemyslaw Czarnowski { 11079fdf63eSPrzemyslaw Czarnowski VmMode mode = parseObjectPathAndGetMode(item.first, resName); 11179fdf63eSPrzemyslaw Czarnowski if (mode != VmMode::Invalid) 11279fdf63eSPrzemyslaw Czarnowski { 113*ac106bf6SEd Tanous handler(service, resName, asyncResp, item); 11479fdf63eSPrzemyslaw Czarnowski return; 11579fdf63eSPrzemyslaw Czarnowski } 11679fdf63eSPrzemyslaw Czarnowski } 11779fdf63eSPrzemyslaw Czarnowski 11879fdf63eSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "Parent item not found"; 119*ac106bf6SEd Tanous asyncResp->res.result(boost::beast::http::status::not_found); 12079fdf63eSPrzemyslaw Czarnowski }, 12179fdf63eSPrzemyslaw Czarnowski service, "/xyz/openbmc_project/VirtualMedia", 12279fdf63eSPrzemyslaw Czarnowski "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); 12379fdf63eSPrzemyslaw Czarnowski } 12479fdf63eSPrzemyslaw Czarnowski 1259e319cf0SAnna Platash /** 1269e319cf0SAnna Platash * @brief Function extracts transfer protocol name from URI. 1279e319cf0SAnna Platash */ 12867df073bSEd Tanous inline std::string getTransferProtocolTypeFromUri(const std::string& imageUri) 12967df073bSEd Tanous { 13067df073bSEd Tanous boost::urls::result<boost::urls::url_view> url = 131079360aeSEd Tanous boost::urls::parse_uri(imageUri); 13267df073bSEd Tanous if (!url) 13367df073bSEd Tanous { 13467df073bSEd Tanous return "None"; 13567df073bSEd Tanous } 136079360aeSEd Tanous std::string_view scheme = url->scheme(); 13767df073bSEd Tanous if (scheme == "smb") 13867df073bSEd Tanous { 13967df073bSEd Tanous return "CIFS"; 14067df073bSEd Tanous } 14167df073bSEd Tanous if (scheme == "https") 14267df073bSEd Tanous { 14367df073bSEd Tanous return "HTTPS"; 14467df073bSEd Tanous } 14567df073bSEd Tanous 14667df073bSEd Tanous return "None"; 14767df073bSEd Tanous } 148107077deSPrzemyslaw Czarnowski 149107077deSPrzemyslaw Czarnowski /** 150107077deSPrzemyslaw Czarnowski * @brief Read all known properties from VM object interfaces 151107077deSPrzemyslaw Czarnowski */ 15222db1728SEd Tanous inline void 1538a592810SEd Tanous vmParseInterfaceObject(const dbus::utility::DBusInteracesMap& interfaces, 154*ac106bf6SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) 155107077deSPrzemyslaw Czarnowski { 1568a592810SEd Tanous for (const auto& [interface, values] : interfaces) 157107077deSPrzemyslaw Czarnowski { 158711ac7a9SEd Tanous if (interface == "xyz.openbmc_project.VirtualMedia.MountPoint") 159107077deSPrzemyslaw Czarnowski { 160711ac7a9SEd Tanous for (const auto& [property, value] : values) 161107077deSPrzemyslaw Czarnowski { 162711ac7a9SEd Tanous if (property == "EndpointId") 163107077deSPrzemyslaw Czarnowski { 164107077deSPrzemyslaw Czarnowski const std::string* endpointIdValue = 165711ac7a9SEd Tanous std::get_if<std::string>(&value); 166711ac7a9SEd Tanous if (endpointIdValue == nullptr) 167107077deSPrzemyslaw Czarnowski { 168711ac7a9SEd Tanous continue; 169711ac7a9SEd Tanous } 170107077deSPrzemyslaw Czarnowski if (!endpointIdValue->empty()) 171107077deSPrzemyslaw Czarnowski { 172107077deSPrzemyslaw Czarnowski // Proxy mode 173*ac106bf6SEd Tanous asyncResp->res 174711ac7a9SEd Tanous .jsonValue["Oem"]["OpenBMC"]["WebSocketEndpoint"] = 175d04ba325SPrzemyslaw Czarnowski *endpointIdValue; 176*ac106bf6SEd Tanous asyncResp->res.jsonValue["TransferProtocolType"] = 177*ac106bf6SEd Tanous "OEM"; 178107077deSPrzemyslaw Czarnowski } 179107077deSPrzemyslaw Czarnowski } 180711ac7a9SEd Tanous if (property == "ImageURL") 181107077deSPrzemyslaw Czarnowski { 182107077deSPrzemyslaw Czarnowski const std::string* imageUrlValue = 183711ac7a9SEd Tanous std::get_if<std::string>(&value); 18426f6976fSEd Tanous if (imageUrlValue != nullptr && !imageUrlValue->empty()) 185107077deSPrzemyslaw Czarnowski { 186da4784d8SPrzemyslaw Czarnowski std::filesystem::path filePath = *imageUrlValue; 187da4784d8SPrzemyslaw Czarnowski if (!filePath.has_filename()) 188da4784d8SPrzemyslaw Czarnowski { 1899e319cf0SAnna Platash // this will handle https share, which not 1909e319cf0SAnna Platash // necessarily has to have filename given. 191*ac106bf6SEd Tanous asyncResp->res.jsonValue["ImageName"] = ""; 192da4784d8SPrzemyslaw Czarnowski } 193da4784d8SPrzemyslaw Czarnowski else 194da4784d8SPrzemyslaw Czarnowski { 195*ac106bf6SEd Tanous asyncResp->res.jsonValue["ImageName"] = 1969e319cf0SAnna Platash filePath.filename(); 197da4784d8SPrzemyslaw Czarnowski } 198da4784d8SPrzemyslaw Czarnowski 199*ac106bf6SEd Tanous asyncResp->res.jsonValue["Image"] = *imageUrlValue; 200*ac106bf6SEd Tanous asyncResp->res.jsonValue["TransferProtocolType"] = 2019e319cf0SAnna Platash getTransferProtocolTypeFromUri(*imageUrlValue); 2029e319cf0SAnna Platash 203*ac106bf6SEd Tanous asyncResp->res.jsonValue["ConnectedVia"] = 204739b87efSEd Tanous virtual_media::ConnectedVia::URI; 205107077deSPrzemyslaw Czarnowski } 206107077deSPrzemyslaw Czarnowski } 207711ac7a9SEd Tanous if (property == "WriteProtected") 2089e319cf0SAnna Platash { 209711ac7a9SEd Tanous const bool* writeProtectedValue = std::get_if<bool>(&value); 210e662eae8SEd Tanous if (writeProtectedValue != nullptr) 2119e319cf0SAnna Platash { 212*ac106bf6SEd Tanous asyncResp->res.jsonValue["WriteProtected"] = 2139e319cf0SAnna Platash *writeProtectedValue; 2149e319cf0SAnna Platash } 2159e319cf0SAnna Platash } 2169e319cf0SAnna Platash } 217107077deSPrzemyslaw Czarnowski } 218711ac7a9SEd Tanous if (interface == "xyz.openbmc_project.VirtualMedia.Process") 219711ac7a9SEd Tanous { 220711ac7a9SEd Tanous for (const auto& [property, value] : values) 221711ac7a9SEd Tanous { 222711ac7a9SEd Tanous if (property == "Active") 223711ac7a9SEd Tanous { 224711ac7a9SEd Tanous const bool* activeValue = std::get_if<bool>(&value); 225e662eae8SEd Tanous if (activeValue == nullptr) 226711ac7a9SEd Tanous { 227711ac7a9SEd Tanous BMCWEB_LOG_DEBUG << "Value Active not found"; 228711ac7a9SEd Tanous return; 229711ac7a9SEd Tanous } 230*ac106bf6SEd Tanous asyncResp->res.jsonValue["Inserted"] = *activeValue; 231711ac7a9SEd Tanous 232e05aec50SEd Tanous if (*activeValue) 233711ac7a9SEd Tanous { 234*ac106bf6SEd Tanous asyncResp->res.jsonValue["ConnectedVia"] = 235739b87efSEd Tanous virtual_media::ConnectedVia::Applet; 236711ac7a9SEd Tanous } 237711ac7a9SEd Tanous } 238711ac7a9SEd Tanous } 239711ac7a9SEd Tanous } 240107077deSPrzemyslaw Czarnowski } 241107077deSPrzemyslaw Czarnowski } 242107077deSPrzemyslaw Czarnowski 243107077deSPrzemyslaw Czarnowski /** 244107077deSPrzemyslaw Czarnowski * @brief Fill template for Virtual Media Item. 245107077deSPrzemyslaw Czarnowski */ 24622db1728SEd Tanous inline nlohmann::json vmItemTemplate(const std::string& name, 247107077deSPrzemyslaw Czarnowski const std::string& resName) 248107077deSPrzemyslaw Czarnowski { 249107077deSPrzemyslaw Czarnowski nlohmann::json item; 250ef4c65b7SEd Tanous item["@odata.id"] = boost::urls::format( 251ef4c65b7SEd Tanous "/redfish/v1/Managers/{}/VirtualMedia/{}", name, resName); 25222db1728SEd Tanous 253d04ba325SPrzemyslaw Czarnowski item["@odata.type"] = "#VirtualMedia.v1_3_0.VirtualMedia"; 254107077deSPrzemyslaw Czarnowski item["Name"] = "Virtual Removable Media"; 255107077deSPrzemyslaw Czarnowski item["Id"] = resName; 256107077deSPrzemyslaw Czarnowski item["WriteProtected"] = true; 257739b87efSEd Tanous item["ConnectedVia"] = virtual_media::ConnectedVia::NotConnected; 258613dabeaSEd Tanous item["MediaTypes"] = nlohmann::json::array_t({"CD", "USBStick"}); 259107077deSPrzemyslaw Czarnowski item["TransferMethod"] = "Stream"; 260d04ba325SPrzemyslaw Czarnowski item["Oem"]["OpenBMC"]["@odata.type"] = 261d04ba325SPrzemyslaw Czarnowski "#OemVirtualMedia.v1_0_0.VirtualMedia"; 26215b89725SV-Sanjana item["Oem"]["OpenBMC"]["@odata.id"] = boost::urls::format( 26315b89725SV-Sanjana "/redfish/v1/Managers/{}/VirtualMedia/{}#/Oem/OpenBMC", name, resName); 264107077deSPrzemyslaw Czarnowski 265107077deSPrzemyslaw Czarnowski return item; 266107077deSPrzemyslaw Czarnowski } 267107077deSPrzemyslaw Czarnowski 268107077deSPrzemyslaw Czarnowski /** 269107077deSPrzemyslaw Czarnowski * @brief Fills collection data 270107077deSPrzemyslaw Czarnowski */ 271*ac106bf6SEd Tanous inline void getVmResourceList(std::shared_ptr<bmcweb::AsyncResp> asyncResp, 272107077deSPrzemyslaw Czarnowski const std::string& service, 273107077deSPrzemyslaw Czarnowski const std::string& name) 274107077deSPrzemyslaw Czarnowski { 275107077deSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "Get available Virtual Media resources."; 276107077deSPrzemyslaw Czarnowski crow::connections::systemBus->async_method_call( 277*ac106bf6SEd Tanous [name, asyncResp{std::move(asyncResp)}]( 2785e7e2dc5SEd Tanous const boost::system::error_code& ec, 27902cad96eSEd Tanous const dbus::utility::ManagedObjectType& subtree) { 280107077deSPrzemyslaw Czarnowski if (ec) 281107077deSPrzemyslaw Czarnowski { 282107077deSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "DBUS response error"; 283107077deSPrzemyslaw Czarnowski return; 284107077deSPrzemyslaw Czarnowski } 285*ac106bf6SEd Tanous nlohmann::json& members = asyncResp->res.jsonValue["Members"]; 286107077deSPrzemyslaw Czarnowski members = nlohmann::json::array(); 287107077deSPrzemyslaw Czarnowski 288107077deSPrzemyslaw Czarnowski for (const auto& object : subtree) 289107077deSPrzemyslaw Czarnowski { 290107077deSPrzemyslaw Czarnowski nlohmann::json item; 2912dfd18efSEd Tanous std::string path = object.first.filename(); 2922dfd18efSEd Tanous if (path.empty()) 293107077deSPrzemyslaw Czarnowski { 294107077deSPrzemyslaw Czarnowski continue; 295107077deSPrzemyslaw Czarnowski } 296107077deSPrzemyslaw Czarnowski 297ef4c65b7SEd Tanous item["@odata.id"] = boost::urls::format( 298ef4c65b7SEd Tanous "/redfish/v1/Managers/{}/VirtualMedia/{}", name, path); 299107077deSPrzemyslaw Czarnowski members.emplace_back(std::move(item)); 300107077deSPrzemyslaw Czarnowski } 301*ac106bf6SEd Tanous asyncResp->res.jsonValue["Members@odata.count"] = members.size(); 302107077deSPrzemyslaw Czarnowski }, 303107077deSPrzemyslaw Czarnowski service, "/xyz/openbmc_project/VirtualMedia", 304107077deSPrzemyslaw Czarnowski "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); 305107077deSPrzemyslaw Czarnowski } 306107077deSPrzemyslaw Czarnowski 30770cbdf53SGeorge Liu inline void 30870cbdf53SGeorge Liu afterGetVmData(const std::string& name, const std::string& /*service*/, 30979fdf63eSPrzemyslaw Czarnowski const std::string& resName, 31079fdf63eSPrzemyslaw Czarnowski const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 31170cbdf53SGeorge Liu const std::pair<sdbusplus::message::object_path, 31279fdf63eSPrzemyslaw Czarnowski dbus::utility::DBusInteracesMap>& item) 31379fdf63eSPrzemyslaw Czarnowski { 31479fdf63eSPrzemyslaw Czarnowski VmMode mode = parseObjectPathAndGetMode(item.first, resName); 31579fdf63eSPrzemyslaw Czarnowski if (mode == VmMode::Invalid) 31679fdf63eSPrzemyslaw Czarnowski { 31779fdf63eSPrzemyslaw Czarnowski return; 31879fdf63eSPrzemyslaw Czarnowski } 31979fdf63eSPrzemyslaw Czarnowski 32079fdf63eSPrzemyslaw Czarnowski asyncResp->res.jsonValue = vmItemTemplate(name, resName); 32179fdf63eSPrzemyslaw Czarnowski 32279fdf63eSPrzemyslaw Czarnowski // Check if dbus path is Legacy type 32379fdf63eSPrzemyslaw Czarnowski if (mode == VmMode::Legacy) 32479fdf63eSPrzemyslaw Czarnowski { 325ef4c65b7SEd Tanous asyncResp->res.jsonValue["Actions"]["#VirtualMedia.InsertMedia"] 326ef4c65b7SEd Tanous ["target"] = boost::urls::format( 327ef4c65b7SEd Tanous "/redfish/v1/Managers/{}/VirtualMedia/{}/Actions/VirtualMedia.InsertMedia", 328ef4c65b7SEd Tanous name, resName); 32979fdf63eSPrzemyslaw Czarnowski } 33079fdf63eSPrzemyslaw Czarnowski 33179fdf63eSPrzemyslaw Czarnowski vmParseInterfaceObject(item.second, asyncResp); 33279fdf63eSPrzemyslaw Czarnowski 333ef4c65b7SEd Tanous asyncResp->res.jsonValue["Actions"]["#VirtualMedia.EjectMedia"] 334ef4c65b7SEd Tanous ["target"] = boost::urls::format( 335ef4c65b7SEd Tanous "/redfish/v1/Managers/{}/VirtualMedia/{}/Actions/VirtualMedia.EjectMedia", 336ef4c65b7SEd Tanous name, resName); 33779fdf63eSPrzemyslaw Czarnowski } 33879fdf63eSPrzemyslaw Czarnowski 339107077deSPrzemyslaw Czarnowski /** 340107077deSPrzemyslaw Czarnowski * @brief Fills data for specific resource 341107077deSPrzemyslaw Czarnowski */ 342*ac106bf6SEd Tanous inline void getVmData(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 343107077deSPrzemyslaw Czarnowski const std::string& service, const std::string& name, 344107077deSPrzemyslaw Czarnowski const std::string& resName) 345107077deSPrzemyslaw Czarnowski { 346107077deSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "Get Virtual Media resource data."; 347107077deSPrzemyslaw Czarnowski 348*ac106bf6SEd Tanous findAndParseObject(service, resName, asyncResp, 34970cbdf53SGeorge Liu std::bind_front(afterGetVmData, name)); 350107077deSPrzemyslaw Czarnowski } 351107077deSPrzemyslaw Czarnowski 352e13c2760SPrzemyslaw Czarnowski /** 353c6f4e017SAgata Olender * @brief Transfer protocols supported for InsertMedia action. 354c6f4e017SAgata Olender * 355c6f4e017SAgata Olender */ 356c6f4e017SAgata Olender enum class TransferProtocol 357c6f4e017SAgata Olender { 358c6f4e017SAgata Olender https, 359c6f4e017SAgata Olender smb, 360c6f4e017SAgata Olender invalid 361c6f4e017SAgata Olender }; 362c6f4e017SAgata Olender 363c6f4e017SAgata Olender /** 364c6f4e017SAgata Olender * @brief Function extracts transfer protocol type from URI. 365c6f4e017SAgata Olender * 366c6f4e017SAgata Olender */ 36767df073bSEd Tanous inline std::optional<TransferProtocol> 368d9f466b3SEd Tanous getTransferProtocolFromUri(boost::urls::url_view imageUri) 36967df073bSEd Tanous { 370079360aeSEd Tanous std::string_view scheme = imageUri.scheme(); 37167df073bSEd Tanous if (scheme == "smb") 37267df073bSEd Tanous { 37367df073bSEd Tanous return TransferProtocol::smb; 37467df073bSEd Tanous } 37567df073bSEd Tanous if (scheme == "https") 37667df073bSEd Tanous { 37767df073bSEd Tanous return TransferProtocol::https; 37867df073bSEd Tanous } 37967df073bSEd Tanous if (!scheme.empty()) 38067df073bSEd Tanous { 38167df073bSEd Tanous return TransferProtocol::invalid; 38267df073bSEd Tanous } 38367df073bSEd Tanous 38467df073bSEd Tanous return {}; 38567df073bSEd Tanous } 386c6f4e017SAgata Olender 387c6f4e017SAgata Olender /** 388c6f4e017SAgata Olender * @brief Function convert transfer protocol from string param. 389c6f4e017SAgata Olender * 390c6f4e017SAgata Olender */ 39122db1728SEd Tanous inline std::optional<TransferProtocol> getTransferProtocolFromParam( 392c6f4e017SAgata Olender const std::optional<std::string>& transferProtocolType) 393c6f4e017SAgata Olender { 394c6f4e017SAgata Olender if (transferProtocolType == std::nullopt) 395c6f4e017SAgata Olender { 396c6f4e017SAgata Olender return {}; 397c6f4e017SAgata Olender } 398c6f4e017SAgata Olender 399c6f4e017SAgata Olender if (*transferProtocolType == "CIFS") 400c6f4e017SAgata Olender { 401c6f4e017SAgata Olender return TransferProtocol::smb; 402c6f4e017SAgata Olender } 403c6f4e017SAgata Olender 404c6f4e017SAgata Olender if (*transferProtocolType == "HTTPS") 405c6f4e017SAgata Olender { 406c6f4e017SAgata Olender return TransferProtocol::https; 407c6f4e017SAgata Olender } 408c6f4e017SAgata Olender 409c6f4e017SAgata Olender return TransferProtocol::invalid; 410c6f4e017SAgata Olender } 411c6f4e017SAgata Olender 412c6f4e017SAgata Olender /** 413c6f4e017SAgata Olender * @brief Function extends URI with transfer protocol type. 414c6f4e017SAgata Olender * 415c6f4e017SAgata Olender */ 41622db1728SEd Tanous inline std::string 417c6f4e017SAgata Olender getUriWithTransferProtocol(const std::string& imageUri, 418c6f4e017SAgata Olender const TransferProtocol& transferProtocol) 419c6f4e017SAgata Olender { 420c6f4e017SAgata Olender if (transferProtocol == TransferProtocol::smb) 421c6f4e017SAgata Olender { 422c6f4e017SAgata Olender return "smb://" + imageUri; 423c6f4e017SAgata Olender } 424c6f4e017SAgata Olender 425c6f4e017SAgata Olender if (transferProtocol == TransferProtocol::https) 426c6f4e017SAgata Olender { 427c6f4e017SAgata Olender return "https://" + imageUri; 428c6f4e017SAgata Olender } 429c6f4e017SAgata Olender 430c6f4e017SAgata Olender return imageUri; 431c6f4e017SAgata Olender } 432c6f4e017SAgata Olender 4331f2a40ceSPrzemyslaw Czarnowski struct InsertMediaActionParams 4341f2a40ceSPrzemyslaw Czarnowski { 435120fa86aSPrzemyslaw Czarnowski std::optional<std::string> imageUrl; 4361f2a40ceSPrzemyslaw Czarnowski std::optional<std::string> userName; 4371f2a40ceSPrzemyslaw Czarnowski std::optional<std::string> password; 4381f2a40ceSPrzemyslaw Czarnowski std::optional<std::string> transferMethod; 4391f2a40ceSPrzemyslaw Czarnowski std::optional<std::string> transferProtocolType; 4401f2a40ceSPrzemyslaw Czarnowski std::optional<bool> writeProtected = true; 4411f2a40ceSPrzemyslaw Czarnowski std::optional<bool> inserted; 4421f2a40ceSPrzemyslaw Czarnowski }; 4431f2a40ceSPrzemyslaw Czarnowski 4441214b7e7SGunnar Mills template <typename T> 4451214b7e7SGunnar Mills static void secureCleanup(T& value) 446988fb7b2SAdrian Ambrożewicz { 4474ecc618fSEd Tanous // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) 448988fb7b2SAdrian Ambrożewicz auto raw = const_cast<typename T::value_type*>(value.data()); 449988fb7b2SAdrian Ambrożewicz explicit_bzero(raw, value.size() * sizeof(*raw)); 450988fb7b2SAdrian Ambrożewicz } 451988fb7b2SAdrian Ambrożewicz 452988fb7b2SAdrian Ambrożewicz class Credentials 453988fb7b2SAdrian Ambrożewicz { 454988fb7b2SAdrian Ambrożewicz public: 455988fb7b2SAdrian Ambrożewicz Credentials(std::string&& user, std::string&& password) : 456988fb7b2SAdrian Ambrożewicz userBuf(std::move(user)), passBuf(std::move(password)) 4571214b7e7SGunnar Mills {} 458988fb7b2SAdrian Ambrożewicz 459988fb7b2SAdrian Ambrożewicz ~Credentials() 460988fb7b2SAdrian Ambrożewicz { 461988fb7b2SAdrian Ambrożewicz secureCleanup(userBuf); 462988fb7b2SAdrian Ambrożewicz secureCleanup(passBuf); 463988fb7b2SAdrian Ambrożewicz } 464988fb7b2SAdrian Ambrożewicz 465988fb7b2SAdrian Ambrożewicz const std::string& user() 466988fb7b2SAdrian Ambrożewicz { 467988fb7b2SAdrian Ambrożewicz return userBuf; 468988fb7b2SAdrian Ambrożewicz } 469988fb7b2SAdrian Ambrożewicz 470988fb7b2SAdrian Ambrożewicz const std::string& password() 471988fb7b2SAdrian Ambrożewicz { 472988fb7b2SAdrian Ambrożewicz return passBuf; 473988fb7b2SAdrian Ambrożewicz } 474988fb7b2SAdrian Ambrożewicz 475988fb7b2SAdrian Ambrożewicz Credentials() = delete; 476988fb7b2SAdrian Ambrożewicz Credentials(const Credentials&) = delete; 477988fb7b2SAdrian Ambrożewicz Credentials& operator=(const Credentials&) = delete; 478ecd6a3a2SEd Tanous Credentials(Credentials&&) = delete; 479ecd6a3a2SEd Tanous Credentials& operator=(Credentials&&) = delete; 480988fb7b2SAdrian Ambrożewicz 48122db1728SEd Tanous private: 482988fb7b2SAdrian Ambrożewicz std::string userBuf; 483988fb7b2SAdrian Ambrożewicz std::string passBuf; 484988fb7b2SAdrian Ambrożewicz }; 485988fb7b2SAdrian Ambrożewicz 486988fb7b2SAdrian Ambrożewicz class CredentialsProvider 487988fb7b2SAdrian Ambrożewicz { 488988fb7b2SAdrian Ambrożewicz public: 4891214b7e7SGunnar Mills template <typename T> 4901214b7e7SGunnar Mills struct Deleter 491988fb7b2SAdrian Ambrożewicz { 492988fb7b2SAdrian Ambrożewicz void operator()(T* buff) const 493988fb7b2SAdrian Ambrożewicz { 494988fb7b2SAdrian Ambrożewicz if (buff) 495988fb7b2SAdrian Ambrożewicz { 496988fb7b2SAdrian Ambrożewicz secureCleanup(*buff); 497988fb7b2SAdrian Ambrożewicz delete buff; 498988fb7b2SAdrian Ambrożewicz } 499988fb7b2SAdrian Ambrożewicz } 500988fb7b2SAdrian Ambrożewicz }; 501988fb7b2SAdrian Ambrożewicz 502988fb7b2SAdrian Ambrożewicz using Buffer = std::vector<char>; 503988fb7b2SAdrian Ambrożewicz using SecureBuffer = std::unique_ptr<Buffer, Deleter<Buffer>>; 504988fb7b2SAdrian Ambrożewicz // Using explicit definition instead of std::function to avoid implicit 505988fb7b2SAdrian Ambrożewicz // conversions eg. stack copy instead of reference 506988fb7b2SAdrian Ambrożewicz using FormatterFunc = void(const std::string& username, 507988fb7b2SAdrian Ambrożewicz const std::string& password, Buffer& dest); 508988fb7b2SAdrian Ambrożewicz 509988fb7b2SAdrian Ambrożewicz CredentialsProvider(std::string&& user, std::string&& password) : 510988fb7b2SAdrian Ambrożewicz credentials(std::move(user), std::move(password)) 5111214b7e7SGunnar Mills {} 512988fb7b2SAdrian Ambrożewicz 513988fb7b2SAdrian Ambrożewicz const std::string& user() 514988fb7b2SAdrian Ambrożewicz { 515988fb7b2SAdrian Ambrożewicz return credentials.user(); 516988fb7b2SAdrian Ambrożewicz } 517988fb7b2SAdrian Ambrożewicz 518988fb7b2SAdrian Ambrożewicz const std::string& password() 519988fb7b2SAdrian Ambrożewicz { 520988fb7b2SAdrian Ambrożewicz return credentials.password(); 521988fb7b2SAdrian Ambrożewicz } 522988fb7b2SAdrian Ambrożewicz 5231917ee95SEd Tanous SecureBuffer pack(FormatterFunc* formatter) 524988fb7b2SAdrian Ambrożewicz { 525988fb7b2SAdrian Ambrożewicz SecureBuffer packed{new Buffer{}}; 526e662eae8SEd Tanous if (formatter != nullptr) 527988fb7b2SAdrian Ambrożewicz { 528988fb7b2SAdrian Ambrożewicz formatter(credentials.user(), credentials.password(), *packed); 529988fb7b2SAdrian Ambrożewicz } 530988fb7b2SAdrian Ambrożewicz 531988fb7b2SAdrian Ambrożewicz return packed; 532988fb7b2SAdrian Ambrożewicz } 533988fb7b2SAdrian Ambrożewicz 534988fb7b2SAdrian Ambrożewicz private: 535988fb7b2SAdrian Ambrożewicz Credentials credentials; 536988fb7b2SAdrian Ambrożewicz }; 537988fb7b2SAdrian Ambrożewicz 538988fb7b2SAdrian Ambrożewicz // Wrapper for boost::async_pipe ensuring proper pipe cleanup 5390a48306bSEd Tanous class SecurePipe 540988fb7b2SAdrian Ambrożewicz { 541988fb7b2SAdrian Ambrożewicz public: 542988fb7b2SAdrian Ambrożewicz using unix_fd = sdbusplus::message::unix_fd; 543988fb7b2SAdrian Ambrożewicz 5440a48306bSEd Tanous SecurePipe(boost::asio::io_context& io, 5450a48306bSEd Tanous CredentialsProvider::SecureBuffer&& bufferIn) : 5460a48306bSEd Tanous impl(io), 5470a48306bSEd Tanous buffer{std::move(bufferIn)} 5481214b7e7SGunnar Mills {} 549988fb7b2SAdrian Ambrożewicz 5500a48306bSEd Tanous ~SecurePipe() 551988fb7b2SAdrian Ambrożewicz { 552988fb7b2SAdrian Ambrożewicz // Named pipe needs to be explicitly removed 553988fb7b2SAdrian Ambrożewicz impl.close(); 554988fb7b2SAdrian Ambrożewicz } 555988fb7b2SAdrian Ambrożewicz 5560a48306bSEd Tanous SecurePipe(const SecurePipe&) = delete; 5570a48306bSEd Tanous SecurePipe(SecurePipe&&) = delete; 5580a48306bSEd Tanous SecurePipe& operator=(const SecurePipe&) = delete; 5590a48306bSEd Tanous SecurePipe& operator=(SecurePipe&&) = delete; 560ecd6a3a2SEd Tanous 5610a48306bSEd Tanous unix_fd fd() const 562988fb7b2SAdrian Ambrożewicz { 563988fb7b2SAdrian Ambrożewicz return unix_fd{impl.native_source()}; 564988fb7b2SAdrian Ambrożewicz } 565988fb7b2SAdrian Ambrożewicz 566988fb7b2SAdrian Ambrożewicz template <typename WriteHandler> 56781ce609eSEd Tanous void asyncWrite(WriteHandler&& handler) 568988fb7b2SAdrian Ambrożewicz { 5690a48306bSEd Tanous impl.async_write_some(boost::asio::buffer(*buffer), 5700a48306bSEd Tanous std::forward<WriteHandler>(handler)); 571988fb7b2SAdrian Ambrożewicz } 572988fb7b2SAdrian Ambrożewicz 573988fb7b2SAdrian Ambrożewicz const std::string name; 574988fb7b2SAdrian Ambrożewicz boost::process::async_pipe impl; 5750a48306bSEd Tanous CredentialsProvider::SecureBuffer buffer; 576988fb7b2SAdrian Ambrożewicz }; 577988fb7b2SAdrian Ambrożewicz 578e13c2760SPrzemyslaw Czarnowski /** 579e13c2760SPrzemyslaw Czarnowski * @brief Function transceives data with dbus directly. 580e13c2760SPrzemyslaw Czarnowski * 581e13c2760SPrzemyslaw Czarnowski * All BMC state properties will be retrieved before sending reset request. 582e13c2760SPrzemyslaw Czarnowski */ 58322db1728SEd Tanous inline void doMountVmLegacy(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 584e13c2760SPrzemyslaw Czarnowski const std::string& service, const std::string& name, 585988fb7b2SAdrian Ambrożewicz const std::string& imageUrl, const bool rw, 586988fb7b2SAdrian Ambrożewicz std::string&& userName, std::string&& password) 587e13c2760SPrzemyslaw Czarnowski { 588988fb7b2SAdrian Ambrożewicz constexpr const size_t secretLimit = 1024; 589988fb7b2SAdrian Ambrożewicz 590988fb7b2SAdrian Ambrożewicz std::shared_ptr<SecurePipe> secretPipe; 591168e20c1SEd Tanous dbus::utility::DbusVariantType unixFd = -1; 592988fb7b2SAdrian Ambrożewicz 593988fb7b2SAdrian Ambrożewicz if (!userName.empty() || !password.empty()) 594988fb7b2SAdrian Ambrożewicz { 595988fb7b2SAdrian Ambrożewicz // Encapsulate in safe buffer 596988fb7b2SAdrian Ambrożewicz CredentialsProvider credentials(std::move(userName), 597988fb7b2SAdrian Ambrożewicz std::move(password)); 598988fb7b2SAdrian Ambrożewicz 599988fb7b2SAdrian Ambrożewicz // Payload must contain data + NULL delimiters 600988fb7b2SAdrian Ambrożewicz if (credentials.user().size() + credentials.password().size() + 2 > 601988fb7b2SAdrian Ambrożewicz secretLimit) 602988fb7b2SAdrian Ambrożewicz { 603988fb7b2SAdrian Ambrożewicz BMCWEB_LOG_ERROR << "Credentials too long to handle"; 604988fb7b2SAdrian Ambrożewicz messages::unrecognizedRequestBody(asyncResp->res); 605988fb7b2SAdrian Ambrożewicz return; 606988fb7b2SAdrian Ambrożewicz } 607988fb7b2SAdrian Ambrożewicz 608988fb7b2SAdrian Ambrożewicz // Pack secret 60922db1728SEd Tanous auto secret = credentials.pack( 61022db1728SEd Tanous [](const auto& user, const auto& pass, auto& buff) { 611988fb7b2SAdrian Ambrożewicz std::copy(user.begin(), user.end(), std::back_inserter(buff)); 612988fb7b2SAdrian Ambrożewicz buff.push_back('\0'); 613988fb7b2SAdrian Ambrożewicz std::copy(pass.begin(), pass.end(), std::back_inserter(buff)); 614988fb7b2SAdrian Ambrożewicz buff.push_back('\0'); 615988fb7b2SAdrian Ambrożewicz }); 616988fb7b2SAdrian Ambrożewicz 617988fb7b2SAdrian Ambrożewicz // Open pipe 618988fb7b2SAdrian Ambrożewicz secretPipe = std::make_shared<SecurePipe>( 61922db1728SEd Tanous crow::connections::systemBus->get_io_context(), std::move(secret)); 620988fb7b2SAdrian Ambrożewicz unixFd = secretPipe->fd(); 621988fb7b2SAdrian Ambrożewicz 622988fb7b2SAdrian Ambrożewicz // Pass secret over pipe 62381ce609eSEd Tanous secretPipe->asyncWrite( 624f5b16f03SVikram Bodireddy [asyncResp](const boost::system::error_code& ec, std::size_t) { 625988fb7b2SAdrian Ambrożewicz if (ec) 626988fb7b2SAdrian Ambrożewicz { 627988fb7b2SAdrian Ambrożewicz BMCWEB_LOG_ERROR << "Failed to pass secret: " << ec; 628988fb7b2SAdrian Ambrożewicz messages::internalError(asyncResp->res); 629988fb7b2SAdrian Ambrożewicz } 630988fb7b2SAdrian Ambrożewicz }); 631988fb7b2SAdrian Ambrożewicz } 632988fb7b2SAdrian Ambrożewicz 633e13c2760SPrzemyslaw Czarnowski crow::connections::systemBus->async_method_call( 6345e7e2dc5SEd Tanous [asyncResp, secretPipe](const boost::system::error_code& ec, 635988fb7b2SAdrian Ambrożewicz bool success) { 636e13c2760SPrzemyslaw Czarnowski if (ec) 637e13c2760SPrzemyslaw Czarnowski { 638e13c2760SPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec; 639e13c2760SPrzemyslaw Czarnowski messages::internalError(asyncResp->res); 640d6da5bebSAdrian Ambrożewicz } 641d6da5bebSAdrian Ambrożewicz else if (!success) 642d6da5bebSAdrian Ambrożewicz { 643d6da5bebSAdrian Ambrożewicz BMCWEB_LOG_ERROR << "Service responded with error"; 644d6da5bebSAdrian Ambrożewicz messages::generalError(asyncResp->res); 645e13c2760SPrzemyslaw Czarnowski } 646e13c2760SPrzemyslaw Czarnowski }, 647e13c2760SPrzemyslaw Czarnowski service, "/xyz/openbmc_project/VirtualMedia/Legacy/" + name, 648988fb7b2SAdrian Ambrożewicz "xyz.openbmc_project.VirtualMedia.Legacy", "Mount", imageUrl, rw, 649988fb7b2SAdrian Ambrożewicz unixFd); 650e13c2760SPrzemyslaw Czarnowski } 651e13c2760SPrzemyslaw Czarnowski 652e13c2760SPrzemyslaw Czarnowski /** 653120fa86aSPrzemyslaw Czarnowski * @brief Function validate parameters of insert media request. 654120fa86aSPrzemyslaw Czarnowski * 655120fa86aSPrzemyslaw Czarnowski */ 656120fa86aSPrzemyslaw Czarnowski inline void validateParams(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 657120fa86aSPrzemyslaw Czarnowski const std::string& service, 658120fa86aSPrzemyslaw Czarnowski const std::string& resName, 659120fa86aSPrzemyslaw Czarnowski InsertMediaActionParams& actionParams) 660120fa86aSPrzemyslaw Czarnowski { 661120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "Validation started"; 662120fa86aSPrzemyslaw Czarnowski // required param imageUrl must not be empty 663120fa86aSPrzemyslaw Czarnowski if (!actionParams.imageUrl) 664120fa86aSPrzemyslaw Czarnowski { 665120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action parameter Image is empty."; 666120fa86aSPrzemyslaw Czarnowski 667120fa86aSPrzemyslaw Czarnowski messages::propertyValueFormatError(asyncResp->res, "<empty>", "Image"); 668120fa86aSPrzemyslaw Czarnowski 669120fa86aSPrzemyslaw Czarnowski return; 670120fa86aSPrzemyslaw Czarnowski } 671120fa86aSPrzemyslaw Czarnowski 672120fa86aSPrzemyslaw Czarnowski // optional param inserted must be true 673120fa86aSPrzemyslaw Czarnowski if ((actionParams.inserted != std::nullopt) && !*actionParams.inserted) 674120fa86aSPrzemyslaw Czarnowski { 675120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR 676120fa86aSPrzemyslaw Czarnowski << "Request action optional parameter Inserted must be true."; 677120fa86aSPrzemyslaw Czarnowski 678120fa86aSPrzemyslaw Czarnowski messages::actionParameterNotSupported(asyncResp->res, "Inserted", 679120fa86aSPrzemyslaw Czarnowski "InsertMedia"); 680120fa86aSPrzemyslaw Czarnowski 681120fa86aSPrzemyslaw Czarnowski return; 682120fa86aSPrzemyslaw Czarnowski } 683120fa86aSPrzemyslaw Czarnowski 684120fa86aSPrzemyslaw Czarnowski // optional param transferMethod must be stream 685120fa86aSPrzemyslaw Czarnowski if ((actionParams.transferMethod != std::nullopt) && 686120fa86aSPrzemyslaw Czarnowski (*actionParams.transferMethod != "Stream")) 687120fa86aSPrzemyslaw Czarnowski { 688120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action optional parameter " 689120fa86aSPrzemyslaw Czarnowski "TransferMethod must be Stream."; 690120fa86aSPrzemyslaw Czarnowski 691120fa86aSPrzemyslaw Czarnowski messages::actionParameterNotSupported(asyncResp->res, "TransferMethod", 692120fa86aSPrzemyslaw Czarnowski "InsertMedia"); 693120fa86aSPrzemyslaw Czarnowski 694120fa86aSPrzemyslaw Czarnowski return; 695120fa86aSPrzemyslaw Czarnowski } 696120fa86aSPrzemyslaw Czarnowski boost::urls::result<boost::urls::url_view> url = 697120fa86aSPrzemyslaw Czarnowski boost::urls::parse_uri(*actionParams.imageUrl); 698120fa86aSPrzemyslaw Czarnowski if (!url) 699120fa86aSPrzemyslaw Czarnowski { 700120fa86aSPrzemyslaw Czarnowski messages::actionParameterValueFormatError( 701120fa86aSPrzemyslaw Czarnowski asyncResp->res, *actionParams.imageUrl, "Image", "InsertMedia"); 702120fa86aSPrzemyslaw Czarnowski return; 703120fa86aSPrzemyslaw Czarnowski } 704120fa86aSPrzemyslaw Czarnowski std::optional<TransferProtocol> uriTransferProtocolType = 705120fa86aSPrzemyslaw Czarnowski getTransferProtocolFromUri(*url); 706120fa86aSPrzemyslaw Czarnowski 707120fa86aSPrzemyslaw Czarnowski std::optional<TransferProtocol> paramTransferProtocolType = 708120fa86aSPrzemyslaw Czarnowski getTransferProtocolFromParam(actionParams.transferProtocolType); 709120fa86aSPrzemyslaw Czarnowski 710120fa86aSPrzemyslaw Czarnowski // ImageUrl does not contain valid protocol type 711120fa86aSPrzemyslaw Czarnowski if (*uriTransferProtocolType == TransferProtocol::invalid) 712120fa86aSPrzemyslaw Czarnowski { 713120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action parameter ImageUrl must " 714120fa86aSPrzemyslaw Czarnowski "contain specified protocol type from list: " 715120fa86aSPrzemyslaw Czarnowski "(smb, https)."; 716120fa86aSPrzemyslaw Czarnowski 717120fa86aSPrzemyslaw Czarnowski messages::resourceAtUriInUnknownFormat(asyncResp->res, *url); 718120fa86aSPrzemyslaw Czarnowski 719120fa86aSPrzemyslaw Czarnowski return; 720120fa86aSPrzemyslaw Czarnowski } 721120fa86aSPrzemyslaw Czarnowski 722120fa86aSPrzemyslaw Czarnowski // transferProtocolType should contain value from list 723120fa86aSPrzemyslaw Czarnowski if (*paramTransferProtocolType == TransferProtocol::invalid) 724120fa86aSPrzemyslaw Czarnowski { 725120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action parameter TransferProtocolType " 726120fa86aSPrzemyslaw Czarnowski "must be provided with value from list: " 727120fa86aSPrzemyslaw Czarnowski "(CIFS, HTTPS)."; 728120fa86aSPrzemyslaw Czarnowski 729120fa86aSPrzemyslaw Czarnowski messages::propertyValueNotInList(asyncResp->res, 730120fa86aSPrzemyslaw Czarnowski *actionParams.transferProtocolType, 731120fa86aSPrzemyslaw Czarnowski "TransferProtocolType"); 732120fa86aSPrzemyslaw Czarnowski return; 733120fa86aSPrzemyslaw Czarnowski } 734120fa86aSPrzemyslaw Czarnowski 735120fa86aSPrzemyslaw Czarnowski // valid transfer protocol not provided either with URI nor param 736120fa86aSPrzemyslaw Czarnowski if ((uriTransferProtocolType == std::nullopt) && 737120fa86aSPrzemyslaw Czarnowski (paramTransferProtocolType == std::nullopt)) 738120fa86aSPrzemyslaw Czarnowski { 739120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action parameter ImageUrl must " 740120fa86aSPrzemyslaw Czarnowski "contain specified protocol type or param " 741120fa86aSPrzemyslaw Czarnowski "TransferProtocolType must be provided."; 742120fa86aSPrzemyslaw Czarnowski 743120fa86aSPrzemyslaw Czarnowski messages::resourceAtUriInUnknownFormat(asyncResp->res, *url); 744120fa86aSPrzemyslaw Czarnowski 745120fa86aSPrzemyslaw Czarnowski return; 746120fa86aSPrzemyslaw Czarnowski } 747120fa86aSPrzemyslaw Czarnowski 748120fa86aSPrzemyslaw Czarnowski // valid transfer protocol provided both with URI and param 749120fa86aSPrzemyslaw Czarnowski if ((paramTransferProtocolType != std::nullopt) && 750120fa86aSPrzemyslaw Czarnowski (uriTransferProtocolType != std::nullopt)) 751120fa86aSPrzemyslaw Czarnowski { 752120fa86aSPrzemyslaw Czarnowski // check if protocol is the same for URI and param 753120fa86aSPrzemyslaw Czarnowski if (*paramTransferProtocolType != *uriTransferProtocolType) 754120fa86aSPrzemyslaw Czarnowski { 755120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action parameter " 756120fa86aSPrzemyslaw Czarnowski "TransferProtocolType must contain the " 757120fa86aSPrzemyslaw Czarnowski "same protocol type as protocol type " 758120fa86aSPrzemyslaw Czarnowski "provided with param imageUrl."; 759120fa86aSPrzemyslaw Czarnowski 760120fa86aSPrzemyslaw Czarnowski messages::actionParameterValueTypeError( 761120fa86aSPrzemyslaw Czarnowski asyncResp->res, *actionParams.transferProtocolType, 762120fa86aSPrzemyslaw Czarnowski "TransferProtocolType", "InsertMedia"); 763120fa86aSPrzemyslaw Czarnowski 764120fa86aSPrzemyslaw Czarnowski return; 765120fa86aSPrzemyslaw Czarnowski } 766120fa86aSPrzemyslaw Czarnowski } 767120fa86aSPrzemyslaw Czarnowski 768120fa86aSPrzemyslaw Czarnowski // validation passed, add protocol to URI if needed 769120fa86aSPrzemyslaw Czarnowski if (uriTransferProtocolType == std::nullopt) 770120fa86aSPrzemyslaw Czarnowski { 771120fa86aSPrzemyslaw Czarnowski actionParams.imageUrl = getUriWithTransferProtocol( 772120fa86aSPrzemyslaw Czarnowski *actionParams.imageUrl, *paramTransferProtocolType); 773120fa86aSPrzemyslaw Czarnowski } 774120fa86aSPrzemyslaw Czarnowski 775452bd8d8SJayaprakash Mutyala if (!actionParams.userName) 776452bd8d8SJayaprakash Mutyala { 777452bd8d8SJayaprakash Mutyala actionParams.userName = ""; 778452bd8d8SJayaprakash Mutyala } 779452bd8d8SJayaprakash Mutyala 780452bd8d8SJayaprakash Mutyala if (!actionParams.password) 781452bd8d8SJayaprakash Mutyala { 782452bd8d8SJayaprakash Mutyala actionParams.password = ""; 783452bd8d8SJayaprakash Mutyala } 784452bd8d8SJayaprakash Mutyala 785120fa86aSPrzemyslaw Czarnowski doMountVmLegacy(asyncResp, service, resName, *actionParams.imageUrl, 786120fa86aSPrzemyslaw Czarnowski !(*actionParams.writeProtected), 787120fa86aSPrzemyslaw Czarnowski std::move(*actionParams.userName), 788120fa86aSPrzemyslaw Czarnowski std::move(*actionParams.password)); 789120fa86aSPrzemyslaw Czarnowski } 790120fa86aSPrzemyslaw Czarnowski 791120fa86aSPrzemyslaw Czarnowski /** 792e13c2760SPrzemyslaw Czarnowski * @brief Function transceives data with dbus directly. 793e13c2760SPrzemyslaw Czarnowski * 794e13c2760SPrzemyslaw Czarnowski * All BMC state properties will be retrieved before sending reset request. 795e13c2760SPrzemyslaw Czarnowski */ 79624e740a7SEd Tanous inline void doEjectAction(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 797e13c2760SPrzemyslaw Czarnowski const std::string& service, const std::string& name, 798e13c2760SPrzemyslaw Czarnowski bool legacy) 799e13c2760SPrzemyslaw Czarnowski { 800e13c2760SPrzemyslaw Czarnowski // Legacy mount requires parameter with image 801e13c2760SPrzemyslaw Czarnowski if (legacy) 802e13c2760SPrzemyslaw Czarnowski { 803e13c2760SPrzemyslaw Czarnowski crow::connections::systemBus->async_method_call( 8045e7e2dc5SEd Tanous [asyncResp](const boost::system::error_code& ec) { 805e13c2760SPrzemyslaw Czarnowski if (ec) 806e13c2760SPrzemyslaw Czarnowski { 807e13c2760SPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec; 808e13c2760SPrzemyslaw Czarnowski 809e13c2760SPrzemyslaw Czarnowski messages::internalError(asyncResp->res); 810e13c2760SPrzemyslaw Czarnowski return; 811e13c2760SPrzemyslaw Czarnowski } 812e13c2760SPrzemyslaw Czarnowski }, 813e13c2760SPrzemyslaw Czarnowski service, "/xyz/openbmc_project/VirtualMedia/Legacy/" + name, 814e13c2760SPrzemyslaw Czarnowski "xyz.openbmc_project.VirtualMedia.Legacy", "Unmount"); 815e13c2760SPrzemyslaw Czarnowski } 816e13c2760SPrzemyslaw Czarnowski else // proxy 817e13c2760SPrzemyslaw Czarnowski { 818e13c2760SPrzemyslaw Czarnowski crow::connections::systemBus->async_method_call( 8195e7e2dc5SEd Tanous [asyncResp](const boost::system::error_code& ec) { 820e13c2760SPrzemyslaw Czarnowski if (ec) 821e13c2760SPrzemyslaw Czarnowski { 822e13c2760SPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec; 823e13c2760SPrzemyslaw Czarnowski 824e13c2760SPrzemyslaw Czarnowski messages::internalError(asyncResp->res); 825e13c2760SPrzemyslaw Czarnowski return; 826e13c2760SPrzemyslaw Czarnowski } 827e13c2760SPrzemyslaw Czarnowski }, 828e13c2760SPrzemyslaw Czarnowski service, "/xyz/openbmc_project/VirtualMedia/Proxy/" + name, 829e13c2760SPrzemyslaw Czarnowski "xyz.openbmc_project.VirtualMedia.Proxy", "Unmount"); 830e13c2760SPrzemyslaw Czarnowski } 831e13c2760SPrzemyslaw Czarnowski } 832e13c2760SPrzemyslaw Czarnowski 83396825bebSEd Tanous inline void handleManagersVirtualMediaActionInsertPost( 83496825bebSEd Tanous crow::App& app, const crow::Request& req, 83522db1728SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 83696825bebSEd Tanous const std::string& name, const std::string& resName) 83796825bebSEd Tanous { 8383ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 83945ca1b86SEd Tanous { 84045ca1b86SEd Tanous return; 84145ca1b86SEd Tanous } 84279fdf63eSPrzemyslaw Czarnowski 84379fdf63eSPrzemyslaw Czarnowski constexpr std::string_view action = "VirtualMedia.InsertMedia"; 84422db1728SEd Tanous if (name != "bmc") 845107077deSPrzemyslaw Czarnowski { 84679fdf63eSPrzemyslaw Czarnowski messages::resourceNotFound(asyncResp->res, action, resName); 847107077deSPrzemyslaw Czarnowski 848107077deSPrzemyslaw Czarnowski return; 849107077deSPrzemyslaw Czarnowski } 85079fdf63eSPrzemyslaw Czarnowski InsertMediaActionParams actionParams; 85198be3e39SEd Tanous 852120fa86aSPrzemyslaw Czarnowski // Read obligatory parameters (url of image) 85315ed6780SWilly Tu if (!json_util::readJsonAction( 85479fdf63eSPrzemyslaw Czarnowski req, asyncResp->res, "Image", actionParams.imageUrl, 85579fdf63eSPrzemyslaw Czarnowski "WriteProtected", actionParams.writeProtected, "UserName", 85679fdf63eSPrzemyslaw Czarnowski actionParams.userName, "Password", actionParams.password, 85779fdf63eSPrzemyslaw Czarnowski "Inserted", actionParams.inserted, "TransferMethod", 85879fdf63eSPrzemyslaw Czarnowski actionParams.transferMethod, "TransferProtocolType", 85979fdf63eSPrzemyslaw Czarnowski actionParams.transferProtocolType)) 86098be3e39SEd Tanous { 86198be3e39SEd Tanous return; 86298be3e39SEd Tanous } 863107077deSPrzemyslaw Czarnowski 8642b73119cSGeorge Liu dbus::utility::getDbusObject( 8652b73119cSGeorge Liu "/xyz/openbmc_project/VirtualMedia", {}, 86679fdf63eSPrzemyslaw Czarnowski [asyncResp, action, actionParams, 8672b73119cSGeorge Liu resName](const boost::system::error_code& ec, 868002d39b4SEd Tanous const dbus::utility::MapperGetObject& getObjectType) mutable { 86922db1728SEd Tanous if (ec) 87022db1728SEd Tanous { 87196825bebSEd Tanous BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec; 87279fdf63eSPrzemyslaw Czarnowski messages::resourceNotFound(asyncResp->res, action, resName); 873107077deSPrzemyslaw Czarnowski 87422db1728SEd Tanous return; 87522db1728SEd Tanous } 87679fdf63eSPrzemyslaw Czarnowski 87722db1728SEd Tanous std::string service = getObjectType.begin()->first; 87822db1728SEd Tanous BMCWEB_LOG_DEBUG << "GetObjectType: " << service; 87922db1728SEd Tanous 88022db1728SEd Tanous crow::connections::systemBus->async_method_call( 88179fdf63eSPrzemyslaw Czarnowski [service, resName, action, actionParams, 8825e7e2dc5SEd Tanous asyncResp](const boost::system::error_code& ec2, 883002d39b4SEd Tanous dbus::utility::ManagedObjectType& subtree) mutable { 8848a592810SEd Tanous if (ec2) 88522db1728SEd Tanous { 88679fdf63eSPrzemyslaw Czarnowski // Not possible in proxy mode 88779fdf63eSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "InsertMedia not " 88879fdf63eSPrzemyslaw Czarnowski "allowed in proxy mode"; 88979fdf63eSPrzemyslaw Czarnowski messages::resourceNotFound(asyncResp->res, action, resName); 89022db1728SEd Tanous 89122db1728SEd Tanous return; 89222db1728SEd Tanous } 89322db1728SEd Tanous for (const auto& object : subtree) 89422db1728SEd Tanous { 895365a73f4SEd Tanous VmMode mode = parseObjectPathAndGetMode(object.first, resName); 8965880f0c5SBoleslaw Ogonczyk Makowski if (mode == VmMode::Legacy) 89722db1728SEd Tanous { 89879fdf63eSPrzemyslaw Czarnowski validateParams(asyncResp, service, resName, actionParams); 89922db1728SEd Tanous 90022db1728SEd Tanous return; 90122db1728SEd Tanous } 90222db1728SEd Tanous } 90322db1728SEd Tanous BMCWEB_LOG_DEBUG << "Parent item not found"; 90496825bebSEd Tanous messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName); 90522db1728SEd Tanous }, 90622db1728SEd Tanous service, "/xyz/openbmc_project/VirtualMedia", 907002d39b4SEd Tanous "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); 9082b73119cSGeorge Liu }); 90996825bebSEd Tanous } 91022db1728SEd Tanous 91196825bebSEd Tanous inline void handleManagersVirtualMediaActionEject( 91296825bebSEd Tanous crow::App& app, const crow::Request& req, 91322db1728SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 91496825bebSEd Tanous const std::string& managerName, const std::string& resName) 91596825bebSEd Tanous { 9163ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 91745ca1b86SEd Tanous { 91845ca1b86SEd Tanous return; 91945ca1b86SEd Tanous } 92079fdf63eSPrzemyslaw Czarnowski 92179fdf63eSPrzemyslaw Czarnowski constexpr std::string_view action = "VirtualMedia.EjectMedia"; 92296825bebSEd Tanous if (managerName != "bmc") 923107077deSPrzemyslaw Czarnowski { 92479fdf63eSPrzemyslaw Czarnowski messages::resourceNotFound(asyncResp->res, action, resName); 92522db1728SEd Tanous 92622db1728SEd Tanous return; 92722db1728SEd Tanous } 92822db1728SEd Tanous 9292b73119cSGeorge Liu dbus::utility::getDbusObject( 9302b73119cSGeorge Liu "/xyz/openbmc_project/VirtualMedia", {}, 93179fdf63eSPrzemyslaw Czarnowski [asyncResp, action, 9322b73119cSGeorge Liu resName](const boost::system::error_code& ec2, 933b9d36b47SEd Tanous const dbus::utility::MapperGetObject& getObjectType) { 9348a592810SEd Tanous if (ec2) 93522db1728SEd Tanous { 9368a592810SEd Tanous BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec2; 93722db1728SEd Tanous messages::internalError(asyncResp->res); 93822db1728SEd Tanous 93922db1728SEd Tanous return; 94022db1728SEd Tanous } 94122db1728SEd Tanous std::string service = getObjectType.begin()->first; 94222db1728SEd Tanous BMCWEB_LOG_DEBUG << "GetObjectType: " << service; 94322db1728SEd Tanous 94422db1728SEd Tanous crow::connections::systemBus->async_method_call( 94579fdf63eSPrzemyslaw Czarnowski [resName, service, action, 94679fdf63eSPrzemyslaw Czarnowski asyncResp](const boost::system::error_code& ec, 94702cad96eSEd Tanous const dbus::utility::ManagedObjectType& subtree) { 94822db1728SEd Tanous if (ec) 94922db1728SEd Tanous { 95079fdf63eSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "ObjectMapper : No Service found"; 95179fdf63eSPrzemyslaw Czarnowski messages::resourceNotFound(asyncResp->res, action, resName); 95222db1728SEd Tanous return; 95322db1728SEd Tanous } 95422db1728SEd Tanous 95522db1728SEd Tanous for (const auto& object : subtree) 95622db1728SEd Tanous { 957365a73f4SEd Tanous VmMode mode = parseObjectPathAndGetMode(object.first, resName); 958365a73f4SEd Tanous if (mode != VmMode::Invalid) 95922db1728SEd Tanous { 960365a73f4SEd Tanous doEjectAction(asyncResp, service, resName, 961365a73f4SEd Tanous mode == VmMode::Legacy); 9625880f0c5SBoleslaw Ogonczyk Makowski return; 96322db1728SEd Tanous } 96422db1728SEd Tanous } 96522db1728SEd Tanous BMCWEB_LOG_DEBUG << "Parent item not found"; 96696825bebSEd Tanous messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName); 96722db1728SEd Tanous }, 96822db1728SEd Tanous service, "/xyz/openbmc_project/VirtualMedia", 969002d39b4SEd Tanous "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); 9702b73119cSGeorge Liu }); 97196825bebSEd Tanous } 97296825bebSEd Tanous 97396825bebSEd Tanous inline void handleManagersVirtualMediaCollectionGet( 97496825bebSEd Tanous crow::App& app, const crow::Request& req, 97522db1728SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 97696825bebSEd Tanous const std::string& name) 97796825bebSEd Tanous { 9783ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 97945ca1b86SEd Tanous { 98045ca1b86SEd Tanous return; 98145ca1b86SEd Tanous } 98222db1728SEd Tanous if (name != "bmc") 98322db1728SEd Tanous { 984002d39b4SEd Tanous messages::resourceNotFound(asyncResp->res, "VirtualMedia", name); 985107077deSPrzemyslaw Czarnowski 986107077deSPrzemyslaw Czarnowski return; 987107077deSPrzemyslaw Czarnowski } 988107077deSPrzemyslaw Czarnowski 9898d1b46d7Szhanghch05 asyncResp->res.jsonValue["@odata.type"] = 990107077deSPrzemyslaw Czarnowski "#VirtualMediaCollection.VirtualMediaCollection"; 9918d1b46d7Szhanghch05 asyncResp->res.jsonValue["Name"] = "Virtual Media Services"; 992ef4c65b7SEd Tanous asyncResp->res.jsonValue["@odata.id"] = 993ef4c65b7SEd Tanous boost::urls::format("/redfish/v1/Managers/{}/VirtualMedia", name); 994107077deSPrzemyslaw Czarnowski 9952b73119cSGeorge Liu dbus::utility::getDbusObject( 9962b73119cSGeorge Liu "/xyz/openbmc_project/VirtualMedia", {}, 9972b73119cSGeorge Liu [asyncResp, name](const boost::system::error_code& ec, 998b9d36b47SEd Tanous const dbus::utility::MapperGetObject& getObjectType) { 999107077deSPrzemyslaw Czarnowski if (ec) 1000107077deSPrzemyslaw Czarnowski { 100196825bebSEd Tanous BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec; 1002107077deSPrzemyslaw Czarnowski messages::internalError(asyncResp->res); 1003107077deSPrzemyslaw Czarnowski 1004107077deSPrzemyslaw Czarnowski return; 1005107077deSPrzemyslaw Czarnowski } 1006107077deSPrzemyslaw Czarnowski std::string service = getObjectType.begin()->first; 1007107077deSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "GetObjectType: " << service; 1008107077deSPrzemyslaw Czarnowski 1009107077deSPrzemyslaw Czarnowski getVmResourceList(asyncResp, service, name); 10102b73119cSGeorge Liu }); 101196825bebSEd Tanous } 1012107077deSPrzemyslaw Czarnowski 101396825bebSEd Tanous inline void 101496825bebSEd Tanous handleVirtualMediaGet(crow::App& app, const crow::Request& req, 101522db1728SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 101696825bebSEd Tanous const std::string& name, const std::string& resName) 101796825bebSEd Tanous { 10183ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 101945ca1b86SEd Tanous { 102045ca1b86SEd Tanous return; 102145ca1b86SEd Tanous } 1022107077deSPrzemyslaw Czarnowski if (name != "bmc") 1023107077deSPrzemyslaw Czarnowski { 1024002d39b4SEd Tanous messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName); 1025107077deSPrzemyslaw Czarnowski 1026107077deSPrzemyslaw Czarnowski return; 1027107077deSPrzemyslaw Czarnowski } 1028107077deSPrzemyslaw Czarnowski 10292b73119cSGeorge Liu dbus::utility::getDbusObject( 10302b73119cSGeorge Liu "/xyz/openbmc_project/VirtualMedia", {}, 1031002d39b4SEd Tanous [asyncResp, name, 10322b73119cSGeorge Liu resName](const boost::system::error_code& ec, 1033b9d36b47SEd Tanous const dbus::utility::MapperGetObject& getObjectType) { 1034107077deSPrzemyslaw Czarnowski if (ec) 1035107077deSPrzemyslaw Czarnowski { 103696825bebSEd Tanous BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec; 1037107077deSPrzemyslaw Czarnowski messages::internalError(asyncResp->res); 1038107077deSPrzemyslaw Czarnowski 1039107077deSPrzemyslaw Czarnowski return; 1040107077deSPrzemyslaw Czarnowski } 1041107077deSPrzemyslaw Czarnowski std::string service = getObjectType.begin()->first; 1042107077deSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "GetObjectType: " << service; 1043107077deSPrzemyslaw Czarnowski 1044107077deSPrzemyslaw Czarnowski getVmData(asyncResp, service, name, resName); 10452b73119cSGeorge Liu }); 104696825bebSEd Tanous } 104796825bebSEd Tanous 104896825bebSEd Tanous inline void requestNBDVirtualMediaRoutes(App& app) 104996825bebSEd Tanous { 105096825bebSEd Tanous BMCWEB_ROUTE( 105196825bebSEd Tanous app, 105296825bebSEd Tanous "/redfish/v1/Managers/<str>/VirtualMedia/<str>/Actions/VirtualMedia.InsertMedia") 105396825bebSEd Tanous .privileges(redfish::privileges::postVirtualMedia) 105496825bebSEd Tanous .methods(boost::beast::http::verb::post)(std::bind_front( 105596825bebSEd Tanous handleManagersVirtualMediaActionInsertPost, std::ref(app))); 105696825bebSEd Tanous 105796825bebSEd Tanous BMCWEB_ROUTE( 105896825bebSEd Tanous app, 105996825bebSEd Tanous "/redfish/v1/Managers/<str>/VirtualMedia/<str>/Actions/VirtualMedia.EjectMedia") 106096825bebSEd Tanous .privileges(redfish::privileges::postVirtualMedia) 106196825bebSEd Tanous .methods(boost::beast::http::verb::post)(std::bind_front( 106296825bebSEd Tanous handleManagersVirtualMediaActionEject, std::ref(app))); 106396825bebSEd Tanous 106496825bebSEd Tanous BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/VirtualMedia/") 106596825bebSEd Tanous .privileges(redfish::privileges::getVirtualMediaCollection) 106696825bebSEd Tanous .methods(boost::beast::http::verb::get)(std::bind_front( 106796825bebSEd Tanous handleManagersVirtualMediaCollectionGet, std::ref(app))); 106896825bebSEd Tanous 106996825bebSEd Tanous BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/VirtualMedia/<str>/") 107096825bebSEd Tanous .privileges(redfish::privileges::getVirtualMedia) 107196825bebSEd Tanous .methods(boost::beast::http::verb::get)( 107296825bebSEd Tanous std::bind_front(handleVirtualMediaGet, std::ref(app))); 1073107077deSPrzemyslaw Czarnowski } 1074107077deSPrzemyslaw Czarnowski 1075107077deSPrzemyslaw Czarnowski } // namespace redfish 1076