summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0002-Entity-manager-Add-support-to-update-assetTag.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0002-Entity-manager-Add-support-to-update-assetTag.patch')
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0002-Entity-manager-Add-support-to-update-assetTag.patch176
1 files changed, 176 insertions, 0 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0002-Entity-manager-Add-support-to-update-assetTag.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0002-Entity-manager-Add-support-to-update-assetTag.patch
new file mode 100644
index 000000000..0fea3e8a0
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/configuration/entity-manager/0002-Entity-manager-Add-support-to-update-assetTag.patch
@@ -0,0 +1,176 @@
+From 0941036f4206d74bfc3d3e505a5d269fb39c48ff Mon Sep 17 00:00:00 2001
+From: mansijos <mansi.joshi@intel.com>
+Date: Tue, 6 Apr 2021 02:12:56 +0530
+Subject: [PATCH] Entity-manager: Add support to update assetTag
+
+Asset tag is an updateable property from User level interface like
+Redfish. User-level interface will update Asset tag in entity-manager,
+which will further update the needed FRU interface property exposed.
+
+Tested:
+Successfully updated in assetTag interface as well as in fru interface
+while using set-property and using redfish as well.
+The new value is preserved after BMC resets.
+
+Change-Id: If7fbfd8325488280f500ab0e2c8b38475813cc3f
+Signed-off-by: mansijos <mansi.joshi@intel.com>
+---
+ src/EntityManager.cpp | 95 +++++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 91 insertions(+), 4 deletions(-)
+
+diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
+index 490c0f5..139ba9a 100644
+--- a/src/EntityManager.cpp
++++ b/src/EntityManager.cpp
+@@ -48,9 +48,19 @@ constexpr const char* lastConfiguration = "/tmp/configuration/last.json";
+ constexpr const char* currentConfiguration = "/var/configuration/system.json";
+ constexpr const char* globalSchema = "global.json";
+ constexpr const int32_t maxMapperDepth = 0;
++constexpr const char* foundObject = "FoundProbe";
+
+ constexpr const bool debug = false;
+
++
++
++using foundProbeData = std::map<std::string, std::string>;
++static foundProbeData foundData;
++static std::map<std::string, foundProbeData> mapFoundData;
++
++constexpr const char* fruConn = "xyz.openbmc_project.FruDevice";
++constexpr const char* fruIntf = "xyz.openbmc_project.FruDevice";
++
+ struct CmpStr
+ {
+ bool operator()(const char* a, const char* b) const
+@@ -577,6 +587,43 @@ void addArrayToDbus(const std::string& name, const nlohmann::json& array,
+ }
+ }
+
++template <typename PropertyType>
++bool persistAssetTag(const PropertyType& newVal,
++ const std::string& jsonPointerString)
++{
++ std::size_t found = jsonPointerString.find_last_of("/\\");
++ std::string jsonPointerPath = jsonPointerString.substr(0, found);
++
++ auto it = mapFoundData.find(jsonPointerPath);
++ if (it == mapFoundData.end())
++ {
++ std::cerr << "Error in finding jsonPointerPath in mapFoundData"
++ << "\n";
++ return false;
++ }
++
++ foundProbeData& tmpMap = it->second;
++ auto foundPath = tmpMap.find("foundPath");
++ if (foundPath == tmpMap.end())
++ {
++ std::cerr << "No prob object data is avaliable in foundProbeData"
++ << "\n";
++ return false;
++ }
++
++ systemBus->async_method_call(
++ [](const boost::system::error_code& ec) {
++ if (ec)
++ {
++ std::cerr << "Error setting AssetTag in FRU interface " << ec
++ << "\n";
++ }
++ },
++ fruConn, foundPath->second, "org.freedesktop.DBus.Properties", "Set",
++ fruIntf, "PRODUCT_ASSET_TAG", std::variant<PropertyType>(newVal));
++ return true;
++}
++
+ template <typename PropertyType>
+ void addProperty(const std::string& propertyName, const PropertyType& value,
+ sdbusplus::asio::dbus_interface* iface,
+@@ -591,9 +638,18 @@ void addProperty(const std::string& propertyName, const PropertyType& value,
+ }
+ iface->register_property(
+ propertyName, value,
+- [&systemConfiguration,
++ [propertyName, &systemConfiguration,
+ jsonPointerString{std::string(jsonPointerString)}](
+ const PropertyType& newVal, PropertyType& val) {
++ if (propertyName == "AssetTag")
++ {
++ if (!persistAssetTag(newVal, jsonPointerString))
++ {
++ std::cerr << "error setting AssetTag in FRU interface\n";
++ return -1;
++ }
++ }
++
+ val = newVal;
+ if (!setJsonFromPointer(jsonPointerString, val,
+ systemConfiguration))
+@@ -993,6 +1049,9 @@ void postToDbus(const nlohmann::json& newConfiguration,
+ populateInterfaceFromJson(systemConfiguration, jsonPointerPath,
+ boardIface, boardValues, objServer);
+ jsonPointerPath += "/";
++
++ std::string foundPath;
++
+ // iterate through board properties
+ for (auto& boardField : boardValues.items())
+ {
+@@ -1002,9 +1061,28 @@ void postToDbus(const nlohmann::json& newConfiguration,
+ createInterface(objServer, boardName, boardField.key(),
+ boardKeyOrig);
+
+- populateInterfaceFromJson(systemConfiguration,
+- jsonPointerPath + boardField.key(),
+- iface, boardField.value(), objServer);
++ if (boardField.key() == "FoundProbe")
++ {
++ foundPath = boardField.value()["Path"];
++ }
++ if (boardField.key() ==
++ "xyz.openbmc_project.Inventory.Decorator.AssetTag")
++ {
++ foundData["foundPath"] = foundPath;
++ mapFoundData[jsonPointerPath + boardField.key()] =
++ foundData;
++
++ populateInterfaceFromJson(
++ systemConfiguration, jsonPointerPath + boardField.key(),
++ iface, boardField.value(), objServer,
++ sdbusplus::asio::PropertyPermission::readWrite);
++ }
++ else
++ {
++ populateInterfaceFromJson(
++ systemConfiguration, jsonPointerPath + boardField.key(),
++ iface, boardField.value(), objServer);
++ }
+ }
+ }
+
+@@ -1362,6 +1440,11 @@ void PerformScan::run()
+ {
+ continue; // non-numeric replacement
+ }
++
++ nlohmann::json recordVal = *recordPtr;
++ // Save the dbus path info of the device
++ recordVal[foundObject]["Path"] = std::get<1>(*itr);
++
+ usedNames.insert(nameIt.value());
+ auto usedIt = std::find(indexes.begin(),
+ indexes.end(), index);
+@@ -1439,6 +1522,10 @@ void PerformScan::run()
+ }
+ }
+
++ // Save the dbus path info of the device
++ record[foundObject]["Path"] =
++ std::get<1>(foundDeviceAndPath);
++
+ if (replaceStr)
+ {
+ std::cerr << "Duplicates found, replacing "
+--
+2.17.1
+