summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWludzik, Jozef <jozef.wludzik@intel.com>2020-07-28 18:14:37 +0300
committerWludzik, Jozef <jozef.wludzik@intel.com>2020-07-28 19:22:25 +0300
commit453a2fb573de983245b2a55d68945742e81534e3 (patch)
tree03958d51970d8a890d313cacd056dd80643e8502
parent05eb73ebe684b8d2879c3802029fd783bdf6686c (diff)
downloadvirtual-media-453a2fb573de983245b2a55d68945742e81534e3.tar.xz
Add missing "ImageURL" property to MountPoint interface
It fixes problem with missing information on VirtualMedia Redfish resource after user mounts media using legacy method. Part of VirtualMedia Redfish resource after fix: { ... "ConnectedVia": "URI", "Id": "Slot_2", "Image": null, "ImageName": "smb://127.0.0.1/public/openSUSE-15.1-x86_64.iso", "Inserted": true, ... } Tested: - Mounted and ejected media using legacy method with success. - Received proper details about mounted image from Redfish. Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com> Change-Id: I445b37aac27dd290ce07f589834c0a6a10d2ceef
-rw-r--r--src/state/initial_state.hpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/state/initial_state.hpp b/src/state/initial_state.hpp
index f64ff25..3a2346c 100644
--- a/src/state/initial_state.hpp
+++ b/src/state/initial_state.hpp
@@ -67,13 +67,13 @@ struct InitialState : public BasicStateT<InitialState>
processIface->register_property(
"Active", bool(false),
[](const bool& req, bool& property) { return 0; },
- [& machine = machine](const bool& property) -> bool {
+ [&machine = machine](const bool& property) -> bool {
return machine.getState().get_if<ActiveState>();
});
processIface->register_property(
"ExitCode", int32_t(0),
[](const int32_t& req, int32_t& property) { return 0; },
- [& machine = machine](const int32_t& property) {
+ [&machine = machine](const int32_t& property) {
return machine.getExitCode();
});
processIface->initialize();
@@ -91,6 +91,20 @@ struct InitialState : public BasicStateT<InitialState>
iface->register_property("EndpointId", machine.getConfig().endPointId);
iface->register_property("Socket", machine.getConfig().unixSocket);
iface->register_property(
+ "ImageURL", std::string(),
+ [](const std::string& req, std::string& property) {
+ throw sdbusplus::exception::SdBusError(
+ EPERM, "Setting ImageURL property is not allowed");
+ return -1;
+ },
+ [&target = machine.getTarget()](const std::string& property) {
+ if (target)
+ {
+ return target->imgUrl;
+ }
+ return std::string();
+ });
+ iface->register_property(
"Timeout", machine.getConfig().timeout.value_or(
Configuration::MountPoint::defaultTimeout));
iface->register_property(
@@ -101,7 +115,7 @@ struct InitialState : public BasicStateT<InitialState>
"not allowed");
return -1;
},
- [& config = machine.getConfig()](const int& property) -> int {
+ [&config = machine.getConfig()](const int& property) -> int {
return config.remainingInactivityTimeout.count();
});
iface->initialize();
@@ -130,7 +144,7 @@ struct InitialState : public BasicStateT<InitialState>
// Common unmount
iface->register_method(
- "Unmount", [& machine = machine, waitCnt,
+ "Unmount", [&machine = machine, waitCnt,
timerPeriod](boost::asio::yield_context yield) {
LogMsg(Logger::Info, "[App]: Unmount called on ",
machine.getName());
@@ -206,7 +220,7 @@ struct InitialState : public BasicStateT<InitialState>
using optional_fd = std::variant<int, unix_fd>;
iface->register_method(
- "Mount", [& machine = machine, handleMount](
+ "Mount", [&machine = machine, handleMount](
boost::asio::yield_context yield,
std::string imgUrl, bool rw, optional_fd fd) {
LogMsg(Logger::Info, "[App]: Mount called on ",
@@ -287,7 +301,7 @@ struct InitialState : public BasicStateT<InitialState>
else
{
iface->register_method(
- "Mount", [& machine = machine,
+ "Mount", [&machine = machine,
handleMount](boost::asio::yield_context yield) {
LogMsg(Logger::Info, "[App]: Mount called on ",
getObjectPath(machine), machine.getName());