From 400cc789598eb41a9dd569c63691b7212fe71b4a Mon Sep 17 00:00:00 2001 From: Vernon Mauery Date: Tue, 9 Oct 2018 13:49:53 -0700 Subject: ipmid: update chassis identify command Modify to use the new provider API. One by one, change calls to remove any legacy API constructs. Tested-by: ipmitool chassis identify ipmitool chassis identify 0 ipmitool chassis identify force Change-Id: I91bc21fdaef74eb32f297e0fa54edbc2e1bf4c2b Signed-off-by: Vernon Mauery --- chassishandler.cpp | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/chassishandler.cpp b/chassishandler.cpp index ef760d5..f8a93b0 100644 --- a/chassishandler.cpp +++ b/chassishandler.cpp @@ -1152,6 +1152,9 @@ void enclosureIdentifyLed(bool flag) { using namespace chassis::internal; std::string connection = std::move(getEnclosureIdentifyConnection()); + auto msg = std::string("enclosureIdentifyLed(") + + boost::lexical_cast(flag) + ")"; + log(msg.c_str()); auto led = dbus.new_method_call(connection.c_str(), identify_led_object_name, "org.freedesktop.DBus.Properties", "Set"); @@ -1191,30 +1194,16 @@ void createIdentifyTimer() } } -ipmi_ret_t ipmi_chassis_identify(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - ipmi_request_t request, - ipmi_response_t response, - ipmi_data_len_t data_len, - ipmi_context_t context) +ipmi::RspType<> ipmiChassisIdentify(std::optional interval, + std::optional force) { - if (*data_len > chassisIdentifyReqLength) - { - return IPMI_CC_REQ_DATA_LEN_INVALID; - } - uint8_t identifyInterval = - *data_len > identifyIntervalPos - ? (static_cast(request))[identifyIntervalPos] - : DEFAULT_IDENTIFY_TIME_OUT; - bool forceIdentify = - (*data_len == chassisIdentifyReqLength) - ? (static_cast(request))[forceIdentifyPos] & 0x01 - : false; - - *data_len = 0; // response have complete code only + uint8_t identifyInterval = interval.value_or(DEFAULT_IDENTIFY_TIME_OUT); + bool forceIdentify = force.value_or(0) & 0x01; + if (identifyInterval || forceIdentify) { - // stop the timer if already started, for force identify we should - // not turn off LED + // stop the timer if already started; + // for force identify we should not turn off LED identifyTimer->stop(); try { @@ -1223,12 +1212,12 @@ ipmi_ret_t ipmi_chassis_identify(ipmi_netfn_t netfn, ipmi_cmd_t cmd, catch (const InternalFailure& e) { report(); - return IPMI_CC_RESPONSE_ERROR; + return ipmi::responseResponseError(); } if (forceIdentify) { - return IPMI_CC_OK; + return ipmi::responseSuccess(); } // start the timer auto time = std::chrono::duration_cast( @@ -1240,7 +1229,7 @@ ipmi_ret_t ipmi_chassis_identify(ipmi_netfn_t netfn, ipmi_cmd_t cmd, identifyTimer->stop(); enclosureIdentifyLedOff(); } - return IPMI_CC_OK; + return ipmi::responseSuccess(); } namespace boot_options @@ -1741,8 +1730,9 @@ void register_netfn_chassis_functions() ipmi_chassis_control, PRIVILEGE_OPERATOR); // - ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_CHASSIS_IDENTIFY, NULL, - ipmi_chassis_identify, PRIVILEGE_OPERATOR); + ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnChassis, + ipmi::chassis::cmdChassisIdentify, + ipmi::Privilege::Operator, ipmiChassisIdentify); // ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_SET_SYS_BOOT_OPTIONS, NULL, -- cgit v1.2.1