Activation: Create ActivationBlocksTransition
Create ActivationBlocksTransition when the Activation property is
set to Activating. Remove it when the property is set to anything else.
Change-Id: I7a6a1921f040a2e738751de1a3a138be5869afda
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/activation.cpp b/activation.cpp
index 2841839..4f2706d 100755
--- a/activation.cpp
+++ b/activation.cpp
@@ -7,18 +7,32 @@
namespace updater
{
+namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server;
+
auto Activation::activation(Activations value) ->
Activations
{
- return sdbusplus::xyz::openbmc_project::Software::server::Activation::
- activation(value);
+ 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
{
- return sdbusplus::xyz::openbmc_project::Software::server::Activation::
- requestedActivation(value);
+ return softwareServer::Activation::requestedActivation(value);
}
} // namespace updater
diff --git a/activation.hpp b/activation.hpp
index 4945531..4aff3e5 100755
--- a/activation.hpp
+++ b/activation.hpp
@@ -1,6 +1,6 @@
#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>
#include "xyz/openbmc_project/Software/ExtendedVersion/server.hpp"
@@ -18,6 +18,24 @@
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.
* @details A concrete implementation for
@@ -40,6 +58,8 @@
sdbusplus::xyz::openbmc_project::Software::
server::Activation::Activations activationStatus) :
ActivationInherit(bus, path.c_str(), true),
+ bus(bus),
+ path(path),
versionId(versionId)
{
// Set Properties.
@@ -66,26 +86,17 @@
RequestedActivations requestedActivation(RequestedActivations value)
override;
+ /** @brief Persistent sdbusplus DBus bus connection */
+ sdbusplus::bus::bus& bus;
+
+ /** @brief Persistent DBus object path */
+ std::string path;
+
/** @brief Version id */
std::string versionId;
-};
-/** @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()) {}
+ /** @brief Persistent ActivationBlocksTransition dbus object */
+ std::unique_ptr<ActivationBlocksTransition> activationBlocksTransition;
};
} // namespace updater