vpd-tool mfgClean: Sync BIOS attributes stub
This commit adds --syncBiosAttributes flag to vpd-tool --mfgClean
option. The changes in this commit allows user to specify
--syncBiosAttributes/-s with --mfgClean option. --syncBiosAttributes
flag when used along with --mfgClean will sync those VPD keywords on
hardware and D-Bus, with the corresponding values of BIOS attributes.
The other keywords not associated with BIOS attribute backup continue to
be updated with the default value in backup_restore JSON file.
Test:
```
root@p10bmc:~# vpd-tool
VPD Command Line Tool
Usage: vpd-tool [OPTIONS]
Options:
-s,--syncBiosAttributes Sync BIOS attribute related keywords from
BIOS Config Manager
MfgClean:
Flag to clean and reset specific keywords on system VPD to its default
value.
vpd-tool --mfgClean
To sync BIOS attribute related keywords with BIOS Config Manager:
vpd-tool --mfgClean --syncBiosAttributes
```
Change-Id: Icdff0bc08e629d12e4de2a21c2499ea621a03c38
Signed-off-by: Souvik Roy <souvikroyofficial10@gmail.com>
diff --git a/vpd-tool/include/vpd_tool.hpp b/vpd-tool/include/vpd_tool.hpp
index 3213af4..f26a0a3 100644
--- a/vpd-tool/include/vpd_tool.hpp
+++ b/vpd-tool/include/vpd_tool.hpp
@@ -259,9 +259,13 @@
* 3. D-Bus cache.
* 4. Backup path.
*
+ * @param[in] i_syncBiosAttributes - Flag which specifies whether BIOS
+ * attribute related keywords need to be synced from BIOS Config Manager
+ * instead of being reset to default value.
+ *
* @return On success returns 0, otherwise returns -1.
*/
- int cleanSystemVpd() const noexcept;
+ int cleanSystemVpd(bool i_syncBiosAttributes = false) const noexcept;
/**
* @brief Dump all the inventory objects in JSON or table format to console.
diff --git a/vpd-tool/src/vpd_tool.cpp b/vpd-tool/src/vpd_tool.cpp
index 93776c1..e197ee6 100644
--- a/vpd-tool/src/vpd_tool.cpp
+++ b/vpd-tool/src/vpd_tool.cpp
@@ -390,10 +390,12 @@
return l_parsedBackupRestoreJson;
}
-int VpdTool::cleanSystemVpd() const noexcept
+int VpdTool::cleanSystemVpd(bool i_syncBiosAttributes) const noexcept
{
try
{
+ (void)i_syncBiosAttributes;
+
// get the keyword map from backup_restore json
// iterate through the keyword map get default value of
// l_keywordName.
diff --git a/vpd-tool/src/vpd_tool_main.cpp b/vpd-tool/src/vpd_tool_main.cpp
index 3fdf5d1..06a6ca7 100644
--- a/vpd-tool/src/vpd_tool_main.cpp
+++ b/vpd-tool/src/vpd_tool_main.cpp
@@ -11,10 +11,14 @@
*
* @param[in] i_mfgCleanConfirmFlag - Confirmation flag to perform manufacturing
* clean.
+ * @param[in] i_syncBiosAttributesFlag - Flag which specifies whether
+ * BIOS attribute related keywords need to be synced from BIOS Config Manager
+ * instead of being reset to default value.
*
* @return Status returned by cleanSystemVpd operation, success otherwise.
*/
-int doMfgClean(const auto& i_mfgCleanConfirmFlag)
+int doMfgClean(const auto& i_mfgCleanConfirmFlag,
+ const auto& i_syncBiosAttributesFlag)
{
if (i_mfgCleanConfirmFlag->empty())
{
@@ -31,7 +35,7 @@
}
vpd::VpdTool l_vpdToolObj;
- return l_vpdToolObj.cleanSystemVpd();
+ return l_vpdToolObj.cleanSystemVpd(!i_syncBiosAttributesFlag->empty());
}
/**
@@ -210,6 +214,8 @@
"MfgClean:\n"
" Flag to clean and reset specific keywords on system VPD to its default value.\n"
" vpd-tool --mfgClean\n"
+ " To sync BIOS attribute related keywords with BIOS Config Manager:\n"
+ " vpd-tool --mfgClean --syncBiosAttributes\n"
"Dump Inventory:\n"
" From DBus to console in JSON format: "
"vpd-tool -i\n"
@@ -286,6 +292,10 @@
auto l_dumpInventoryTableFlag =
l_app.add_flag("--table, -t", "Dump inventory in table format");
+ auto l_mfgCleanSyncBiosAttributesFlag = l_app.add_flag(
+ "--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");
+
CLI11_PARSE(l_app, argc, argv);
if (checkOptionValuePair(l_objectOption, l_vpdPath, l_recordOption,
@@ -321,7 +331,8 @@
if (!l_mfgCleanFlag->empty())
{
- return doMfgClean(l_mfgCleanConfirmFlag);
+ return doMfgClean(l_mfgCleanConfirmFlag,
+ l_mfgCleanSyncBiosAttributesFlag);
}
if (!l_dumpInventoryFlag->empty())