diff options
-rw-r--r-- | activation.cpp | 4 | ||||
-rw-r--r-- | activation.hpp | 64 | ||||
-rw-r--r-- | item_updater.cpp | 47 |
3 files changed, 86 insertions, 29 deletions
diff --git a/activation.cpp b/activation.cpp index ae8ebe9..1ed765c 100644 --- a/activation.cpp +++ b/activation.cpp @@ -38,9 +38,9 @@ void Activation::unsubscribeFromSystemdSignals() return; } -void Activation::delete_() +void Delete::delete_() { - parent.erase(versionId); + parent.parent.erase(parent.versionId); } auto Activation::activation(Activations value) -> diff --git a/activation.hpp b/activation.hpp index 6c303db..d1d050a 100644 --- a/activation.hpp +++ b/activation.hpp @@ -19,14 +19,15 @@ using AssociationList = std::vector<std::tuple<std::string, std::string, std::string>>; using ActivationInherit = sdbusplus::server::object::object< sdbusplus::xyz::openbmc_project::Software::server::Activation, - sdbusplus::org::openbmc::server::Associations, - sdbusplus::xyz::openbmc_project::Object::server::Delete>; + sdbusplus::org::openbmc::server::Associations>; using ActivationBlocksTransitionInherit = sdbusplus::server::object::object< sdbusplus::xyz::openbmc_project::Software::server::ActivationBlocksTransition>; using RedundancyPriorityInherit = sdbusplus::server::object::object< sdbusplus::xyz::openbmc_project::Software::server::RedundancyPriority>; using ActivationProgressInherit = sdbusplus::server::object::object< sdbusplus::xyz::openbmc_project::Software::server::ActivationProgress>; +using DeleteInherit = sdbusplus::server::object::object< + sdbusplus::xyz::openbmc_project::Object::server::Delete>; namespace sdbusRule = sdbusplus::bus::match::rules; @@ -166,8 +167,55 @@ class ActivationProgress : public ActivationProgressInherit std::string path; }; -// TODO: openbmc/openbmc#2086 - Add removeActiveAssociation() after -// Delete() is implemented +/** @class ActivationDelete + * @brief OpenBMC Delete implementation. + * @details A concrete implementation for xyz.openbmc_project.Object.Delete + * DBus API. + */ +class Delete : public DeleteInherit +{ + public: + /** @brief Constructs Delete. + * + * @param[in] bus - The Dbus bus object + * @param[in] path - The Dbus object path + * @param[in] parent - Parent object. + */ + // Delete(sdbusplus::bus::bus& bus, const std::string& path) : + Delete(sdbusplus::bus::bus& bus, + const std::string& path, + Activation& parent) : + DeleteInherit(bus, path.c_str(), true), + parent(parent), + bus(bus), + path(path) + { + std::vector<std::string> interfaces({interface}); + bus.emit_interfaces_added(path.c_str(), interfaces); + } + + ~Delete() + { + std::vector<std::string> interfaces({interface}); + bus.emit_interfaces_removed(path.c_str(), interfaces); + } + + /** + * @brief delete the d-bus object. + */ + void delete_() override; + + /** @brief Parent Object. */ + Activation& parent; + + private: + // TODO Remove once openbmc/openbmc#1975 is resolved + static constexpr auto interface = + "xyz.openbmc_project.Object.Delete"; + sdbusplus::bus::bus& bus; + std::string path; +}; + /** @class Activation * @brief OpenBMC activation software management implementation. * @details A concrete implementation for @@ -272,11 +320,6 @@ class Activation : public ActivationInherit */ void updateUbootEnvVars(); - /** - * @brief delete the d-bus object. - */ - void delete_() override; - /** @brief Persistent sdbusplus DBus bus connection */ sdbusplus::bus::bus& bus; @@ -298,6 +341,9 @@ class Activation : public ActivationInherit /** @brief Persistent ActivationProgress dbus object */ std::unique_ptr<ActivationProgress> activationProgress; + /** @brief Persistent Delete dbus object */ + std::unique_ptr<Delete> deleteObject; + /** @brief Used to subscribe to dbus systemd signals **/ sdbusplus::bus::match_t systemdSignals; diff --git a/item_updater.cpp b/item_updater.cpp index 2282c28..33f4096 100644 --- a/item_updater.cpp +++ b/item_updater.cpp @@ -119,15 +119,19 @@ void ItemUpdater::createActivation(sdbusplus::message::message& msg) bmcInventoryPath)); } - activations.insert(std::make_pair( - versionId, - std::make_unique<Activation>( - bus, - path, - *this, - versionId, - activationState, - associations))); + auto activationPtr = std::make_unique<Activation>( + bus, + path, + *this, + versionId, + activationState, + associations); + + activationPtr->deleteObject = + std::make_unique<Delete>(bus, path, *activationPtr); + + activations.insert(std::make_pair(versionId, std::move(activationPtr))); + versions.insert(std::make_pair( versionId, std::make_unique<VersionClass>( @@ -212,15 +216,22 @@ void ItemUpdater::processBMCImage() std::move(versionPtr))); // Create Activation instance for this version. - activations.insert(std::make_pair( - id, - std::make_unique<Activation>( - bus, - path, - *this, - id, - server::Activation::Activations::Active, - associations))); + auto activationPtr = std::make_unique<Activation>( + bus, + path, + *this, + id, + activationState, + associations); + + // Add Delete() if this isn't the functional version + if (!isVersionFunctional) + { + activationPtr->deleteObject = + std::make_unique<Delete>(bus, path, *activationPtr); + } + + activations.insert(std::make_pair(id, std::move(activationPtr))); // If Active, create RedundancyPriority instance for this version. if (activationState == server::Activation::Activations::Active) |