JSON and API prototype to update powerVS VPD
The commit introduces JSON file to hold the VPD that needs to be
updated for systems with PowerVS configuration.
It also adds API to fetch JSON as per system IM and prototype for API
which will checks the existing data and based on that will either skip
or update the VPD.
Change-Id: I5c279ce210831667be669c2a7c9c7d9c160de336
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/vpd-manager/include/utility/json_utility.hpp b/vpd-manager/include/utility/json_utility.hpp
index e570f9e..8a4ae44 100644
--- a/vpd-manager/include/utility/json_utility.hpp
+++ b/vpd-manager/include/utility/json_utility.hpp
@@ -1055,5 +1055,38 @@
return l_frusReplaceableAtStandby;
}
+/**
+ * @brief API to select powerVS JSON based on system IM.
+ *
+ * The API selects respective JSON based on system IM, parse it and return the
+ * JSON object. Empty JSON will be returned in case of any error. Caller needs
+ * to handle empty value.
+ *
+ * @param[in] i_imValue - IM value of the system.
+ * @return Parsed JSON object, empty JSON otherwise.
+ */
+inline nlohmann::json getPowerVsJson(const types::BinaryVector& i_imValue)
+{
+ try
+ {
+ if ((i_imValue.at(0) == constants::HEX_VALUE_50) &&
+ (i_imValue.at(1) == constants::HEX_VALUE_00) &&
+ (i_imValue.at(2) == constants::HEX_VALUE_30))
+ {
+ return jsonUtility::getParsedJson(constants::power_vs_50003_json);
+ }
+ else if (i_imValue.at(0) == constants::HEX_VALUE_50 &&
+ (i_imValue.at(1) == constants::HEX_VALUE_00) &&
+ (i_imValue.at(2) == constants::HEX_VALUE_10))
+ {
+ return jsonUtility::getParsedJson(constants::power_vs_50001_json);
+ }
+ return nlohmann::json{};
+ }
+ catch (const std::exception& l_ex)
+ {
+ return nlohmann::json{};
+ }
+}
} // namespace jsonUtility
} // namespace vpd