vpd-tool force reset command

This commit implements ‘force reset’ user option in vpd-tool. Command
clears the BMC persisted data and recollects the VPD for all the FRUs
mentioned in system config JSON.

Command will only be processed if chassis is powered off.

stub API is added in VpdTool class to implement this command.

Output:
```
root@p10bmc:/tmp# obmcutil state
CurrentBMCState     : xyz.openbmc_project.State.BMC.BMCState.Ready
CurrentPowerState   : xyz.openbmc_project.State.Chassis.PowerState.On
CurrentHostState    : xyz.openbmc_project.State.Host.HostState.Running
BootProgress        : xyz.openbmc_project.State.Boot.Progress.ProgressStages.MemoryInit
OperatingSystemState: xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Inactive

When chassis is powered on, force reset command will fail:
root@p10bmc:/tmp# ./vpd-tool -f
The chassis power state is not Off. Force reset operation is not allowed.
```

Change-Id: I58ed0f11cf182d718ae957c4fbe803dc24f83d09
Signed-off-by: Anupama B R <anupama.b.r1@ibm.com>
diff --git a/vpd-tool/include/tool_constants.hpp b/vpd-tool/include/tool_constants.hpp
index 6e89957..26c8e75 100644
--- a/vpd-tool/include/tool_constants.hpp
+++ b/vpd-tool/include/tool_constants.hpp
@@ -30,5 +30,9 @@
 constexpr auto objectMapperService = "xyz.openbmc_project.ObjectMapper";
 constexpr auto objectMapperObjectPath = "/xyz/openbmc_project/object_mapper";
 constexpr auto objectMapperInfName = "xyz.openbmc_project.ObjectMapper";
+constexpr auto chassisStateManagerService = "xyz.openbmc_project.State.Chassis";
+constexpr auto chassisStateManagerObjectPath =
+    "/xyz/openbmc_project/state/chassis0";
+constexpr auto chassisStateManagerInfName = "xyz.openbmc_project.State.Chassis";
 } // namespace constants
 } // namespace vpd
diff --git a/vpd-tool/include/tool_utils.hpp b/vpd-tool/include/tool_utils.hpp
index 598cdd2..97359c9 100644
--- a/vpd-tool/include/tool_utils.hpp
+++ b/vpd-tool/include/tool_utils.hpp
@@ -834,5 +834,39 @@
     return l_valueRead;
 }
 
+/**
+ * @brief API to check if chassis is powered off.
+ *
+ * This API queries Phosphor Chassis State Manager to know whether
+ * chassis is powered off.
+ *
+ * @return true if chassis is powered off, false otherwise.
+ */
+inline bool isChassisPowerOff()
+{
+    try
+    {
+        // ToDo: Handle in case system has multiple chassis
+        auto l_powerState = readDbusProperty(
+            constants::chassisStateManagerService,
+            constants::chassisStateManagerObjectPath,
+            constants::chassisStateManagerInfName, "CurrentPowerState");
+
+        if (auto l_curPowerState = std::get_if<std::string>(&l_powerState);
+            l_curPowerState &&
+            ("xyz.openbmc_project.State.Chassis.PowerState.Off" ==
+             *l_curPowerState))
+        {
+            return true;
+        }
+    }
+    catch (const std::exception& l_ex)
+    {
+        // Todo: Enale log when verbose is enabled
+        std::cerr << l_ex.what() << std::endl;
+    }
+    return false;
+}
+
 } // namespace utils
 } // namespace vpd
diff --git a/vpd-tool/include/vpd_tool.hpp b/vpd-tool/include/vpd_tool.hpp
index 7898d00..d1248da 100644
--- a/vpd-tool/include/vpd_tool.hpp
+++ b/vpd-tool/include/vpd_tool.hpp
@@ -287,5 +287,17 @@
      * @return On success returns 0, otherwise returns -1.
      */
     int dumpInventory(bool i_dumpTable = false) const noexcept;
+
+    /**
+     * @brief Resets the VPD on DBus for all the Frus.
+     *
+     * API clears the inventory persisted data and restarts the phosphor
+     * inventory manager(PIM) DBus service and the VPD manager service. VPD
+     * manager service collects the VPD for all the FRU's listed on the system
+     * config JSON and calls PIM to publish VPD on DBus.
+     *
+     * @return On success returns 0, otherwise returns -1.
+     */
+    int resetVpdOnDbus();
 };
 } // namespace vpd