Create Constructor for BMC Activation
- Create Activation Block Transition
- Create override functions so that actions can be taken
based on the value that the properties are being set to.
- Create ActivationBlockTransition when the Activating
property is set to Activating. Remove it when the property
is set to anything else.
Change-Id: Id48d049cca54ae0bcbed6afe41e67e20e6a5e44c
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/Makefile.am b/Makefile.am
index 62e7ae5..7d65c7a 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,7 +7,8 @@
watch.hpp \
version.hpp \
image_manager.hpp \
- item_updater.hpp
+ item_updater.hpp \
+ activation.hpp
sbin_PROGRAMS = \
phosphor-version-software-manager \
@@ -35,6 +36,7 @@
download_manager_main.cpp
phosphor_image_updater_SOURCES = \
+ activation.cpp \
item_updater.cpp \
item_updater_main.cpp
diff --git a/activation.cpp b/activation.cpp
new file mode 100644
index 0000000..3f8795c
--- /dev/null
+++ b/activation.cpp
@@ -0,0 +1,54 @@
+#include "activation.hpp"
+
+namespace phosphor
+{
+namespace software
+{
+namespace updater
+{
+
+namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server;
+
+auto Activation::activation(Activations value) ->
+ Activations
+{
+ if (value == softwareServer::Activation::Activations::Activating)
+ {
+ if (!activationBlocksTransition)
+ {
+ activationBlocksTransition =
+ std::make_unique<ActivationBlocksTransition>(
+ bus,
+ path);
+ }
+ }
+ else
+ {
+ activationBlocksTransition.reset(nullptr);
+ }
+ return softwareServer::Activation::activation(value);
+}
+
+auto Activation::requestedActivation(RequestedActivations value) ->
+ RequestedActivations
+{
+ if ((value == softwareServer::Activation::RequestedActivations::Active) &&
+ (softwareServer::Activation::requestedActivation() !=
+ softwareServer::Activation::RequestedActivations::Active))
+ {
+ if ((softwareServer::Activation::activation() ==
+ softwareServer::Activation::Activations::Ready) ||
+ (softwareServer::Activation::activation() ==
+ softwareServer::Activation::Activations::Failed))
+ {
+ Activation::activation(
+ softwareServer::Activation::Activations::Activating);
+
+ }
+ }
+ return softwareServer::Activation::requestedActivation(value);
+}
+
+} // namespace updater
+} // namespace software
+} // namespace phosphor
diff --git a/activation.hpp b/activation.hpp
index 3b5e254..09183f1 100644
--- a/activation.hpp
+++ b/activation.hpp
@@ -1,7 +1,8 @@
#pragma once
-#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server.hpp>
#include <xyz/openbmc_project/Software/Activation/server.hpp>
+#include <xyz/openbmc_project/Software/ActivationBlocksTransition/server.hpp>
namespace phosphor
{
@@ -12,6 +13,26 @@
using ActivationInherit = sdbusplus::server::object::object<
sdbusplus::xyz::openbmc_project::Software::server::Activation>;
+using ActivationBlocksTransitionInherit = sdbusplus::server::object::object<
+ sdbusplus::xyz::openbmc_project::Software::server::ActivationBlocksTransition>;
+
+/** @class ActivationBlocksTransition
+ * @brief OpenBMC ActivationBlocksTransition implementation.
+ * @details A concrete implementation for
+ * xyz.openbmc_project.Software.ActivationBlocksTransition DBus API.
+ */
+class ActivationBlocksTransition : public ActivationBlocksTransitionInherit
+{
+ public:
+ /** @brief Constructs ActivationBlocksTransition.
+ *
+ * @param[in] bus - The Dbus bus object
+ * @param[in] path - The Dbus object path
+ */
+ ActivationBlocksTransition(sdbusplus::bus::bus& bus,
+ const std::string& path) :
+ ActivationBlocksTransitionInherit(bus, path.c_str()) {}
+};
/** @class Activation
* @brief OpenBMC activation software management implementation.
@@ -43,6 +64,23 @@
emit_object_added();
}
+ /** @brief Overloaded Activation property setter function
+ *
+ * @param[in] value - One of Activation::Activations
+ *
+ * @return Success or exception thrown
+ */
+ Activations activation(Activations value) override;
+
+ /** @brief Overloaded requestedActivation property setter function
+ *
+ * @param[in] value - One of Activation::RequestedActivations
+ *
+ * @return Success or exception thrown
+ */
+ RequestedActivations requestedActivation(RequestedActivations value)
+ override;
+
/** @brief Persistent sdbusplus DBus bus connection */
sdbusplus::bus::bus& bus;
@@ -51,6 +89,9 @@
/** @brief Version id */
std::string versionId;
+
+ /** @brief Persistent ActivationBlocksTransition dbus object */
+ std::unique_ptr<ActivationBlocksTransition> activationBlocksTransition;
};
} // namespace updater