From be5b9899d071e8f9937dc2701b53b81bcbed6cc1 Mon Sep 17 00:00:00 2001 From: Tom Joseph Date: Sat, 15 Jul 2017 00:55:23 +0530 Subject: dcmi: asset-tag: Add API to write asset tag to the DBUS object Change-Id: Ia4bf3f99a865617535c65a023c8e697792cd43b4 Signed-off-by: Tom Joseph --- dcmihandler.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'dcmihandler.cpp') 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(); } +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(assetTag)); + + auto reply = bus.call(method); + if (reply.is_method_error()) + { + log("Error in writing asset tag"); + elog(); + } +} + } // namespace dcmi ipmi_ret_t getAssetTag(ipmi_netfn_t netfn, ipmi_cmd_t cmd, -- cgit v1.2.1