summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Tritz <mtritz@us.ibm.com>2017-09-21 00:53:06 -0500
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2017-09-28 19:31:25 +0000
commit234a07e856d3d03fe474a13d335df4d32e316ce6 (patch)
tree241517105fc778d5861a0d0571a8d61db980544e
parent833e4f3788dde8b3111fd97fcdbe67267fffdfb3 (diff)
downloadopenpower-pnor-code-mgmt-234a07e856d3d03fe474a13d335df4d32e316ce6.tar.gz
openpower-pnor-code-mgmt-234a07e856d3d03fe474a13d335df4d32e316ce6.zip
Host updater: Add function to delete all versions
As a part of openbmc/openbmc#2264, implements a DeleteAll for all non-functional host versions in the host updater. Change-Id: I2943df248463ba8b4537096cf08f902d758c24a0 Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
-rw-r--r--item_updater.cpp28
-rwxr-xr-xitem_updater.hpp9
2 files changed, 36 insertions, 1 deletions
diff --git a/item_updater.cpp b/item_updater.cpp
index d0a3562d0..261b9d6d8 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -459,6 +459,34 @@ void ItemUpdater::erase(std::string entryId)
activations.erase(entryId);
}
+void ItemUpdater::deleteAll()
+{
+ std::vector<std::string> deletableActivations;
+
+ for (const auto& activationIt : activations)
+ {
+ if (!isVersionFunctional(activationIt.first))
+ {
+ deletableActivations.push_back(activationIt.first);
+ }
+ }
+
+ for (const auto& deletableIt : deletableActivations)
+ {
+ ItemUpdater::erase(deletableIt);
+ }
+
+ // Remove any remaining pnor-ro- or pnor-rw- volumes that do not match
+ // the current version.
+ auto method = bus.new_method_call(
+ SYSTEMD_BUSNAME,
+ SYSTEMD_PATH,
+ SYSTEMD_INTERFACE,
+ "StartUnit");
+ method.append("obmc-flash-bios-cleanup.service", "replace");
+ bus.call_noreply(method);
+}
+
// TODO: openbmc/openbmc#1402 Monitor flash usage
void ItemUpdater::freeSpace()
{
diff --git a/item_updater.hpp b/item_updater.hpp
index 5d2a15eac..06e65a06d 100755
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -5,6 +5,7 @@
#include <xyz/openbmc_project/Common/FactoryReset/server.hpp>
#include "version.hpp"
#include "org/openbmc/Associations/server.hpp"
+#include "xyz/openbmc_project/Collection/DeleteAll/server.hpp"
namespace openpower
{
@@ -15,7 +16,8 @@ namespace updater
using ItemUpdaterInherit = sdbusplus::server::object::object<
sdbusplus::xyz::openbmc_project::Common::server::FactoryReset,
- sdbusplus::org::openbmc::server::Associations>;
+ sdbusplus::org::openbmc::server::Associations,
+ sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
namespace MatchRules = sdbusplus::bus::match::rules;
using AssociationList =
@@ -79,6 +81,11 @@ class ItemUpdater : public ItemUpdaterInherit
*/
void erase(std::string entryId);
+ /**
+ * @brief Erases any non-active pnor versions.
+ */
+ void deleteAll();
+
/** @brief Deletes the active pnor version with highest priority
if the total number of volume exceeds the threshold.
*/
OpenPOWER on IntegriCloud