sched-host-tran: add base interfaces for Scheduled Host Transition
Implement interfaces to get/set scheduledTime and requestedTransition.
Tested:
1. Check scheduledTime
# busctl get-property xyz.openbmc_project.State.ScheduledHostTransition \
/xyz/openbmc_project/state/host0 \
xyz.openbmc_project.State.ScheduledHostTransition ScheduledTime
t 0
# busctl set-property xyz.openbmc_project.State.ScheduledHostTransition \
/xyz/openbmc_project/state/host0 \
xyz.openbmc_project.State.ScheduledHostTransition ScheduledTime t 1
# busctl get-property xyz.openbmc_project.State.ScheduledHostTransition \
/xyz/openbmc_project/state/host0 \
xyz.openbmc_project.State.ScheduledHostTransition ScheduledTime
t 1
2. Check requestedTransition
# busctl get-property xyz.openbmc_project.State.ScheduledHostTransition \
/xyz/openbmc_project/state/host0 \
xyz.openbmc_project.State.ScheduledHostTransition RequestedTransition
s "xyz.openbmc_project.State.Host.Transition.On"
# busctl set-property xyz.openbmc_project.State.ScheduledHostTransition \
/xyz/openbmc_project/state/host0 \
xyz.openbmc_project.State.ScheduledHostTransition RequestedTransition \
s "xyz.openbmc_project.State.Host.Transition.Off"
# busctl get-property xyz.openbmc_project.State.ScheduledHostTransition \
/xyz/openbmc_project/state/host0 \
xyz.openbmc_project.State.ScheduledHostTransition RequestedTransition
s "xyz.openbmc_project.State.Host.Transition.Off"
Change-Id: Ie7da8034d37c1069db043772f35982ca821826ae
Signed-off-by: Carol Wang <wangkair@cn.ibm.com>
diff --git a/scheduled_host_transition.hpp b/scheduled_host_transition.hpp
new file mode 100644
index 0000000..ebf3fba
--- /dev/null
+++ b/scheduled_host_transition.hpp
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <sdbusplus/bus.hpp>
+#include <phosphor-logging/log.hpp>
+#include <xyz/openbmc_project/State/ScheduledHostTransition/server.hpp>
+
+namespace phosphor
+{
+namespace state
+{
+namespace manager
+{
+
+using ScheduledHostTransitionInherit = sdbusplus::server::object::object<
+ sdbusplus::xyz::openbmc_project::State::server::ScheduledHostTransition>;
+
+/** @class ScheduledHostTransition
+ * @brief Scheduled host transition implementation.
+ * @details A concrete implementation for
+ * xyz.openbmc_project.State.ScheduledHostTransition
+ */
+class ScheduledHostTransition : public ScheduledHostTransitionInherit
+{
+ public:
+ ScheduledHostTransition(sdbusplus::bus::bus& bus, const char* objPath) :
+ ScheduledHostTransitionInherit(bus, objPath)
+ {
+ }
+
+ ~ScheduledHostTransition() = default;
+
+ /**
+ * @brief Handle with scheduled time
+ *
+ * @param[in] value - The seconds since epoch
+ * @return The time for the transition. It is the same as the input value if
+ * it is set successfully. Otherwise, it won't return value, but throw an
+ * error.
+ **/
+ uint64_t scheduledTime(uint64_t value) override;
+};
+} // namespace manager
+} // namespace state
+} // namespace phosphor
\ No newline at end of file