Refactor: remove DeleteAll interface
There is no need for ItemUpdater to implement DeleteAll interface,
remove it.
Also make Activation::versionId private and provide a public
getVersionId() method;
Make ItemUpdater::erase() to pass const reference.
Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: Ifd6c61fc21b2967d6c83f1df7aaa3b2e94cae86c
diff --git a/src/activation.hpp b/src/activation.hpp
index b46105b..7ad03c9 100644
--- a/src/activation.hpp
+++ b/src/activation.hpp
@@ -128,7 +128,7 @@
Status activationStatus, const AssociationList& assocs,
AssociationInterface* associationInterface) :
ActivationInherit(bus, path.c_str(), true),
- versionId(versionId), bus(bus), path(path),
+ bus(bus), path(path), versionId(versionId),
systemdSignals(
bus,
sdbusRule::type::signal() + sdbusRule::member("JobRemoved") +
@@ -171,8 +171,11 @@
RequestedActivations
requestedActivation(RequestedActivations value) override;
- /** @brief Version id */
- std::string versionId;
+ /** @brief Get the version ID */
+ const std::string& getVersionId() const
+ {
+ return versionId;
+ }
private:
/** @brief Check if systemd state change is relevant to this object
@@ -226,6 +229,9 @@
/** @brief Persistent DBus object path */
std::string path;
+ /** @brief Version id */
+ std::string versionId;
+
/** @brief Used to subscribe to dbus systemd signals */
sdbusplus::bus::match_t systemdSignals;
diff --git a/src/item_updater.cpp b/src/item_updater.cpp
index d9a502f..49b95df 100644
--- a/src/item_updater.cpp
+++ b/src/item_updater.cpp
@@ -123,7 +123,7 @@
return;
}
-void ItemUpdater::erase(std::string versionId)
+void ItemUpdater::erase(const std::string& versionId)
{
auto it = versions.find(versionId);
if (it == versions.end())
@@ -153,12 +153,6 @@
}
}
-void ItemUpdater::deleteAll()
-{
- // TODO: when PSU's running firmware is implemented, delete all versions
- // that are not the running firmware.
-}
-
void ItemUpdater::createActiveAssociation(const std::string& path)
{
assocs.emplace_back(
@@ -268,7 +262,7 @@
if (associations.empty())
{
// Remove the activation
- erase(activationPtr->versionId);
+ erase(activationPtr->getVersionId());
}
else
{
diff --git a/src/item_updater.hpp b/src/item_updater.hpp
index c0a64fa..67f6e57 100644
--- a/src/item_updater.hpp
+++ b/src/item_updater.hpp
@@ -25,8 +25,8 @@
class Version;
using ItemUpdaterInherit = sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Association::server::Definitions,
- sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
+ sdbusplus::xyz::openbmc_project::Association::server::Definitions>;
+
namespace MatchRules = sdbusplus::bus::match::rules;
/** @class ItemUpdater
@@ -57,12 +57,7 @@
*
* @param[in] versionId - Id of the version to delete
*/
- void erase(std::string versionId);
-
- /**
- * @brief Erases any non-active versions.
- */
- void deleteAll();
+ void erase(const std::string& versionId);
/** @brief Creates an active association to the
* newly active software image