From 453a2fb573de983245b2a55d68945742e81534e3 Mon Sep 17 00:00:00 2001 From: "Wludzik, Jozef" Date: Tue, 28 Jul 2020 17:14:37 +0200 Subject: 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 Change-Id: I445b37aac27dd290ce07f589834c0a6a10d2ceef --- src/state/initial_state.hpp | 26 ++++++++++++++++++++------ 1 file 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 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(); }); 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(); @@ -90,6 +90,20 @@ struct InitialState : public BasicStateT machine.getConfig().nbdDevice.to_string()); 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)); @@ -101,7 +115,7 @@ struct InitialState : public BasicStateT "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 // 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 using optional_fd = std::variant; 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 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()); -- cgit v1.2.3