summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorCzarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>2019-12-20 16:15:32 +0300
committerCzarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>2020-01-29 00:58:16 +0300
commit332c885786635d2ab0d797105fee8e90400388c3 (patch)
treef86d67dd0076f51e72eaabdbe969909e36d2ac33 /src/main.cpp
parent4356bc7e028534877aa9aad5a8b7102020acf261 (diff)
downloadvirtual-media-332c885786635d2ab0d797105fee8e90400388c3.tar.xz
Manage remote media state transitions
This is a first part of bigger functionality which provides host to use virtual media. First part provides skeleton and definitions of states and events defining state machine, also brings working implementation of proxy mode and some starting point to implement legacy mode. There are at least three additional patchsets implementing legacy mode with https and cifs support and secure passing of secrets. Specifically this change adds StateMachine class used to keep track state of each mount point: - StateMachine is made as std::variant of object derived from BasicState. - Each state has its own possible transitions defined (events). - Transitions defines appropriate behavior. - Specific event triggers transition from one to other specific state (1:1 relation). Tested: Manual tests on WilsonCity platform: - mounting and unmounting using redfish and webui - check state on dbus interfaces Change-Id: I4b13085e1f8884fcedd7d97e76910c21e87ab7f8 Signed-off-by: Rapkiewicz, Pawel <pawel.rapkiewicz@intel.com> Signed-off-by: Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 792cdf2..3636e59 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,5 +1,6 @@
#include "configuration.hpp"
#include "logger.hpp"
+#include "state_machine.hpp"
#include "system.hpp"
#include <sys/mount.h>
@@ -40,12 +41,25 @@ class App
objManager = std::make_shared<sdbusplus::server::manager::manager>(
*bus, "/xyz/openbmc_project/VirtualMedia");
- devMonitor.run([](const NBDDevice& device, StateChange change) {
- // placeholder for some future actions
+ for (const auto& [name, entry] : config.mountPoints)
+ {
+ mpsm[name] = std::make_shared<MountPointStateMachine>(
+ ioc, devMonitor, name, entry);
+ mpsm[name]->emitRegisterDBusEvent(bus, objServer);
+ }
+
+ devMonitor.run([this](const NBDDevice& device, StateChange change) {
+ for (auto& [name, entry] : mpsm)
+ {
+ entry->emitUdevStateChangeEvent(device, change);
+ }
});
}
private:
+ boost::container::flat_map<std::string,
+ std::shared_ptr<MountPointStateMachine>>
+ mpsm;
boost::asio::io_context& ioc;
std::shared_ptr<sdbusplus::asio::connection> bus;
std::shared_ptr<sdbusplus::asio::object_server> objServer;