summaryrefslogtreecommitdiff
path: root/redfish-core/lib/chassis.hpp
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2019-02-15 01:30:45 +0300
committerEd Tanous <ed.tanous@intel.com>2019-03-18 20:09:12 +0300
commitbeeca0ae7d30ea68f3e6e5841ec631ee25248ffb (patch)
tree365b7de83e3fbc163a09fcd3ee77e54d71c5e62f /redfish-core/lib/chassis.hpp
parentc68604bd993d00ad11ee394514295ff5a2ef6f12 (diff)
downloadbmcweb-beeca0ae7d30ea68f3e6e5841ec631ee25248ffb.tar.xz
Redfish: Add Chassis PowerState call
Make a call to /xyz/openbmc_project/state/chassis0 to get the chassis PowerState. Very similiar to how we get the System PowerState https://github.com/openbmc/bmcweb/blob/abf2add6a35aaf42ba60c4ae955a4d8925b13b19/redfish-core/lib/systems.hpp#L471 Resolves openbmc/bmcweb#27 Tested: Loaded this on a Witherspoon and power on/off. Saw correct PowerState. Signed-off-by: Gunnar Mills <gmills@us.ibm.com> Change-Id: I9dd008a902098f1872560d985249375a2d317f25
Diffstat (limited to 'redfish-core/lib/chassis.hpp')
-rw-r--r--redfish-core/lib/chassis.hpp46
1 files changed, 45 insertions, 1 deletions
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index d24e641595..f78789a8a8 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -24,6 +24,50 @@ namespace redfish
{
/**
+ * @brief Retrieves chassis state properties over dbus
+ *
+ * @param[in] aResp - Shared pointer for completing asynchronous calls.
+ *
+ * @return None.
+ */
+void getChassisState(std::shared_ptr<AsyncResp> aResp)
+{
+ crow::connections::systemBus->async_method_call(
+ [aResp{std::move(aResp)}](
+ const boost::system::error_code ec,
+ const std::variant<std::string> &chassisState) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
+ messages::internalError(aResp->res);
+ return;
+ }
+
+ const std::string *s = std::get_if<std::string>(&chassisState);
+ BMCWEB_LOG_DEBUG << "Chassis state: " << *s;
+ if (s != nullptr)
+ {
+ // Verify Chassis State
+ if (*s == "xyz.openbmc_project.State.Chassis.PowerState.On")
+ {
+ aResp->res.jsonValue["PowerState"] = "On";
+ aResp->res.jsonValue["Status"]["State"] = "Enabled";
+ }
+ else if (*s ==
+ "xyz.openbmc_project.State.Chassis.PowerState.Off")
+ {
+ aResp->res.jsonValue["PowerState"] = "Off";
+ aResp->res.jsonValue["Status"]["State"] = "StandbyOffline";
+ }
+ }
+ },
+ "xyz.openbmc_project.State.Chassis",
+ "/xyz/openbmc_project/state/chassis0",
+ "org.freedesktop.DBus.Properties", "Get",
+ "xyz.openbmc_project.State.Chassis", "CurrentPowerState");
+}
+
+/**
* DBus types primitives for several generic DBus interfaces
* TODO(Pawel) consider move this to separate file into boost::dbus
*/
@@ -241,7 +285,6 @@ class Chassis : public Node
"/redfish/v1/$metadata#Chassis.Chassis";
res.jsonValue["Name"] = "Chassis Collection";
res.jsonValue["ChassisType"] = "RackMount";
- res.jsonValue["PowerState"] = "On";
auto asyncResp = std::make_shared<AsyncResp>(res);
crow::connections::systemBus->async_method_call(
@@ -330,6 +373,7 @@ class Chassis : public Node
{{"@odata.id", "/redfish/v1/Systems/system"}}};
asyncResp->res.jsonValue["Links"]["ManagedBy"] = {
{{"@odata.id", "/redfish/v1/Managers/bmc"}}};
+ getChassisState(asyncResp);
},
connectionName, path, "org.freedesktop.DBus.Properties",
"GetAll",