summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dcmihandler.cpp26
-rw-r--r--dcmihandler.hpp6
2 files changed, 32 insertions, 0 deletions
diff --git a/dcmihandler.cpp b/dcmihandler.cpp
index 0b98036..4c4f8b7 100644
--- a/dcmihandler.cpp
+++ b/dcmihandler.cpp
@@ -105,6 +105,32 @@ std::string readAssetTag()
return assetTag.get<std::string>();
}
+void writeAssetTag(const std::string& assetTag)
+{
+ sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
+ dcmi::assettag::ObjectTree objectTree;
+
+ // Read the object tree with the inventory root to figure out the object
+ // that has implemented the Asset tag interface.
+ readAssetTagObjectTree(objectTree);
+
+ auto method = bus.new_method_call(
+ (objectTree.begin()->second.begin()->first).c_str(),
+ (objectTree.begin()->first).c_str(),
+ dcmi::propIntf,
+ "Set");
+ method.append(dcmi::assetTagIntf);
+ method.append(dcmi::assetTagProp);
+ method.append(sdbusplus::message::variant<std::string>(assetTag));
+
+ auto reply = bus.call(method);
+ if (reply.is_method_error())
+ {
+ log<level::ERR>("Error in writing asset tag");
+ elog<InternalFailure>();
+ }
+}
+
} // namespace dcmi
ipmi_ret_t getAssetTag(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
diff --git a/dcmihandler.hpp b/dcmihandler.hpp
index c64e56b..de0d82f 100644
--- a/dcmihandler.hpp
+++ b/dcmihandler.hpp
@@ -96,6 +96,12 @@ void readAssetTagObjectTree(dcmi::assettag::ObjectTree& objectTree);
*/
std::string readAssetTag();
+/** @brief Write the asset tag to the asset tag DBUS property
+ *
+ * @param[in] assetTag - Asset Tag to be written to the property.
+ */
+void writeAssetTag(const std::string& assetTag);
+
} // namespace dcmi
#endif
OpenPOWER on IntegriCloud