Move isFieldModeEnabled to common utility

This commit moves isFieldModeEnabled API from SingleFab class to common
utility. Field mode check is going to be required by upcoming PST
features, and hence this API needs to be an utility API in order to be
accessed throughout the repository.

Change-Id: I3f0024b81493e3284ea0c9ea070e110dc1ef6375
Signed-off-by: Souvik Roy <souvikroyofficial10@gmail.com>
diff --git a/vpd-manager/include/single_fab.hpp b/vpd-manager/include/single_fab.hpp
index 5e4fb76..edd5f30 100644
--- a/vpd-manager/include/single_fab.hpp
+++ b/vpd-manager/include/single_fab.hpp
@@ -55,13 +55,6 @@
     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;
-
-    /**
      * @brief API to update IM value on system planar EEPROM path to P11 series.
      *
      * @param[in] i_currentImValuePlanar - current IM value in planar EEPROM.
diff --git a/vpd-manager/include/utility/common_utility.hpp b/vpd-manager/include/utility/common_utility.hpp
index de7a9ae..e1564f8 100644
--- a/vpd-manager/include/utility/common_utility.hpp
+++ b/vpd-manager/include/utility/common_utility.hpp
@@ -274,5 +274,33 @@
     return static_cast<size_t>(l_timeStampSeconds);
 }
 
+/**
+ * @brief API to check is field mode enabled.
+ *
+ * @return true, if field mode is enabled. otherwise false.
+ */
+inline bool isFieldModeEnabled() noexcept
+{
+    try
+    {
+        std::vector<std::string> l_cmdOutput =
+            executeCmd("/sbin/fw_printenv fieldmode");
+
+        if (l_cmdOutput.size() > 0)
+        {
+            toLower(l_cmdOutput[0]);
+
+            // Remove the new line character from the string.
+            l_cmdOutput[0].erase(l_cmdOutput[0].length() - 1);
+
+            return l_cmdOutput[0] == "fieldmode=true";
+        }
+    }
+    catch (const std::exception& l_ex)
+    {}
+
+    return false;
+}
+
 } // namespace commonUtility
 } // namespace vpd
diff --git a/vpd-manager/src/single_fab.cpp b/vpd-manager/src/single_fab.cpp
index 1f61165..9c4f5ec 100644
--- a/vpd-manager/src/single_fab.cpp
+++ b/vpd-manager/src/single_fab.cpp
@@ -123,29 +123,6 @@
     }
 }
 
-bool SingleFab::isFieldModeEnabled() const noexcept
-{
-    try
-    {
-        std::vector<std::string> l_cmdOutput =
-            commonUtility::executeCmd("/sbin/fw_printenv fieldmode");
-
-        if (l_cmdOutput.size() > 0)
-        {
-            commonUtility::toLower(l_cmdOutput[0]);
-
-            // Remove the new line character from the string.
-            l_cmdOutput[0].erase(l_cmdOutput[0].length() - 1);
-
-            return l_cmdOutput[0] == "fieldmode=true" ? true : false;
-        }
-    }
-    catch (const std::exception& l_ex)
-    {}
-
-    return false;
-}
-
 void SingleFab::updateSystemImValueInVpdToP11Series(
     std::string i_currentImValuePlanar) const noexcept
 {
@@ -183,7 +160,7 @@
 {
     const std::string& l_planarImValue = getImFromPlanar();
     const std::string& l_eBmcImValue = getImFromPersistedLocation();
-    const bool& l_isFieldModeEnabled = isFieldModeEnabled();
+    const bool& l_isFieldModeEnabled = commonUtility::isFieldModeEnabled();
     const bool& l_isLabModeEnabled =
         !l_isFieldModeEnabled;                       // used for understanding
     const bool& l_isPowerVsImage = vpdSpecificUtility::isPowerVsImage();