Move single FAB API under the separate class
SingleFab class provides functionalities to support single FAB feature.
This commit moves the single FAB related API under SingleFab class.
Change-Id: I8d55cd2134f5812f83f5fc5033df097ab1b1f8f2
Signed-off-by: Anupama B R <anupama.b.r1@ibm.com>
diff --git a/vpd-manager/include/constants.hpp b/vpd-manager/include/constants.hpp
index cddc8ab..f71b18e 100644
--- a/vpd-manager/include/constants.hpp
+++ b/vpd-manager/include/constants.hpp
@@ -121,8 +121,6 @@
constexpr auto systemInvPath = "/xyz/openbmc_project/inventory/system";
constexpr auto pimPath = "/xyz/openbmc_project/inventory";
constexpr auto pimIntf = "xyz.openbmc_project.Inventory.Manager";
-constexpr auto pimPersistVsbpPath =
- "/var/lib/phosphor-inventory-manager/xyz/openbmc_project/inventory/system/chassis/motherboard/com.ibm.ipzvpd.VSBP";
constexpr auto ipzVpdInf = "com.ibm.ipzvpd.";
constexpr auto kwdVpdInf = "com.ibm.ipzvpd.VINI";
constexpr auto vsysInf = "com.ibm.ipzvpd.VSYS";
diff --git a/vpd-manager/include/single_fab.hpp b/vpd-manager/include/single_fab.hpp
new file mode 100644
index 0000000..03c6cee
--- /dev/null
+++ b/vpd-manager/include/single_fab.hpp
@@ -0,0 +1,26 @@
+#pragma once
+
+#include <string>
+
+namespace vpd
+{
+/**
+ * @brief class to implement single fab feature.
+ *
+ * The class hosts functionalities required to support single FAB feature.
+ *
+ */
+class SingleFab
+{
+ // ToDo: public API to be implemented, which can be called by the user to
+ // support single FAB.
+
+ private:
+ /**
+ * @brief API to get IM value from persisted location.
+ *
+ * @return IM value on success, empty string otherwise.
+ */
+ std::string getImFromPersistedLocation() const noexcept;
+};
+} // namespace vpd
diff --git a/vpd-manager/include/utility/json_utility.hpp b/vpd-manager/include/utility/json_utility.hpp
index 9ecdf74..c3d358c 100644
--- a/vpd-manager/include/utility/json_utility.hpp
+++ b/vpd-manager/include/utility/json_utility.hpp
@@ -1113,46 +1113,5 @@
return nlohmann::json{};
}
}
-
-/** @brief API to get IM value from persisted data location.
- *
- * @return IM value on success, empty string otherwise.
- */
-inline std::string getImFromPersistedLocation() noexcept
-{
- std::string l_imFilePath{constants::pimPersistVsbpPath};
-
- try
- {
- auto l_parsedVsbpJsonObj = getParsedJson(l_imFilePath);
- if (!l_parsedVsbpJsonObj.contains("value0") ||
- !l_parsedVsbpJsonObj["value0"].contains(constants::kwdIM) ||
- !l_parsedVsbpJsonObj["value0"][constants::kwdIM].is_array())
- {
- throw std::runtime_error(
- "Json is empty or mandatory tag(s) missing from JSON");
- }
-
- types::BinaryVector l_imValue =
- l_parsedVsbpJsonObj["value0"][constants::kwdIM]
- .get<types::BinaryVector>();
-
- std::ostringstream l_imData;
- for (auto& l_byte : l_imValue)
- {
- l_imData << std::setw(2) << std::setfill('0') << std::hex
- << static_cast<int>(l_byte);
- }
- return l_imData.str();
- }
- catch (const std::exception& l_ex)
- {
- logging::logMessage(
- "Error while getting IM value from PIM persisted file: " +
- l_imFilePath + ", reason: " + std::string(l_ex.what()));
- }
-
- return std::string();
-}
} // namespace jsonUtility
} // namespace vpd