Skip to content

Commit

Permalink
vpd-tool mfgClean: Sync BIOS attributes stub
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Souvik Roy committed Jan 23, 2025
1 parent f41b758 commit 0b24f47
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 4 additions & 1 deletion vpd-tool/include/vpd_tool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion vpd-tool/src/vpd_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 14 additions & 3 deletions vpd-tool/src/vpd_tool_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand All @@ -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());
}

/**
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 0b24f47

Please sign in to comment.