From 7f80e0b534b91b3a868f33934d92024427235e89 Mon Sep 17 00:00:00 2001 From: Saqib Khan Date: Sun, 22 Oct 2017 11:29:07 -0500 Subject: 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 --- version.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'version.cpp') diff --git a/version.cpp b/version.cpp index 5dbab3508..c8fe7cf95 100644 --- a/version.cpp +++ b/version.cpp @@ -93,6 +93,46 @@ std::map Version::getValue( 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> properties; + + msg.read(interface, properties); + + for (const auto& p : properties) + { + if (p.first == "CurrentPowerState") + { + chassisState = p.second.get(); + } + } + + if ((parent.isVersionFunctional(this->versionId)) && + (chassisState != CHASSIS_STATE_OFF)) + { + if (deleteObject) + { + deleteObject.reset(nullptr); + } + } + else + { + if (!deleteObject) + { + deleteObject = std::make_unique(bus, objPath, *this); + } + } +} + } // namespace updater } // namespace software } // namespace openpower -- cgit v1.2.1