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/configuration/ibm/50001_power_vs.json b/configuration/ibm/50001_power_vs.json
new file mode 100644
index 0000000..b4064a6
--- /dev/null
+++ b/configuration/ibm/50001_power_vs.json
@@ -0,0 +1,27 @@
+{
+ "/sys/bus/spi/drivers/at25/spi12.0/eeprom": {
+ "VINI": {
+ "PN": [48, 50, 89, 75, 57, 52, 48]
+ }
+ },
+ "/sys/bus/spi/drivers/at25/spi22.0/eeprom": {
+ "VINI": {
+ "PN": [48, 50, 89, 75, 57, 52, 48]
+ }
+ },
+ "/sys/bus/spi/drivers/at25/spi32.0/eeprom": {
+ "VINI": {
+ "PN": [48, 50, 89, 75, 57, 52, 48]
+ }
+ },
+ "/sys/bus/spi/drivers/at25/spi42.0/eeprom": {
+ "VINI": {
+ "PN": [48, 50, 89, 75, 57, 52, 48]
+ }
+ },
+ "/sys/bus/i2c/drivers/at24/8-0051/eeprom": {
+ "VINI": {
+ "PN": [48, 51, 82, 86, 50, 56, 50]
+ }
+ }
+}
diff --git a/configuration/ibm/50003_power_vs.json b/configuration/ibm/50003_power_vs.json
new file mode 100644
index 0000000..b8b5008
--- /dev/null
+++ b/configuration/ibm/50003_power_vs.json
@@ -0,0 +1,47 @@
+{
+ "/sys/bus/spi/drivers/at25/spi12.0/eeprom": {
+ "VINI": {
+ "PN": [48, 51, 85, 72, 48, 57, 56]
+ }
+ },
+ "/sys/bus/spi/drivers/at25/spi22.0/eeprom": {
+ "VINI": {
+ "PN": [48, 51, 85, 72, 48, 57, 56]
+ }
+ },
+ "/sys/bus/spi/drivers/at25/spi32.0/eeprom": {
+ "VINI": {
+ "PN": [48, 51, 85, 72, 48, 57, 56]
+ }
+ },
+ "/sys/bus/spi/drivers/at25/spi42.0/eeprom": {
+ "VINI": {
+ "PN": [48, 51, 85, 72, 48, 57, 56]
+ }
+ },
+ "/sys/bus/spi/drivers/at25/spi52.0/eeprom": {
+ "VINI": {
+ "PN": [48, 51, 85, 72, 48, 57, 56]
+ }
+ },
+ "/sys/bus/spi/drivers/at25/spi62.0/eeprom": {
+ "VINI": {
+ "PN": [48, 51, 85, 72, 48, 57, 56]
+ }
+ },
+ "/sys/bus/spi/drivers/at25/spi72.0/eeprom": {
+ "VINI": {
+ "PN": [48, 51, 85, 72, 48, 57, 56]
+ }
+ },
+ "/sys/bus/spi/drivers/at25/spi82.0/eeprom": {
+ "VINI": {
+ "PN": [48, 51, 85, 72, 48, 57, 56]
+ }
+ },
+ "/sys/bus/i2c/drivers/at24/8-0051/eeprom": {
+ "VINI": {
+ "PN": [48, 51, 82, 86, 50, 57, 48]
+ }
+ }
+}
diff --git a/vpd-manager/include/constants.hpp b/vpd-manager/include/constants.hpp
index 9358f78..f71b18e 100644
--- a/vpd-manager/include/constants.hpp
+++ b/vpd-manager/include/constants.hpp
@@ -138,6 +138,7 @@
constexpr auto kwdSE = "SE";
constexpr auto kwdHW = "HW";
constexpr auto kwdIM = "IM";
+constexpr auto kwdPN = "PN";
constexpr auto recVSYS = "VSYS";
constexpr auto recVCEN = "VCEN";
constexpr auto locationCodeInf = "com.ibm.ipzvpd.Location";
@@ -228,5 +229,9 @@
"com.ibm.VPD.Collection.Status.InProgress";
static constexpr auto vpdCollectionNotStarted =
"com.ibm.VPD.Collection.Status.NotStarted";
+static constexpr auto power_vs_50003_json =
+ "/usr/share/vpd/50003_power_vs.json";
+static constexpr auto power_vs_50001_json =
+ "/usr/share/vpd/50001_power_vs.json";
} // namespace constants
} // namespace vpd
diff --git a/vpd-manager/include/manager.hpp b/vpd-manager/include/manager.hpp
index e744f7a..ad67694 100644
--- a/vpd-manager/include/manager.hpp
+++ b/vpd-manager/include/manager.hpp
@@ -262,6 +262,19 @@
void processFailedEeproms();
/**
+ * @brief API to check and update PowerVS VPD.
+ *
+ * The API will read the existing data from the DBus and if found
+ * different than what has been read from JSON, it will update the VPD with
+ * JSON data on hardware and DBus both.
+ *
+ * @param[in] i_powerVsJsonObj - PowerVS JSON object.
+ * @param[out] o_failedPathList - List of path failed to update.
+ */
+ void checkAndUpdatePowerVsVpd(const nlohmann::json& i_powerVsJsonObj,
+ std::vector<std::string>& o_failedPathList);
+
+ /**
* @brief API to handle configuration w.r.t. PowerVS systems.
*
* Some FRUs VPD is specific to powerVS system. The API detects the
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
diff --git a/vpd-manager/src/manager.cpp b/vpd-manager/src/manager.cpp
index b608e0b..5f502cf 100644
--- a/vpd-manager/src/manager.cpp
+++ b/vpd-manager/src/manager.cpp
@@ -323,11 +323,18 @@
});
}
+void Manager::checkAndUpdatePowerVsVpd(
+ const nlohmann::json& i_powerVsJsonObj,
+ std::vector<std::string>& o_failedPathList)
+{
+ (void)i_powerVsJsonObj;
+ (void)o_failedPathList;
+ // TODO: Check and update powerVS VPD
+}
+
void Manager::ConfigurePowerVsSystem()
{
- // This API should check for required powerVS configuration and will
- // update the VPD accordingly.
-
+ std::vector<std::string> l_failedPathList;
try
{
types::BinaryVector l_imValue = dbusUtility::getImFromDbus();
@@ -342,6 +349,22 @@
// misconfigurations?
return;
}
+
+ const nlohmann::json& l_powerVsJsonObj =
+ jsonUtility::getPowerVsJson(l_imValue);
+
+ if (l_powerVsJsonObj.empty())
+ {
+ throw std::runtime_error("PowerVS Json not found");
+ }
+
+ checkAndUpdatePowerVsVpd(l_powerVsJsonObj, l_failedPathList);
+
+ if (!l_failedPathList.empty())
+ {
+ throw std::runtime_error(
+ "Part number update failed for following paths: ");
+ }
}
catch (const std::exception& l_ex)
{