Skip to content

Commit 9123781

Browse files
spinlerbaemyung
authored andcommitted
Check PowerSupply availability prop for State/Hlth
This commit makes use of the Available property on the power supply D-Bus object when determining the power supply state and health in the PowerSupply response. The power supply monitor code from phosphor-power will set the property to false if it can determine that the power supply isn't able to provide power due to certain faults. If the PS isn't available, then the Health property will be set to Critical, and the State will be set to UnavailableOffline (assuming it shouldn't be Absent instead). This is necessary because on IBM systems the Functional property determines the fault LED state as well as the health value, and in certain cases the fault LED needs to stay off even though the PS health is not OK. A specific example of this is when the PS cord is unplugged: no fault LED is desired but it is desired for the Redfish output to show that there is an issue with the PS. If the Available property isn't present on D-Bus, it acts as if it had a value of true and behaves the same as it does today. Tested: Available = false: "Health": "Critical", "State": "UnavailableOffline" Available = true, Functional = false: "Health": "Critical", "State": "Enabled" PS missing: "Health": "Critical", "State": "Absent" Everything OK: "Health": "OK", "State": "Enabled" No Available property on D-Bus: "Health": "OK", "State": "Enabled" Change-Id: I1a3194bf3a6ca3936954b31439070dcc2f343411 Signed-off-by: Matt Spinler <[email protected]> Signed-off-by: Myung Bae <[email protected]>
1 parent 9d803de commit 9123781

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

redfish-core/lib/power_supply.hpp

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,12 @@ inline void getValidPowerSupplyPath(
208208

209209
inline void getPowerSupplyState(
210210
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
211-
const std::string& service, const std::string& path)
211+
const std::string& service, const std::string& path, bool available)
212212
{
213213
dbus::utility::getProperty<bool>(
214214
service, path, "xyz.openbmc_project.Inventory.Item", "Present",
215-
[asyncResp](const boost::system::error_code& ec, const bool value) {
215+
[asyncResp,
216+
available](const boost::system::error_code& ec, const bool value) {
216217
if (ec)
217218
{
218219
if (ec.value() != EBADR)
@@ -229,17 +230,23 @@ inline void getPowerSupplyState(
229230
asyncResp->res.jsonValue["Status"]["State"] =
230231
resource::State::Absent;
231232
}
233+
else if (!available)
234+
{
235+
asyncResp->res.jsonValue["Status"]["State"] =
236+
resource::State::UnavailableOffline;
237+
}
232238
});
233239
}
234240

235241
inline void getPowerSupplyHealth(
236242
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
237-
const std::string& service, const std::string& path)
243+
const std::string& service, const std::string& path, bool available)
238244
{
239245
dbus::utility::getProperty<bool>(
240246
service, path, "xyz.openbmc_project.State.Decorator.OperationalStatus",
241247
"Functional",
242-
[asyncResp](const boost::system::error_code& ec, const bool value) {
248+
[asyncResp,
249+
available](const boost::system::error_code& ec, const bool value) {
243250
if (ec)
244251
{
245252
if (ec.value() != EBADR)
@@ -251,14 +258,39 @@ inline void getPowerSupplyHealth(
251258
return;
252259
}
253260

254-
if (!value)
261+
if (!value || !available)
255262
{
256263
asyncResp->res.jsonValue["Status"]["Health"] =
257264
resource::Health::Critical;
258265
}
259266
});
260267
}
261268

269+
inline void getPowerSupplyStateAndHealth(
270+
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
271+
const std::string& service, const std::string& path)
272+
{
273+
dbus::utility::getProperty<bool>(
274+
service, path, "xyz.openbmc_project.State.Decorator.Availability",
275+
"Available",
276+
[asyncResp, service,
277+
path](const boost::system::error_code& ec, const bool available) {
278+
if (ec)
279+
{
280+
if (ec.value() != EBADR)
281+
{
282+
BMCWEB_LOG_ERROR("DBUS response error for Available {}",
283+
ec.value());
284+
messages::internalError(asyncResp->res);
285+
}
286+
return;
287+
}
288+
289+
getPowerSupplyState(asyncResp, service, path, available);
290+
getPowerSupplyHealth(asyncResp, service, path, available);
291+
});
292+
}
293+
262294
inline void getPowerSupplyAsset(
263295
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
264296
const std::string& service, const std::string& path)
@@ -478,8 +510,7 @@ inline void doPowerSupplyGet(
478510
asyncResp->res.jsonValue["Status"]["State"] = resource::State::Enabled;
479511
asyncResp->res.jsonValue["Status"]["Health"] = resource::Health::OK;
480512

481-
getPowerSupplyState(asyncResp, service, powerSupplyPath);
482-
getPowerSupplyHealth(asyncResp, service, powerSupplyPath);
513+
getPowerSupplyStateAndHealth(asyncResp, service, powerSupplyPath);
483514
getPowerSupplyAsset(asyncResp, service, powerSupplyPath);
484515
getPowerSupplyFirmwareVersion(asyncResp, service, powerSupplyPath);
485516
getPowerSupplyLocation(asyncResp, service, powerSupplyPath);

0 commit comments

Comments
 (0)