Add Health information for PCIeDevice
This commit is to add Health information according to the Redfish
PCIeDevice schema.
ref: https://redfish.dmtf.org/schemas/v1/PCIeDevice.v1_9_0.json
Code that updates the OperationalStatus for all the inventory
https://github.com/openbmc/openpower-vpd-parser/blob/ \
3fb026386546cfd288ab4f86156c9aa0ffa145d6/ibm_vpd_app.cpp#L620
Tested: Validator passed
'''
curl -k https://$bmc/redfish/v1/Systems/system/PCIeDevices/pcie_card8
{
"@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card8",
"@odata.type": "#PCIeDevice.v1_9_0.PCIeDevice",
"Id": "pcie_card8",
"Manufacturer": "",
"Model": "6B87",
"Name": "PCIe Device",
"PCIeFunctions": {
"@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card8/PCIeFunctions"
},
"PCIeInterface": {
"LanesInUse": -1
},
"PartNumber": "03FL194",
"SerialNumber": "Y131UF09S00J",
"Slot": {
"Location": {
"PartLocation": {
"ServiceLabel": "U78DB.ND0.WZS0018-P0-C8"
}
}
},
"SparePartNumber": "03FL195",
"Status": {
"Health": "OK",
"State": "Enabled"
}
}
'''
Change-Id: I53026792d0c223c10065c58aef9f3b9dc04a24ed
Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index b5c6c15..9dee9d3 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -142,6 +142,33 @@
}
inline void
+ getPCIeDeviceHealth(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& pcieDevicePath,
+ const std::string& service)
+{
+ sdbusplus::asio::getProperty<bool>(
+ *crow::connections::systemBus, service, pcieDevicePath,
+ "xyz.openbmc_project.State.Decorator.OperationalStatus", "Functional",
+ [asyncResp](const boost::system::error_code& ec, const bool value) {
+ if (ec)
+ {
+ if (ec.value() != EBADR)
+ {
+ BMCWEB_LOG_ERROR << "DBUS response error for Health "
+ << ec.value();
+ messages::internalError(asyncResp->res);
+ }
+ return;
+ }
+
+ if (!value)
+ {
+ asyncResp->res.jsonValue["Status"]["Health"] = "Critical";
+ }
+ });
+}
+
+inline void
getPCIeDeviceState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& pcieDevicePath,
const std::string& service)
@@ -323,6 +350,7 @@
asyncResp->res.jsonValue["Name"] = "PCIe Device";
asyncResp->res.jsonValue["Id"] = pcieDeviceId;
asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
+ asyncResp->res.jsonValue["Status"]["Health"] = "OK";
}
inline void
@@ -349,6 +377,7 @@
addPCIeDeviceCommonProperties(asyncResp, pcieDeviceId);
getPCIeDeviceAsset(asyncResp, pcieDevicePath, service);
getPCIeDeviceState(asyncResp, pcieDevicePath, service);
+ getPCIeDeviceHealth(asyncResp, pcieDevicePath, service);
getPCIeDeviceProperties(
asyncResp, pcieDevicePath, service,
[asyncResp, pcieDeviceId](