#include #include #include #include #include using BMCState = sdbusplus::server::xyz::openbmc_project::state::BMC; void registerNetFnGlobalFunctions() __attribute__((constructor)); /** @brief implements cold and warm reset commands * @param - None * @returns IPMI completion code. */ ipmi::RspType<> ipmiGlobalReset(ipmi::Context::ptr ctx) { ipmi::DbusObjectInfo bmcStateObj; boost::system::error_code ec = ipmi::getDbusObject( ctx, BMCState::interface, BMCState::namespace_path::value, BMCState::namespace_path::bmc, bmcStateObj); if (!ec) { std::string service; ec = ipmi::getService(ctx, BMCState::interface, bmcStateObj.first, service); if (!ec) { ec = ipmi::setDbusProperty( ctx, service, bmcStateObj.first, BMCState::interface, BMCState::property_names::requested_bmc_transition, convertForMessage(BMCState::Transition::Reboot)); } } if (ec) { lg2::error("Exception in Global Reset: {ERROR}", "ERROR", ec.message()); return ipmi::responseUnspecifiedError(); } // Status code. return ipmi::responseSuccess(); } void registerNetFnGlobalFunctions() { // Cold Reset ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnApp, ipmi::app::cmdColdReset, ipmi::Privilege::Admin, ipmiGlobalReset); return; }