item_updater: Add version dbus object.
Implementing the Version object under item_updater helps
to retain the version of the active images after the bmc
is rebooted and the image_dir no longer holds version file.
Change-Id: I55349bbc62b212b4e034239f4f6743129c8b1070
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index bc382e8..9e909d9 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -5,6 +5,7 @@
#include "item_updater.hpp"
#include "xyz/openbmc_project/Software/Version/server.hpp"
#include <experimental/filesystem>
+#include "version.hpp"
namespace phosphor
{
@@ -24,6 +25,8 @@
void ItemUpdater::createActivation(sdbusplus::message::message& msg)
{
sdbusplus::message::object_path objPath;
+ auto purpose = server::Version::VersionPurpose::Unknown;
+ std::string version;
std::map<std::string,
std::map<std::string,
sdbusplus::message::variant<std::string>>> interfaces;
@@ -32,28 +35,31 @@
for (const auto& intf : interfaces)
{
- if (intf.first.compare(VERSION_IFACE))
+ if (intf.first == VERSION_IFACE)
{
- continue;
- }
-
- for (const auto& property : intf.second)
- {
- if (!property.first.compare("Purpose"))
+ for (const auto& property : intf.second)
{
- // Only process the BMC images
- auto value = sdbusplus::message::variant_ns::get<std::string>(
- property.second);
- if (value !=
- convertForMessage(server::Version::VersionPurpose::BMC) &&
- value !=
- convertForMessage(server::Version::VersionPurpose::System))
+ if (property.first == "Purpose")
{
- return;
+ std::string str = sdbusplus::message::variant_ns::
+ get<std::string>(property.second);
+ purpose = server::Version::
+ convertVersionPurposeFromString(str);
+ }
+ else if (property.first == "Version")
+ {
+ version = sdbusplus::message::variant_ns::
+ get<std::string>(property.second);
}
}
}
}
+ if (version.empty() ||
+ (purpose != server::Version::VersionPurpose::BMC &&
+ purpose != server::Version::VersionPurpose::System))
+ {
+ return;
+ }
// Version id is the last item in the path
auto pos = path.rfind("/");
@@ -81,12 +87,21 @@
activationState = server::Activation::Activations::Active;
}
activations.insert(std::make_pair(
+ versionId,
+ std::make_unique<Activation>(
+ bus,
+ path,
versionId,
- std::make_unique<Activation>(
- bus,
- path,
- versionId,
- activationState)));
+ activationState)));
+ versions.insert(std::make_pair(
+ versionId,
+ std::make_unique<phosphor::software::
+ manager::Version>(
+ bus,
+ path,
+ version,
+ purpose,
+ "")));
}
return;
}