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> 28*ef4c65b7SEd 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; 249*ef4c65b7SEd Tanous item["@odata.id"] = boost::urls::format( 250*ef4c65b7SEd 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"; 261107077deSPrzemyslaw Czarnowski 262107077deSPrzemyslaw Czarnowski return item; 263107077deSPrzemyslaw Czarnowski } 264107077deSPrzemyslaw Czarnowski 265107077deSPrzemyslaw Czarnowski /** 266107077deSPrzemyslaw Czarnowski * @brief Fills collection data 267107077deSPrzemyslaw Czarnowski */ 26822db1728SEd Tanous inline void getVmResourceList(std::shared_ptr<bmcweb::AsyncResp> aResp, 269107077deSPrzemyslaw Czarnowski const std::string& service, 270107077deSPrzemyslaw Czarnowski const std::string& name) 271107077deSPrzemyslaw Czarnowski { 272107077deSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "Get available Virtual Media resources."; 273107077deSPrzemyslaw Czarnowski crow::connections::systemBus->async_method_call( 27402cad96eSEd Tanous [name, aResp{std::move(aResp)}]( 2755e7e2dc5SEd Tanous const boost::system::error_code& ec, 27602cad96eSEd Tanous const dbus::utility::ManagedObjectType& subtree) { 277107077deSPrzemyslaw Czarnowski if (ec) 278107077deSPrzemyslaw Czarnowski { 279107077deSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "DBUS response error"; 280107077deSPrzemyslaw Czarnowski return; 281107077deSPrzemyslaw Czarnowski } 282107077deSPrzemyslaw Czarnowski nlohmann::json& members = aResp->res.jsonValue["Members"]; 283107077deSPrzemyslaw Czarnowski members = nlohmann::json::array(); 284107077deSPrzemyslaw Czarnowski 285107077deSPrzemyslaw Czarnowski for (const auto& object : subtree) 286107077deSPrzemyslaw Czarnowski { 287107077deSPrzemyslaw Czarnowski nlohmann::json item; 2882dfd18efSEd Tanous std::string path = object.first.filename(); 2892dfd18efSEd Tanous if (path.empty()) 290107077deSPrzemyslaw Czarnowski { 291107077deSPrzemyslaw Czarnowski continue; 292107077deSPrzemyslaw Czarnowski } 293107077deSPrzemyslaw Czarnowski 294*ef4c65b7SEd Tanous item["@odata.id"] = boost::urls::format( 295*ef4c65b7SEd Tanous "/redfish/v1/Managers/{}/VirtualMedia/{}", name, path); 296107077deSPrzemyslaw Czarnowski members.emplace_back(std::move(item)); 297107077deSPrzemyslaw Czarnowski } 298107077deSPrzemyslaw Czarnowski aResp->res.jsonValue["Members@odata.count"] = members.size(); 299107077deSPrzemyslaw Czarnowski }, 300107077deSPrzemyslaw Czarnowski service, "/xyz/openbmc_project/VirtualMedia", 301107077deSPrzemyslaw Czarnowski "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); 302107077deSPrzemyslaw Czarnowski } 303107077deSPrzemyslaw Czarnowski 30470cbdf53SGeorge Liu inline void 30570cbdf53SGeorge Liu afterGetVmData(const std::string& name, const std::string& /*service*/, 30679fdf63eSPrzemyslaw Czarnowski const std::string& resName, 30779fdf63eSPrzemyslaw Czarnowski const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 30870cbdf53SGeorge Liu const std::pair<sdbusplus::message::object_path, 30979fdf63eSPrzemyslaw Czarnowski dbus::utility::DBusInteracesMap>& item) 31079fdf63eSPrzemyslaw Czarnowski { 31179fdf63eSPrzemyslaw Czarnowski VmMode mode = parseObjectPathAndGetMode(item.first, resName); 31279fdf63eSPrzemyslaw Czarnowski if (mode == VmMode::Invalid) 31379fdf63eSPrzemyslaw Czarnowski { 31479fdf63eSPrzemyslaw Czarnowski return; 31579fdf63eSPrzemyslaw Czarnowski } 31679fdf63eSPrzemyslaw Czarnowski 31779fdf63eSPrzemyslaw Czarnowski asyncResp->res.jsonValue = vmItemTemplate(name, resName); 31879fdf63eSPrzemyslaw Czarnowski 31979fdf63eSPrzemyslaw Czarnowski // Check if dbus path is Legacy type 32079fdf63eSPrzemyslaw Czarnowski if (mode == VmMode::Legacy) 32179fdf63eSPrzemyslaw Czarnowski { 322*ef4c65b7SEd Tanous asyncResp->res.jsonValue["Actions"]["#VirtualMedia.InsertMedia"] 323*ef4c65b7SEd Tanous ["target"] = boost::urls::format( 324*ef4c65b7SEd Tanous "/redfish/v1/Managers/{}/VirtualMedia/{}/Actions/VirtualMedia.InsertMedia", 325*ef4c65b7SEd Tanous name, resName); 32679fdf63eSPrzemyslaw Czarnowski } 32779fdf63eSPrzemyslaw Czarnowski 32879fdf63eSPrzemyslaw Czarnowski vmParseInterfaceObject(item.second, asyncResp); 32979fdf63eSPrzemyslaw Czarnowski 330*ef4c65b7SEd Tanous asyncResp->res.jsonValue["Actions"]["#VirtualMedia.EjectMedia"] 331*ef4c65b7SEd Tanous ["target"] = boost::urls::format( 332*ef4c65b7SEd Tanous "/redfish/v1/Managers/{}/VirtualMedia/{}/Actions/VirtualMedia.EjectMedia", 333*ef4c65b7SEd Tanous name, resName); 33479fdf63eSPrzemyslaw Czarnowski } 33579fdf63eSPrzemyslaw Czarnowski 336107077deSPrzemyslaw Czarnowski /** 337107077deSPrzemyslaw Czarnowski * @brief Fills data for specific resource 338107077deSPrzemyslaw Czarnowski */ 33922db1728SEd Tanous inline void getVmData(const std::shared_ptr<bmcweb::AsyncResp>& aResp, 340107077deSPrzemyslaw Czarnowski const std::string& service, const std::string& name, 341107077deSPrzemyslaw Czarnowski const std::string& resName) 342107077deSPrzemyslaw Czarnowski { 343107077deSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "Get Virtual Media resource data."; 344107077deSPrzemyslaw Czarnowski 34579fdf63eSPrzemyslaw Czarnowski findAndParseObject(service, resName, aResp, 34670cbdf53SGeorge Liu std::bind_front(afterGetVmData, name)); 347107077deSPrzemyslaw Czarnowski } 348107077deSPrzemyslaw Czarnowski 349e13c2760SPrzemyslaw Czarnowski /** 350c6f4e017SAgata Olender * @brief Transfer protocols supported for InsertMedia action. 351c6f4e017SAgata Olender * 352c6f4e017SAgata Olender */ 353c6f4e017SAgata Olender enum class TransferProtocol 354c6f4e017SAgata Olender { 355c6f4e017SAgata Olender https, 356c6f4e017SAgata Olender smb, 357c6f4e017SAgata Olender invalid 358c6f4e017SAgata Olender }; 359c6f4e017SAgata Olender 360c6f4e017SAgata Olender /** 361c6f4e017SAgata Olender * @brief Function extracts transfer protocol type from URI. 362c6f4e017SAgata Olender * 363c6f4e017SAgata Olender */ 36467df073bSEd Tanous inline std::optional<TransferProtocol> 365d9f466b3SEd Tanous getTransferProtocolFromUri(boost::urls::url_view imageUri) 36667df073bSEd Tanous { 367079360aeSEd Tanous std::string_view scheme = imageUri.scheme(); 36867df073bSEd Tanous if (scheme == "smb") 36967df073bSEd Tanous { 37067df073bSEd Tanous return TransferProtocol::smb; 37167df073bSEd Tanous } 37267df073bSEd Tanous if (scheme == "https") 37367df073bSEd Tanous { 37467df073bSEd Tanous return TransferProtocol::https; 37567df073bSEd Tanous } 37667df073bSEd Tanous if (!scheme.empty()) 37767df073bSEd Tanous { 37867df073bSEd Tanous return TransferProtocol::invalid; 37967df073bSEd Tanous } 38067df073bSEd Tanous 38167df073bSEd Tanous return {}; 38267df073bSEd Tanous } 383c6f4e017SAgata Olender 384c6f4e017SAgata Olender /** 385c6f4e017SAgata Olender * @brief Function convert transfer protocol from string param. 386c6f4e017SAgata Olender * 387c6f4e017SAgata Olender */ 38822db1728SEd Tanous inline std::optional<TransferProtocol> getTransferProtocolFromParam( 389c6f4e017SAgata Olender const std::optional<std::string>& transferProtocolType) 390c6f4e017SAgata Olender { 391c6f4e017SAgata Olender if (transferProtocolType == std::nullopt) 392c6f4e017SAgata Olender { 393c6f4e017SAgata Olender return {}; 394c6f4e017SAgata Olender } 395c6f4e017SAgata Olender 396c6f4e017SAgata Olender if (*transferProtocolType == "CIFS") 397c6f4e017SAgata Olender { 398c6f4e017SAgata Olender return TransferProtocol::smb; 399c6f4e017SAgata Olender } 400c6f4e017SAgata Olender 401c6f4e017SAgata Olender if (*transferProtocolType == "HTTPS") 402c6f4e017SAgata Olender { 403c6f4e017SAgata Olender return TransferProtocol::https; 404c6f4e017SAgata Olender } 405c6f4e017SAgata Olender 406c6f4e017SAgata Olender return TransferProtocol::invalid; 407c6f4e017SAgata Olender } 408c6f4e017SAgata Olender 409c6f4e017SAgata Olender /** 410c6f4e017SAgata Olender * @brief Function extends URI with transfer protocol type. 411c6f4e017SAgata Olender * 412c6f4e017SAgata Olender */ 41322db1728SEd Tanous inline std::string 414c6f4e017SAgata Olender getUriWithTransferProtocol(const std::string& imageUri, 415c6f4e017SAgata Olender const TransferProtocol& transferProtocol) 416c6f4e017SAgata Olender { 417c6f4e017SAgata Olender if (transferProtocol == TransferProtocol::smb) 418c6f4e017SAgata Olender { 419c6f4e017SAgata Olender return "smb://" + imageUri; 420c6f4e017SAgata Olender } 421c6f4e017SAgata Olender 422c6f4e017SAgata Olender if (transferProtocol == TransferProtocol::https) 423c6f4e017SAgata Olender { 424c6f4e017SAgata Olender return "https://" + imageUri; 425c6f4e017SAgata Olender } 426c6f4e017SAgata Olender 427c6f4e017SAgata Olender return imageUri; 428c6f4e017SAgata Olender } 429c6f4e017SAgata Olender 4301f2a40ceSPrzemyslaw Czarnowski struct InsertMediaActionParams 4311f2a40ceSPrzemyslaw Czarnowski { 432120fa86aSPrzemyslaw Czarnowski std::optional<std::string> imageUrl; 4331f2a40ceSPrzemyslaw Czarnowski std::optional<std::string> userName; 4341f2a40ceSPrzemyslaw Czarnowski std::optional<std::string> password; 4351f2a40ceSPrzemyslaw Czarnowski std::optional<std::string> transferMethod; 4361f2a40ceSPrzemyslaw Czarnowski std::optional<std::string> transferProtocolType; 4371f2a40ceSPrzemyslaw Czarnowski std::optional<bool> writeProtected = true; 4381f2a40ceSPrzemyslaw Czarnowski std::optional<bool> inserted; 4391f2a40ceSPrzemyslaw Czarnowski }; 4401f2a40ceSPrzemyslaw Czarnowski 4411214b7e7SGunnar Mills template <typename T> 4421214b7e7SGunnar Mills static void secureCleanup(T& value) 443988fb7b2SAdrian Ambrożewicz { 4444ecc618fSEd Tanous // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) 445988fb7b2SAdrian Ambrożewicz auto raw = const_cast<typename T::value_type*>(value.data()); 446988fb7b2SAdrian Ambrożewicz explicit_bzero(raw, value.size() * sizeof(*raw)); 447988fb7b2SAdrian Ambrożewicz } 448988fb7b2SAdrian Ambrożewicz 449988fb7b2SAdrian Ambrożewicz class Credentials 450988fb7b2SAdrian Ambrożewicz { 451988fb7b2SAdrian Ambrożewicz public: 452988fb7b2SAdrian Ambrożewicz Credentials(std::string&& user, std::string&& password) : 453988fb7b2SAdrian Ambrożewicz userBuf(std::move(user)), passBuf(std::move(password)) 4541214b7e7SGunnar Mills {} 455988fb7b2SAdrian Ambrożewicz 456988fb7b2SAdrian Ambrożewicz ~Credentials() 457988fb7b2SAdrian Ambrożewicz { 458988fb7b2SAdrian Ambrożewicz secureCleanup(userBuf); 459988fb7b2SAdrian Ambrożewicz secureCleanup(passBuf); 460988fb7b2SAdrian Ambrożewicz } 461988fb7b2SAdrian Ambrożewicz 462988fb7b2SAdrian Ambrożewicz const std::string& user() 463988fb7b2SAdrian Ambrożewicz { 464988fb7b2SAdrian Ambrożewicz return userBuf; 465988fb7b2SAdrian Ambrożewicz } 466988fb7b2SAdrian Ambrożewicz 467988fb7b2SAdrian Ambrożewicz const std::string& password() 468988fb7b2SAdrian Ambrożewicz { 469988fb7b2SAdrian Ambrożewicz return passBuf; 470988fb7b2SAdrian Ambrożewicz } 471988fb7b2SAdrian Ambrożewicz 472988fb7b2SAdrian Ambrożewicz Credentials() = delete; 473988fb7b2SAdrian Ambrożewicz Credentials(const Credentials&) = delete; 474988fb7b2SAdrian Ambrożewicz Credentials& operator=(const Credentials&) = delete; 475ecd6a3a2SEd Tanous Credentials(Credentials&&) = delete; 476ecd6a3a2SEd Tanous Credentials& operator=(Credentials&&) = delete; 477988fb7b2SAdrian Ambrożewicz 47822db1728SEd Tanous private: 479988fb7b2SAdrian Ambrożewicz std::string userBuf; 480988fb7b2SAdrian Ambrożewicz std::string passBuf; 481988fb7b2SAdrian Ambrożewicz }; 482988fb7b2SAdrian Ambrożewicz 483988fb7b2SAdrian Ambrożewicz class CredentialsProvider 484988fb7b2SAdrian Ambrożewicz { 485988fb7b2SAdrian Ambrożewicz public: 4861214b7e7SGunnar Mills template <typename T> 4871214b7e7SGunnar Mills struct Deleter 488988fb7b2SAdrian Ambrożewicz { 489988fb7b2SAdrian Ambrożewicz void operator()(T* buff) const 490988fb7b2SAdrian Ambrożewicz { 491988fb7b2SAdrian Ambrożewicz if (buff) 492988fb7b2SAdrian Ambrożewicz { 493988fb7b2SAdrian Ambrożewicz secureCleanup(*buff); 494988fb7b2SAdrian Ambrożewicz delete buff; 495988fb7b2SAdrian Ambrożewicz } 496988fb7b2SAdrian Ambrożewicz } 497988fb7b2SAdrian Ambrożewicz }; 498988fb7b2SAdrian Ambrożewicz 499988fb7b2SAdrian Ambrożewicz using Buffer = std::vector<char>; 500988fb7b2SAdrian Ambrożewicz using SecureBuffer = std::unique_ptr<Buffer, Deleter<Buffer>>; 501988fb7b2SAdrian Ambrożewicz // Using explicit definition instead of std::function to avoid implicit 502988fb7b2SAdrian Ambrożewicz // conversions eg. stack copy instead of reference 503988fb7b2SAdrian Ambrożewicz using FormatterFunc = void(const std::string& username, 504988fb7b2SAdrian Ambrożewicz const std::string& password, Buffer& dest); 505988fb7b2SAdrian Ambrożewicz 506988fb7b2SAdrian Ambrożewicz CredentialsProvider(std::string&& user, std::string&& password) : 507988fb7b2SAdrian Ambrożewicz credentials(std::move(user), std::move(password)) 5081214b7e7SGunnar Mills {} 509988fb7b2SAdrian Ambrożewicz 510988fb7b2SAdrian Ambrożewicz const std::string& user() 511988fb7b2SAdrian Ambrożewicz { 512988fb7b2SAdrian Ambrożewicz return credentials.user(); 513988fb7b2SAdrian Ambrożewicz } 514988fb7b2SAdrian Ambrożewicz 515988fb7b2SAdrian Ambrożewicz const std::string& password() 516988fb7b2SAdrian Ambrożewicz { 517988fb7b2SAdrian Ambrożewicz return credentials.password(); 518988fb7b2SAdrian Ambrożewicz } 519988fb7b2SAdrian Ambrożewicz 5201917ee95SEd Tanous SecureBuffer pack(FormatterFunc* formatter) 521988fb7b2SAdrian Ambrożewicz { 522988fb7b2SAdrian Ambrożewicz SecureBuffer packed{new Buffer{}}; 523e662eae8SEd Tanous if (formatter != nullptr) 524988fb7b2SAdrian Ambrożewicz { 525988fb7b2SAdrian Ambrożewicz formatter(credentials.user(), credentials.password(), *packed); 526988fb7b2SAdrian Ambrożewicz } 527988fb7b2SAdrian Ambrożewicz 528988fb7b2SAdrian Ambrożewicz return packed; 529988fb7b2SAdrian Ambrożewicz } 530988fb7b2SAdrian Ambrożewicz 531988fb7b2SAdrian Ambrożewicz private: 532988fb7b2SAdrian Ambrożewicz Credentials credentials; 533988fb7b2SAdrian Ambrożewicz }; 534988fb7b2SAdrian Ambrożewicz 535988fb7b2SAdrian Ambrożewicz // Wrapper for boost::async_pipe ensuring proper pipe cleanup 5360a48306bSEd Tanous class SecurePipe 537988fb7b2SAdrian Ambrożewicz { 538988fb7b2SAdrian Ambrożewicz public: 539988fb7b2SAdrian Ambrożewicz using unix_fd = sdbusplus::message::unix_fd; 540988fb7b2SAdrian Ambrożewicz 5410a48306bSEd Tanous SecurePipe(boost::asio::io_context& io, 5420a48306bSEd Tanous CredentialsProvider::SecureBuffer&& bufferIn) : 5430a48306bSEd Tanous impl(io), 5440a48306bSEd Tanous buffer{std::move(bufferIn)} 5451214b7e7SGunnar Mills {} 546988fb7b2SAdrian Ambrożewicz 5470a48306bSEd Tanous ~SecurePipe() 548988fb7b2SAdrian Ambrożewicz { 549988fb7b2SAdrian Ambrożewicz // Named pipe needs to be explicitly removed 550988fb7b2SAdrian Ambrożewicz impl.close(); 551988fb7b2SAdrian Ambrożewicz } 552988fb7b2SAdrian Ambrożewicz 5530a48306bSEd Tanous SecurePipe(const SecurePipe&) = delete; 5540a48306bSEd Tanous SecurePipe(SecurePipe&&) = delete; 5550a48306bSEd Tanous SecurePipe& operator=(const SecurePipe&) = delete; 5560a48306bSEd Tanous SecurePipe& operator=(SecurePipe&&) = delete; 557ecd6a3a2SEd Tanous 5580a48306bSEd Tanous unix_fd fd() const 559988fb7b2SAdrian Ambrożewicz { 560988fb7b2SAdrian Ambrożewicz return unix_fd{impl.native_source()}; 561988fb7b2SAdrian Ambrożewicz } 562988fb7b2SAdrian Ambrożewicz 563988fb7b2SAdrian Ambrożewicz template <typename WriteHandler> 56481ce609eSEd Tanous void asyncWrite(WriteHandler&& handler) 565988fb7b2SAdrian Ambrożewicz { 5660a48306bSEd Tanous impl.async_write_some(boost::asio::buffer(*buffer), 5670a48306bSEd Tanous std::forward<WriteHandler>(handler)); 568988fb7b2SAdrian Ambrożewicz } 569988fb7b2SAdrian Ambrożewicz 570988fb7b2SAdrian Ambrożewicz const std::string name; 571988fb7b2SAdrian Ambrożewicz boost::process::async_pipe impl; 5720a48306bSEd Tanous CredentialsProvider::SecureBuffer buffer; 573988fb7b2SAdrian Ambrożewicz }; 574988fb7b2SAdrian Ambrożewicz 575e13c2760SPrzemyslaw Czarnowski /** 576e13c2760SPrzemyslaw Czarnowski * @brief Function transceives data with dbus directly. 577e13c2760SPrzemyslaw Czarnowski * 578e13c2760SPrzemyslaw Czarnowski * All BMC state properties will be retrieved before sending reset request. 579e13c2760SPrzemyslaw Czarnowski */ 58022db1728SEd Tanous inline void doMountVmLegacy(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 581e13c2760SPrzemyslaw Czarnowski const std::string& service, const std::string& name, 582988fb7b2SAdrian Ambrożewicz const std::string& imageUrl, const bool rw, 583988fb7b2SAdrian Ambrożewicz std::string&& userName, std::string&& password) 584e13c2760SPrzemyslaw Czarnowski { 585988fb7b2SAdrian Ambrożewicz constexpr const size_t secretLimit = 1024; 586988fb7b2SAdrian Ambrożewicz 587988fb7b2SAdrian Ambrożewicz std::shared_ptr<SecurePipe> secretPipe; 588168e20c1SEd Tanous dbus::utility::DbusVariantType unixFd = -1; 589988fb7b2SAdrian Ambrożewicz 590988fb7b2SAdrian Ambrożewicz if (!userName.empty() || !password.empty()) 591988fb7b2SAdrian Ambrożewicz { 592988fb7b2SAdrian Ambrożewicz // Encapsulate in safe buffer 593988fb7b2SAdrian Ambrożewicz CredentialsProvider credentials(std::move(userName), 594988fb7b2SAdrian Ambrożewicz std::move(password)); 595988fb7b2SAdrian Ambrożewicz 596988fb7b2SAdrian Ambrożewicz // Payload must contain data + NULL delimiters 597988fb7b2SAdrian Ambrożewicz if (credentials.user().size() + credentials.password().size() + 2 > 598988fb7b2SAdrian Ambrożewicz secretLimit) 599988fb7b2SAdrian Ambrożewicz { 600988fb7b2SAdrian Ambrożewicz BMCWEB_LOG_ERROR << "Credentials too long to handle"; 601988fb7b2SAdrian Ambrożewicz messages::unrecognizedRequestBody(asyncResp->res); 602988fb7b2SAdrian Ambrożewicz return; 603988fb7b2SAdrian Ambrożewicz } 604988fb7b2SAdrian Ambrożewicz 605988fb7b2SAdrian Ambrożewicz // Pack secret 60622db1728SEd Tanous auto secret = credentials.pack( 60722db1728SEd Tanous [](const auto& user, const auto& pass, auto& buff) { 608988fb7b2SAdrian Ambrożewicz std::copy(user.begin(), user.end(), std::back_inserter(buff)); 609988fb7b2SAdrian Ambrożewicz buff.push_back('\0'); 610988fb7b2SAdrian Ambrożewicz std::copy(pass.begin(), pass.end(), std::back_inserter(buff)); 611988fb7b2SAdrian Ambrożewicz buff.push_back('\0'); 612988fb7b2SAdrian Ambrożewicz }); 613988fb7b2SAdrian Ambrożewicz 614988fb7b2SAdrian Ambrożewicz // Open pipe 615988fb7b2SAdrian Ambrożewicz secretPipe = std::make_shared<SecurePipe>( 61622db1728SEd Tanous crow::connections::systemBus->get_io_context(), std::move(secret)); 617988fb7b2SAdrian Ambrożewicz unixFd = secretPipe->fd(); 618988fb7b2SAdrian Ambrożewicz 619988fb7b2SAdrian Ambrożewicz // Pass secret over pipe 62081ce609eSEd Tanous secretPipe->asyncWrite( 621f5b16f03SVikram Bodireddy [asyncResp](const boost::system::error_code& ec, std::size_t) { 622988fb7b2SAdrian Ambrożewicz if (ec) 623988fb7b2SAdrian Ambrożewicz { 624988fb7b2SAdrian Ambrożewicz BMCWEB_LOG_ERROR << "Failed to pass secret: " << ec; 625988fb7b2SAdrian Ambrożewicz messages::internalError(asyncResp->res); 626988fb7b2SAdrian Ambrożewicz } 627988fb7b2SAdrian Ambrożewicz }); 628988fb7b2SAdrian Ambrożewicz } 629988fb7b2SAdrian Ambrożewicz 630e13c2760SPrzemyslaw Czarnowski crow::connections::systemBus->async_method_call( 6315e7e2dc5SEd Tanous [asyncResp, secretPipe](const boost::system::error_code& ec, 632988fb7b2SAdrian Ambrożewicz bool success) { 633e13c2760SPrzemyslaw Czarnowski if (ec) 634e13c2760SPrzemyslaw Czarnowski { 635e13c2760SPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec; 636e13c2760SPrzemyslaw Czarnowski messages::internalError(asyncResp->res); 637d6da5bebSAdrian Ambrożewicz } 638d6da5bebSAdrian Ambrożewicz else if (!success) 639d6da5bebSAdrian Ambrożewicz { 640d6da5bebSAdrian Ambrożewicz BMCWEB_LOG_ERROR << "Service responded with error"; 641d6da5bebSAdrian Ambrożewicz messages::generalError(asyncResp->res); 642e13c2760SPrzemyslaw Czarnowski } 643e13c2760SPrzemyslaw Czarnowski }, 644e13c2760SPrzemyslaw Czarnowski service, "/xyz/openbmc_project/VirtualMedia/Legacy/" + name, 645988fb7b2SAdrian Ambrożewicz "xyz.openbmc_project.VirtualMedia.Legacy", "Mount", imageUrl, rw, 646988fb7b2SAdrian Ambrożewicz unixFd); 647e13c2760SPrzemyslaw Czarnowski } 648e13c2760SPrzemyslaw Czarnowski 649e13c2760SPrzemyslaw Czarnowski /** 650120fa86aSPrzemyslaw Czarnowski * @brief Function validate parameters of insert media request. 651120fa86aSPrzemyslaw Czarnowski * 652120fa86aSPrzemyslaw Czarnowski */ 653120fa86aSPrzemyslaw Czarnowski inline void validateParams(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 654120fa86aSPrzemyslaw Czarnowski const std::string& service, 655120fa86aSPrzemyslaw Czarnowski const std::string& resName, 656120fa86aSPrzemyslaw Czarnowski InsertMediaActionParams& actionParams) 657120fa86aSPrzemyslaw Czarnowski { 658120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "Validation started"; 659120fa86aSPrzemyslaw Czarnowski // required param imageUrl must not be empty 660120fa86aSPrzemyslaw Czarnowski if (!actionParams.imageUrl) 661120fa86aSPrzemyslaw Czarnowski { 662120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action parameter Image is empty."; 663120fa86aSPrzemyslaw Czarnowski 664120fa86aSPrzemyslaw Czarnowski messages::propertyValueFormatError(asyncResp->res, "<empty>", "Image"); 665120fa86aSPrzemyslaw Czarnowski 666120fa86aSPrzemyslaw Czarnowski return; 667120fa86aSPrzemyslaw Czarnowski } 668120fa86aSPrzemyslaw Czarnowski 669120fa86aSPrzemyslaw Czarnowski // optional param inserted must be true 670120fa86aSPrzemyslaw Czarnowski if ((actionParams.inserted != std::nullopt) && !*actionParams.inserted) 671120fa86aSPrzemyslaw Czarnowski { 672120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR 673120fa86aSPrzemyslaw Czarnowski << "Request action optional parameter Inserted must be true."; 674120fa86aSPrzemyslaw Czarnowski 675120fa86aSPrzemyslaw Czarnowski messages::actionParameterNotSupported(asyncResp->res, "Inserted", 676120fa86aSPrzemyslaw Czarnowski "InsertMedia"); 677120fa86aSPrzemyslaw Czarnowski 678120fa86aSPrzemyslaw Czarnowski return; 679120fa86aSPrzemyslaw Czarnowski } 680120fa86aSPrzemyslaw Czarnowski 681120fa86aSPrzemyslaw Czarnowski // optional param transferMethod must be stream 682120fa86aSPrzemyslaw Czarnowski if ((actionParams.transferMethod != std::nullopt) && 683120fa86aSPrzemyslaw Czarnowski (*actionParams.transferMethod != "Stream")) 684120fa86aSPrzemyslaw Czarnowski { 685120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action optional parameter " 686120fa86aSPrzemyslaw Czarnowski "TransferMethod must be Stream."; 687120fa86aSPrzemyslaw Czarnowski 688120fa86aSPrzemyslaw Czarnowski messages::actionParameterNotSupported(asyncResp->res, "TransferMethod", 689120fa86aSPrzemyslaw Czarnowski "InsertMedia"); 690120fa86aSPrzemyslaw Czarnowski 691120fa86aSPrzemyslaw Czarnowski return; 692120fa86aSPrzemyslaw Czarnowski } 693120fa86aSPrzemyslaw Czarnowski boost::urls::result<boost::urls::url_view> url = 694120fa86aSPrzemyslaw Czarnowski boost::urls::parse_uri(*actionParams.imageUrl); 695120fa86aSPrzemyslaw Czarnowski if (!url) 696120fa86aSPrzemyslaw Czarnowski { 697120fa86aSPrzemyslaw Czarnowski messages::actionParameterValueFormatError( 698120fa86aSPrzemyslaw Czarnowski asyncResp->res, *actionParams.imageUrl, "Image", "InsertMedia"); 699120fa86aSPrzemyslaw Czarnowski return; 700120fa86aSPrzemyslaw Czarnowski } 701120fa86aSPrzemyslaw Czarnowski std::optional<TransferProtocol> uriTransferProtocolType = 702120fa86aSPrzemyslaw Czarnowski getTransferProtocolFromUri(*url); 703120fa86aSPrzemyslaw Czarnowski 704120fa86aSPrzemyslaw Czarnowski std::optional<TransferProtocol> paramTransferProtocolType = 705120fa86aSPrzemyslaw Czarnowski getTransferProtocolFromParam(actionParams.transferProtocolType); 706120fa86aSPrzemyslaw Czarnowski 707120fa86aSPrzemyslaw Czarnowski // ImageUrl does not contain valid protocol type 708120fa86aSPrzemyslaw Czarnowski if (*uriTransferProtocolType == TransferProtocol::invalid) 709120fa86aSPrzemyslaw Czarnowski { 710120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action parameter ImageUrl must " 711120fa86aSPrzemyslaw Czarnowski "contain specified protocol type from list: " 712120fa86aSPrzemyslaw Czarnowski "(smb, https)."; 713120fa86aSPrzemyslaw Czarnowski 714120fa86aSPrzemyslaw Czarnowski messages::resourceAtUriInUnknownFormat(asyncResp->res, *url); 715120fa86aSPrzemyslaw Czarnowski 716120fa86aSPrzemyslaw Czarnowski return; 717120fa86aSPrzemyslaw Czarnowski } 718120fa86aSPrzemyslaw Czarnowski 719120fa86aSPrzemyslaw Czarnowski // transferProtocolType should contain value from list 720120fa86aSPrzemyslaw Czarnowski if (*paramTransferProtocolType == TransferProtocol::invalid) 721120fa86aSPrzemyslaw Czarnowski { 722120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action parameter TransferProtocolType " 723120fa86aSPrzemyslaw Czarnowski "must be provided with value from list: " 724120fa86aSPrzemyslaw Czarnowski "(CIFS, HTTPS)."; 725120fa86aSPrzemyslaw Czarnowski 726120fa86aSPrzemyslaw Czarnowski messages::propertyValueNotInList(asyncResp->res, 727120fa86aSPrzemyslaw Czarnowski *actionParams.transferProtocolType, 728120fa86aSPrzemyslaw Czarnowski "TransferProtocolType"); 729120fa86aSPrzemyslaw Czarnowski return; 730120fa86aSPrzemyslaw Czarnowski } 731120fa86aSPrzemyslaw Czarnowski 732120fa86aSPrzemyslaw Czarnowski // valid transfer protocol not provided either with URI nor param 733120fa86aSPrzemyslaw Czarnowski if ((uriTransferProtocolType == std::nullopt) && 734120fa86aSPrzemyslaw Czarnowski (paramTransferProtocolType == std::nullopt)) 735120fa86aSPrzemyslaw Czarnowski { 736120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action parameter ImageUrl must " 737120fa86aSPrzemyslaw Czarnowski "contain specified protocol type or param " 738120fa86aSPrzemyslaw Czarnowski "TransferProtocolType must be provided."; 739120fa86aSPrzemyslaw Czarnowski 740120fa86aSPrzemyslaw Czarnowski messages::resourceAtUriInUnknownFormat(asyncResp->res, *url); 741120fa86aSPrzemyslaw Czarnowski 742120fa86aSPrzemyslaw Czarnowski return; 743120fa86aSPrzemyslaw Czarnowski } 744120fa86aSPrzemyslaw Czarnowski 745120fa86aSPrzemyslaw Czarnowski // valid transfer protocol provided both with URI and param 746120fa86aSPrzemyslaw Czarnowski if ((paramTransferProtocolType != std::nullopt) && 747120fa86aSPrzemyslaw Czarnowski (uriTransferProtocolType != std::nullopt)) 748120fa86aSPrzemyslaw Czarnowski { 749120fa86aSPrzemyslaw Czarnowski // check if protocol is the same for URI and param 750120fa86aSPrzemyslaw Czarnowski if (*paramTransferProtocolType != *uriTransferProtocolType) 751120fa86aSPrzemyslaw Czarnowski { 752120fa86aSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Request action parameter " 753120fa86aSPrzemyslaw Czarnowski "TransferProtocolType must contain the " 754120fa86aSPrzemyslaw Czarnowski "same protocol type as protocol type " 755120fa86aSPrzemyslaw Czarnowski "provided with param imageUrl."; 756120fa86aSPrzemyslaw Czarnowski 757120fa86aSPrzemyslaw Czarnowski messages::actionParameterValueTypeError( 758120fa86aSPrzemyslaw Czarnowski asyncResp->res, *actionParams.transferProtocolType, 759120fa86aSPrzemyslaw Czarnowski "TransferProtocolType", "InsertMedia"); 760120fa86aSPrzemyslaw Czarnowski 761120fa86aSPrzemyslaw Czarnowski return; 762120fa86aSPrzemyslaw Czarnowski } 763120fa86aSPrzemyslaw Czarnowski } 764120fa86aSPrzemyslaw Czarnowski 765120fa86aSPrzemyslaw Czarnowski // validation passed, add protocol to URI if needed 766120fa86aSPrzemyslaw Czarnowski if (uriTransferProtocolType == std::nullopt) 767120fa86aSPrzemyslaw Czarnowski { 768120fa86aSPrzemyslaw Czarnowski actionParams.imageUrl = getUriWithTransferProtocol( 769120fa86aSPrzemyslaw Czarnowski *actionParams.imageUrl, *paramTransferProtocolType); 770120fa86aSPrzemyslaw Czarnowski } 771120fa86aSPrzemyslaw Czarnowski 772452bd8d8SJayaprakash Mutyala if (!actionParams.userName) 773452bd8d8SJayaprakash Mutyala { 774452bd8d8SJayaprakash Mutyala actionParams.userName = ""; 775452bd8d8SJayaprakash Mutyala } 776452bd8d8SJayaprakash Mutyala 777452bd8d8SJayaprakash Mutyala if (!actionParams.password) 778452bd8d8SJayaprakash Mutyala { 779452bd8d8SJayaprakash Mutyala actionParams.password = ""; 780452bd8d8SJayaprakash Mutyala } 781452bd8d8SJayaprakash Mutyala 782120fa86aSPrzemyslaw Czarnowski doMountVmLegacy(asyncResp, service, resName, *actionParams.imageUrl, 783120fa86aSPrzemyslaw Czarnowski !(*actionParams.writeProtected), 784120fa86aSPrzemyslaw Czarnowski std::move(*actionParams.userName), 785120fa86aSPrzemyslaw Czarnowski std::move(*actionParams.password)); 786120fa86aSPrzemyslaw Czarnowski } 787120fa86aSPrzemyslaw Czarnowski 788120fa86aSPrzemyslaw Czarnowski /** 789e13c2760SPrzemyslaw Czarnowski * @brief Function transceives data with dbus directly. 790e13c2760SPrzemyslaw Czarnowski * 791e13c2760SPrzemyslaw Czarnowski * All BMC state properties will be retrieved before sending reset request. 792e13c2760SPrzemyslaw Czarnowski */ 79324e740a7SEd Tanous inline void doEjectAction(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 794e13c2760SPrzemyslaw Czarnowski const std::string& service, const std::string& name, 795e13c2760SPrzemyslaw Czarnowski bool legacy) 796e13c2760SPrzemyslaw Czarnowski { 797e13c2760SPrzemyslaw Czarnowski // Legacy mount requires parameter with image 798e13c2760SPrzemyslaw Czarnowski if (legacy) 799e13c2760SPrzemyslaw Czarnowski { 800e13c2760SPrzemyslaw Czarnowski crow::connections::systemBus->async_method_call( 8015e7e2dc5SEd Tanous [asyncResp](const boost::system::error_code& ec) { 802e13c2760SPrzemyslaw Czarnowski if (ec) 803e13c2760SPrzemyslaw Czarnowski { 804e13c2760SPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec; 805e13c2760SPrzemyslaw Czarnowski 806e13c2760SPrzemyslaw Czarnowski messages::internalError(asyncResp->res); 807e13c2760SPrzemyslaw Czarnowski return; 808e13c2760SPrzemyslaw Czarnowski } 809e13c2760SPrzemyslaw Czarnowski }, 810e13c2760SPrzemyslaw Czarnowski service, "/xyz/openbmc_project/VirtualMedia/Legacy/" + name, 811e13c2760SPrzemyslaw Czarnowski "xyz.openbmc_project.VirtualMedia.Legacy", "Unmount"); 812e13c2760SPrzemyslaw Czarnowski } 813e13c2760SPrzemyslaw Czarnowski else // proxy 814e13c2760SPrzemyslaw Czarnowski { 815e13c2760SPrzemyslaw Czarnowski crow::connections::systemBus->async_method_call( 8165e7e2dc5SEd Tanous [asyncResp](const boost::system::error_code& ec) { 817e13c2760SPrzemyslaw Czarnowski if (ec) 818e13c2760SPrzemyslaw Czarnowski { 819e13c2760SPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec; 820e13c2760SPrzemyslaw Czarnowski 821e13c2760SPrzemyslaw Czarnowski messages::internalError(asyncResp->res); 822e13c2760SPrzemyslaw Czarnowski return; 823e13c2760SPrzemyslaw Czarnowski } 824e13c2760SPrzemyslaw Czarnowski }, 825e13c2760SPrzemyslaw Czarnowski service, "/xyz/openbmc_project/VirtualMedia/Proxy/" + name, 826e13c2760SPrzemyslaw Czarnowski "xyz.openbmc_project.VirtualMedia.Proxy", "Unmount"); 827e13c2760SPrzemyslaw Czarnowski } 828e13c2760SPrzemyslaw Czarnowski } 829e13c2760SPrzemyslaw Czarnowski 83096825bebSEd Tanous inline void handleManagersVirtualMediaActionInsertPost( 83196825bebSEd Tanous crow::App& app, const crow::Request& req, 83222db1728SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 83396825bebSEd Tanous const std::string& name, const std::string& resName) 83496825bebSEd Tanous { 8353ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 83645ca1b86SEd Tanous { 83745ca1b86SEd Tanous return; 83845ca1b86SEd Tanous } 83979fdf63eSPrzemyslaw Czarnowski 84079fdf63eSPrzemyslaw Czarnowski constexpr std::string_view action = "VirtualMedia.InsertMedia"; 84122db1728SEd Tanous if (name != "bmc") 842107077deSPrzemyslaw Czarnowski { 84379fdf63eSPrzemyslaw Czarnowski messages::resourceNotFound(asyncResp->res, action, resName); 844107077deSPrzemyslaw Czarnowski 845107077deSPrzemyslaw Czarnowski return; 846107077deSPrzemyslaw Czarnowski } 84779fdf63eSPrzemyslaw Czarnowski InsertMediaActionParams actionParams; 84898be3e39SEd Tanous 849120fa86aSPrzemyslaw Czarnowski // Read obligatory parameters (url of image) 85015ed6780SWilly Tu if (!json_util::readJsonAction( 85179fdf63eSPrzemyslaw Czarnowski req, asyncResp->res, "Image", actionParams.imageUrl, 85279fdf63eSPrzemyslaw Czarnowski "WriteProtected", actionParams.writeProtected, "UserName", 85379fdf63eSPrzemyslaw Czarnowski actionParams.userName, "Password", actionParams.password, 85479fdf63eSPrzemyslaw Czarnowski "Inserted", actionParams.inserted, "TransferMethod", 85579fdf63eSPrzemyslaw Czarnowski actionParams.transferMethod, "TransferProtocolType", 85679fdf63eSPrzemyslaw Czarnowski actionParams.transferProtocolType)) 85798be3e39SEd Tanous { 85898be3e39SEd Tanous return; 85998be3e39SEd Tanous } 860107077deSPrzemyslaw Czarnowski 8612b73119cSGeorge Liu dbus::utility::getDbusObject( 8622b73119cSGeorge Liu "/xyz/openbmc_project/VirtualMedia", {}, 86379fdf63eSPrzemyslaw Czarnowski [asyncResp, action, actionParams, 8642b73119cSGeorge Liu resName](const boost::system::error_code& ec, 865002d39b4SEd Tanous const dbus::utility::MapperGetObject& getObjectType) mutable { 86622db1728SEd Tanous if (ec) 86722db1728SEd Tanous { 86896825bebSEd Tanous BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec; 86979fdf63eSPrzemyslaw Czarnowski messages::resourceNotFound(asyncResp->res, action, resName); 870107077deSPrzemyslaw Czarnowski 87122db1728SEd Tanous return; 87222db1728SEd Tanous } 87379fdf63eSPrzemyslaw Czarnowski 87422db1728SEd Tanous std::string service = getObjectType.begin()->first; 87522db1728SEd Tanous BMCWEB_LOG_DEBUG << "GetObjectType: " << service; 87622db1728SEd Tanous 87722db1728SEd Tanous crow::connections::systemBus->async_method_call( 87879fdf63eSPrzemyslaw Czarnowski [service, resName, action, actionParams, 8795e7e2dc5SEd Tanous asyncResp](const boost::system::error_code& ec2, 880002d39b4SEd Tanous dbus::utility::ManagedObjectType& subtree) mutable { 8818a592810SEd Tanous if (ec2) 88222db1728SEd Tanous { 88379fdf63eSPrzemyslaw Czarnowski // Not possible in proxy mode 88479fdf63eSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "InsertMedia not " 88579fdf63eSPrzemyslaw Czarnowski "allowed in proxy mode"; 88679fdf63eSPrzemyslaw Czarnowski messages::resourceNotFound(asyncResp->res, action, resName); 88722db1728SEd Tanous 88822db1728SEd Tanous return; 88922db1728SEd Tanous } 89022db1728SEd Tanous for (const auto& object : subtree) 89122db1728SEd Tanous { 892365a73f4SEd Tanous VmMode mode = parseObjectPathAndGetMode(object.first, resName); 8935880f0c5SBoleslaw Ogonczyk Makowski if (mode == VmMode::Legacy) 89422db1728SEd Tanous { 89579fdf63eSPrzemyslaw Czarnowski validateParams(asyncResp, service, resName, actionParams); 89622db1728SEd Tanous 89722db1728SEd Tanous return; 89822db1728SEd Tanous } 89922db1728SEd Tanous } 90022db1728SEd Tanous BMCWEB_LOG_DEBUG << "Parent item not found"; 90196825bebSEd Tanous messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName); 90222db1728SEd Tanous }, 90322db1728SEd Tanous service, "/xyz/openbmc_project/VirtualMedia", 904002d39b4SEd Tanous "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); 9052b73119cSGeorge Liu }); 90696825bebSEd Tanous } 90722db1728SEd Tanous 90896825bebSEd Tanous inline void handleManagersVirtualMediaActionEject( 90996825bebSEd Tanous crow::App& app, const crow::Request& req, 91022db1728SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 91196825bebSEd Tanous const std::string& managerName, const std::string& resName) 91296825bebSEd Tanous { 9133ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 91445ca1b86SEd Tanous { 91545ca1b86SEd Tanous return; 91645ca1b86SEd Tanous } 91779fdf63eSPrzemyslaw Czarnowski 91879fdf63eSPrzemyslaw Czarnowski constexpr std::string_view action = "VirtualMedia.EjectMedia"; 91996825bebSEd Tanous if (managerName != "bmc") 920107077deSPrzemyslaw Czarnowski { 92179fdf63eSPrzemyslaw Czarnowski messages::resourceNotFound(asyncResp->res, action, resName); 92222db1728SEd Tanous 92322db1728SEd Tanous return; 92422db1728SEd Tanous } 92522db1728SEd Tanous 9262b73119cSGeorge Liu dbus::utility::getDbusObject( 9272b73119cSGeorge Liu "/xyz/openbmc_project/VirtualMedia", {}, 92879fdf63eSPrzemyslaw Czarnowski [asyncResp, action, 9292b73119cSGeorge Liu resName](const boost::system::error_code& ec2, 930b9d36b47SEd Tanous const dbus::utility::MapperGetObject& getObjectType) { 9318a592810SEd Tanous if (ec2) 93222db1728SEd Tanous { 9338a592810SEd Tanous BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec2; 93422db1728SEd Tanous messages::internalError(asyncResp->res); 93522db1728SEd Tanous 93622db1728SEd Tanous return; 93722db1728SEd Tanous } 93822db1728SEd Tanous std::string service = getObjectType.begin()->first; 93922db1728SEd Tanous BMCWEB_LOG_DEBUG << "GetObjectType: " << service; 94022db1728SEd Tanous 94122db1728SEd Tanous crow::connections::systemBus->async_method_call( 94279fdf63eSPrzemyslaw Czarnowski [resName, service, action, 94379fdf63eSPrzemyslaw Czarnowski asyncResp](const boost::system::error_code& ec, 94402cad96eSEd Tanous const dbus::utility::ManagedObjectType& subtree) { 94522db1728SEd Tanous if (ec) 94622db1728SEd Tanous { 94779fdf63eSPrzemyslaw Czarnowski BMCWEB_LOG_ERROR << "ObjectMapper : No Service found"; 94879fdf63eSPrzemyslaw Czarnowski messages::resourceNotFound(asyncResp->res, action, resName); 94922db1728SEd Tanous return; 95022db1728SEd Tanous } 95122db1728SEd Tanous 95222db1728SEd Tanous for (const auto& object : subtree) 95322db1728SEd Tanous { 954365a73f4SEd Tanous VmMode mode = parseObjectPathAndGetMode(object.first, resName); 955365a73f4SEd Tanous if (mode != VmMode::Invalid) 95622db1728SEd Tanous { 957365a73f4SEd Tanous doEjectAction(asyncResp, service, resName, 958365a73f4SEd Tanous mode == VmMode::Legacy); 9595880f0c5SBoleslaw Ogonczyk Makowski return; 96022db1728SEd Tanous } 96122db1728SEd Tanous } 96222db1728SEd Tanous BMCWEB_LOG_DEBUG << "Parent item not found"; 96396825bebSEd Tanous messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName); 96422db1728SEd Tanous }, 96522db1728SEd Tanous service, "/xyz/openbmc_project/VirtualMedia", 966002d39b4SEd Tanous "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); 9672b73119cSGeorge Liu }); 96896825bebSEd Tanous } 96996825bebSEd Tanous 97096825bebSEd Tanous inline void handleManagersVirtualMediaCollectionGet( 97196825bebSEd Tanous crow::App& app, const crow::Request& req, 97222db1728SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 97396825bebSEd Tanous const std::string& name) 97496825bebSEd Tanous { 9753ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 97645ca1b86SEd Tanous { 97745ca1b86SEd Tanous return; 97845ca1b86SEd Tanous } 97922db1728SEd Tanous if (name != "bmc") 98022db1728SEd Tanous { 981002d39b4SEd Tanous messages::resourceNotFound(asyncResp->res, "VirtualMedia", name); 982107077deSPrzemyslaw Czarnowski 983107077deSPrzemyslaw Czarnowski return; 984107077deSPrzemyslaw Czarnowski } 985107077deSPrzemyslaw Czarnowski 9868d1b46d7Szhanghch05 asyncResp->res.jsonValue["@odata.type"] = 987107077deSPrzemyslaw Czarnowski "#VirtualMediaCollection.VirtualMediaCollection"; 9888d1b46d7Szhanghch05 asyncResp->res.jsonValue["Name"] = "Virtual Media Services"; 989*ef4c65b7SEd Tanous asyncResp->res.jsonValue["@odata.id"] = 990*ef4c65b7SEd Tanous boost::urls::format("/redfish/v1/Managers/{}/VirtualMedia", name); 991107077deSPrzemyslaw Czarnowski 9922b73119cSGeorge Liu dbus::utility::getDbusObject( 9932b73119cSGeorge Liu "/xyz/openbmc_project/VirtualMedia", {}, 9942b73119cSGeorge Liu [asyncResp, name](const boost::system::error_code& ec, 995b9d36b47SEd Tanous const dbus::utility::MapperGetObject& getObjectType) { 996107077deSPrzemyslaw Czarnowski if (ec) 997107077deSPrzemyslaw Czarnowski { 99896825bebSEd Tanous BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec; 999107077deSPrzemyslaw Czarnowski messages::internalError(asyncResp->res); 1000107077deSPrzemyslaw Czarnowski 1001107077deSPrzemyslaw Czarnowski return; 1002107077deSPrzemyslaw Czarnowski } 1003107077deSPrzemyslaw Czarnowski std::string service = getObjectType.begin()->first; 1004107077deSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "GetObjectType: " << service; 1005107077deSPrzemyslaw Czarnowski 1006107077deSPrzemyslaw Czarnowski getVmResourceList(asyncResp, service, name); 10072b73119cSGeorge Liu }); 100896825bebSEd Tanous } 1009107077deSPrzemyslaw Czarnowski 101096825bebSEd Tanous inline void 101196825bebSEd Tanous handleVirtualMediaGet(crow::App& app, const crow::Request& req, 101222db1728SEd Tanous const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, 101396825bebSEd Tanous const std::string& name, const std::string& resName) 101496825bebSEd Tanous { 10153ba00073SCarson Labrado if (!redfish::setUpRedfishRoute(app, req, asyncResp)) 101645ca1b86SEd Tanous { 101745ca1b86SEd Tanous return; 101845ca1b86SEd Tanous } 1019107077deSPrzemyslaw Czarnowski if (name != "bmc") 1020107077deSPrzemyslaw Czarnowski { 1021002d39b4SEd Tanous messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName); 1022107077deSPrzemyslaw Czarnowski 1023107077deSPrzemyslaw Czarnowski return; 1024107077deSPrzemyslaw Czarnowski } 1025107077deSPrzemyslaw Czarnowski 10262b73119cSGeorge Liu dbus::utility::getDbusObject( 10272b73119cSGeorge Liu "/xyz/openbmc_project/VirtualMedia", {}, 1028002d39b4SEd Tanous [asyncResp, name, 10292b73119cSGeorge Liu resName](const boost::system::error_code& ec, 1030b9d36b47SEd Tanous const dbus::utility::MapperGetObject& getObjectType) { 1031107077deSPrzemyslaw Czarnowski if (ec) 1032107077deSPrzemyslaw Czarnowski { 103396825bebSEd Tanous BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " << ec; 1034107077deSPrzemyslaw Czarnowski messages::internalError(asyncResp->res); 1035107077deSPrzemyslaw Czarnowski 1036107077deSPrzemyslaw Czarnowski return; 1037107077deSPrzemyslaw Czarnowski } 1038107077deSPrzemyslaw Czarnowski std::string service = getObjectType.begin()->first; 1039107077deSPrzemyslaw Czarnowski BMCWEB_LOG_DEBUG << "GetObjectType: " << service; 1040107077deSPrzemyslaw Czarnowski 1041107077deSPrzemyslaw Czarnowski getVmData(asyncResp, service, name, resName); 10422b73119cSGeorge Liu }); 104396825bebSEd Tanous } 104496825bebSEd Tanous 104596825bebSEd Tanous inline void requestNBDVirtualMediaRoutes(App& app) 104696825bebSEd Tanous { 104796825bebSEd Tanous BMCWEB_ROUTE( 104896825bebSEd Tanous app, 104996825bebSEd Tanous "/redfish/v1/Managers/<str>/VirtualMedia/<str>/Actions/VirtualMedia.InsertMedia") 105096825bebSEd Tanous .privileges(redfish::privileges::postVirtualMedia) 105196825bebSEd Tanous .methods(boost::beast::http::verb::post)(std::bind_front( 105296825bebSEd Tanous handleManagersVirtualMediaActionInsertPost, std::ref(app))); 105396825bebSEd Tanous 105496825bebSEd Tanous BMCWEB_ROUTE( 105596825bebSEd Tanous app, 105696825bebSEd Tanous "/redfish/v1/Managers/<str>/VirtualMedia/<str>/Actions/VirtualMedia.EjectMedia") 105796825bebSEd Tanous .privileges(redfish::privileges::postVirtualMedia) 105896825bebSEd Tanous .methods(boost::beast::http::verb::post)(std::bind_front( 105996825bebSEd Tanous handleManagersVirtualMediaActionEject, std::ref(app))); 106096825bebSEd Tanous 106196825bebSEd Tanous BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/VirtualMedia/") 106296825bebSEd Tanous .privileges(redfish::privileges::getVirtualMediaCollection) 106396825bebSEd Tanous .methods(boost::beast::http::verb::get)(std::bind_front( 106496825bebSEd Tanous handleManagersVirtualMediaCollectionGet, std::ref(app))); 106596825bebSEd Tanous 106696825bebSEd Tanous BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/VirtualMedia/<str>/") 106796825bebSEd Tanous .privileges(redfish::privileges::getVirtualMedia) 106896825bebSEd Tanous .methods(boost::beast::http::verb::get)( 106996825bebSEd Tanous std::bind_front(handleVirtualMediaGet, std::ref(app))); 1070107077deSPrzemyslaw Czarnowski } 1071107077deSPrzemyslaw Czarnowski 1072107077deSPrzemyslaw Czarnowski } // namespace redfish 1073