summaryrefslogtreecommitdiffstats
path: root/chassishandler.cpp
diff options
context:
space:
mode:
authorVernon Mauery <vernon.mauery@linux.intel.com>2019-05-16 14:48:47 -0700
committerVernon Mauery <vernon.mauery@linux.intel.com>2019-05-16 14:54:10 -0700
commit6d5b2f7e1c6e142b6198be45e3766d7d8cf5c9bc (patch)
tree398369ba8a79ba3666513d73dae4d1eda94e6254 /chassishandler.cpp
parente004e221800a43b2569c0a337674433ffa61e7a4 (diff)
downloadphosphor-host-ipmid-6d5b2f7e1c6e142b6198be45e3766d7d8cf5c9bc.tar.gz
phosphor-host-ipmid-6d5b2f7e1c6e142b6198be45e3766d7d8cf5c9bc.zip
Get Chassis Status should not bail if button interfaces are not present
The recent rewrite of Get Chassis Status also added support for reading the front panel enables status instead of returning a hard-coded false. But the implementation also errors out if the interface is not present This makes the interfaces optional, returning false if they are not presnt and reading them correctly if they are. Tested-by: running ipmitool chassis status with and without the xyz.openbmc_project.Chassis.Buttons service running: # ipmitool chassis status System Power : on Power Overload : false Power Interlock : inactive Main Power Fault : false Power Control Fault : false Power Restore Policy : previous Last Power Event : Chassis Intrusion : inactive Front-Panel Lockout : inactive Drive Fault : false Cooling/Fan Fault : false Sleep Button Disable : not allowed Diag Button Disable : not allowed Reset Button Disable : allowed Power Button Disable : allowed Sleep Button Disabled: false Diag Button Disabled : false Reset Button Disabled: false Power Button Disabled: false # systemctl stop xyz.openbmc_project.Chassis.Buttons@0.service # ipmitool chassis status System Power : on Power Overload : false Power Interlock : inactive Main Power Fault : false Power Control Fault : false Power Restore Policy : previous Last Power Event : Chassis Intrusion : inactive Front-Panel Lockout : inactive Drive Fault : false Cooling/Fan Fault : false Front Panel Control : none Change-Id: If845194b6f052ba84f8b062ac4259ec66f706bb5 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
Diffstat (limited to 'chassishandler.cpp')
-rw-r--r--chassishandler.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/chassishandler.cpp b/chassishandler.cpp
index dafc055..c9b39c0 100644
--- a/chassishandler.cpp
+++ b/chassishandler.cpp
@@ -936,17 +936,28 @@ ipmi::RspType<bool, // Power is on
}
// Front Panel Button Capabilities and disable/enable status(Optional)
- std::optional<bool> powerButtonDisabled =
+ std::optional<bool> powerButtonReading =
getButtonEnabled(powerButtonPath, powerButtonIntf);
- constexpr bool powerButtonDisableAllow = true;
+ // allow disable if the interface is present
+ bool powerButtonDisableAllow = static_cast<bool>(powerButtonReading);
+ // default return the button is enabled (not disabled)
+ bool powerButtonDisabled = false;
+ if (powerButtonDisableAllow)
+ {
+ // return the real value of the button status, if present
+ powerButtonDisabled = *powerButtonReading;
+ }
- std::optional<bool> resetButtonDisabled =
+ std::optional<bool> resetButtonReading =
getButtonEnabled(resetButtonPath, resetButtonIntf);
- constexpr bool resetButtonDisableAllow = true;
-
- if (!powerButtonDisabled || !resetButtonDisabled)
+ // allow disable if the interface is present
+ bool resetButtonDisableAllow = static_cast<bool>(resetButtonReading);
+ // default return the button is enabled (not disabled)
+ bool resetButtonDisabled = false;
+ if (resetButtonDisableAllow)
{
- return ipmi::responseUnspecifiedError();
+ // return the real value of the button status, if present
+ resetButtonDisabled = *resetButtonReading;
}
// This response has a lot of hard-coded, unsupported fields
@@ -985,7 +996,7 @@ ipmi::RspType<bool, // Power is on
coolingFanFault, chassisIdentifyState, chassisIdentifySupport,
false, // reserved
- *powerButtonDisabled, *resetButtonDisabled, diagButtonDisabled,
+ powerButtonDisabled, resetButtonDisabled, diagButtonDisabled,
sleepButtonDisabled, powerButtonDisableAllow, resetButtonDisableAllow,
diagButtonDisableAllow, sleepButtonDisableAllow);
}
OpenPOWER on IntegriCloud