PNOR: Fix the delete implementation
- In order to remove the delete object from functional
image, the delete interface is moved inside the
version class so that both item_updater and image_manager
can make use of the same implementation.
- To avoid having two delete objects attached to the same
HOST version (item_updater and image_manager), we are now
deleting the image_manager object once the activation
is complete.
Partially resolves openbmc/openbmc#2490
Change-Id: Ie515cc01d5f154e6e55b9a3fb71d831730cd46f6
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/version.cpp b/version.cpp
index 5dbab35..c8fe7cf 100644
--- a/version.cpp
+++ b/version.cpp
@@ -93,6 +93,46 @@
return keys;
}
+void Delete::delete_()
+{
+ if (parent.eraseCallback)
+ {
+ parent.eraseCallback(parent.getId(parent.version()));
+ }
+}
+
+void Version::updateDeleteInterface(sdbusplus::message::message& msg)
+{
+ std::string interface, chassisState;
+ std::map<std::string, sdbusplus::message::variant<std::string>> properties;
+
+ msg.read(interface, properties);
+
+ for (const auto& p : properties)
+ {
+ if (p.first == "CurrentPowerState")
+ {
+ chassisState = p.second.get<std::string>();
+ }
+ }
+
+ if ((parent.isVersionFunctional(this->versionId)) &&
+ (chassisState != CHASSIS_STATE_OFF))
+ {
+ if (deleteObject)
+ {
+ deleteObject.reset(nullptr);
+ }
+ }
+ else
+ {
+ if (!deleteObject)
+ {
+ deleteObject = std::make_unique<Delete>(bus, objPath, *this);
+ }
+ }
+}
+
} // namespace updater
} // namespace software
} // namespace openpower