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/src/vpd_tool_main.cpp b/vpd-tool/src/vpd_tool_main.cpp
index c7a846f..4dde248 100644
--- a/vpd-tool/src/vpd_tool_main.cpp
+++ b/vpd-tool/src/vpd_tool_main.cpp
@@ -8,6 +8,32 @@
#include <iostream>
/**
+ * @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.
+ *
+ * Note: Force reset only happens if chassis is powered off.
+ *
+ * @return On success returns 0, otherwise returns -1.
+ */
+int forceReset()
+{
+ if (vpd::utils::isChassisPowerOff())
+ {
+ vpd::VpdTool l_vpdToolObj;
+ return l_vpdToolObj.resetVpdOnDbus();
+ }
+
+ std::cerr
+ << "The chassis power state is not Off. Force reset operation is not allowed."
+ << std::endl;
+ return vpd::constants::FAILURE;
+}
+
+/**
* @brief API to perform manufacturing clean.
*
* @param[in] i_mfgCleanConfirmFlag - Confirmation flag to perform manufacturing
@@ -230,7 +256,9 @@
" From DBus to console in JSON format: "
"vpd-tool -i\n"
" From DBus to console in Table format: "
- "vpd-tool -i -t\n");
+ "vpd-tool -i -t\n"
+ "Force Reset:\n"
+ " vpd-tool --forceReset\n");
}
int main(int argc, char** argv)
@@ -305,6 +333,10 @@
"--syncBiosAttributes, -s",
"Using this flag with --mfgClean option, Syncs the BIOS attribute related keywords from BIOS Config Manager service instead resetting keyword's value to default value");
+ auto l_forceResetFlag = l_app.add_flag(
+ "--forceReset, -f, -F",
+ "Force collect for hardware. CAUTION: Developer only option.");
+
CLI11_PARSE(l_app, argc, argv);
if (checkOptionValuePair(l_objectOption, l_vpdPath, l_recordOption,
@@ -373,6 +405,11 @@
return l_vpdToolObj.dumpInventory(!l_dumpInventoryTableFlag->empty());
}
+ if (!l_forceResetFlag->empty())
+ {
+ return forceReset();
+ }
+
std::cout << l_app.help() << std::endl;
return vpd::constants::FAILURE;
}