Implementation of deleteFRUVPD api
The api sets present property of given FRU as false.
If the present property is already set to false, it will
log error.
One of the use case:
This api is to be called before requesting VPD parser to
collect VPD of any given FRU in case of concurrent
maintenance.
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
Change-Id: Ibbe2eba34e586e02bcb0bec38945a81d1efe6109
diff --git a/ibm_vpd_utils.cpp b/ibm_vpd_utils.cpp
index de25528..b135d5e 100644
--- a/ibm_vpd_utils.cpp
+++ b/ibm_vpd_utils.cpp
@@ -145,7 +145,7 @@
auto result = bus.call(properties);
if (!result.is_method_error())
{
- std::variant<Binary, std::string> val;
+ inventory::Value val;
result.read(val);
if (auto pVal = std::get_if<Binary>(&val))
{
@@ -156,6 +156,17 @@
{
propVal.assign(pVal->data(), pVal->size());
}
+ else if (auto pVal = get_if<bool>(&val))
+ {
+ if (*pVal == false)
+ {
+ propVal = "false";
+ }
+ else
+ {
+ propVal = "true";
+ }
+ }
}
return propVal;
}
diff --git a/vpd-manager/manager.cpp b/vpd-manager/manager.cpp
index 23e6290..4c8b416 100644
--- a/vpd-manager/manager.cpp
+++ b/vpd-manager/manager.cpp
@@ -12,6 +12,7 @@
#include <filesystem>
#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
using namespace openpower::vpd::constants;
using namespace openpower::vpd::inventory;
@@ -68,6 +69,11 @@
interface->register_method("PerformVPDRecollection",
[this]() { this->performVPDRecollection(); });
+ interface->register_method(
+ "deleteFRUVPD", [this](const sdbusplus::message::object_path& path) {
+ this->deleteFRUVPD(path);
+ });
+
sd_bus_default(&sdBus);
initManager();
}
@@ -585,6 +591,38 @@
}
}
+void Manager::deleteFRUVPD(const sdbusplus::message::object_path& path)
+{
+ using InvalidArgument =
+ sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument;
+ using Argument = xyz::openbmc_project::Common::InvalidArgument;
+
+ // if path not found in Json.
+ if (frus.find(path) == frus.end())
+ {
+ elog<InvalidArgument>(
+ Argument::ARGUMENT_NAME("Object Path"),
+ Argument::ARGUMENT_VALUE(std::string(path).c_str()));
+ }
+
+ // if the FRU is not present then log error
+ if (readBusProperty(path, "xyz.openbmc_project.Inventory.Item",
+ "Present") == "false")
+ {
+ elog<InvalidArgument>(
+ Argument::ARGUMENT_NAME("FRU not preset"),
+ Argument::ARGUMENT_VALUE(std::string(path).c_str()));
+ }
+ else
+ {
+ inventory::ObjectMap objectMap = {
+ {path,
+ {{"xyz.openbmc_project.Inventory.Item", {{"Present", false}}}}}};
+
+ common::utility::callPIM(move(objectMap));
+ }
+}
+
} // namespace manager
} // namespace vpd
} // namespace openpower
\ No newline at end of file
diff --git a/vpd-manager/manager.hpp b/vpd-manager/manager.hpp
index 12fc1d4..13de42e 100644
--- a/vpd-manager/manager.hpp
+++ b/vpd-manager/manager.hpp
@@ -110,6 +110,13 @@
*/
void performVPDRecollection();
+ /** @brief Api to delete FRU VPD.
+ * This api will set the present property of given FRU to false. If already
+ * set to false, It will log an error.
+ * @param[in] path - Object path of FRU.
+ */
+ void deleteFRUVPD(const sdbusplus::message::object_path& path);
+
private:
/**
* @brief An api to process some initial requirements.