supportedTransitions: Add in support for new prop
This new property was added [1] to allow users to define the specific
host transition operations they want to allow.
This commit starts with the default, allowing all operations. Future
commits will provide mechanisms to configure this.
Tested:
```
busctl get-property xyz.openbmc_project.State.Host
/xyz/openbmc_project/state/host0
xyz.openbmc_project.State.Host
AllowedHostTransitions
as 5 "xyz.openbmc_project.State.Host.Transition.On"
"xyz.openbmc_project.State.Host.Transition.Off"
"xyz.openbmc_project.State.Host.Transition.Reboot"
"xyz.openbmc_project.State.Host.Transition.GracefulWarmReboot"
"xyz.openbmc_project.State.Host.Transition.ForceWarmReboot"
```
[1]: https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/68933
Change-Id: Ifdac18ab67e3e68d49b9bca9446ba84ee954f96c
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/host_state_manager.cpp b/host_state_manager.cpp
index cf8105f..bf5e79a 100644
--- a/host_state_manager.cpp
+++ b/host_state_manager.cpp
@@ -26,6 +26,7 @@
#include <fstream>
#include <iostream>
#include <map>
+#include <set>
#include <string>
// Register class version with Cereal
@@ -84,6 +85,14 @@
return;
}
+void Host::setupSupportedTransitions()
+{
+ std::set<Transition> supportedTransitions = {
+ Transition::On, Transition::Off, Transition::Reboot,
+ Transition::GracefulWarmReboot, Transition::ForceWarmReboot};
+ server::Host::allowedHostTransitions(supportedTransitions);
+}
+
void Host::createSystemdTargetMaps()
{
stateTargetTable = {
diff --git a/host_state_manager.hpp b/host_state_manager.hpp
index 8227a06..3c21d80 100644
--- a/host_state_manager.hpp
+++ b/host_state_manager.hpp
@@ -78,6 +78,9 @@
// Will throw exception on fail
determineInitialState();
+ // Setup supported transitions against this host object
+ setupSupportedTransitions();
+
// Sets auto-reboot attempts to max-allowed
attemptsLeft(sdbusplus::server::xyz::openbmc_project::control::boot::
RebootAttempts::retryAttempts());
@@ -160,6 +163,13 @@
void determineInitialState();
/**
+ * @brief Configure supported transitions for system
+ *
+ * @return Will throw exceptions on failure
+ **/
+ void setupSupportedTransitions();
+
+ /**
* create systemd target instance names and mapping table
**/
void createSystemdTargetMaps();