From 0b24f472bcda3a801ad8cb26101035d8e1ca53ee Mon Sep 17 00:00:00 2001 From: Souvik Roy Date: Mon, 20 Jan 2025 04:18:20 -0600 Subject: [PATCH] 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 along with --mfgClean. Note: This is just a stub implementation of --syncBiosAttributes. Change-Id: I7bdda2c4c237476ac4f9d718960fe35c12b30580 Signed-off-by: Souvik Roy --- vpd-tool/include/vpd_tool.hpp | 5 ++++- vpd-tool/src/vpd_tool.cpp | 4 +++- vpd-tool/src/vpd_tool_main.cpp | 17 ++++++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/vpd-tool/include/vpd_tool.hpp b/vpd-tool/include/vpd_tool.hpp index 3213af4a..62572093 100644 --- a/vpd-tool/include/vpd_tool.hpp +++ b/vpd-tool/include/vpd_tool.hpp @@ -259,9 +259,12 @@ class VpdTool * 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 + * * @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 991dfe59..2a359ab1 100644 --- a/vpd-tool/src/vpd_tool.cpp +++ b/vpd-tool/src/vpd_tool.cpp @@ -392,10 +392,12 @@ nlohmann::json VpdTool::getBackupRestoreCfgJsonObj() const noexcept 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 51d63903..0c23cc35 100644 --- a/vpd-tool/src/vpd_tool_main.cpp +++ b/vpd-tool/src/vpd_tool_main.cpp @@ -11,10 +11,13 @@ * * @param[in] i_mfgCleanConfirmFlag - Confirmation flag to perform manufacturing * clean. + * @param[in] i_mfgCleanSyncBiosAttributesFlag - Flag which specifies whether + * BIOS attribute related keywords need to be synced from BIOS Config Manager * * @return Status returned by cleanSystemVpd operation, success otherwise. */ -int doMfgClean(const auto& i_mfgCleanConfirmFlag) +int doMfgClean(const auto& i_mfgCleanConfirmFlag, + const auto& i_mfgCleanSyncBiosAttributesFlag) { if (i_mfgCleanConfirmFlag->empty()) { @@ -31,7 +34,8 @@ int doMfgClean(const auto& i_mfgCleanConfirmFlag) } vpd::VpdTool l_vpdToolObj; - return l_vpdToolObj.cleanSystemVpd(); + return l_vpdToolObj.cleanSystemVpd( + !i_mfgCleanSyncBiosAttributesFlag->empty()); } /** @@ -210,6 +214,8 @@ void updateFooter(CLI::App& i_app) "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 @@ int main(int argc, char** argv) auto l_dumpInventoryTableFlag = l_app.add_flag("--table, -t", "Dump inventory in table format"); + auto l_mfgCleanSyncBiosAttributesFlag = l_app.add_flag( + "--syncBiosAttributes, -s", + "Sync BIOS attribute related keywords from BIOS Config Manager"); + CLI11_PARSE(l_app, argc, argv); if (checkOptionValuePair(l_objectOption, l_vpdPath, l_recordOption, @@ -321,7 +331,8 @@ int main(int argc, char** argv) if (!l_mfgCleanFlag->empty()) { - return doMfgClean(l_mfgCleanConfirmFlag); + return doMfgClean(l_mfgCleanConfirmFlag, + l_mfgCleanSyncBiosAttributesFlag); } if (!l_dumpInventoryFlag->empty())