diff options
| author | Michael Tritz <mtritz@us.ibm.com> | 2017-09-18 16:38:23 -0500 |
|---|---|---|
| committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-09-29 01:53:54 +0000 |
| commit | bc1bf3af74d1ecac11dbb763369651bc6bf43db1 (patch) | |
| tree | 8554fc81c5517a745bf437e32bd8a15fb0389fe4 | |
| parent | b9da66347006afb23a010179d551a3c39df03225 (diff) | |
| download | phosphor-bmc-code-mgmt-bc1bf3af74d1ecac11dbb763369651bc6bf43db1.tar.gz phosphor-bmc-code-mgmt-bc1bf3af74d1ecac11dbb763369651bc6bf43db1.zip | |
BMC Updater: Add function to delete all versions
This commit extends the item updater with a function to delete all
non-current versions uploaded to the machine.
Resolves openbmc/openbmc#2264
Change-Id: I4d835d5020766f8bb5e9653b28535acfb191fe53
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
| -rw-r--r-- | item_updater.cpp | 27 | ||||
| -rw-r--r-- | item_updater.hpp | 8 |
2 files changed, 34 insertions, 1 deletions
diff --git a/item_updater.cpp b/item_updater.cpp index a19aebc..9f79963 100644 --- a/item_updater.cpp +++ b/item_updater.cpp @@ -297,6 +297,33 @@ void ItemUpdater::erase(std::string entryId) this->activations.erase(entryId); } +void ItemUpdater::deleteAll() +{ + std::vector<std::string> deletableVersions; + + for (const auto& versionIt : versions) + { + if (!versionIt.second->isFunctional()) + { + deletableVersions.push_back(versionIt.first); + } + } + + for (const auto& deletableIt : deletableVersions) + { + ItemUpdater::erase(deletableIt); + } + + // Remove any volumes that do not match current versions. + auto method = bus.new_method_call( + SYSTEMD_BUSNAME, + SYSTEMD_PATH, + SYSTEMD_INTERFACE, + "StartUnit"); + method.append("obmc-flash-bmc-cleanup.service", "replace"); + bus.call_noreply(method); +} + ItemUpdater::ActivationStatus ItemUpdater::validateSquashFSImage( const std::string& filePath) { diff --git a/item_updater.hpp b/item_updater.hpp index d55e807..580aecf 100644 --- a/item_updater.hpp +++ b/item_updater.hpp @@ -6,6 +6,7 @@ #include <xyz/openbmc_project/Common/FactoryReset/server.hpp> #include <xyz/openbmc_project/Control/FieldMode/server.hpp> #include "org/openbmc/Associations/server.hpp" +#include "xyz/openbmc_project/Collection/DeleteAll/server.hpp" namespace phosphor { @@ -17,7 +18,8 @@ namespace updater using ItemUpdaterInherit = sdbusplus::server::object::object< sdbusplus::xyz::openbmc_project::Common::server::FactoryReset, sdbusplus::xyz::openbmc_project::Control::server::FieldMode, - sdbusplus::org::openbmc::server::Associations>; + sdbusplus::org::openbmc::server::Associations, + sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>; namespace MatchRules = sdbusplus::bus::match::rules; @@ -85,6 +87,10 @@ class ItemUpdater : public ItemUpdaterInherit */ void erase(std::string entryId); + /** + * @brief Deletes all versions except for the current one + */ + void deleteAll(); /** @brief Creates an active association to the * newly active software image |

