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/activation.cpp b/activation.cpp
index 9859cd6..d4ca885 100644
--- a/activation.cpp
+++ b/activation.cpp
@@ -4,7 +4,6 @@
#include "serialize.hpp"
#include <phosphor-logging/log.hpp>
-
namespace phosphor
{
namespace software
@@ -38,11 +37,6 @@
return;
}
-void Delete::delete_()
-{
- parent.parent.erase(parent.versionId);
-}
-
auto Activation::activation(Activations value) ->
Activations
{
@@ -113,6 +107,9 @@
roVolumeCreated = false;
Activation::unsubscribeFromSystemdSignals();
+ // Remove version object from image manager
+ Activation::deleteImageManagerObject();
+
// Create active association
parent.createActiveAssociation(path);
@@ -128,6 +125,47 @@
return softwareServer::Activation::activation(value);
}
+void Activation::deleteImageManagerObject()
+{
+ // Get the Delete object for <versionID> inside image_manager
+ auto method = this->bus.new_method_call(MAPPER_BUSNAME,
+ MAPPER_PATH,
+ MAPPER_INTERFACE,
+ "GetObject");
+ method.append(path);
+ method.append(std::vector<std::string>({
+ "xyz.openbmc_project.Object.Delete"}));
+ auto mapperResponseMsg = bus.call(method);
+ if (mapperResponseMsg.is_method_error())
+ {
+ log<level::ERR>("Error in Get Delete Object",
+ entry("VERSIONPATH=%s", path));
+ return;
+ }
+ std::map<std::string, std::vector<std::string>> mapperResponse;
+ mapperResponseMsg.read(mapperResponse);
+ if (mapperResponse.begin() == mapperResponse.end())
+ {
+ log<level::ERR>("ERROR in reading the mapper response",
+ entry("VERSIONPATH=%s", path));
+ return;
+ }
+
+ // Call the Delete object for <versionID> inside image_manager
+ method = this->bus.new_method_call((mapperResponse.begin()->first).c_str(),
+ path.c_str(),
+ "xyz.openbmc_project.Object.Delete",
+ "Delete");
+ mapperResponseMsg = bus.call(method);
+ //Check that the bus call didn't result in an error
+ if (mapperResponseMsg.is_method_error())
+ {
+ log<level::ERR>("Error in Deleting image from image manager",
+ entry("VERSIONPATH=%s", path));
+ return;
+ }
+}
+
auto Activation::requestedActivation(RequestedActivations value) ->
RequestedActivations
{