From cd7af44f12a56813a464b77828502138ed3eacf2 Mon Sep 17 00:00:00 2001 From: Lakshmi Yadlapati Date: Fri, 27 Jan 2023 17:31:40 -0600 Subject: Add State information for FabricAdapter This commit is to add state information according to the Redfish FabricAdapter schema. If the `xyz.openbmc_project.Inventory.Item` interface does not exist, the state information property is not displayed. ref: http://redfish.dmtf.org/schemas/v1/FabricAdapter.v1_4_0.json Tested: Validator passes # ``` curl -k https://$bmc:/redfish/v1/Systems/system/FabricAdapters/disk_backplane0 { "@odata.id": "/redfish/v1/Systems/system/FabricAdapters/disk_backplane0", "@odata.type": "#FabricAdapter.v1_4_0.FabricAdapter", "Id": "disk_backplane0", "Location": { "PartLocation": { "ServiceLabel": "U78DA.ND0.WZS0042-P1" } }, "Model": "6B89", "Name": "Fabric Adapter", "PartNumber": "02WG682", "SerialNumber": "YA31UF09P002", "SparePartNumber": "02WG681", "Status": { "State": "Enabled" } } ``` Change-Id: I1e541910d8d3d69b21594ee05e972517d8b8c12d Signed-off-by: Lakshmi Yadlapati --- Redfish.md | 1 + redfish-core/lib/fabric_adapters.hpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Redfish.md b/Redfish.md index 1f2ca29573..3ebb8d1272 100644 --- a/Redfish.md +++ b/Redfish.md @@ -681,6 +681,7 @@ other. - PartNumber - SerialNumber - SparePartNumber +- Status ### /redfish/v1/Systems/system/LogServices/ diff --git a/redfish-core/lib/fabric_adapters.hpp b/redfish-core/lib/fabric_adapters.hpp index f6099e6392..ba52e679c3 100644 --- a/redfish-core/lib/fabric_adapters.hpp +++ b/redfish-core/lib/fabric_adapters.hpp @@ -118,6 +118,32 @@ inline void }); } +inline void + getFabricAdapterState(const std::shared_ptr& aResp, + const std::string& serviceName, + const std::string& fabricAdapterPath) +{ + sdbusplus::asio::getProperty( + *crow::connections::systemBus, serviceName, fabricAdapterPath, + "xyz.openbmc_project.Inventory.Item", "Present", + [aResp](const boost::system::error_code ec, const bool present) { + if (ec) + { + if (ec.value() != EBADR) + { + BMCWEB_LOG_ERROR << "DBUS response error for State"; + messages::internalError(aResp->res); + } + return; + } + + if (!present) + { + aResp->res.jsonValue["Status"]["State"] = "Absent"; + } + }); +} + inline void doAdapterGet(const std::shared_ptr& aResp, const std::string& systemName, const std::string& adapterId, @@ -133,8 +159,11 @@ inline void doAdapterGet(const std::shared_ptr& aResp, aResp->res.jsonValue["@odata.id"] = crow::utility::urlFromPieces( "redfish", "v1", "Systems", systemName, "FabricAdapters", adapterId); + aResp->res.jsonValue["Status"]["State"] = "Enabled"; + getFabricAdapterLocation(aResp, serviceName, fabricAdapterPath); getFabricAdapterAsset(aResp, serviceName, fabricAdapterPath); + getFabricAdapterState(aResp, serviceName, fabricAdapterPath); } inline bool checkFabricAdapterId(const std::string& adapterPath, -- cgit v1.2.3