From 6fce1d3c8e208a1331dc9fa47da23e95c604dd4b Mon Sep 17 00:00:00 2001 From: Anupama B R Date: Sun, 12 Jan 2025 23:59:00 -0600 Subject: [PATCH] vpd-tool: Show user option for fixSystemVpd This commit implements showing possible user options on the console for fix system VPD command. Member function added in VpdTool class, prints the user option on the console. output: ''' root@p10bmc:/tmp# ./vpd-tool_option --fixSystemVPD Enter 1 => If you choose the data on backup for all mismatching record-keyword pairs Enter 2 => If you choose the data on primary for all mismatching record-keyword pairs Enter 3 => If you wish to explore more options Enter 0 => To exit successfully : ''' Signed-off-by: Anupama B R --- vpd-tool/include/tool_types.hpp | 12 ++++++++ vpd-tool/include/vpd_tool.hpp | 8 +++++ vpd-tool/src/vpd_tool.cpp | 52 +++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/vpd-tool/include/tool_types.hpp b/vpd-tool/include/tool_types.hpp index bb205bdf..f42b752b 100644 --- a/vpd-tool/include/tool_types.hpp +++ b/vpd-tool/include/tool_types.hpp @@ -58,5 +58,17 @@ using WriteVpdParams = std::variant; // Return type of ObjectMapper GetObject API using MapperGetObject = std::map>; +enum UserOption +{ + Exit, + UseBackupDataForAll, + UseSystemBackplaneDataForAll, + MoreOptions, + UseBackupDataForCurrent, + UseSystemBackplaneDataForCurrent, + NewValueOnBoth, + SkipCurrent +}; + } // namespace types } // namespace vpd diff --git a/vpd-tool/include/vpd_tool.hpp b/vpd-tool/include/vpd_tool.hpp index 49391da8..e350a85b 100644 --- a/vpd-tool/include/vpd_tool.hpp +++ b/vpd-tool/include/vpd_tool.hpp @@ -106,6 +106,14 @@ class VpdTool */ nlohmann::json getBackupRestoreCfgJsonObj() const noexcept; + /** + * @brief Prints the user options for fix system VPD command. + * + * @param[in] i_option - Option to use. + */ + void printFixSystemVpdOption( + const types::UserOption& i_option) const noexcept; + public: /** * @brief Read keyword value. diff --git a/vpd-tool/src/vpd_tool.cpp b/vpd-tool/src/vpd_tool.cpp index 31e4ac98..5bd33714 100644 --- a/vpd-tool/src/vpd_tool.cpp +++ b/vpd-tool/src/vpd_tool.cpp @@ -245,7 +245,14 @@ nlohmann::json VpdTool::getInventoryPropertyJson( int VpdTool::fixSystemVpd() noexcept { int l_rc = constants::FAILURE; + + printFixSystemVpdOption(types::UserOption::UseBackupDataForAll); + printFixSystemVpdOption(types::UserOption::UseSystemBackplaneDataForAll); + printFixSystemVpdOption(types::UserOption::MoreOptions); + printFixSystemVpdOption(types::UserOption::Exit); + // ToDo: Implementation needs to be added + return l_rc; } @@ -394,4 +401,49 @@ bool VpdTool::isFruPresent(const std::string& i_objectPath) const noexcept return l_returnValue; } +void VpdTool::printFixSystemVpdOption( + const types::UserOption& i_option) const noexcept +{ + switch (i_option) + { + case types::UserOption::Exit: + std::cout << "Enter 0 => To exit successfully : "; + break; + case types::UserOption::UseBackupDataForAll: + std::cout << "Enter 1 => If you choose the data on backup for all " + "mismatching record-keyword pairs" + << std::endl; + break; + case types::UserOption::UseSystemBackplaneDataForAll: + std::cout << "Enter 2 => If you choose the data on primary for all " + "mismatching record-keyword pairs" + << std::endl; + break; + case types::UserOption::MoreOptions: + std::cout << "Enter 3 => If you wish to explore more options" + << std::endl; + break; + case types::UserOption::UseBackupDataForCurrent: + std::cout << "Enter 4 => If you choose the data on backup as the " + "right value" + << std::endl; + break; + case types::UserOption::UseSystemBackplaneDataForCurrent: + std::cout << "Enter 5 => If you choose the data on primary as the " + "right value" + << std::endl; + break; + case types::UserOption::NewValueOnBoth: + std::cout + << "Enter 6 => If you wish to enter a new value to update " + "both on backup and primary" + << std::endl; + break; + case types::UserOption::SkipCurrent: + std::cout << "Enter 7 => If you wish to skip the above " + "record-keyword pair" + << std::endl; + break; + } +} } // namespace vpd