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 9279fdf63eSPrzemyslaw Czarnowski inline void findAndParseObject(const std::string& service, 9379fdf63eSPrzemyslaw Czarnowski const std::string& resName, 9479fdf63eSPrzemyslaw Czarnowski const std::shared_ptr<bmcweb::AsyncResp>& aResp, 9579fdf63eSPrzemyslaw Czarnowski CheckItemHandler&& handler) 9679fdf63eSPrzemyslaw Czarnowski { 9779fdf63eSPrzemyslaw Czarnowski crow::connections::systemBus->async_method_call( 9879fdf63eSPrzemyslaw Czarnowski [service, resName, aResp, 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 { 11379fdf63eSPrzemyslaw Czarnowski handler(service, resName, aResp, item); 11479fdf63eSPrzemyslaw Czarnowski return; 11579fdf63eSPrzemyslaw Czarnowski } 11679fdf63eSPrzemyslaw Czarnowski } 11779fdf63eSPrzemyslaw Czarnowski 11879fdf63eSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "Parent item not found"; 11979fdf63eSPrzemyslaw Czarnowski aResp->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, 1548d1b46d7Szhanghch05 const std::shared_ptr<bmcweb::AsyncResp>& aResp) 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 173711ac7a9SEd Tanous aResp->res 174711ac7a9SEd Tanous .jsonValue["Oem"]["OpenBMC"]["WebSocketEndpoint"] = 175d04ba325SPrzemyslaw Czarnowski *endpointIdValue; 176107077deSPrzemyslaw Czarnowski aResp->res.jsonValue["TransferProtocolType"] = "OEM"; 177107077deSPrzemyslaw Czarnowski } 178107077deSPrzemyslaw Czarnowski } 179711ac7a9SEd Tanous if (property == "ImageURL") 180107077deSPrzemyslaw Czarnowski { 181107077deSPrzemyslaw Czarnowski const std::string* imageUrlValue = 182711ac7a9SEd Tanous std::get_if<std::string>(&value); 18326f6976fSEd Tanous if (imageUrlValue != nullptr && !imageUrlValue->empty()) 184107077deSPrzemyslaw Czarnowski { 185da4784d8SPrzemyslaw Czarnowski std::filesystem::path filePath = *imageUrlValue; 186da4784d8SPrzemyslaw Czarnowski if (!filePath.has_filename()) 187da4784d8SPrzemyslaw Czarnowski { 1889e319cf0SAnna Platash // this will handle https share, which not 1899e319cf0SAnna Platash // necessarily has to have filename given. 190da4784d8SPrzemyslaw Czarnowski aResp->res.jsonValue["ImageName"] = ""; 191da4784d8SPrzemyslaw Czarnowski } 192da4784d8SPrzemyslaw Czarnowski else 193da4784d8SPrzemyslaw Czarnowski { 1949e319cf0SAnna Platash aResp->res.jsonValue["ImageName"] = 1959e319cf0SAnna Platash filePath.filename(); 196da4784d8SPrzemyslaw Czarnowski } 197da4784d8SPrzemyslaw Czarnowski 198da4784d8SPrzemyslaw Czarnowski aResp->res.jsonValue["Image"] = *imageUrlValue; 1999e319cf0SAnna Platash aResp->res.jsonValue["TransferProtocolType"] = 2009e319cf0SAnna Platash getTransferProtocolTypeFromUri(*imageUrlValue); 2019e319cf0SAnna Platash 202739b87efSEd Tanous aResp->res.jsonValue["ConnectedVia"] = 203739b87efSEd Tanous virtual_media::ConnectedVia::URI; 204107077deSPrzemyslaw Czarnowski } 205107077deSPrzemyslaw Czarnowski } 206711ac7a9SEd Tanous if (property == "WriteProtected") 2079e319cf0SAnna Platash { 208711ac7a9SEd Tanous const bool* writeProtectedValue = std::get_if<bool>(&value); 209e662eae8SEd Tanous if (writeProtectedValue != nullptr) 2109e319cf0SAnna Platash { 2119e319cf0SAnna Platash aResp->res.jsonValue["WriteProtected"] = 2129e319cf0SAnna Platash *writeProtectedValue; 2139e319cf0SAnna Platash } 2149e319cf0SAnna Platash } 2159e319cf0SAnna Platash } 216107077deSPrzemyslaw Czarnowski } 217711ac7a9SEd Tanous if (interface == "xyz.openbmc_project.VirtualMedia.Process") 218711ac7a9SEd Tanous { 219711ac7a9SEd Tanous for (const auto& [property, value] : values) 220711ac7a9SEd Tanous { 221711ac7a9SEd Tanous if (property == "Active") 222711ac7a9SEd Tanous { 223711ac7a9SEd Tanous const bool* activeValue = std::get_if<bool>(&value); 224e662eae8SEd Tanous if (activeValue == nullptr) 225711ac7a9SEd Tanous { 226711ac7a9SEd Tanous BMCWEB_LOG_DEBUG << "Value Active not found"; 227711ac7a9SEd Tanous return; 228711ac7a9SEd Tanous } 229711ac7a9SEd Tanous aResp->res.jsonValue["Inserted"] = *activeValue; 230711ac7a9SEd Tanous 231e05aec50SEd Tanous if (*activeValue) 232711ac7a9SEd Tanous { 233739b87efSEd Tanous aResp->res.jsonValue["ConnectedVia"] = 234739b87efSEd Tanous virtual_media::ConnectedVia::Applet; 235711ac7a9SEd Tanous } 236711ac7a9SEd Tanous } 237711ac7a9SEd Tanous } 238711ac7a9SEd Tanous } 239107077deSPrzemyslaw Czarnowski } 240107077deSPrzemyslaw Czarnowski } 241107077deSPrzemyslaw Czarnowski 242107077deSPrzemyslaw Czarnowski /** 243107077deSPrzemyslaw Czarnowski * @brief Fill template for Virtual Media Item. 244107077deSPrzemyslaw Czarnowski */ 24522db1728SEd Tanous inline nlohmann::json vmItemTemplate(const std::string& name, 246107077deSPrzemyslaw Czarnowski const std::string& resName) 247107077deSPrzemyslaw Czarnowski { 248107077deSPrzemyslaw Czarnowski nlohmann::json item; 249ef4c65b7SEd Tanous item["@odata.id"] = boost::urls::format( 250ef4c65b7SEd Tanous "/redfish/v1/Managers/{}/VirtualMedia/{}", name, resName); 25122db1728SEd Tanous 252d04ba325SPrzemyslaw Czarnowski item["@odata.type"] = "#VirtualMedia.v1_3_0.VirtualMedia"; 253107077deSPrzemyslaw Czarnowski item["Name"] = "Virtual Removable Media"; 254107077deSPrzemyslaw Czarnowski item["Id"] = resName; 255107077deSPrzemyslaw Czarnowski item["WriteProtected"] = true; 256739b87efSEd Tanous item["ConnectedVia"] = virtual_media::ConnectedVia::NotConnected; 257613dabeaSEd Tanous item["MediaTypes"] = nlohmann::json::array_t({"CD", "USBStick"}); 258107077deSPrzemyslaw Czarnowski item["TransferMethod"] = "Stream"; 259d04ba325SPrzemyslaw Czarnowski item["Oem"]["OpenBMC"]["@odata.type"] = 260d04ba325SPrzemyslaw Czarnowski "#OemVirtualMedia.v1_0_0.VirtualMedia"; 261*15b89725SV-Sanjana item["Oem"]["OpenBMC"]["@odata.id"] = boost::urls::format( 262*15b89725SV-Sanjana "/redfish/v1/Managers/{}/VirtualMedia/{}#/Oem/OpenBMC", name, resName); 263107077deSPrzemyslaw Czarnowski 264107077deSPrzemyslaw Czarnowski return item; 265107077deSPrzemyslaw Czarnowski } 266107077deSPrzemyslaw Czarnowski 267107077deSPrzemyslaw Czarnowski /** 268107077deSPrzemyslaw Czarnowski * @brief Fills collection data 269107077deSPrzemyslaw Czarnowski */ 27022db1728SEd Tanous inline void getVmResourceList(std::shared_ptr<bmcweb::AsyncResp> aResp, 271107077deSPrzemyslaw Czarnowski const std::string& service, 272107077deSPrzemyslaw Czarnowski const std::string& name) 273107077deSPrzemyslaw Czarnowski { 274107077deSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "Get available Virtual Media resources."; 275107077deSPrzemyslaw Czarnowski crow::connections::systemBus->async_method_call( 27602cad96eSEd Tanous [name, aResp{std::move(aResp)}]( 2775e7e2dc5SEd Tanous const boost::system::error_code& ec, 27802cad96eSEd Tanous const dbus::utility::ManagedObjectType& subtree) { 279107077deSPrzemyslaw Czarnowski if (ec) 280107077deSPrzemyslaw Czarnowski { 281107077deSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "DBUS response error"; 282107077deSPrzemyslaw Czarnowski return; 283107077deSPrzemyslaw Czarnowski } 284107077deSPrzemyslaw Czarnowski nlohmann::json& members = aResp->res.jsonValue["Members"]; 285107077deSPrzemyslaw Czarnowski members = nlohmann::json::array(); 286107077deSPrzemyslaw Czarnowski 287107077deSPrzemyslaw Czarnowski for (const auto& object : subtree) 288107077deSPrzemyslaw Czarnowski { 289107077deSPrzemyslaw Czarnowski nlohmann::json item; 2902dfd18efSEd Tanous std::string path = object.first.filename(); 2912dfd18efSEd Tanous if (path.empty()) 292107077deSPrzemyslaw Czarnowski { 293107077deSPrzemyslaw Czarnowski continue; 294107077deSPrzemyslaw Czarnowski } 295107077deSPrzemyslaw Czarnowski 296ef4c65b7SEd Tanous item["@odata.id"] = boost::urls::format( 297ef4c65b7SEd Tanous "/redfish/v1/Managers/{}/VirtualMedia/{}", name, path); 298107077deSPrzemyslaw Czarnowski members.emplace_back(std::move(item)); 299107077deSPrzemyslaw Czarnowski } 300107077deSPrzemyslaw Czarnowski aResp->res.jsonValue["Members@odata.count"] = members.size(); 301107077deSPrzemyslaw Czarnowski }, 302107077deSPrzemyslaw Czarnowski service, "/xyz/openbmc_project/VirtualMedia", 303107077deSPrzemyslaw Czarnowski "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); 304107077deSPrzemyslaw Czarnowski } 305107077deSPrzemyslaw Czarnowski 30670cbdf53SGeorge Liu inline void 30770cbdf53SGeorge Liu afterGetVmData(const std::string& name, const std::string& /*service*/, 30879fdf63eSPrzemyslaw Czarnowski const std::string& resName, 30979fdf63eSPrzemyslaw Czarnowski const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 31070cbdf53SGeorge Liu const std::pair<sdbusplus::message::object_path, 31179fdf63eSPrzemyslaw Czarnowski dbus::utility::DBusInteracesMap>& item) 31279fdf63eSPrzemyslaw Czarnowski { 31379fdf63eSPrzemyslaw Czarnowski VmMode mode = parseObjectPathAndGetMode(item.first, resName); 31479fdf63eSPrzemyslaw Czarnowski if (mode == VmMode::Invalid) 31579fdf63eSPrzemyslaw Czarnowski { 31679fdf63eSPrzemyslaw Czarnowski return; 31779fdf63eSPrzemyslaw Czarnowski } 31879fdf63eSPrzemyslaw Czarnowski 31979fdf63eSPrzemyslaw Czarnowski asyncResp->res.jsonValue = vmItemTemplate(name, resName); 32079fdf63eSPrzemyslaw Czarnowski 32179fdf63eSPrzemyslaw Czarnowski // Check if dbus path is Legacy type 32279fdf63eSPrzemyslaw Czarnowski if (mode == VmMode::Legacy) 32379fdf63eSPrzemyslaw Czarnowski { 324ef4c65b7SEd Tanous asyncResp->res.jsonValue["Actions"]["#VirtualMedia.InsertMedia"] 325ef4c65b7SEd Tanous ["target"] = boost::urls::format( 326ef4c65b7SEd Tanous "/redfish/v1/Managers/{}/VirtualMedia/{}/Actions/VirtualMedia.InsertMedia", 327ef4c65b7SEd Tanous name, resName); 32879fdf63eSPrzemyslaw Czarnowski } 32979fdf63eSPrzemyslaw Czarnowski 33079fdf63eSPrzemyslaw Czarnowski vmParseInterfaceObject(item.second, asyncResp); 33179fdf63eSPrzemyslaw Czarnowski 332ef4c65b7SEd Tanous asyncResp->res.jsonValue["Actions"]["#VirtualMedia.EjectMedia"] 333ef4c65b7SEd Tanous ["target"] = boost::urls::format( 334ef4c65b7SEd Tanous "/redfish/v1/Managers/{}/VirtualMedia/{}/Actions/VirtualMedia.EjectMedia", 335ef4c65b7SEd Tanous name, resName); 33679fdf63eSPrzemyslaw Czarnowski } 33779fdf63eSPrzemyslaw Czarnowski 338107077deSPrzemyslaw Czarnowski /** 339107077deSPrzemyslaw Czarnowski * @brief Fills data for specific resource 340107077deSPrzemyslaw Czarnowski */ 34122db1728SEd Tanous inline void getVmData(const std::shared_ptr<bmcweb::AsyncResp>& aResp, 342107077deSPrzemyslaw Czarnowski const std::string& service, const std::string& name, 343107077deSPrzemyslaw Czarnowski const std::string& resName) 344107077deSPrzemyslaw Czarnowski { 345107077deSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "Get Virtual Media resource data."; 346107077deSPrzemyslaw Czarnowski 34779fdf63eSPrzemyslaw Czarnowski findAndParseObject(service, resName, aResp, 34870cbdf53SGeorge Liu std::bind_front(afterGetVmData, name)); 349107077deSPrzemyslaw Czarnowski } 350107077deSPrzemyslaw Czarnowski 351e13c2760SPrzemyslaw Czarnowski /** 352c6f4e017SAgata Olender * @brief Transfer protocols supported for InsertMedia action. 353c6f4e017SAgata Olender * 354c6f4e017SAgata Olender */ 355c6f4e017SAgata Olender enum class TransferProtocol 356c6f4e017SAgata Olender { 357c6f4e017SAgata Olender https, 358c6f4e017SAgata Olender smb, 359c6f4e017SAgata Olender invalid 360c6f4e017SAgata Olender }; 361c6f4e017SAgata Olender 362c6f4e017SAgata Olender /** 363c6f4e017SAgata Olender * @brief Function extracts transfer protocol type from URI. 364c6f4e017SAgata Olender * 365c6f4e017SAgata Olender */ 36667df073bSEd Tanous inline std::optional<TransferProtocol> 367d9f466b3SEd Tanous getTransferProtocolFromUri(boost::urls::url_view imageUri) 36867df073bSEd Tanous { 369079360aeSEd Tanous std::string_view scheme = imageUri.scheme(); 37067df073bSEd Tanous if (scheme == "smb") 37167df073bSEd Tanous { 37267df073bSEd Tanous return TransferProtocol::smb; 37367df073bSEd Tanous } 37467df073bSEd Tanous if (scheme == "https") 37567df073bSEd Tanous { 37667df073bSEd Tanous return TransferProtocol::https; 37767df073bSEd Tanous } 37867df073bSEd Tanous if (!scheme.empty()) 37967df073bSEd Tanous { 38067df073bSEd Tanous return TransferProtocol::invalid; 38167df073bSEd Tanous } 38267df073bSEd Tanous 38367df073bSEd Tanous return {}; 38467df073bSEd Tanous } 385c6f4e017SAgata Olender 386c6f4e017SAgata Olender /** 387c6f4e017SAgata Olender * @brief Function convert transfer protocol from string param. 388c6f4e017SAgata Olender * 389c6f4e017SAgata Olender */ 39022db1728SEd Tanous inline std::optional<TransferProtocol> getTransferProtocolFromParam( 391c6f4e017SAgata Olender const std::optional<std::string>& transferProtocolType) 392c6f4e017SAgata Olender { 393c6f4e017SAgata Olender if (transferProtocolType == std::nullopt) 394c6f4e017SAgata Olender { 395c6f4e017SAgata Olender return {}; 396c6f4e017SAgata Olender } 397c6f4e017SAgata Olender 398c6f4e017SAgata Olender if (*transferProtocolType == "CIFS") 399c6f4e017SAgata Olender { 400c6f4e017SAgata Olender return TransferProtocol::smb; 401c6f4e017SAgata Olender } 402c6f4e017SAgata Olender 403c6f4e017SAgata Olender if (*transferProtocolType == "HTTPS") 404c6f4e017SAgata Olender { 405c6f4e017SAgata Olender return TransferProtocol::https; 406c6f4e017SAgata Olender } 407c6f4e017SAgata Olender 408c6f4e017SAgata Olender return TransferProtocol::invalid; 409c6f4e017SAgata Olender } 410c6f4e017SAgata Olender 411c6f4e017SAgata Olender /** 412c6f4e017SAgata Olender * @brief Function extends URI with transfer protocol type. 413c6f4e017SAgata Olender * 414c6f4e017SAgata Olender */ 41522db1728SEd Tanous inline std::string 416c6f4e017SAgata Olender getUriWithTransferProtocol(const std::string& imageUri, 417c6f4e017SAgata Olender const TransferProtocol& transferProtocol) 418c6f4e017SAgata Olender { 419c6f4e017SAgata Olender if (transferProtocol == TransferProtocol::smb) 420c6f4e017SAgata Olender { 421c6f4e017SAgata Olender return "smb://" + imageUri; 422c6f4e017SAgata Olender } 423c6f4e017SAgata Olender 424c6f4e017SAgata Olender if (transferProtocol == TransferProtocol::https) 425c6f4e017SAgata Olender { 426c6f4e017SAgata Olender return "https://" + imageUri; 427c6f4e017SAgata Olender } 428c6f4e017SAgata Olender 429c6f4e017SAgata Olender return imageUri; 430c6f4e017SAgata Olender } 431c6f4e017SAgata Olender 4321f2a40ceSPrzemyslaw Czarnowski struct InsertMediaActionParams 4331f2a40ceSPrzemyslaw Czarnowski { 434120fa86aSPrzemyslaw Czarnowski std::optional<std::string> imageUrl; 4351f2a40ceSPrzemyslaw Czarnowski std::optional<std::string> userName; 4361f2a40ceSPrzemyslaw Czarnowski std::optional<std::string> password; 4371f2a40ceSPrzemyslaw Czarnowski std::optional<std::string> transferMethod; 4381f2a40ceSPrzemyslaw Czarnowski std::optional<std::string> transferProtocolType; 4391f2a40ceSPrzemyslaw Czarnowski std::optional<bool> writeProtected = true; 4401f2a40ceSPrzemyslaw Czarnowski std::optional<bool> inserted; 4411f2a40ceSPrzemyslaw Czarnowski }; 4421f2a40ceSPrzemyslaw Czarnowski 4431214b7e7SGunnar Mills template <typename T> 4441214b7e7SGunnar Mills static void secureCleanup(T& value) 445988fb7b2SAdrian Ambrożewicz { 4464ecc618fSEd Tanous // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) 447988fb7b2SAdrian Ambrożewicz auto raw = const_cast<typename T::value_type*>(value.data()); 448988fb7b2SAdrian Ambrożewicz explicit_bzero(raw, value.size() * sizeof(*raw)); 449988fb7b2SAdrian Ambrożewicz } 450988fb7b2SAdrian Ambrożewicz 451988fb7b2SAdrian Ambrożewicz class Credentials 452988fb7b2SAdrian Ambrożewicz { 453988fb7b2SAdrian Ambrożewicz public: 454988fb7b2SAdrian Ambrożewicz Credentials(std::string&& user, std::string&& password) : 455988fb7b2SAdrian Ambrożewicz userBuf(std::move(user)), passBuf(std::move(password)) 4561214b7e7SGunnar Mills {} 457988fb7b2SAdrian Ambrożewicz 458988fb7b2SAdrian Ambrożewicz ~Credentials() 459988fb7b2SAdrian Ambrożewicz { 460988fb7b2SAdrian Ambrożewicz secureCleanup(userBuf); 461988fb7b2SAdrian Ambrożewicz secureCleanup(passBuf); 462988fb7b2SAdrian Ambrożewicz } 463988fb7b2SAdrian Ambrożewicz 464988fb7b2SAdrian Ambrożewicz const std::string& user() 465988fb7b2SAdrian Ambrożewicz { 466988fb7b2SAdrian Ambrożewicz return userBuf; 467988fb7b2SAdrian Ambrożewicz } 468988fb7b2SAdrian Ambrożewicz 469988fb7b2SAdrian Ambrożewicz const std::string& password() 470988fb7b2SAdrian Ambrożewicz { 471988fb7b2SAdrian Ambrożewicz return passBuf; 472988fb7b2SAdrian Ambrożewicz } 473988fb7b2SAdrian Ambrożewicz 474988fb7b2SAdrian Ambrożewicz Credentials() = delete; 475988fb7b2SAdrian Ambrożewicz Credentials(const Credentials&) = delete; 476988fb7b2SAdrian Ambrożewicz Credentials& operator=(const Credentials&) = delete; 477ecd6a3a2SEd Tanous Credentials(Credentials&&) = delete; 478ecd6a3a2SEd Tanous Credentials& operator=(Credentials&&) = delete; 479988fb7b2SAdrian Ambrożewicz 48022db1728SEd Tanous private: 481988fb7b2SAdrian Ambrożewicz std::string userBuf; 482988fb7b2SAdrian Ambrożewicz std::string passBuf; 483988fb7b2SAdrian Ambrożewicz }; 484988fb7b2SAdrian Ambrożewicz 485988fb7b2SAdrian Ambrożewicz class CredentialsProvider 486988fb7b2SAdrian Ambrożewicz { 487988fb7b2SAdrian Ambrożewicz public: 4881214b7e7SGunnar Mills template <typename T> 4891214b7e7SGunnar Mills struct Deleter 490988fb7b2SAdrian Ambrożewicz { 491988fb7b2SAdrian Ambrożewicz void operator()(T* buff) const 492988fb7b2SAdrian Ambrożewicz { 493988fb7b2SAdrian Ambrożewicz if (buff) 494988fb7b2SAdrian Ambrożewicz { 495988fb7b2SAdrian Ambrożewicz secureCleanup(*buff); 496988fb7b2SAdrian Ambrożewicz delete buff; 497988fb7b2SAdrian Ambrożewicz } 498988fb7b2SAdrian Ambrożewicz } 499988fb7b2SAdrian Ambrożewicz }; 500988fb7b2SAdrian Ambrożewicz 501988fb7b2SAdrian Ambrożewicz using Buffer = std::vector<char>; 502988fb7b2SAdrian Ambrożewicz using SecureBuffer = std::unique_ptr<Buffer, Deleter<Buffer>>; 503988fb7b2SAdrian Ambrożewicz // Using explicit definition instead of std::function to avoid implicit 504988fb7b2SAdrian Ambrożewicz // conversions eg. stack copy instead of reference 505988fb7b2SAdrian Ambrożewicz using FormatterFunc = void(const std::string& username, 506988fb7b2SAdrian Ambrożewicz const std::string& password, Buffer& dest); 507988fb7b2SAdrian Ambrożewicz 508988fb7b2SAdrian Ambrożewicz CredentialsProvider(std::string&& user, std::string&& password) : 509988fb7b2SAdrian Ambrożewicz credentials(std::move(user), std::move(password)) 5101214b7e7SGunnar Mills {} 511988fb7b2SAdrian Ambrożewicz 512988fb7b2SAdrian Ambrożewicz const std::string& user() 513988fb7b2SAdrian Ambrożewicz { 514988fb7b2SAdrian Ambrożewicz return credentials.user(); 515988fb7b2SAdrian Ambrożewicz } 516988fb7b2SAdrian Ambrożewicz 517988fb7b2SAdrian Ambrożewicz const std::string& password() 518988fb7b2SAdrian Ambrożewicz { 519988fb7b2SAdrian Ambrożewicz return credentials.password(); 520988fb7b2SAdrian Ambrożewicz } 521988fb7b2SAdrian Ambrożewicz 5221917ee95SEd Tanous SecureBuffer pack(FormatterFunc* formatter) 523988fb7b2SAdrian Ambrożewicz { 524988fb7b2SAdrian Ambrożewicz SecureBuffer packed{new Buffer{}}; 525e662eae8SEd Tanous if (formatter != nullptr) 526988fb7b2SAdrian Ambrożewicz { 527988fb7b2SAdrian Ambrożewicz formatter(credentials.user(), credentials.password(), *packed); 528988fb7b2SAdrian Ambrożewicz } 529988fb7b2SAdrian Ambrożewicz 530988fb7b2SAdrian Ambrożewicz return packed; 531988fb7b2SAdrian Ambrożewicz } 532988fb7b2SAdrian Ambrożewicz 533988fb7b2SAdrian Ambrożewicz private: 534988fb7b2SAdrian Ambrożewicz Credentials credentials; 535988fb7b2SAdrian Ambrożewicz }; 536988fb7b2SAdrian Ambrożewicz 537988fb7b2SAdrian Ambrożewicz // Wrapper for boost::async_pipe ensuring proper pipe cleanup 5380a48306bSEd Tanous class SecurePipe 539988fb7b2SAdrian Ambrożewicz { 540988fb7b2SAdrian Ambrożewicz public: 541988fb7b2SAdrian Ambrożewicz using unix_fd = sdbusplus::message::unix_fd; 542988fb7b2SAdrian Ambrożewicz 5430a48306bSEd Tanous SecurePipe(boost::asio::io_context& io, 5440a48306bSEd Tanous CredentialsProvider::SecureBuffer&& bufferIn) : 5450a48306bSEd Tanous impl(io), 5460a48306bSEd Tanous buffer{std::move(bufferIn)} 5471214b7e7SGunnar Mills {} 548988fb7b2SAdrian Ambrożewicz 5490a48306bSEd Tanous ~SecurePipe() 550988fb7b2SAdrian Ambrożewicz { 551988fb7b2SAdrian Ambrożewicz // Named pipe needs to be explicitly removed 552988fb7b2SAdrian Ambrożewicz impl.close(); 553988fb7b2SAdrian Ambrożewicz } 554988fb7b2SAdrian Ambrożewicz 5550a48306bSEd Tanous SecurePipe(const SecurePipe&) = delete; 5560a48306bSEd Tanous SecurePipe(SecurePipe&&) = delete; 5570a48306bSEd Tanous SecurePipe& operator=(const SecurePipe&) = delete; 5580a48306bSEd Tanous SecurePipe& operator=(SecurePipe&&) = delete; 559ecd6a3a2SEd Tanous 5600a48306bSEd Tanous unix_fd fd() const 561988fb7b2SAdrian Ambrożewicz { 562988fb7b2SAdrian Ambrożewicz return unix_fd{impl.native_source()}; 563988fb7b2SAdrian Ambrożewicz } 564988fb7b2SAdrian Ambrożewicz 565988fb7b2SAdrian Ambrożewicz template <typename WriteHandler> 56681ce609eSEd Tanous void asyncWrite(WriteHandler&& handler) 567988fb7b2SAdrian Ambrożewicz { 5680a48306bSEd Tanous impl.async_write_some(boost::asio::buffer(*buffer), 5690a48306bSEd Tanous std::forward<WriteHandler>(handler)); 570988fb7b2SAdrian Ambrożewicz } 571988fb7b2SAdrian Ambrożewicz 572988fb7b2SAdrian Ambrożewicz const std::string name; 573988fb7b2SAdrian Ambrożewicz boost::process::async_pipe impl; 5740a48306bSEd Tanous CredentialsProvider::SecureBuffer buffer; 575988fb7b2SAdrian Ambrożewicz }; 576988fb7b2SAdrian Ambrożewicz 577e13c2760SPrzemyslaw Czarnowski /** 578e13c2760SPrzemyslaw Czarnowski * @brief Function transceives data with dbus directly. 579e13c2760SPrzemyslaw Czarnowski * 580e13c2760SPrzemyslaw Czarnowski * All BMC state properties will be retrieved before sending reset request. 581e13c2760SPrzemyslaw Czarnowski */ 58222db1728SEd Tanous inline void doMountVmLegacy(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 583e13c2760SPrzemyslaw Czarnowski const std::string& service, const std::string& name, 584988fb7b2SAdrian Ambrożewicz const std::string& imageUrl, const bool rw, 585988fb7b2SAdrian Ambrożewicz std::string&& userName, std::string&& password) 586e13c2760SPrzemyslaw Czarnowski { 587988fb7b2SAdrian Ambrożewicz constexpr const size_t secretLimit = 1024; 588988fb7b2SAdrian Ambrożewicz 589988fb7b2SAdrian Ambrożewicz std::shared_ptr<SecurePipe> secretPipe; 590168e20c1SEd Tanous dbus::utility::DbusVariantType unixFd = -1; 591988fb7b2SAdrian Ambrożewicz 592988fb7b2SAdrian Ambrożewicz if (!userName.empty() || !password.empty()) 593988fb7b2SAdrian Ambrożewicz { 594988fb7b2SAdrian Ambrożewicz // Encapsulate in safe buffer 595988fb7b2SAdrian Ambrożewicz CredentialsProvider credentials(std::move(userName), 596988fb7b2SAdrian Ambrożewicz std::move(password)); 597988fb7b2SAdrian Ambrożewicz 598988fb7b2SAdrian Ambrożewicz // Payload must contain data + NULL delimiters 599988fb7b2SAdrian Ambrożewicz if (credentials.user().size() + credentials.password().size() + 2 > 600988fb7b2SAdrian Ambrożewicz secretLimit) 601988fb7b2SAdrian Ambrożewicz { 602988fb7b2SAdrian Ambrożewicz BMCWEB_LOG_ERROR << "Credentials too long to handle"; 603988fb7b2SAdrian Ambrożewicz messages::unrecognizedRequestBody(asyncResp->res); 604988fb7b2SAdrian Ambrożewicz return; 605988fb7b2SAdrian Ambrożewicz } 606988fb7b2SAdrian Ambrożewicz 607988fb7b2SAdrian Ambrożewicz // Pack secret 60822db1728SEd Tanous auto secret = credentials.pack( 60922db1728SEd Tanous [](const auto& user, const auto& pass, auto& buff) { 610988fb7b2SAdrian Ambrożewicz std::copy(user.begin(), user.end(), std::back_inserter(buff)); 611988fb7b2SAdrian Ambrożewicz buff.push_back('\0'); 612988fb7b2SAdrian Ambrożewicz std::copy(pass.begin(), pass.end(), std::back_inserter(buff)); 613988fb7b2SAdrian Ambrożewicz buff.push_back('\0'); 614988fb7b2SAdrian Ambrożewicz }); 615988fb7b2SAdrian Ambrożewicz 616988fb7b2SAdrian Ambrożewicz // Open pipe 617988fb7b2SAdrian Ambrożewicz secretPipe = std::make_shared<SecurePipe>( 61822db1728SEd Tanous crow::connections::systemBus->get_io_context(), std::move(secret)); 619988fb7b2SAdrian Ambrożewicz unixFd = secretPipe->fd(); 620988fb7b2SAdrian Ambrożewicz 621988fb7b2SAdrian Ambrożewicz // Pass secret over pipe 62281ce609eSEd Tanous secretPipe->asyncWrite( 623f5b16f03SVikram Bodireddy [asyncResp](const boost::system::error_code& ec, std::size_t) { 624988fb7b2SAdrian Ambrożewicz if (ec) 625988fb7b2SAdrian Ambrożewicz { 626988fb7b2SAdrian Ambrożewicz BMCWEB_LOG_ERROR << "Failed to pass secret: " << ec; 627988fb7b2SAdrian Ambrożewicz messages::internalError(asyncResp->res); 628988fb7b2SAdrian Ambrożewicz } 629988fb7b2SAdrian Ambrożewicz }); 630988fb7b2SAdrian Ambrożewicz } 631988fb7b2SAdrian Ambrożewicz 632e13c2760SPrzemyslaw Czarnowski crow::connections::systemBus->async_method_call( 6335e7e2dc5SEd Tanous [asyncResp, secretPipe](const boost::system::error_code& ec, 634988fb7b2SAdrian Ambrożewicz bool success) { 635e13c2760SPrzemyslaw Czarnowski if (ec) 636e13c2760SPrzemyslaw Czarnowski { 637e13c2760SPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec; 638e13c2760SPrzemyslaw Czarnowski messages::internalError(asyncResp->res); 639d6da5bebSAdrian Ambrożewicz } 640d6da5bebSAdrian Ambrożewicz else if (!success) 641d6da5bebSAdrian Ambrożewicz { 642d6da5bebSAdrian Ambrożewicz BMCWEB_LOG_ERROR << "Service responded with error"; 643d6da5bebSAdrian Ambrożewicz messages::generalError(asyncResp->res); 644e13c2760SPrzemyslaw Czarnowski } 645e13c2760SPrzemyslaw Czarnowski }, 646e13c2760SPrzemyslaw Czarnowski service, "/xyz/openbmc_project/VirtualMedia/Legacy/" + name, 647988fb7b2SAdrian Ambrożewicz "xyz.openbmc_project.VirtualMedia.Legacy", "Mount", imageUrl, rw, 648988fb7b2SAdrian Ambrożewicz unixFd); 649e13c2760SPrzemyslaw Czarnowski } 650e13c2760SPrzemyslaw Czarnowski 651e13c2760SPrzemyslaw Czarnowski /** 652120fa86aSPrzemyslaw Czarnowski * @brief Function validate parameters of insert media request. 653120fa86aSPrzemyslaw Czarnowski * 654120fa86aSPrzemyslaw Czarnowski */ 655120fa86aSPrzemyslaw Czarnowski inline void validateParams(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 656120fa86aSPrzemyslaw Czarnowski const std::string& service, 657120fa86aSPrzemyslaw Czarnowski const std::string& resName, 658120fa86aSPrzemyslaw Czarnowski InsertMediaActionParams& actionParams) 659120fa86aSPrzemyslaw Czarnowski { 660120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "Validation started"; 661120fa86aSPrzemyslaw Czarnowski // required param imageUrl must not be empty 662120fa86aSPrzemyslaw Czarnowski if (!actionParams.imageUrl) 663120fa86aSPrzemyslaw Czarnowski { 664120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action parameter Image is empty."; 665120fa86aSPrzemyslaw Czarnowski 666120fa86aSPrzemyslaw Czarnowski messages::propertyValueFormatError(asyncResp->res, "<empty>", "Image"); 667120fa86aSPrzemyslaw Czarnowski 668120fa86aSPrzemyslaw Czarnowski return; 669120fa86aSPrzemyslaw Czarnowski } 670120fa86aSPrzemyslaw Czarnowski 671120fa86aSPrzemyslaw Czarnowski // optional param inserted must be true 672120fa86aSPrzemyslaw Czarnowski if ((actionParams.inserted != std::nullopt) && !*actionParams.inserted) 673120fa86aSPrzemyslaw Czarnowski { 674120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR 675120fa86aSPrzemyslaw Czarnowski << "Request action optional parameter Inserted must be true."; 676120fa86aSPrzemyslaw Czarnowski 677120fa86aSPrzemyslaw Czarnowski messages::actionParameterNotSupported(asyncResp->res, "Inserted", 678120fa86aSPrzemyslaw Czarnowski "InsertMedia"); 679120fa86aSPrzemyslaw Czarnowski 680120fa86aSPrzemyslaw Czarnowski return; 681120fa86aSPrzemyslaw Czarnowski } 682120fa86aSPrzemyslaw Czarnowski 683120fa86aSPrzemyslaw Czarnowski // optional param transferMethod must be stream 684120fa86aSPrzemyslaw Czarnowski if ((actionParams.transferMethod != std::nullopt) && 685120fa86aSPrzemyslaw Czarnowski (*actionParams.transferMethod != "Stream")) 686120fa86aSPrzemyslaw Czarnowski { 687120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action optional parameter " 688120fa86aSPrzemyslaw Czarnowski "TransferMethod must be Stream."; 689120fa86aSPrzemyslaw Czarnowski 690120fa86aSPrzemyslaw Czarnowski messages::actionParameterNotSupported(asyncResp->res, "TransferMethod", 691120fa86aSPrzemyslaw Czarnowski "InsertMedia"); 692120fa86aSPrzemyslaw Czarnowski 693120fa86aSPrzemyslaw Czarnowski return; 694120fa86aSPrzemyslaw Czarnowski } 695120fa86aSPrzemyslaw Czarnowski boost::urls::result<boost::urls::url_view> url = 696120fa86aSPrzemyslaw Czarnowski boost::urls::parse_uri(*actionParams.imageUrl); 697120fa86aSPrzemyslaw Czarnowski if (!url) 698120fa86aSPrzemyslaw Czarnowski { 699120fa86aSPrzemyslaw Czarnowski messages::actionParameterValueFormatError( 700120fa86aSPrzemyslaw Czarnowski asyncResp->res, *actionParams.imageUrl, "Image", "InsertMedia"); 701120fa86aSPrzemyslaw Czarnowski return; 702120fa86aSPrzemyslaw Czarnowski } 703120fa86aSPrzemyslaw Czarnowski std::optional<TransferProtocol> uriTransferProtocolType = 704120fa86aSPrzemyslaw Czarnowski getTransferProtocolFromUri(*url); 705120fa86aSPrzemyslaw Czarnowski 706120fa86aSPrzemyslaw Czarnowski std::optional<TransferProtocol> paramTransferProtocolType = 707120fa86aSPrzemyslaw Czarnowski getTransferProtocolFromParam(actionParams.transferProtocolType); 708120fa86aSPrzemyslaw Czarnowski 709120fa86aSPrzemyslaw Czarnowski // ImageUrl does not contain valid protocol type 710120fa86aSPrzemyslaw Czarnowski if (*uriTransferProtocolType == TransferProtocol::invalid) 711120fa86aSPrzemyslaw Czarnowski { 712120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action parameter ImageUrl must " 713120fa86aSPrzemyslaw Czarnowski "contain specified protocol type from list: " 714120fa86aSPrzemyslaw Czarnowski "(smb, https)."; 715120fa86aSPrzemyslaw Czarnowski 716120fa86aSPrzemyslaw Czarnowski messages::resourceAtUriInUnknownFormat(asyncResp->res, *url); 717120fa86aSPrzemyslaw Czarnowski 718120fa86aSPrzemyslaw Czarnowski return; 719120fa86aSPrzemyslaw Czarnowski } 720120fa86aSPrzemyslaw Czarnowski 721120fa86aSPrzemyslaw Czarnowski // transferProtocolType should contain value from list 722120fa86aSPrzemyslaw Czarnowski if (*paramTransferProtocolType == TransferProtocol::invalid) 723120fa86aSPrzemyslaw Czarnowski { 724120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action parameter TransferProtocolType " 725120fa86aSPrzemyslaw Czarnowski "must be provided with value from list: " 726120fa86aSPrzemyslaw Czarnowski "(CIFS, HTTPS)."; 727120fa86aSPrzemyslaw Czarnowski 728120fa86aSPrzemyslaw Czarnowski messages::propertyValueNotInList(asyncResp->res, 729120fa86aSPrzemyslaw Czarnowski *actionParams.transferProtocolType, 730120fa86aSPrzemyslaw Czarnowski "TransferProtocolType"); 731120fa86aSPrzemyslaw Czarnowski return; 732120fa86aSPrzemyslaw Czarnowski } 733120fa86aSPrzemyslaw Czarnowski 734120fa86aSPrzemyslaw Czarnowski // valid transfer protocol not provided either with URI nor param 735120fa86aSPrzemyslaw Czarnowski if ((uriTransferProtocolType == std::nullopt) && 736120fa86aSPrzemyslaw Czarnowski (paramTransferProtocolType == std::nullopt)) 737120fa86aSPrzemyslaw Czarnowski { 738120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action parameter ImageUrl must " 739120fa86aSPrzemyslaw Czarnowski "contain specified protocol type or param " 740120fa86aSPrzemyslaw Czarnowski "TransferProtocolType must be provided."; 741120fa86aSPrzemyslaw Czarnowski 742120fa86aSPrzemyslaw Czarnowski messages::resourceAtUriInUnknownFormat(asyncResp->res, *url); 743120fa86aSPrzemyslaw Czarnowski 744120fa86aSPrzemyslaw Czarnowski return; 745120fa86aSPrzemyslaw Czarnowski } 746120fa86aSPrzemyslaw Czarnowski 747120fa86aSPrzemyslaw Czarnowski // valid transfer protocol provided both with URI and param 748120fa86aSPrzemyslaw Czarnowski if ((paramTransferProtocolType != std::nullopt) && 749120fa86aSPrzemyslaw Czarnowski (uriTransferProtocolType != std::nullopt)) 750120fa86aSPrzemyslaw Czarnowski { 751120fa86aSPrzemyslaw Czarnowski // check if protocol is the same for URI and param 752120fa86aSPrzemyslaw Czarnowski if (*paramTransferProtocolType != *uriTransferProtocolType) 753120fa86aSPrzemyslaw Czarnowski { 754120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action parameter " 755120fa86aSPrzemyslaw Czarnowski "TransferProtocolType must contain the " 756120fa86aSPrzemyslaw Czarnowski "same protocol type as protocol type " 757120fa86aSPrzemyslaw Czarnowski "provided with param imageUrl."; 758120fa86aSPrzemyslaw Czarnowski 759120fa86aSPrzemyslaw Czarnowski messages::actionParameterValueTypeError( 760120fa86aSPrzemyslaw Czarnowski asyncResp->res, *actionParams.transferProtocolType, 761120fa86aSPrzemyslaw Czarnowski "TransferProtocolType", "InsertMedia"); 762120fa86aSPrzemyslaw Czarnowski 763120fa86aSPrzemyslaw Czarnowski return; 764120fa86aSPrzemyslaw Czarnowski } 765120fa86aSPrzemyslaw Czarnowski } 766120fa86aSPrzemyslaw Czarnowski 767120fa86aSPrzemyslaw Czarnowski // validation passed, add protocol to URI if needed 768120fa86aSPrzemyslaw Czarnowski if (uriTransferProtocolType == std::nullopt) 769120fa86aSPrzemyslaw Czarnowski { 770120fa86aSPrzemyslaw Czarnowski actionParams.imageUrl = getUriWithTransferProtocol( 771120fa86aSPrzemyslaw Czarnowski *actionParams.imageUrl, *paramTransferProtocolType); 772120fa86aSPrzemyslaw Czarnowski } 773120fa86aSPrzemyslaw Czarnowski 774452bd8d8SJayaprakash Mutyala if (!actionParams.userName) 775452bd8d8SJayaprakash Mutyala { 776452bd8d8SJayaprakash Mutyala actionParams.userName = ""; 777452bd8d8SJayaprakash Mutyala } 778452bd8d8SJayaprakash Mutyala 779452bd8d8SJayaprakash Mutyala if (!actionParams.password) 780452bd8d8SJayaprakash Mutyala { 781452bd8d8SJayaprakash Mutyala actionParams.password = ""; 782452bd8d8SJayaprakash Mutyala } 783452bd8d8SJayaprakash Mutyala 784120fa86aSPrzemyslaw Czarnowski doMountVmLegacy(asyncResp, service, resName, *actionParams.imageUrl, 785120fa86aSPrzemyslaw Czarnowski !(*actionParams.writeProtected), 786120fa86aSPrzemyslaw Czarnowski std::move(*actionParams.userName), 787120fa86aSPrzemyslaw Czarnowski std::move(*actionParams.password)); 788120fa86aSPrzemyslaw Czarnowski } 789120fa86aSPrzemyslaw Czarnowski 790120fa86aSPrzemyslaw Czarnowski /** 791e13c2760SPrzemyslaw Czarnowski * @brief Function transceives data with dbus directly. 792e13c2760SPrzemyslaw Czarnowski * 793e13c2760SPrzemyslaw Czarnowski * All BMC state properties will be retrieved before sending reset request. 794e13c2760SPrzemyslaw Czarnowski */ 79524e740a7SEd Tanous inline void doEjectAction(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 796e13c2760SPrzemyslaw Czarnowski const std::string& service, const std::string& name, 797e13c2760SPrzemyslaw Czarnowski bool legacy) 798e13c2760SPrzemyslaw Czarnowski { 799e13c2760SPrzemyslaw Czarnowski // Legacy mount requires parameter with image 800e13c2760SPrzemyslaw Czarnowski if (legacy) 801e13c2760SPrzemyslaw Czarnowski { 802e13c2760SPrzemyslaw Czarnowski crow::connections::systemBus->async_method_call( 8035e7e2dc5SEd Tanous [asyncResp](const boost::system::error_code& ec) { 804e13c2760SPrzemyslaw Czarnowski if (ec) 805e13c2760SPrzemyslaw Czarnowski { 806e13c2760SPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec; 807e13c2760SPrzemyslaw Czarnowski 808e13c2760SPrzemyslaw Czarnowski messages::internalError(asyncResp->res); 809e13c2760SPrzemyslaw Czarnowski return; 810e13c2760SPrzemyslaw Czarnowski } 811e13c2760SPrzemyslaw Czarnowski }, 812e13c2760SPrzemyslaw Czarnowski service, "/xyz/openbmc_project/VirtualMedia/Legacy/" + name, 813e13c2760SPrzemyslaw Czarnowski "xyz.openbmc_project.VirtualMedia.Legacy", "Unmount"); 814e13c2760SPrzemyslaw Czarnowski } 815e13c2760SPrzemyslaw Czarnowski else // proxy 816e13c2760SPrzemyslaw Czarnowski { 817e13c2760SPrzemyslaw Czarnowski crow::connections::systemBus->async_method_call( 8185e7e2dc5SEd Tanous [asyncResp](const boost::system::error_code& ec) { 819e13c2760SPrzemyslaw Czarnowski if (ec) 820e13c2760SPrzemyslaw Czarnowski { 821e13c2760SPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec; 822e13c2760SPrzemyslaw Czarnowski 823e13c2760SPrzemyslaw Czarnowski messages::internalError(asyncResp->res); 824e13c2760SPrzemyslaw Czarnowski return; 825e13c2760SPrzemyslaw Czarnowski } 826e13c2760SPrzemyslaw Czarnowski }, 827e13c2760SPrzemyslaw Czarnowski service, "/xyz/openbmc_project/VirtualMedia/Proxy/" + name, 828e13c2760SPrzemyslaw Czarnowski "xyz.openbmc_project.VirtualMedia.Proxy", "Unmount"); 829e13c2760SPrzemyslaw Czarnowski } 830e13c2760SPrzemyslaw Czarnowski } 831e13c2760SPrzemyslaw Czarnowski 83296825bebSEd Tanous inline void handleManagersVirtualMediaActionInsertPost( 83396825bebSEd Tanous crow::App& app, const crow::Request& req, 83422db1728SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 83596825bebSEd Tanous const std::string& name, const std::string& resName) 83696825bebSEd Tanous { 8373ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 83845ca1b86SEd Tanous { 83945ca1b86SEd Tanous return; 84045ca1b86SEd Tanous } 84179fdf63eSPrzemyslaw Czarnowski 84279fdf63eSPrzemyslaw Czarnowski constexpr std::string_view action = "VirtualMedia.InsertMedia"; 84322db1728SEd Tanous if (name != "bmc") 844107077deSPrzemyslaw Czarnowski { 84579fdf63eSPrzemyslaw Czarnowski messages::resourceNotFound(asyncResp->res, action, resName); 846107077deSPrzemyslaw Czarnowski 847107077deSPrzemyslaw Czarnowski return; 848107077deSPrzemyslaw Czarnowski } 84979fdf63eSPrzemyslaw Czarnowski InsertMediaActionParams actionParams; 85098be3e39SEd Tanous 851120fa86aSPrzemyslaw Czarnowski // Read obligatory parameters (url of image) 85215ed6780SWilly Tu if (!json_util::readJsonAction( 85379fdf63eSPrzemyslaw Czarnowski req, asyncResp->res, "Image", actionParams.imageUrl, 85479fdf63eSPrzemyslaw Czarnowski "WriteProtected", actionParams.writeProtected, "UserName", 85579fdf63eSPrzemyslaw Czarnowski actionParams.userName, "Password", actionParams.password, 85679fdf63eSPrzemyslaw Czarnowski "Inserted", actionParams.inserted, "TransferMethod", 85779fdf63eSPrzemyslaw Czarnowski actionParams.transferMethod, "TransferProtocolType", 85879fdf63eSPrzemyslaw Czarnowski actionParams.transferProtocolType)) 85998be3e39SEd Tanous { 86098be3e39SEd Tanous return; 86198be3e39SEd Tanous } 862107077deSPrzemyslaw Czarnowski 8632b73119cSGeorge Liu dbus::utility::getDbusObject( 8642b73119cSGeorge Liu "/xyz/openbmc_project/VirtualMedia", {}, 86579fdf63eSPrzemyslaw Czarnowski [asyncResp, action, actionParams, 8662b73119cSGeorge Liu resName](const boost::system::error_code& ec, 867002d39b4SEd Tanous const dbus::utility::MapperGetObject& getObjectType) mutable { 86822db1728SEd Tanous if (ec) 86922db1728SEd Tanous { 87096825bebSEd Tanous BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec; 87179fdf63eSPrzemyslaw Czarnowski messages::resourceNotFound(asyncResp->res, action, resName); 872107077deSPrzemyslaw Czarnowski 87322db1728SEd Tanous return; 87422db1728SEd Tanous } 87579fdf63eSPrzemyslaw Czarnowski 87622db1728SEd Tanous std::string service = getObjectType.begin()->first; 87722db1728SEd Tanous BMCWEB_LOG_DEBUG << "GetObjectType: " << service; 87822db1728SEd Tanous 87922db1728SEd Tanous crow::connections::systemBus->async_method_call( 88079fdf63eSPrzemyslaw Czarnowski [service, resName, action, actionParams, 8815e7e2dc5SEd Tanous asyncResp](const boost::system::error_code& ec2, 882002d39b4SEd Tanous dbus::utility::ManagedObjectType& subtree) mutable { 8838a592810SEd Tanous if (ec2) 88422db1728SEd Tanous { 88579fdf63eSPrzemyslaw Czarnowski // Not possible in proxy mode 88679fdf63eSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "InsertMedia not " 88779fdf63eSPrzemyslaw Czarnowski "allowed in proxy mode"; 88879fdf63eSPrzemyslaw Czarnowski messages::resourceNotFound(asyncResp->res, action, resName); 88922db1728SEd Tanous 89022db1728SEd Tanous return; 89122db1728SEd Tanous } 89222db1728SEd Tanous for (const auto& object : subtree) 89322db1728SEd Tanous { 894365a73f4SEd Tanous VmMode mode = parseObjectPathAndGetMode(object.first, resName); 8955880f0c5SBoleslaw Ogonczyk Makowski if (mode == VmMode::Legacy) 89622db1728SEd Tanous { 89779fdf63eSPrzemyslaw Czarnowski validateParams(asyncResp, service, resName, actionParams); 89822db1728SEd Tanous 89922db1728SEd Tanous return; 90022db1728SEd Tanous } 90122db1728SEd Tanous } 90222db1728SEd Tanous BMCWEB_LOG_DEBUG << "Parent item not found"; 90396825bebSEd Tanous messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName); 90422db1728SEd Tanous }, 90522db1728SEd Tanous service, "/xyz/openbmc_project/VirtualMedia", 906002d39b4SEd Tanous "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); 9072b73119cSGeorge Liu }); 90896825bebSEd Tanous } 90922db1728SEd Tanous 91096825bebSEd Tanous inline void handleManagersVirtualMediaActionEject( 91196825bebSEd Tanous crow::App& app, const crow::Request& req, 91222db1728SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 91396825bebSEd Tanous const std::string& managerName, const std::string& resName) 91496825bebSEd Tanous { 9153ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 91645ca1b86SEd Tanous { 91745ca1b86SEd Tanous return; 91845ca1b86SEd Tanous } 91979fdf63eSPrzemyslaw Czarnowski 92079fdf63eSPrzemyslaw Czarnowski constexpr std::string_view action = "VirtualMedia.EjectMedia"; 92196825bebSEd Tanous if (managerName != "bmc") 922107077deSPrzemyslaw Czarnowski { 92379fdf63eSPrzemyslaw Czarnowski messages::resourceNotFound(asyncResp->res, action, resName); 92422db1728SEd Tanous 92522db1728SEd Tanous return; 92622db1728SEd Tanous } 92722db1728SEd Tanous 9282b73119cSGeorge Liu dbus::utility::getDbusObject( 9292b73119cSGeorge Liu "/xyz/openbmc_project/VirtualMedia", {}, 93079fdf63eSPrzemyslaw Czarnowski [asyncResp, action, 9312b73119cSGeorge Liu resName](const boost::system::error_code& ec2, 932b9d36b47SEd Tanous const dbus::utility::MapperGetObject& getObjectType) { 9338a592810SEd Tanous if (ec2) 93422db1728SEd Tanous { 9358a592810SEd Tanous BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec2; 93622db1728SEd Tanous messages::internalError(asyncResp->res); 93722db1728SEd Tanous 93822db1728SEd Tanous return; 93922db1728SEd Tanous } 94022db1728SEd Tanous std::string service = getObjectType.begin()->first; 94122db1728SEd Tanous BMCWEB_LOG_DEBUG << "GetObjectType: " << service; 94222db1728SEd Tanous 94322db1728SEd Tanous crow::connections::systemBus->async_method_call( 94479fdf63eSPrzemyslaw Czarnowski [resName, service, action, 94579fdf63eSPrzemyslaw Czarnowski asyncResp](const boost::system::error_code& ec, 94602cad96eSEd Tanous const dbus::utility::ManagedObjectType& subtree) { 94722db1728SEd Tanous if (ec) 94822db1728SEd Tanous { 94979fdf63eSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "ObjectMapper : No Service found"; 95079fdf63eSPrzemyslaw Czarnowski messages::resourceNotFound(asyncResp->res, action, resName); 95122db1728SEd Tanous return; 95222db1728SEd Tanous } 95322db1728SEd Tanous 95422db1728SEd Tanous for (const auto& object : subtree) 95522db1728SEd Tanous { 956365a73f4SEd Tanous VmMode mode = parseObjectPathAndGetMode(object.first, resName); 957365a73f4SEd Tanous if (mode != VmMode::Invalid) 95822db1728SEd Tanous { 959365a73f4SEd Tanous doEjectAction(asyncResp, service, resName, 960365a73f4SEd Tanous mode == VmMode::Legacy); 9615880f0c5SBoleslaw Ogonczyk Makowski return; 96222db1728SEd Tanous } 96322db1728SEd Tanous } 96422db1728SEd Tanous BMCWEB_LOG_DEBUG << "Parent item not found"; 96596825bebSEd Tanous messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName); 96622db1728SEd Tanous }, 96722db1728SEd Tanous service, "/xyz/openbmc_project/VirtualMedia", 968002d39b4SEd Tanous "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); 9692b73119cSGeorge Liu }); 97096825bebSEd Tanous } 97196825bebSEd Tanous 97296825bebSEd Tanous inline void handleManagersVirtualMediaCollectionGet( 97396825bebSEd Tanous crow::App& app, const crow::Request& req, 97422db1728SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 97596825bebSEd Tanous const std::string& name) 97696825bebSEd Tanous { 9773ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 97845ca1b86SEd Tanous { 97945ca1b86SEd Tanous return; 98045ca1b86SEd Tanous } 98122db1728SEd Tanous if (name != "bmc") 98222db1728SEd Tanous { 983002d39b4SEd Tanous messages::resourceNotFound(asyncResp->res, "VirtualMedia", name); 984107077deSPrzemyslaw Czarnowski 985107077deSPrzemyslaw Czarnowski return; 986107077deSPrzemyslaw Czarnowski } 987107077deSPrzemyslaw Czarnowski 9888d1b46d7Szhanghch05 asyncResp->res.jsonValue["@odata.type"] = 989107077deSPrzemyslaw Czarnowski "#VirtualMediaCollection.VirtualMediaCollection"; 9908d1b46d7Szhanghch05 asyncResp->res.jsonValue["Name"] = "Virtual Media Services"; 991ef4c65b7SEd Tanous asyncResp->res.jsonValue["@odata.id"] = 992ef4c65b7SEd Tanous boost::urls::format("/redfish/v1/Managers/{}/VirtualMedia", name); 993107077deSPrzemyslaw Czarnowski 9942b73119cSGeorge Liu dbus::utility::getDbusObject( 9952b73119cSGeorge Liu "/xyz/openbmc_project/VirtualMedia", {}, 9962b73119cSGeorge Liu [asyncResp, name](const boost::system::error_code& ec, 997b9d36b47SEd Tanous const dbus::utility::MapperGetObject& getObjectType) { 998107077deSPrzemyslaw Czarnowski if (ec) 999107077deSPrzemyslaw Czarnowski { 100096825bebSEd Tanous BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec; 1001107077deSPrzemyslaw Czarnowski messages::internalError(asyncResp->res); 1002107077deSPrzemyslaw Czarnowski 1003107077deSPrzemyslaw Czarnowski return; 1004107077deSPrzemyslaw Czarnowski } 1005107077deSPrzemyslaw Czarnowski std::string service = getObjectType.begin()->first; 1006107077deSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "GetObjectType: " << service; 1007107077deSPrzemyslaw Czarnowski 1008107077deSPrzemyslaw Czarnowski getVmResourceList(asyncResp, service, name); 10092b73119cSGeorge Liu }); 101096825bebSEd Tanous } 1011107077deSPrzemyslaw Czarnowski 101296825bebSEd Tanous inline void 101396825bebSEd Tanous handleVirtualMediaGet(crow::App& app, const crow::Request& req, 101422db1728SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 101596825bebSEd Tanous const std::string& name, const std::string& resName) 101696825bebSEd Tanous { 10173ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 101845ca1b86SEd Tanous { 101945ca1b86SEd Tanous return; 102045ca1b86SEd Tanous } 1021107077deSPrzemyslaw Czarnowski if (name != "bmc") 1022107077deSPrzemyslaw Czarnowski { 1023002d39b4SEd Tanous messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName); 1024107077deSPrzemyslaw Czarnowski 1025107077deSPrzemyslaw Czarnowski return; 1026107077deSPrzemyslaw Czarnowski } 1027107077deSPrzemyslaw Czarnowski 10282b73119cSGeorge Liu dbus::utility::getDbusObject( 10292b73119cSGeorge Liu "/xyz/openbmc_project/VirtualMedia", {}, 1030002d39b4SEd Tanous [asyncResp, name, 10312b73119cSGeorge Liu resName](const boost::system::error_code& ec, 1032b9d36b47SEd Tanous const dbus::utility::MapperGetObject& getObjectType) { 1033107077deSPrzemyslaw Czarnowski if (ec) 1034107077deSPrzemyslaw Czarnowski { 103596825bebSEd Tanous BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec; 1036107077deSPrzemyslaw Czarnowski messages::internalError(asyncResp->res); 1037107077deSPrzemyslaw Czarnowski 1038107077deSPrzemyslaw Czarnowski return; 1039107077deSPrzemyslaw Czarnowski } 1040107077deSPrzemyslaw Czarnowski std::string service = getObjectType.begin()->first; 1041107077deSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "GetObjectType: " << service; 1042107077deSPrzemyslaw Czarnowski 1043107077deSPrzemyslaw Czarnowski getVmData(asyncResp, service, name, resName); 10442b73119cSGeorge Liu }); 104596825bebSEd Tanous } 104696825bebSEd Tanous 104796825bebSEd Tanous inline void requestNBDVirtualMediaRoutes(App& app) 104896825bebSEd Tanous { 104996825bebSEd Tanous BMCWEB_ROUTE( 105096825bebSEd Tanous app, 105196825bebSEd Tanous "/redfish/v1/Managers/<str>/VirtualMedia/<str>/Actions/VirtualMedia.InsertMedia") 105296825bebSEd Tanous .privileges(redfish::privileges::postVirtualMedia) 105396825bebSEd Tanous .methods(boost::beast::http::verb::post)(std::bind_front( 105496825bebSEd Tanous handleManagersVirtualMediaActionInsertPost, std::ref(app))); 105596825bebSEd Tanous 105696825bebSEd Tanous BMCWEB_ROUTE( 105796825bebSEd Tanous app, 105896825bebSEd Tanous "/redfish/v1/Managers/<str>/VirtualMedia/<str>/Actions/VirtualMedia.EjectMedia") 105996825bebSEd Tanous .privileges(redfish::privileges::postVirtualMedia) 106096825bebSEd Tanous .methods(boost::beast::http::verb::post)(std::bind_front( 106196825bebSEd Tanous handleManagersVirtualMediaActionEject, std::ref(app))); 106296825bebSEd Tanous 106396825bebSEd Tanous BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/VirtualMedia/") 106496825bebSEd Tanous .privileges(redfish::privileges::getVirtualMediaCollection) 106596825bebSEd Tanous .methods(boost::beast::http::verb::get)(std::bind_front( 106696825bebSEd Tanous handleManagersVirtualMediaCollectionGet, std::ref(app))); 106796825bebSEd Tanous 106896825bebSEd Tanous BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/VirtualMedia/<str>/") 106996825bebSEd Tanous .privileges(redfish::privileges::getVirtualMedia) 107096825bebSEd Tanous .methods(boost::beast::http::verb::get)( 107196825bebSEd Tanous std::bind_front(handleVirtualMediaGet, std::ref(app))); 1072107077deSPrzemyslaw Czarnowski } 1073107077deSPrzemyslaw Czarnowski 1074107077deSPrzemyslaw Czarnowski } // namespace redfish 1075