Set ExtendedVersion property on Activations
Activation objects are created by this application in three scenarios:
1. When an InterfacesAdded event notifies the application about a new
PSU image that was uploaded to IMG_DIR (/tmp/images).
2. When getting the firmware version that is already running on a PSU
in the system.
3. When a firmware version is found in the file system (IMG_DIR_BUILTIN
or IMG_DIR_PERSIST).
In scenario #2, there are two Activation properties that are not set:
1. Path: the file system path to the image directory.
2. ExtendedVersion: contains the manufacturer and model.
In scenario #3, a firmware version may be found in the file system that
is the same as the version running on a PSU. In this case, the
Activation object has already been created. The Path property on the
existing Activation is set to the file system path.
However, the ExtendedVersion property of the existing Activation is not
set. Due to this, the Activation has no manufacturer or model
information. This means it cannot be used to update other PSUs.
Solve this problem by setting the ExtendedVersion property of the
existing Activation when a matching version is found in the file system.
This will enable the Activation to obtain the manufacturer and model
information. This in turn will allow the Activation to be used to update
other PSUs that are not running the latest version.
Tested:
* Verified that extendedVersion, manufacturer, and model data members
are set when the Activation constructor is called.
* Verified that extendedVersion, manufacturer, and model data members
are set when the new, overridden extendedVersion() method is called.
* Verified that the ExtendedVersion property is set by scanDirectory()
if an Activation already exists.
* For the complete test plan see:
https://gist.github.com/smccarney/2a3bf72c6faa436199a70968cd99e30e
Change-Id: I7107b8c1d631ada5cd55648f92cf2c1e5cd90778
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/src/activation.cpp b/src/activation.cpp
index 65db23b..a7ffd6c 100644
--- a/src/activation.cpp
+++ b/src/activation.cpp
@@ -25,10 +25,12 @@
constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
namespace fs = std::filesystem;
-namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server;
using namespace phosphor::logging;
-using SoftwareActivation = softwareServer::Activation;
+using SoftwareActivation =
+ sdbusplus::server::xyz::openbmc_project::software::Activation;
+using ExtendedVersion =
+ sdbusplus::server::xyz::openbmc_project::software::ExtendedVersion;
auto Activation::activation(Activations value) -> Activations
{
@@ -64,6 +66,15 @@
return SoftwareActivation::requestedActivation(value);
}
+auto Activation::extendedVersion(std::string value) -> std::string
+{
+ auto info = Version::getExtVersionInfo(value);
+ manufacturer = info["manufacturer"];
+ model = info["model"];
+
+ return ExtendedVersion::extendedVersion(value);
+}
+
void Activation::unitStateChange(sdbusplus::message_t& msg)
{
uint32_t newStateID{};
diff --git a/src/activation.hpp b/src/activation.hpp
index 092fe3d..cd90217 100644
--- a/src/activation.hpp
+++ b/src/activation.hpp
@@ -148,10 +148,6 @@
associations(assocs);
path(filePath);
- auto info = Version::getExtVersionInfo(extVersion);
- manufacturer = info["manufacturer"];
- model = info["model"];
-
// Emit deferred signal.
emit_object_added();
}
@@ -176,6 +172,14 @@
RequestedActivations
requestedActivation(RequestedActivations value) override;
+ /** @brief Overloaded ExtendedVersion property setter function
+ *
+ * @param[in] value - Extended version value
+ *
+ * @return New value of property
+ */
+ std::string extendedVersion(std::string value) override;
+
/** @brief Get the object path */
const std::string& getObjectPath() const
{
diff --git a/src/item_updater.cpp b/src/item_updater.cpp
index 62d2145..a77d2e4 100644
--- a/src/item_updater.cpp
+++ b/src/item_updater.cpp
@@ -535,9 +535,12 @@
}
else
{
- // This is a version that a running PSU is using, set the path
- // on the version object
+ // Activation already exists. It may have been created for code that is
+ // running on one or more PSUs. Set Path and ExtendedVersion properties.
+ // The properties are not set when the Activation is created for code
+ // running on a PSU. The properties are needed to update other PSUs.
it->second->path(modelDir);
+ it->second->extendedVersion(extVersion);
}
}
diff --git a/test/test_item_updater.cpp b/test/test_item_updater.cpp
index bf1fd9c..4f9af37 100644
--- a/test/test_item_updater.cpp
+++ b/test/test_item_updater.cpp
@@ -514,8 +514,8 @@
itemUpdater = std::make_unique<ItemUpdater>(mockedBus, dBusPath);
// The valid image in test/psu-images-valid-version0/model-3/ has the same
- // version as the running PSU, so no objects will be created, but only the
- // path will be set to the version object
+ // version as the running PSU, so no objects will be created. However, the
+ // Path and ExtendedVersion properties will be set on the Activation object.
EXPECT_CALL(sdbusMock, sd_bus_emit_object_added(_, StrEq(objPath)))
.Times(0);
EXPECT_CALL(sdbusMock, sd_bus_emit_properties_changed_strv(
@@ -523,6 +523,12 @@
StrEq("xyz.openbmc_project.Common.FilePath"),
Pointee(StrEq("Path"))))
.Times(1);
+ EXPECT_CALL(sdbusMock,
+ sd_bus_emit_properties_changed_strv(
+ _, StrEq(objPath),
+ StrEq("xyz.openbmc_project.Software.ExtendedVersion"),
+ Pointee(StrEq("ExtendedVersion"))))
+ .Times(1);
scanDirectory("./psu-images-valid-version0");
}