1b29d2e84SChris Austen*** Settings *** 2b29d2e84SChris AustenDocumentation This module is for IPMI client for copying ipmitool to 3a2dab3c8SSivas SRR... openbmc box and execute ipmitool IPMI standard 4a2dab3c8SSivas SRR... command. IPMI raw command will use dbus-send command 5b29d2e84SChris AustenResource ../lib/resource.txt 64d6c1dabSGeorge KeishingResource ../lib/connection_client.robot 7ae7c2281SPrashanth KattiResource ../lib/utils.robot 8ae7c2281SPrashanth KattiResource ../lib/state_manager.robot 9ae7c2281SPrashanth Katti 10a2dab3c8SSivas SRRLibrary String 11a2dab3c8SSivas SRR 12a2dab3c8SSivas SRR*** Variables *** 13d7f11f70SGeorge Keishing${dbusHostIpmicmd1}= dbus-send --system ${OPENBMC_BASE_URI}HostIpmi/1 14d7f11f70SGeorge Keishing${dbusHostIpmiCmdReceivedMsg}= ${OPENBMC_BASE_DBUS}.HostIpmi.ReceivedMessage 15a2dab3c8SSivas SRR${netfnByte}= ${EMPTY} 16a2dab3c8SSivas SRR${cmdByte}= ${EMPTY} 17a2dab3c8SSivas SRR${arrayByte}= array:byte: 18*a7913898SMichael Walsh${IPMI_EXT_CMD}= ipmitool -I lanplus -C 3 19*a7913898SMichael Walsh${IPMI_USER_OPTIONS} ${EMPTY} 20ae7c2281SPrashanth Katti${IPMI_INBAND_CMD}= ipmitool -C 3 217a212a09SRahul Maheshwari${HOST}= -H 227a212a09SRahul Maheshwari${RAW}= raw 23b29d2e84SChris Austen 24b29d2e84SChris Austen*** Keywords *** 257a212a09SRahul Maheshwari 26b29d2e84SChris AustenRun IPMI Command 2738032805SGunnar Mills [Arguments] ${args} 287a212a09SRahul Maheshwari ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External' 297a212a09SRahul Maheshwari ... Run External IPMI RAW Command ${args} 30ae7c2281SPrashanth Katti ... ELSE IF '${IPMI_COMMAND}' == 'Inband' 31ae7c2281SPrashanth Katti ... Run Inband IPMI RAW Command ${args} 327a212a09SRahul Maheshwari ... ELSE IF '${IPMI_COMMAND}' == 'Dbus' 337a212a09SRahul Maheshwari ... Run Dbus IPMI RAW Command ${args} 34ae7c2281SPrashanth Katti ... ELSE Fail msg=Invalid IPMI Command type provided : ${IPMI_COMMAND} 35c9ea9368SGunnar Mills [Return] ${resp} 367a212a09SRahul Maheshwari 377a212a09SRahul MaheshwariRun IPMI Standard Command 3838032805SGunnar Mills [Arguments] ${args} 397a212a09SRahul Maheshwari ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External' 407a212a09SRahul Maheshwari ... Run External IPMI Standard Command ${args} 41ae7c2281SPrashanth Katti ... ELSE IF '${IPMI_COMMAND}' == 'Inband' 42ae7c2281SPrashanth Katti ... Run Inband IPMI Standard Command ${args} 437a212a09SRahul Maheshwari ... ELSE IF '${IPMI_COMMAND}' == 'Dbus' 447a212a09SRahul Maheshwari ... Run Dbus IPMI Standard Command ${args} 45ae7c2281SPrashanth Katti ... ELSE Fail msg=Invalid IPMI Command type provided : ${IPMI_COMMAND} 467a212a09SRahul Maheshwari 47c9ea9368SGunnar Mills [Return] ${resp} 487a212a09SRahul Maheshwari 497a212a09SRahul MaheshwariRun Dbus IPMI RAW Command 5038032805SGunnar Mills [Arguments] ${args} 51a2dab3c8SSivas SRR ${valueinBytes}= Byte Conversion ${args} 52a2dab3c8SSivas SRR ${cmd}= Catenate ${dbushostipmicmd1} ${dbusHostIpmiCmdReceivedMsg} 53a2dab3c8SSivas SRR ${cmd}= Catenate ${cmd} ${valueinBytes} 54a2dab3c8SSivas SRR ${output} ${stderr}= Execute Command ${cmd} return_stderr=True 55b29d2e84SChris Austen Should Be Empty ${stderr} 56b29d2e84SChris Austen set test variable ${OUTPUT} "${output}" 57b29d2e84SChris Austen 587a212a09SRahul MaheshwariRun Dbus IPMI Standard Command 5938032805SGunnar Mills [Arguments] ${args} 604d6c1dabSGeorge Keishing Copy ipmitool 617a212a09SRahul Maheshwari ${stdout} ${stderr} ${output}= Execute Command 627a212a09SRahul Maheshwari ... /tmp/ipmitool -I dbus ${args} return_stdout=True 637a212a09SRahul Maheshwari ... return_stderr= True return_rc=True 64b29d2e84SChris Austen Should Be Equal ${output} ${0} msg=${stderr} 65c9ea9368SGunnar Mills [Return] ${stdout} 66b29d2e84SChris Austen 67ae7c2281SPrashanth KattiRun Inband IPMI Raw Command 68ae7c2281SPrashanth Katti [Documentation] Run Inband IPMI raw command. 69ae7c2281SPrashanth Katti [Arguments] ${args} ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} 70ae7c2281SPrashanth Katti ... ${os_password}=${OS_PASSWORD} 71ae7c2281SPrashanth Katti 72ae7c2281SPrashanth Katti # Desription of arguments: 73ae7c2281SPrashanth Katti # ${args} parameters to IPMI command. 74ae7c2281SPrashanth Katti # ${os_host} IP address of the OS Host. 75ae7c2281SPrashanth Katti # ${os_username} OS Host Login user name. 76ae7c2281SPrashanth Katti # ${os_password} OS Host Login passwrd. 77ae7c2281SPrashanth Katti 78ae7c2281SPrashanth Katti Login To OS Host ${os_host} ${os_username} ${os_password} 79ae7c2281SPrashanth Katti Check If IPMI Tool Exist 80ae7c2281SPrashanth Katti 81ae7c2281SPrashanth Katti ${inband_raw_cmd}= Catenate ${IPMI_INBAND_CMD} ${RAW} ${args} 82ae7c2281SPrashanth Katti ${stdout} ${stderr}= Execute Command ${inband_raw_cmd} return_stderr=True 83ae7c2281SPrashanth Katti Should Be Empty ${stderr} msg=${stdout} 84ae7c2281SPrashanth Katti [Return] ${stdout} 85ae7c2281SPrashanth Katti 86ae7c2281SPrashanth KattiRun Inband IPMI Standard Command 87ae7c2281SPrashanth Katti [Documentation] Run Inband IPMI standard command. 88ae7c2281SPrashanth Katti [Arguments] ${args} ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} 89ae7c2281SPrashanth Katti ... ${os_password}=${OS_PASSWORD} 90ae7c2281SPrashanth Katti 91ae7c2281SPrashanth Katti # Desription of arguments: 92ae7c2281SPrashanth Katti # ${args} parameters to IPMI command. 93ae7c2281SPrashanth Katti # ${os_host} IP address of the OS Host. 94ae7c2281SPrashanth Katti # ${os_username} OS Host Login user name. 95ae7c2281SPrashanth Katti # ${os_password} OS Host Login passwrd. 96ae7c2281SPrashanth Katti 97ae7c2281SPrashanth Katti Login To OS Host ${os_host} ${os_username} ${os_password} 98ae7c2281SPrashanth Katti Check If IPMI Tool Exist 99ae7c2281SPrashanth Katti 100ae7c2281SPrashanth Katti ${inband_std_cmd}= Catenate ${IPMI_INBAND_CMD} ${args} 101ae7c2281SPrashanth Katti ${stdout} ${stderr}= Execute Command ${inband_std_cmd} return_stderr=True 102ae7c2281SPrashanth Katti Should Be Empty ${stderr} msg=${stdout} 103ae7c2281SPrashanth Katti [Return] ${stdout} 104ae7c2281SPrashanth Katti 1057a212a09SRahul MaheshwariRun External IPMI RAW Command 10638032805SGunnar Mills [Arguments] ${args} 1077a212a09SRahul Maheshwari ${ipmi_raw_cmd}= Catenate SEPARATOR= 108*a7913898SMichael Walsh ... ${IPMI_EXT_CMD} -P${SPACE}${IPMI_PASSWORD}${SPACE} 1097a212a09SRahul Maheshwari ... ${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${RAW}${SPACE}${args} 1107a212a09SRahul Maheshwari ${rc} ${output}= Run and Return RC and Output ${ipmi_raw_cmd} 1117a212a09SRahul Maheshwari Should Be Equal ${rc} ${0} msg=${output} 112c9ea9368SGunnar Mills [Return] ${output} 1137a212a09SRahul Maheshwari 1147a212a09SRahul MaheshwariRun External IPMI Standard Command 11538032805SGunnar Mills [Arguments] ${args} 116*a7913898SMichael Walsh 1177a212a09SRahul Maheshwari ${ipmi_cmd}= Catenate SEPARATOR= 118*a7913898SMichael Walsh ... ${IPMI_EXT_CMD} ${IPMI_USER_OPTIONS} -P${SPACE}${IPMI_PASSWORD} 119*a7913898SMichael Walsh ... ${SPACE}${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${args} 1207a212a09SRahul Maheshwari ${rc} ${output}= Run and Return RC and Output ${ipmi_cmd} 1217a212a09SRahul Maheshwari Should Be Equal ${rc} ${0} msg=${output} 122c9ea9368SGunnar Mills [Return] ${output} 1237a212a09SRahul Maheshwari 124ae7c2281SPrashanth KattiCheck If IPMI Tool Exist 125ae7c2281SPrashanth Katti [Documentation] Check if IPMI Tool installed or not. 126ae7c2281SPrashanth Katti ${output}= Execute Command which ipmitool 127ae7c2281SPrashanth Katti Should Not Be Empty ${output} msg=ipmitool not installed. 1287a212a09SRahul Maheshwari 129a2dab3c8SSivas SRRByte Conversion 130a2dab3c8SSivas SRR [Documentation] Byte Conversion method receives IPMI RAW commands as 131a2dab3c8SSivas SRR ... argument in string format. 132a2dab3c8SSivas SRR ... Sample argument is as follows 133a2dab3c8SSivas SRR ... "0x04 0x30 9 0x01 0x00 0x35 0x00 0x00 0x00 0x00 0x00 134a2dab3c8SSivas SRR ... 0x00" 135a2dab3c8SSivas SRR ... IPMI RAW command format is as follows 136a2dab3c8SSivas SRR ... <netfn Byte> <cmd Byte> <Data Bytes..> 137a2dab3c8SSivas SRR ... This method converts IPMI command format into 138a2dab3c8SSivas SRR ... dbus command format as follows 139a2dab3c8SSivas SRR ... <byte:seq-id> <byte:netfn> <byte:lun> <byte:cmd> 140a2dab3c8SSivas SRR ... <array:byte:data> 141a2dab3c8SSivas SRR ... Sample dbus Host IPMI Received Message argument 142a2dab3c8SSivas SRR ... byte:0x00 byte:0x04 byte:0x00 byte:0x30 143a2dab3c8SSivas SRR ... array:byte:9,0x01,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00 14438032805SGunnar Mills [Arguments] ${args} 145a2dab3c8SSivas SRR ${argLength}= Get Length ${args} 146a2dab3c8SSivas SRR Set Global Variable ${arrayByte} array:byte: 147a2dab3c8SSivas SRR @{listargs}= Split String ${args} 148a2dab3c8SSivas SRR ${index}= Set Variable ${0} 149a2dab3c8SSivas SRR :FOR ${word} in @{listargs} 150a2dab3c8SSivas SRR \ Run Keyword if ${index} == 0 Set NetFn Byte ${word} 151a2dab3c8SSivas SRR \ Run Keyword if ${index} == 1 Set Cmd Byte ${word} 152a2dab3c8SSivas SRR \ Run Keyword if ${index} > 1 Set Array Byte ${word} 153a2dab3c8SSivas SRR \ ${index}= Set Variable ${index + 1} 154a2dab3c8SSivas SRR ${length}= Get Length ${arrayByte} 155a2dab3c8SSivas SRR ${length}= Evaluate ${length} - 1 156a2dab3c8SSivas SRR ${arrayByteLocal}= Get Substring ${arrayByte} 0 ${length} 157a2dab3c8SSivas SRR Set Global Variable ${arrayByte} ${arrayByteLocal} 158a2dab3c8SSivas SRR ${valueinBytesWithArray}= Catenate byte:0x00 ${netfnByte} byte:0x00 159a2dab3c8SSivas SRR ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${cmdByte} 160a2dab3c8SSivas SRR ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${arrayByte} 161a2dab3c8SSivas SRR ${valueinBytesWithoutArray}= Catenate byte:0x00 ${netfnByte} byte:0x00 162a2dab3c8SSivas SRR ${valueinBytesWithoutArray}= Catenate ${valueinBytesWithoutArray} ${cmdByte} 163a2dab3c8SSivas SRR# To Check scenario for smaller IPMI raw commands with only 2 arguments 164a2dab3c8SSivas SRR# instead of usual 12 arguments. 165a2dab3c8SSivas SRR# Sample small IPMI raw command: Run IPMI command 0x06 0x36 166a2dab3c8SSivas SRR# If IPMI raw argument length is only 9 then return value in bytes without 167a2dab3c8SSivas SRR# array population. 168a2dab3c8SSivas SRR# Equivalent dbus-send argument for smaller IPMI raw command: 169a2dab3c8SSivas SRR# byte:0x00 byte:0x06 byte:0x00 byte:0x36 170a2dab3c8SSivas SRR Run Keyword if ${argLength} == 9 Return from Keyword ${valueinBytesWithoutArray} 171c9ea9368SGunnar Mills [Return] ${valueinBytesWithArray} 172a2dab3c8SSivas SRR 173a2dab3c8SSivas SRR 174a2dab3c8SSivas SRRSet NetFn Byte 17538032805SGunnar Mills [Arguments] ${word} 176a2dab3c8SSivas SRR ${netfnByteLocal}= Catenate byte:${word} 177a2dab3c8SSivas SRR Set Global Variable ${netfnByte} ${netfnByteLocal} 178a2dab3c8SSivas SRR 179a2dab3c8SSivas SRRSet Cmd Byte 18038032805SGunnar Mills [Arguments] ${word} 181a2dab3c8SSivas SRR ${cmdByteLocal}= Catenate byte:${word} 182a2dab3c8SSivas SRR Set Global Variable ${cmdByte} ${cmdByteLocal} 183a2dab3c8SSivas SRR 184a2dab3c8SSivas SRRSet Array Byte 18538032805SGunnar Mills [Arguments] ${word} 186a2dab3c8SSivas SRR ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByte} ${word} 187a2dab3c8SSivas SRR ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByteLocal} , 188a2dab3c8SSivas SRR Set Global Variable ${arrayByte} ${arrayByteLocal} 189a2dab3c8SSivas SRR 190b29d2e84SChris AustenCopy ipmitool 191b29d2e84SChris Austen OperatingSystem.File Should Exist tools/ipmitool msg=The ipmitool program could not be found in the tools directory. It is not part of the automation code by default. You must manually copy or link the correct openbmc version of the tool in to the tools directory in order to run this test suite. 192b29d2e84SChris Austen 193b29d2e84SChris Austen Import Library SCPLibrary WITH NAME scp 194b29d2e84SChris Austen scp.Open connection ${OPENBMC_HOST} username=${OPENBMC_USERNAME} password=${OPENBMC_PASSWORD} 195b29d2e84SChris Austen scp.Put File tools/ipmitool /tmp 196b29d2e84SChris Austen SSHLibrary.Open Connection ${OPENBMC_HOST} 197b29d2e84SChris Austen Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} 198b29d2e84SChris Austen Execute Command chmod +x /tmp/ipmitool 199