Handle file mode for system VPD collection
This commit adds changes to read system VPD from designated file
location in case VPD collection mode is 'file mode' for the system.
In non-field mode, VPD collection mode is determined by reading u-boot
variable "vpdmode".
```
Test:
Good path:
1. Updated u-boot vpdmode to file mode.
2. Copied the system VPD to designated location for file mode.
3. After system reboot, observed that system VPD is collected successfully.
Bad path:
1. Updated u-boot vpdmode to file mode.
2. Skipped copying system VPD to designated file location.
3. After system reboot, observed that vpd-manger logged a critical PEL as system VPD parsing is failed.
Part of info from PEL:
"User Data 1": {
"Section Version": "1",
"Sub-section type": "1",
"Created by": "bmc error logging",
"DESCRIPTION": "Standard runtime exception. Reason: System VPD parsing failed, from path [/var/lib/vpd/file/sys/bus/i2c/drivers/at24/8-0050/eeprom]. Either file doesn't exist or error occurred while parsing the file.",
"FileName": "/usr/src/debug/openpower-fru-vpd/1.0+git/vpd-manager/oem-handler/ibm_handler.cpp",
"FunctionName": "performInitialSetup",
"InteranlRc": "0",
"UserData1": "",
"UserData2": ""
}
```
Change-Id: Iae4eb64fe91e608f9ae61ab7f88ae41d36bc1007
Signed-off-by: Anupama B R <anupama.b.r1@ibm.com>
diff --git a/vpd-manager/oem-handler/ibm_handler.cpp b/vpd-manager/oem-handler/ibm_handler.cpp
index dcb0ddd..bd06a7f 100644
--- a/vpd-manager/oem-handler/ibm_handler.cpp
+++ b/vpd-manager/oem-handler/ibm_handler.cpp
@@ -755,8 +755,26 @@
throw JsonException("System config JSON is empty", m_sysCfgJsonObj);
}
+ uint16_t l_errCode = 0;
+ std::string l_systemVpdPath{SYSTEM_VPD_FILE_PATH};
+ commonUtility::getEffectiveFruPath(m_vpdCollectionMode, l_systemVpdPath,
+ l_errCode);
+
+ if (l_errCode)
+ {
+ throw std::runtime_error(
+ "Failed to get effective System VPD path, for [" + l_systemVpdPath +
+ "], reason: " + commonUtility::getErrCodeMsg(l_errCode));
+ }
+
// parse system VPD
- auto l_parsedVpdMap = m_worker->parseVpdFile(SYSTEM_VPD_FILE_PATH);
+ auto l_parsedVpdMap = m_worker->parseVpdFile(l_systemVpdPath);
+ if (std::holds_alternative<std::monostate>(l_parsedVpdMap))
+ {
+ throw std::runtime_error(
+ "System VPD parsing failed, from path [" + l_systemVpdPath +
+ "]. Either file doesn't exist or error occurred while parsing the file.");
+ }
// Implies it is default JSON.
std::string l_systemJson{JSON_ABSOLUTE_PATH_PREFIX};
@@ -770,7 +788,6 @@
"No system JSON found corresponding to IM read from VPD.");
}
- uint16_t l_errCode = 0;
// re-parse the JSON once appropriate JSON has been selected.
m_sysCfgJsonObj = jsonUtility::getParsedJson(l_systemJson, l_errCode);