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 7*ae7c2281SPrashanth KattiResource ../lib/utils.robot 8*ae7c2281SPrashanth KattiResource ../lib/state_manager.robot 9*ae7c2281SPrashanth 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: 18f7b8a6c9SRahul Maheshwari${IPMI_EXT_CMD}= ipmitool -I lanplus -C 3 -P 19*ae7c2281SPrashanth Katti${IPMI_INBAND_CMD}= ipmitool -C 3 207a212a09SRahul Maheshwari${HOST}= -H 217a212a09SRahul Maheshwari${RAW}= raw 22b29d2e84SChris Austen 23b29d2e84SChris Austen*** Keywords *** 247a212a09SRahul Maheshwari 25b29d2e84SChris AustenRun IPMI Command 2638032805SGunnar Mills [Arguments] ${args} 277a212a09SRahul Maheshwari ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External' 287a212a09SRahul Maheshwari ... Run External IPMI RAW Command ${args} 29*ae7c2281SPrashanth Katti ... ELSE IF '${IPMI_COMMAND}' == 'Inband' 30*ae7c2281SPrashanth Katti ... Run Inband IPMI RAW Command ${args} 317a212a09SRahul Maheshwari ... ELSE IF '${IPMI_COMMAND}' == 'Dbus' 327a212a09SRahul Maheshwari ... Run Dbus IPMI RAW Command ${args} 33*ae7c2281SPrashanth Katti ... ELSE Fail msg=Invalid IPMI Command type provided : ${IPMI_COMMAND} 34c9ea9368SGunnar Mills [Return] ${resp} 357a212a09SRahul Maheshwari 367a212a09SRahul MaheshwariRun IPMI Standard Command 3738032805SGunnar Mills [Arguments] ${args} 387a212a09SRahul Maheshwari ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External' 397a212a09SRahul Maheshwari ... Run External IPMI Standard Command ${args} 40*ae7c2281SPrashanth Katti ... ELSE IF '${IPMI_COMMAND}' == 'Inband' 41*ae7c2281SPrashanth Katti ... Run Inband IPMI Standard Command ${args} 427a212a09SRahul Maheshwari ... ELSE IF '${IPMI_COMMAND}' == 'Dbus' 437a212a09SRahul Maheshwari ... Run Dbus IPMI Standard Command ${args} 44*ae7c2281SPrashanth Katti ... ELSE Fail msg=Invalid IPMI Command type provided : ${IPMI_COMMAND} 457a212a09SRahul Maheshwari 46c9ea9368SGunnar Mills [Return] ${resp} 477a212a09SRahul Maheshwari 487a212a09SRahul MaheshwariRun Dbus IPMI RAW Command 4938032805SGunnar Mills [Arguments] ${args} 50a2dab3c8SSivas SRR ${valueinBytes}= Byte Conversion ${args} 51a2dab3c8SSivas SRR ${cmd}= Catenate ${dbushostipmicmd1} ${dbusHostIpmiCmdReceivedMsg} 52a2dab3c8SSivas SRR ${cmd}= Catenate ${cmd} ${valueinBytes} 53a2dab3c8SSivas SRR ${output} ${stderr}= Execute Command ${cmd} return_stderr=True 54b29d2e84SChris Austen Should Be Empty ${stderr} 55b29d2e84SChris Austen set test variable ${OUTPUT} "${output}" 56b29d2e84SChris Austen 577a212a09SRahul MaheshwariRun Dbus IPMI Standard Command 5838032805SGunnar Mills [Arguments] ${args} 594d6c1dabSGeorge Keishing Copy ipmitool 607a212a09SRahul Maheshwari ${stdout} ${stderr} ${output}= Execute Command 617a212a09SRahul Maheshwari ... /tmp/ipmitool -I dbus ${args} return_stdout=True 627a212a09SRahul Maheshwari ... return_stderr= True return_rc=True 63b29d2e84SChris Austen Should Be Equal ${output} ${0} msg=${stderr} 64c9ea9368SGunnar Mills [Return] ${stdout} 65b29d2e84SChris Austen 66*ae7c2281SPrashanth KattiRun Inband IPMI Raw Command 67*ae7c2281SPrashanth Katti [Documentation] Run Inband IPMI raw command. 68*ae7c2281SPrashanth Katti [Arguments] ${args} ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} 69*ae7c2281SPrashanth Katti ... ${os_password}=${OS_PASSWORD} 70*ae7c2281SPrashanth Katti 71*ae7c2281SPrashanth Katti # Desription of arguments: 72*ae7c2281SPrashanth Katti # ${args} parameters to IPMI command. 73*ae7c2281SPrashanth Katti # ${os_host} IP address of the OS Host. 74*ae7c2281SPrashanth Katti # ${os_username} OS Host Login user name. 75*ae7c2281SPrashanth Katti # ${os_password} OS Host Login passwrd. 76*ae7c2281SPrashanth Katti 77*ae7c2281SPrashanth Katti Login To OS Host ${os_host} ${os_username} ${os_password} 78*ae7c2281SPrashanth Katti Check If IPMI Tool Exist 79*ae7c2281SPrashanth Katti 80*ae7c2281SPrashanth Katti ${inband_raw_cmd}= Catenate ${IPMI_INBAND_CMD} ${RAW} ${args} 81*ae7c2281SPrashanth Katti ${stdout} ${stderr}= Execute Command ${inband_raw_cmd} return_stderr=True 82*ae7c2281SPrashanth Katti Should Be Empty ${stderr} msg=${stdout} 83*ae7c2281SPrashanth Katti [Return] ${stdout} 84*ae7c2281SPrashanth Katti 85*ae7c2281SPrashanth KattiRun Inband IPMI Standard Command 86*ae7c2281SPrashanth Katti [Documentation] Run Inband IPMI standard command. 87*ae7c2281SPrashanth Katti [Arguments] ${args} ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} 88*ae7c2281SPrashanth Katti ... ${os_password}=${OS_PASSWORD} 89*ae7c2281SPrashanth Katti 90*ae7c2281SPrashanth Katti # Desription of arguments: 91*ae7c2281SPrashanth Katti # ${args} parameters to IPMI command. 92*ae7c2281SPrashanth Katti # ${os_host} IP address of the OS Host. 93*ae7c2281SPrashanth Katti # ${os_username} OS Host Login user name. 94*ae7c2281SPrashanth Katti # ${os_password} OS Host Login passwrd. 95*ae7c2281SPrashanth Katti 96*ae7c2281SPrashanth Katti Login To OS Host ${os_host} ${os_username} ${os_password} 97*ae7c2281SPrashanth Katti Check If IPMI Tool Exist 98*ae7c2281SPrashanth Katti 99*ae7c2281SPrashanth Katti ${inband_std_cmd}= Catenate ${IPMI_INBAND_CMD} ${args} 100*ae7c2281SPrashanth Katti ${stdout} ${stderr}= Execute Command ${inband_std_cmd} return_stderr=True 101*ae7c2281SPrashanth Katti Should Be Empty ${stderr} msg=${stdout} 102*ae7c2281SPrashanth Katti [Return] ${stdout} 103*ae7c2281SPrashanth Katti 1047a212a09SRahul MaheshwariRun External IPMI RAW Command 10538032805SGunnar Mills [Arguments] ${args} 1067a212a09SRahul Maheshwari ${ipmi_raw_cmd}= Catenate SEPARATOR= 1077a212a09SRahul Maheshwari ... ${IPMI_EXT_CMD}${SPACE}${IPMI_PASSWORD}${SPACE} 1087a212a09SRahul Maheshwari ... ${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${RAW}${SPACE}${args} 1097a212a09SRahul Maheshwari ${rc} ${output}= Run and Return RC and Output ${ipmi_raw_cmd} 1107a212a09SRahul Maheshwari Should Be Equal ${rc} ${0} msg=${output} 111c9ea9368SGunnar Mills [Return] ${output} 1127a212a09SRahul Maheshwari 1137a212a09SRahul MaheshwariRun External IPMI Standard Command 11438032805SGunnar Mills [Arguments] ${args} 1157a212a09SRahul Maheshwari ${ipmi_cmd}= Catenate SEPARATOR= 1167a212a09SRahul Maheshwari ... ${IPMI_EXT_CMD}${SPACE}${IPMI_PASSWORD}${SPACE} 1177a212a09SRahul Maheshwari ... ${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${args} 1187a212a09SRahul Maheshwari ${rc} ${output}= Run and Return RC and Output ${ipmi_cmd} 1197a212a09SRahul Maheshwari Should Be Equal ${rc} ${0} msg=${output} 120c9ea9368SGunnar Mills [Return] ${output} 1217a212a09SRahul Maheshwari 122*ae7c2281SPrashanth KattiCheck If IPMI Tool Exist 123*ae7c2281SPrashanth Katti [Documentation] Check if IPMI Tool installed or not. 124*ae7c2281SPrashanth Katti ${output}= Execute Command which ipmitool 125*ae7c2281SPrashanth Katti Should Not Be Empty ${output} msg=ipmitool not installed. 1267a212a09SRahul Maheshwari 127a2dab3c8SSivas SRRByte Conversion 128a2dab3c8SSivas SRR [Documentation] Byte Conversion method receives IPMI RAW commands as 129a2dab3c8SSivas SRR ... argument in string format. 130a2dab3c8SSivas SRR ... Sample argument is as follows 131a2dab3c8SSivas SRR ... "0x04 0x30 9 0x01 0x00 0x35 0x00 0x00 0x00 0x00 0x00 132a2dab3c8SSivas SRR ... 0x00" 133a2dab3c8SSivas SRR ... IPMI RAW command format is as follows 134a2dab3c8SSivas SRR ... <netfn Byte> <cmd Byte> <Data Bytes..> 135a2dab3c8SSivas SRR ... This method converts IPMI command format into 136a2dab3c8SSivas SRR ... dbus command format as follows 137a2dab3c8SSivas SRR ... <byte:seq-id> <byte:netfn> <byte:lun> <byte:cmd> 138a2dab3c8SSivas SRR ... <array:byte:data> 139a2dab3c8SSivas SRR ... Sample dbus Host IPMI Received Message argument 140a2dab3c8SSivas SRR ... byte:0x00 byte:0x04 byte:0x00 byte:0x30 141a2dab3c8SSivas SRR ... array:byte:9,0x01,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00 14238032805SGunnar Mills [Arguments] ${args} 143a2dab3c8SSivas SRR ${argLength}= Get Length ${args} 144a2dab3c8SSivas SRR Set Global Variable ${arrayByte} array:byte: 145a2dab3c8SSivas SRR @{listargs}= Split String ${args} 146a2dab3c8SSivas SRR ${index}= Set Variable ${0} 147a2dab3c8SSivas SRR :FOR ${word} in @{listargs} 148a2dab3c8SSivas SRR \ Run Keyword if ${index} == 0 Set NetFn Byte ${word} 149a2dab3c8SSivas SRR \ Run Keyword if ${index} == 1 Set Cmd Byte ${word} 150a2dab3c8SSivas SRR \ Run Keyword if ${index} > 1 Set Array Byte ${word} 151a2dab3c8SSivas SRR \ ${index}= Set Variable ${index + 1} 152a2dab3c8SSivas SRR ${length}= Get Length ${arrayByte} 153a2dab3c8SSivas SRR ${length}= Evaluate ${length} - 1 154a2dab3c8SSivas SRR ${arrayByteLocal}= Get Substring ${arrayByte} 0 ${length} 155a2dab3c8SSivas SRR Set Global Variable ${arrayByte} ${arrayByteLocal} 156a2dab3c8SSivas SRR ${valueinBytesWithArray}= Catenate byte:0x00 ${netfnByte} byte:0x00 157a2dab3c8SSivas SRR ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${cmdByte} 158a2dab3c8SSivas SRR ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${arrayByte} 159a2dab3c8SSivas SRR ${valueinBytesWithoutArray}= Catenate byte:0x00 ${netfnByte} byte:0x00 160a2dab3c8SSivas SRR ${valueinBytesWithoutArray}= Catenate ${valueinBytesWithoutArray} ${cmdByte} 161a2dab3c8SSivas SRR# To Check scenario for smaller IPMI raw commands with only 2 arguments 162a2dab3c8SSivas SRR# instead of usual 12 arguments. 163a2dab3c8SSivas SRR# Sample small IPMI raw command: Run IPMI command 0x06 0x36 164a2dab3c8SSivas SRR# If IPMI raw argument length is only 9 then return value in bytes without 165a2dab3c8SSivas SRR# array population. 166a2dab3c8SSivas SRR# Equivalent dbus-send argument for smaller IPMI raw command: 167a2dab3c8SSivas SRR# byte:0x00 byte:0x06 byte:0x00 byte:0x36 168a2dab3c8SSivas SRR Run Keyword if ${argLength} == 9 Return from Keyword ${valueinBytesWithoutArray} 169c9ea9368SGunnar Mills [Return] ${valueinBytesWithArray} 170a2dab3c8SSivas SRR 171a2dab3c8SSivas SRR 172a2dab3c8SSivas SRRSet NetFn Byte 17338032805SGunnar Mills [Arguments] ${word} 174a2dab3c8SSivas SRR ${netfnByteLocal}= Catenate byte:${word} 175a2dab3c8SSivas SRR Set Global Variable ${netfnByte} ${netfnByteLocal} 176a2dab3c8SSivas SRR 177a2dab3c8SSivas SRRSet Cmd Byte 17838032805SGunnar Mills [Arguments] ${word} 179a2dab3c8SSivas SRR ${cmdByteLocal}= Catenate byte:${word} 180a2dab3c8SSivas SRR Set Global Variable ${cmdByte} ${cmdByteLocal} 181a2dab3c8SSivas SRR 182a2dab3c8SSivas SRRSet Array Byte 18338032805SGunnar Mills [Arguments] ${word} 184a2dab3c8SSivas SRR ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByte} ${word} 185a2dab3c8SSivas SRR ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByteLocal} , 186a2dab3c8SSivas SRR Set Global Variable ${arrayByte} ${arrayByteLocal} 187a2dab3c8SSivas SRR 188b29d2e84SChris AustenCopy ipmitool 189b29d2e84SChris 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. 190b29d2e84SChris Austen 191b29d2e84SChris Austen Import Library SCPLibrary WITH NAME scp 192b29d2e84SChris Austen scp.Open connection ${OPENBMC_HOST} username=${OPENBMC_USERNAME} password=${OPENBMC_PASSWORD} 193b29d2e84SChris Austen scp.Put File tools/ipmitool /tmp 194b29d2e84SChris Austen SSHLibrary.Open Connection ${OPENBMC_HOST} 195b29d2e84SChris Austen Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} 196b29d2e84SChris Austen Execute Command chmod +x /tmp/ipmitool 197