Add Chassis State Transition interface

This adds the Chassis State Transition interface in preparation
to support the mapping defined in the design document below.

ref: https://gerrit.openbmc-project.xyz/c/openbmc/docs/+/22358

Tested: Compiles. Since this adds a new function that is not used yet,
        there is not much in the way of testing that can be done on this
        individual commit. But the next commit that calls it does do the
        testing of this new function.

Change-Id: I6acfb795a9a33ff5227a5d6e1830774ab732ac0c
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/chassishandler.cpp b/chassishandler.cpp
index 32344a7..3a650b6 100644
--- a/chassishandler.cpp
+++ b/chassishandler.cpp
@@ -32,6 +32,7 @@
 #include <xyz/openbmc_project/Control/Boot/Source/server.hpp>
 #include <xyz/openbmc_project/Control/Boot/Type/server.hpp>
 #include <xyz/openbmc_project/Control/Power/RestorePolicy/server.hpp>
+#include <xyz/openbmc_project/State/Chassis/server.hpp>
 #include <xyz/openbmc_project/State/Host/server.hpp>
 #include <xyz/openbmc_project/State/PowerOnHours/server.hpp>
 
@@ -848,6 +849,40 @@
 }
 
 //------------------------------------------
+// Calls into Chassis State Manager Dbus object
+//------------------------------------------
+int initiateChassisStateTransition(ipmi::Context::ptr& ctx,
+                                   State::Chassis::Transition transition)
+{
+    // OpenBMC Chassis State Manager dbus framework
+    constexpr auto chassisStatePath = "/xyz/openbmc_project/state/chassis0";
+    constexpr auto chassisStateIntf = "xyz.openbmc_project.State.Chassis";
+
+    std::string service;
+    boost::system::error_code ec =
+        ipmi::getService(ctx, chassisStateIntf, chassisStatePath, service);
+
+    // Convert to string equivalent of the passed in transition enum.
+    auto request = State::convertForMessage(transition);
+
+    if (!ec)
+    {
+        ec = ipmi::setDbusProperty(ctx, service, chassisStatePath,
+                                   chassisStateIntf, "RequestedPowerTransition",
+                                   request);
+    }
+    if (ec)
+    {
+        log<level::ERR>("Failed to initiate transition",
+                        entry("EXCEPTION=%s, REQUEST=%s", ec.message().c_str(),
+                              request.c_str()));
+        return -1;
+    }
+
+    return 0;
+}
+
+//------------------------------------------
 // Set Enabled property to inform NMI source
 // handling to trigger a NMI_OUT BSOD.
 //------------------------------------------