1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
From 514b76d1c05d7ed7fb7e1df27833e423e04c9a1c Mon Sep 17 00:00:00 2001
From: "Jason M. Bills" <jason.m.bills@linux.intel.com>
Date: Tue, 21 May 2019 09:57:16 -0700
Subject: [PATCH] Use xyz.openbmc_project.State.Chassis for IPMI chassis status
Instead of directly using pgood on dbus, this change uses the
xyz.openbmc_project.State.Chassis "CurrentPowerState" property
for the IPMI chassis status command. This will allow us to
remove pgood from dbus.
Tested:
Ran IPMI chassis commands and confirmed that they behave as
expected:
ipmitool power status
Chassis Power is on
ipmitool power off
Chassis Power Control: Down/Off
ipmitool power status
Chassis Power is off
ipmitool power on
Chassis Power Control: Up/On
ipmitool power status
Chassis Power is on
Change-Id: I7836c16b76c3b309f176186f3e2453082e4cd1af
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
---
chassishandler.cpp | 61 ++++++++++++++++++++++++++++++++++++------------------
1 file changed, 41 insertions(+), 20 deletions(-)
diff --git a/chassishandler.cpp b/chassishandler.cpp
index 1738ccc..e4e842d 100644
--- a/chassishandler.cpp
+++ b/chassishandler.cpp
@@ -824,44 +824,65 @@ std::optional<uint2_t> getPowerRestorePolicy()
*/
std::optional<bool> getPowerStatus()
{
- constexpr const char* powerControlObj =
- "/xyz/openbmc_project/Chassis/Control/Power0";
- constexpr const char* powerControlIntf =
- "xyz.openbmc_project.Chassis.Control.Power";
bool powerGood = false;
std::shared_ptr<sdbusplus::asio::connection> busp = getSdBus();
try
{
+ constexpr const char* chassisStatePath =
+ "/xyz/openbmc_project/state/chassis0";
+ constexpr const char* chassisStateIntf =
+ "xyz.openbmc_project.State.Chassis";
auto service =
- ipmi::getService(*busp, powerControlIntf, powerControlObj);
+ ipmi::getService(*busp, chassisStateIntf, chassisStatePath);
- ipmi::Value variant = ipmi::getDbusProperty(
- *busp, service, powerControlObj, powerControlIntf, "pgood");
- powerGood = static_cast<bool>(std::get<int>(variant));
+ ipmi::Value variant =
+ ipmi::getDbusProperty(*busp, service, chassisStatePath,
+ chassisStateIntf, "CurrentPowerState");
+ std::string powerState = std::get<std::string>(variant);
+ if (powerState == "xyz.openbmc_project.State.Chassis.PowerState.On")
+ {
+ powerGood = true;
+ }
}
catch (const std::exception& e)
{
try
{
- // FIXME: some legacy modules use the older path; try that next
- constexpr const char* legacyPwrCtrlObj =
- "/org/openbmc/control/power0";
- constexpr const char* legacyPwrCtrlIntf =
- "org.openbmc.control.Power";
+ // FIXME: some modules use pgood; try that next
+ constexpr const char* powerControlObj =
+ "/xyz/openbmc_project/Chassis/Control/Power0";
+ constexpr const char* powerControlIntf =
+ "xyz.openbmc_project.Chassis.Control.Power";
auto service =
- ipmi::getService(*busp, legacyPwrCtrlIntf, legacyPwrCtrlObj);
+ ipmi::getService(*busp, powerControlIntf, powerControlObj);
ipmi::Value variant = ipmi::getDbusProperty(
- *busp, service, legacyPwrCtrlObj, legacyPwrCtrlIntf, "pgood");
+ *busp, service, powerControlObj, powerControlIntf, "pgood");
powerGood = static_cast<bool>(std::get<int>(variant));
}
catch (const std::exception& e)
{
- log<level::ERR>("Failed to fetch pgood property",
- entry("ERROR=%s", e.what()),
- entry("PATH=%s", powerControlObj),
- entry("INTERFACE=%s", powerControlIntf));
- return std::nullopt;
+ try
+ {
+ // FIXME: some legacy modules use the older path; try that next
+ constexpr const char* legacyPwrCtrlObj =
+ "/org/openbmc/control/power0";
+ constexpr const char* legacyPwrCtrlIntf =
+ "org.openbmc.control.Power";
+ auto service = ipmi::getService(*busp, legacyPwrCtrlIntf,
+ legacyPwrCtrlObj);
+
+ ipmi::Value variant =
+ ipmi::getDbusProperty(*busp, service, legacyPwrCtrlObj,
+ legacyPwrCtrlIntf, "pgood");
+ powerGood = static_cast<bool>(std::get<int>(variant));
+ }
+ catch (const std::exception& e)
+ {
+ log<level::ERR>("Failed to fetch pgood property",
+ entry("ERROR=%s", e.what()));
+ return std::nullopt;
+ }
}
}
return std::make_optional(powerGood);
--
2.7.4
|