Implement get/set shutdown policy IPMI OEM commands
Using the interface defined in intel-dbus-interface
Tested By:
ipmitool raw 0x30 0x60 1
ipmitool raw 0x30 0x62
Change-Id: I31c11218dcd23df8ef19e1f0f525dda889a696b3
Signed-off-by: Yong Li <yong.b.li@linux.intel.com>
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index 1cb8791..0711183 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -23,6 +23,7 @@
#include <boost/container/flat_map.hpp>
#include <boost/process/child.hpp>
#include <boost/process/io.hpp>
+#include <com/intel/Control/OCOTShutdownPolicy/server.hpp>
#include <commandutils.hpp>
#include <iostream>
#include <ipmid/api.hpp>
@@ -557,7 +558,29 @@
Value variant = getDbusProperty(dbus, service, oemShutdownPolicyObjPath,
oemShutdownPolicyIntf,
oemShutdownPolicyObjPathProp);
- resp->policy = sdbusplus::message::variant_ns::get<uint8_t>(variant);
+
+ if (sdbusplus::com::intel::Control::server::OCOTShutdownPolicy::
+ convertPolicyFromString(std::get<std::string>(variant)) ==
+ sdbusplus::com::intel::Control::server::OCOTShutdownPolicy::Policy::
+ NoShutdownOnOCOT)
+ {
+ resp->policy = 0;
+ }
+ else if (sdbusplus::com::intel::Control::server::OCOTShutdownPolicy::
+ convertPolicyFromString(std::get<std::string>(variant)) ==
+ sdbusplus::com::intel::Control::server::OCOTShutdownPolicy::
+ Policy::ShutdownOnOCOT)
+ {
+ resp->policy = 1;
+ }
+ else
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "oem_set_shutdown_policy: invalid property!",
+ phosphor::logging::entry(
+ "PROP=%s", std::get<std::string>(variant).c_str()));
+ return IPMI_CC_UNSPECIFIED_ERROR;
+ }
// TODO needs to check if it is multi-node products,
// policy is only supported on node 3/4
resp->policySupport = shutdownPolicySupported;
@@ -579,6 +602,9 @@
ipmi_context_t context)
{
uint8_t* req = reinterpret_cast<uint8_t*>(request);
+ sdbusplus::com::intel::Control::server::OCOTShutdownPolicy::Policy policy =
+ sdbusplus::com::intel::Control::server::OCOTShutdownPolicy::Policy::
+ NoShutdownOnOCOT;
// TODO needs to check if it is multi-node products,
// policy is only supported on node 3/4
@@ -598,13 +624,25 @@
return IPMI_CC_INVALID_FIELD_REQUEST;
}
+ if (*req == noShutdownOnOCOT)
+ {
+ policy = sdbusplus::com::intel::Control::server::OCOTShutdownPolicy::
+ Policy::NoShutdownOnOCOT;
+ }
+ else
+ {
+ policy = sdbusplus::com::intel::Control::server::OCOTShutdownPolicy::
+ Policy::ShutdownOnOCOT;
+ }
+
try
{
std::string service =
getService(dbus, oemShutdownPolicyIntf, oemShutdownPolicyObjPath);
- setDbusProperty(dbus, service, oemShutdownPolicyObjPath,
- oemShutdownPolicyIntf, oemShutdownPolicyObjPathProp,
- *req);
+ setDbusProperty(
+ dbus, service, oemShutdownPolicyObjPath, oemShutdownPolicyIntf,
+ oemShutdownPolicyObjPathProp,
+ sdbusplus::com::intel::Control::server::convertForMessage(policy));
}
catch (sdbusplus::exception_t& e)
{