diff options
-rw-r--r-- | Redfish.md | 6 | ||||
-rw-r--r-- | redfish-core/lib/fan.hpp | 57 |
2 files changed, 62 insertions, 1 deletions
diff --git a/Redfish.md b/Redfish.md index 4607589af2..8584673ccc 100644 --- a/Redfish.md +++ b/Redfish.md @@ -320,6 +320,12 @@ Fields common to all schemas - Members - Members@odata.count +#### /redfish/v1/Chassis/{ChassisId}/ThermalSubsystem/Fans/{FanName}/ + +#### Fan + +- Status + ### /redfish/v1/Chassis/{ChassisId}/Power#/PowerControl/{ControlName}/ #### PowerControl diff --git a/redfish-core/lib/fan.hpp b/redfish-core/lib/fan.hpp index 47d65ee23b..fb2ba20cc1 100644 --- a/redfish-core/lib/fan.hpp +++ b/redfish-core/lib/fan.hpp @@ -7,7 +7,9 @@ #include "registries/privilege_registry.hpp" #include "utils/chassis_utils.hpp" +#include <boost/system/error_code.hpp> #include <boost/url/format.hpp> +#include <sdbusplus/asio/property.hpp> #include <sdbusplus/message/types.hpp> #include <functional> @@ -222,6 +224,58 @@ inline void addFanCommonProperties(crow::Response& resp, resp.jsonValue["Id"] = fanId; resp.jsonValue["@odata.id"] = boost::urls::format( "/redfish/v1/Chassis/{}/ThermalSubsystem/Fans/{}", chassisId, fanId); + resp.jsonValue["Status"]["State"] = "Enabled"; + resp.jsonValue["Status"]["Health"] = "OK"; +} + +inline void getFanHealth(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& fanPath, const std::string& service) +{ + sdbusplus::asio::getProperty<bool>( + *crow::connections::systemBus, service, fanPath, + "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 getFanState(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& fanPath, const std::string& service) +{ + sdbusplus::asio::getProperty<bool>( + *crow::connections::systemBus, service, fanPath, + "xyz.openbmc_project.Inventory.Item", "Present", + [asyncResp](const boost::system::error_code& ec, const bool value) { + if (ec) + { + if (ec.value() != EBADR) + { + BMCWEB_LOG_ERROR << "DBUS response error for State " + << ec.value(); + messages::internalError(asyncResp->res); + } + return; + } + + if (!value) + { + asyncResp->res.jsonValue["Status"]["State"] = "Absent"; + } + }); } inline void @@ -229,8 +283,9 @@ inline void const std::string& chassisId, const std::string& fanId, const std::string& fanPath, const std::string& service) { - BMCWEB_LOG_DEBUG << "fanPath = " << fanPath << " service = " << service; addFanCommonProperties(asyncResp->res, chassisId, fanId); + getFanState(asyncResp, fanPath, service); + getFanHealth(asyncResp, fanPath, service); } inline void doFanGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |