diff options
-rw-r--r-- | Redfish.md | 1 | ||||
-rw-r--r-- | redfish-core/lib/fan.hpp | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/Redfish.md b/Redfish.md index d72a2f8933..cd03a7ca86 100644 --- a/Redfish.md +++ b/Redfish.md @@ -324,6 +324,7 @@ Fields common to all schemas #### Fan +- Location - Manufacturer - Model - PartNumber diff --git a/redfish-core/lib/fan.hpp b/redfish-core/lib/fan.hpp index 0acb762a04..76805315d3 100644 --- a/redfish-core/lib/fan.hpp +++ b/redfish-core/lib/fan.hpp @@ -335,6 +335,30 @@ inline void getFanAsset(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, }); } +inline void getFanLocation(const std::shared_ptr<bmcweb::AsyncResp>& aResp, + const std::string& fanPath, + const std::string& service) +{ + sdbusplus::asio::getProperty<std::string>( + *crow::connections::systemBus, service, fanPath, + "xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode", + [aResp](const boost::system::error_code& ec, + const std::string& property) { + if (ec) + { + if (ec.value() != EBADR) + { + BMCWEB_LOG_ERROR << "DBUS response error for Location" + << ec.value(); + messages::internalError(aResp->res); + } + return; + } + aResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] = + property; + }); +} + inline void afterGetValidFanPath(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& chassisId, const std::string& fanId, @@ -344,6 +368,7 @@ inline void getFanState(asyncResp, fanPath, service); getFanHealth(asyncResp, fanPath, service); getFanAsset(asyncResp, fanPath, service); + getFanLocation(asyncResp, fanPath, service); } inline void doFanGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |