Fix "Error in Deleting image from image manager"
When deleting the updated image from the Version object,
the code would query the mapper to get the busname. This
call would return 2 busnames, the one for the Activation
object and the one for the Version object. Then the code
would call Delete on the first busname on the list which
would be the Activation one, causing an error because the
running image can't be deleted from the Activation object.
Instead of querying the mapper for all busnames of a path,
and adding logic to figure out which one is the Version one,
the updater already knows the Version busname, so just use
that directly.
Part of openbmc/openbmc#2764
Change-Id: Ia490e11c0fd312fe0c05279964c2cb0c4461ccb3
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/activation.cpp b/activation.cpp
index d4ca885..72cc212 100644
--- a/activation.cpp
+++ b/activation.cpp
@@ -127,36 +127,12 @@
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(),
+ auto method = this->bus.new_method_call(VERSION_BUSNAME,
path.c_str(),
"xyz.openbmc_project.Object.Delete",
"Delete");
- mapperResponseMsg = bus.call(method);
+ auto mapperResponseMsg = bus.call(method);
//Check that the bus call didn't result in an error
if (mapperResponseMsg.is_method_error())
{