BMC: Fix the delete implementation.
- Implement delete interface inside version class
so that both item_updater and image_manager can
share the same interface. This meant removing the
delete interface from inside the activation class.
- The delete is created as a separate object inside
version, only if the image is non-functional.
This helps remove the delete interface from a
running BMC/HOST image.
- As part of the activation process, the version from
inside the image_manager is deleted and so is the
version's tarfile from the image upload dir.
Partially resolves openbmc/openbmc#2490
Change-Id: Ib35bf188df85ebd2277d3d9ad04300e434965eea
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/version.hpp b/version.hpp
index 99c64c9..b7efe44 100644
--- a/version.hpp
+++ b/version.hpp
@@ -3,6 +3,7 @@
#include <sdbusplus/bus.hpp>
#include "xyz/openbmc_project/Software/Version/server.hpp"
#include "xyz/openbmc_project/Common/FilePath/server.hpp"
+#include "xyz/openbmc_project/Object/Delete/server.hpp"
#include <functional>
namespace phosphor
@@ -17,6 +18,58 @@
using VersionInherit = sdbusplus::server::object::object<
sdbusplus::xyz::openbmc_project::Software::server::Version,
sdbusplus::xyz::openbmc_project::Common::server::FilePath>;
+using DeleteInherit = sdbusplus::server::object::object<
+ sdbusplus::xyz::openbmc_project::Object::server::Delete>;
+
+class Version;
+class Delete;
+
+/** @class Delete
+ * @brief OpenBMC Delete implementation.
+ * @details A concrete implementation for xyz.openbmc_project.Object.Delete
+ * D-Bus API.
+ */
+class Delete : public DeleteInherit
+{
+ public:
+ /** @brief Constructs Delete.
+ *
+ * @param[in] bus - The D-Bus bus object
+ * @param[in] path - The D-Bus object path
+ * @param[in] parent - Parent object.
+ */
+ Delete(sdbusplus::bus::bus& bus,
+ const std::string& path,
+ Version& 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;
+
+ private:
+
+ /** @brief Parent Object. */
+ Version& parent;
+
+ // 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 Version
* @brief OpenBMC version software management implementation.
@@ -33,15 +86,19 @@
* @param[in] versionString - The version string
* @param[in] versionPurpose - The version purpose
* @param[in] filePath - The image filesystem path
+ * @param[in] callback - The eraseFunc callback
*/
Version(sdbusplus::bus::bus& bus,
const std::string& objPath,
const std::string& versionString,
VersionPurpose versionPurpose,
- const std::string& filePath) : VersionInherit(
+ const std::string& filePath,
+ eraseFunc callback) : VersionInherit(
bus, (objPath).c_str(), true),
versionStr(versionString)
{
+ // Bind erase method
+ eraseCallback = callback;
// Set properties.
purpose(versionPurpose);
version(versionString);
@@ -87,7 +144,14 @@
*/
bool isFunctional();
+ /** @brief Persistent Delete D-Bus object */
+ std::unique_ptr<Delete> deleteObject;
+
+ /** @brief The parent's erase callback. */
+ eraseFunc eraseCallback;
+
private:
+
/** @brief This Version's version string */
const std::string versionStr;
};