psu-ng: Retrieve PSU VPD keyword from D-Bus.
Extract PSU VPD keyword from D-Bus and assign associated string value to
VPD string.
Change-Id: Iaf8112df7e388e6fd4363798c92d76f0a67e3b69
Signed-off-by: Faisal Awada <faisal@us.ibm.com>
diff --git a/phosphor-power-supply/power_supply.cpp b/phosphor-power-supply/power_supply.cpp
index 4d7e8e8..7389e3a 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -906,19 +906,29 @@
// TODO: non-IBM inventory updates?
#if IBM_VPD
- modelName = readVPDValue(CCIN, Type::HwmonDeviceDebug, CC_KW_SIZE);
+ if (driverName != IBMCFFPS_DD_NAME)
+ {
+ getPsuVpdFromDbus("CC", modelName);
+ getPsuVpdFromDbus("PN", pn);
+ getPsuVpdFromDbus("FN", fn);
+ getPsuVpdFromDbus("SN", sn);
+ assetProps.emplace(SN_PROP, sn);
+ }
+ else
+ {
+ modelName = readVPDValue(CCIN, Type::HwmonDeviceDebug, CC_KW_SIZE);
+ pn = readVPDValue(PART_NUMBER, Type::Debug, PN_KW_SIZE);
+ fn = readVPDValue(FRU_NUMBER, Type::Debug, FN_KW_SIZE);
+
+ header = readVPDValue(SERIAL_HEADER, Type::Debug, HEADER_SIZE);
+ sn = readVPDValue(SERIAL_NUMBER, Type::Debug, SERIAL_SIZE);
+ assetProps.emplace(SN_PROP, header + sn);
+ }
+
assetProps.emplace(MODEL_PROP, modelName);
-
- pn = readVPDValue(PART_NUMBER, Type::Debug, PN_KW_SIZE);
assetProps.emplace(PN_PROP, pn);
-
- fn = readVPDValue(FRU_NUMBER, Type::Debug, FN_KW_SIZE);
assetProps.emplace(SPARE_PN_PROP, fn);
- header = readVPDValue(SERIAL_HEADER, Type::Debug, HEADER_SIZE);
- sn = readVPDValue(SERIAL_NUMBER, Type::Debug, SERIAL_SIZE);
- assetProps.emplace(SN_PROP, header + sn);
-
fwVersion = readVPDValue(FW_VERSION, Type::HwmonDeviceDebug,
VERSION_SIZE);
versionProps.emplace(VERSION_PROP, fwVersion);
@@ -1224,4 +1234,24 @@
}
}
+void PowerSupply::getPsuVpdFromDbus(const std::string& keyword,
+ std::string& vpdStr)
+{
+ try
+ {
+ std::vector<uint8_t> value;
+ vpdStr.clear();
+ util::getProperty(VINI_IFACE, keyword, inventoryPath,
+ INVENTORY_MGR_IFACE, bus, value);
+ for (char c : value)
+ {
+ vpdStr += c;
+ }
+ }
+ catch (const sdbusplus::exception_t& e)
+ {
+ log<level::ERR>(
+ fmt::format("Failed getProperty error: {}", e.what()).c_str());
+ }
+}
} // namespace phosphor::power::psu