summaryrefslogtreecommitdiff
path: root/redfish-core/lib/virtual_media.hpp
diff options
context:
space:
mode:
authorAdrian Ambrożewicz <adrian.ambrozewicz@linux.intel.com>2020-01-13 20:31:01 +0300
committerAgata Olender <agata.olender@intel.com>2020-03-16 11:07:00 +0300
commitd6da5bebfe4c0ac206570cd69f20406da06ea40b (patch)
treef25077fbed3791a327e55814bb5d03c9dcba8da3 /redfish-core/lib/virtual_media.hpp
parent91e130a365a0d3b93357e6efa0a5be8a0b53c6d1 (diff)
downloadbmcweb-d6da5bebfe4c0ac206570cd69f20406da06ea40b.tar.xz
Add handling of WriteProtected parameter to InsertMedia action.
As continuation for VirtualMedia Redfish support, this patch adds handling and passing WriteProtected parameter to Virtual Media 'Mount' D-Bus call. WriteProtected parameter determines Read-Only mode for both USB Gadget and NBD stack. Tested: Manual and automated tests on WilsonCity platform: - mounting and unmounting images over CIFS and HTTPS (single, multiple at the same time etc) - positive and negative tests for D-Bus calls - ensuring proper information is exposed on D-Bus Signed-off-by: Agata Olender <agata.olender@intel.com> Change-Id: I5920c389785f5568754803f3c4989c188f9e0826
Diffstat (limited to 'redfish-core/lib/virtual_media.hpp')
-rw-r--r--redfish-core/lib/virtual_media.hpp65
1 files changed, 26 insertions, 39 deletions
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index 6e83973669..a76ff50c0b 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -347,10 +347,13 @@ class VirtualMediaActionInsertMedia : public Node
{
// Legacy mode
std::string imageUrl;
+ bool writeProtected;
// Read obligatory paramters (url of image)
- if (!json_util::readJson(req, aResp->res,
- "Image", imageUrl))
+ if (!json_util::readJson(
+ req, aResp->res, "Image", imageUrl,
+ "WriteProtected", writeProtected))
+
{
BMCWEB_LOG_DEBUG
<< "Image is not provided";
@@ -371,8 +374,9 @@ class VirtualMediaActionInsertMedia : public Node
// manager is irrelevant for VirtualMedia
// dbus calls
- doVmAction(std::move(aResp), service,
- resName, true, imageUrl);
+ doMountVmLegacy(std::move(aResp), service,
+ resName, imageUrl,
+ !writeProtected);
return;
}
@@ -396,42 +400,25 @@ class VirtualMediaActionInsertMedia : public Node
*
* All BMC state properties will be retrieved before sending reset request.
*/
- void doVmAction(std::shared_ptr<AsyncResp> asyncResp,
- const std::string &service, const std::string &name,
- bool legacy, const std::string &imageUrl)
+ void doMountVmLegacy(std::shared_ptr<AsyncResp> asyncResp,
+ const std::string &service, const std::string &name,
+ const std::string &imageUrl, const bool rw)
{
-
- // Legacy mount requires parameter with image
- if (legacy)
- {
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec;
- messages::internalError(asyncResp->res);
-
- return;
- }
- },
- service, "/xyz/openbmc_project/VirtualMedia/Legacy/" + name,
- "xyz.openbmc_project.VirtualMedia.Legacy", "Mount", imageUrl);
- }
- else // proxy
- {
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec;
- messages::internalError(asyncResp->res);
-
- return;
- }
- },
- service, "/xyz/openbmc_project/VirtualMedia/Proxy/" + name,
- "xyz.openbmc_project.VirtualMedia.Proxy", "Mount");
- }
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code ec, bool success) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "Bad D-Bus request error: " << ec;
+ messages::internalError(asyncResp->res);
+ }
+ else if (!success)
+ {
+ BMCWEB_LOG_ERROR << "Service responded with error";
+ messages::generalError(asyncResp->res);
+ }
+ },
+ service, "/xyz/openbmc_project/VirtualMedia/Legacy/" + name,
+ "xyz.openbmc_project.VirtualMedia.Legacy", "Mount", imageUrl, rw);
}
};