Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vpd-tool mfgClean: Sync BIOS attributes stub #601

Draft
wants to merge 1 commit into
base: 1110
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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