API to check is field mode enabled
This commit implements an API to check if field mode is enabled.
Change-Id: Icb2ae1df2588e5cb3fd81e30bf739745de5fbb42
Signed-off-by: Rekha Aparna <vrekhaaparna@ibm.com>
diff --git a/vpd-manager/include/single_fab.hpp b/vpd-manager/include/single_fab.hpp
index c618cb8..0e456e8 100644
--- a/vpd-manager/include/single_fab.hpp
+++ b/vpd-manager/include/single_fab.hpp
@@ -38,5 +38,12 @@
* @return true if value updated successfully, otherwise false.
*/
bool setImOnPlanar(const std::string& i_imValue) const noexcept;
+
+ /**
+ * @brief API to check is field mode enabled.
+ *
+ * @return true, if field mode is enabled. otherwise false.
+ */
+ bool isFieldModeEnabled() const noexcept;
};
} // namespace vpd
diff --git a/vpd-manager/src/single_fab.cpp b/vpd-manager/src/single_fab.cpp
index c198841..5cf8602 100644
--- a/vpd-manager/src/single_fab.cpp
+++ b/vpd-manager/src/single_fab.cpp
@@ -7,6 +7,7 @@
#include "types.hpp"
#include <nlohmann/json.hpp>
+#include <utility/common_utility.hpp>
#include <utility/json_utility.hpp>
namespace vpd
@@ -111,4 +112,24 @@
return false;
}
}
+
+bool SingleFab::isFieldModeEnabled() const noexcept
+{
+ try
+ {
+ std::vector<std::string> l_cmdOutput =
+ commonUtility::executeCmd("/sbin/fw_printenv -n fieldmode 2>&1");
+
+ if (l_cmdOutput.size() > 0)
+ {
+ commonUtility::toLower(l_cmdOutput[0]);
+
+ return l_cmdOutput[0] == "false" ? false : true;
+ }
+ }
+ catch (const std::exception& l_ex)
+ {}
+
+ return false;
+}
} // namespace vpd