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 5839a0c27SSandhya SomashekarResource ../lib/resource.robot 64d6c1dabSGeorge KeishingResource ../lib/connection_client.robot 7ae7c2281SPrashanth KattiResource ../lib/utils.robot 8ae7c2281SPrashanth KattiResource ../lib/state_manager.robot 9ae7c2281SPrashanth Katti 10a2dab3c8SSivas SRRLibrary String 1134c79af0SMichael WalshLibrary var_funcs.py 1219621bacSMichael WalshLibrary ipmi_client.py 13a2dab3c8SSivas SRR 14a2dab3c8SSivas SRR*** Variables *** 15d7f11f70SGeorge Keishing${dbusHostIpmicmd1}= dbus-send --system ${OPENBMC_BASE_URI}HostIpmi/1 16d7f11f70SGeorge Keishing${dbusHostIpmiCmdReceivedMsg}= ${OPENBMC_BASE_DBUS}.HostIpmi.ReceivedMessage 17a2dab3c8SSivas SRR${netfnByte}= ${EMPTY} 18a2dab3c8SSivas SRR${cmdByte}= ${EMPTY} 19a2dab3c8SSivas SRR${arrayByte}= array:byte: 20a7913898SMichael Walsh${IPMI_USER_OPTIONS} ${EMPTY} 2175f55dc7SGeorge Keishing${IPMI_INBAND_CMD}= ipmitool -C ${IPMI_CIPHER_LEVEL} -N ${IPMI_TIMEOUT} -p ${IPMI_PORT} 227a212a09SRahul Maheshwari${HOST}= -H 237a212a09SRahul Maheshwari${RAW}= raw 24b29d2e84SChris Austen 25b29d2e84SChris Austen*** Keywords *** 267a212a09SRahul Maheshwari 27b29d2e84SChris AustenRun IPMI Command 283ef2e92cSMichael Walsh [Documentation] Run the raw IPMI command. 293ef2e92cSMichael Walsh [Arguments] ${command} ${fail_on_err}=${1} &{options} 303ef2e92cSMichael Walsh 313ef2e92cSMichael Walsh # Description of argument(s): 323ef2e92cSMichael Walsh # command The IPMI command string to be executed 333ef2e92cSMichael Walsh # (e.g. "power status"). 343ef2e92cSMichael Walsh # fail_on_err Fail if the IPMI command execution fails. 353ef2e92cSMichael Walsh # options Additional ipmitool command options (e.g. 363ef2e92cSMichael Walsh # -C=3, -I=lanplus, etc.). Currently, only 373ef2e92cSMichael Walsh # used for external IPMI commands. 383ef2e92cSMichael Walsh 397a212a09SRahul Maheshwari ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External' 403ef2e92cSMichael Walsh ... Run External IPMI Raw Command ${command} ${fail_on_err} &{options} 41ae7c2281SPrashanth Katti ... ELSE IF '${IPMI_COMMAND}' == 'Inband' 423ef2e92cSMichael Walsh ... Run Inband IPMI Raw Command ${command} 437a212a09SRahul Maheshwari ... ELSE IF '${IPMI_COMMAND}' == 'Dbus' 443ef2e92cSMichael Walsh ... Run Dbus IPMI RAW Command ${command} 45ae7c2281SPrashanth Katti ... ELSE Fail msg=Invalid IPMI Command type provided: ${IPMI_COMMAND} 46c9ea9368SGunnar Mills [Return] ${resp} 477a212a09SRahul Maheshwari 483ef2e92cSMichael Walsh 497a212a09SRahul MaheshwariRun IPMI Standard Command 50f4a807bfSJoy Onyerikwu [Documentation] Run the standard IPMI command. 51d0e58e73SMichael Walsh [Arguments] ${command} ${fail_on_err}=${1} ${expected_rc}=${0} &{options} 5220f3bf73SRahul Maheshwari 5320f3bf73SRahul Maheshwari # Description of argument(s): 543ef2e92cSMichael Walsh # command The IPMI command string to be executed 553ef2e92cSMichael Walsh # (e.g. "0x06 0x36"). 563ef2e92cSMichael Walsh # fail_on_err Fail if the IPMI command execution fails. 57d0e58e73SMichael Walsh # expected_rc The expected return code from the ipmi 58d0e58e73SMichael Walsh # command (e.g. ${0}, ${1}, etc.). 593ef2e92cSMichael Walsh # options Additional ipmitool command options (e.g. 603ef2e92cSMichael Walsh # -C=3, -I=lanplus, etc.). Currently, only 613ef2e92cSMichael Walsh # used for external IPMI commands. 6220f3bf73SRahul Maheshwari 637a212a09SRahul Maheshwari ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External' 64d0e58e73SMichael Walsh ... Run External IPMI Standard Command ${command} ${fail_on_err} ${expected_rc} &{options} 65ae7c2281SPrashanth Katti ... ELSE IF '${IPMI_COMMAND}' == 'Inband' 663ef2e92cSMichael Walsh ... Run Inband IPMI Standard Command ${command} ${fail_on_err} 677a212a09SRahul Maheshwari ... ELSE IF '${IPMI_COMMAND}' == 'Dbus' 683ef2e92cSMichael Walsh ... Run Dbus IPMI Standard Command ${command} 69ae7c2281SPrashanth Katti ... ELSE Fail msg=Invalid IPMI Command type provided : ${IPMI_COMMAND} 70c9ea9368SGunnar Mills [Return] ${resp} 717a212a09SRahul Maheshwari 723ef2e92cSMichael Walsh 737a212a09SRahul MaheshwariRun Dbus IPMI RAW Command 74f4a807bfSJoy Onyerikwu [Documentation] Run the raw IPMI command through dbus. 753ef2e92cSMichael Walsh [Arguments] ${command} 763ef2e92cSMichael Walsh ${valueinBytes}= Byte Conversion ${command} 77a2dab3c8SSivas SRR ${cmd}= Catenate ${dbushostipmicmd1} ${dbusHostIpmiCmdReceivedMsg} 78a2dab3c8SSivas SRR ${cmd}= Catenate ${cmd} ${valueinBytes} 79a2dab3c8SSivas SRR ${output} ${stderr}= Execute Command ${cmd} return_stderr=True 80b29d2e84SChris Austen Should Be Empty ${stderr} 81b29d2e84SChris Austen set test variable ${OUTPUT} "${output}" 82b29d2e84SChris Austen 833ef2e92cSMichael Walsh 847a212a09SRahul MaheshwariRun Dbus IPMI Standard Command 85f4a807bfSJoy Onyerikwu [Documentation] Run the standard IPMI command through dbus. 863ef2e92cSMichael Walsh [Arguments] ${command} 874d6c1dabSGeorge Keishing Copy ipmitool 887a212a09SRahul Maheshwari ${stdout} ${stderr} ${output}= Execute Command 893ef2e92cSMichael Walsh ... /tmp/ipmitool -I dbus ${command} return_stdout=True 907a212a09SRahul Maheshwari ... return_stderr= True return_rc=True 91b29d2e84SChris Austen Should Be Equal ${output} ${0} msg=${stderr} 92c9ea9368SGunnar Mills [Return] ${stdout} 93b29d2e84SChris Austen 943ef2e92cSMichael Walsh 95ae7c2281SPrashanth KattiRun Inband IPMI Raw Command 96f4a807bfSJoy Onyerikwu [Documentation] Run the raw IPMI command in-band. 974ad123acSchithrag [Arguments] ${command} ${fail_on_err}=${1} ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} 98ae7c2281SPrashanth Katti ... ${os_password}=${OS_PASSWORD} 99ae7c2281SPrashanth Katti 1003ef2e92cSMichael Walsh # Description of argument(s): 1013ef2e92cSMichael Walsh # command The IPMI command string to be executed 1023ef2e92cSMichael Walsh # (e.g. "0x06 0x36"). 1033ef2e92cSMichael Walsh # os_host The host name or IP address of the OS Host. 1043ef2e92cSMichael Walsh # os_username The OS host user name. 1053ef2e92cSMichael Walsh # os_password The OS host passwrd. 106ae7c2281SPrashanth Katti 107ae7c2281SPrashanth Katti Login To OS Host ${os_host} ${os_username} ${os_password} 108ae7c2281SPrashanth Katti Check If IPMI Tool Exist 109ae7c2281SPrashanth Katti 1103ef2e92cSMichael Walsh ${ipmi_cmd}= Catenate ${IPMI_INBAND_CMD} ${RAW} ${command} 1113ef2e92cSMichael Walsh Qprint Issuing ${ipmi_cmd} 1123ef2e92cSMichael Walsh ${stdout} ${stderr}= Execute Command ${ipmi_cmd} return_stderr=True 1134ad123acSchithrag Return From Keyword If ${fail_on_err} == ${0} ${stderr} 114ae7c2281SPrashanth Katti Should Be Empty ${stderr} msg=${stdout} 115ae7c2281SPrashanth Katti [Return] ${stdout} 116ae7c2281SPrashanth Katti 1173ef2e92cSMichael Walsh 118ae7c2281SPrashanth KattiRun Inband IPMI Standard Command 119f4a807bfSJoy Onyerikwu [Documentation] Run the standard IPMI command in-band. 1203ef2e92cSMichael Walsh [Arguments] ${command} ${fail_on_err}=${1} ${os_host}=${OS_HOST} 12120f3bf73SRahul Maheshwari ... ${os_username}=${OS_USERNAME} ${os_password}=${OS_PASSWORD} 1229e8c0d88SNaman Navin Hegde ... ${login_host}=${1} 123ae7c2281SPrashanth Katti 1243ef2e92cSMichael Walsh # Description of argument(s): 1253ef2e92cSMichael Walsh # command The IPMI command string to be executed 1263ef2e92cSMichael Walsh # (e.g. "power status"). 1273ef2e92cSMichael Walsh # os_host The host name or IP address of the OS Host. 1283ef2e92cSMichael Walsh # os_username The OS host user name. 1293ef2e92cSMichael Walsh # os_password The OS host passwrd. 1309e8c0d88SNaman Navin Hegde # login_host Indicates that this keyword should login to host OS. 131ae7c2281SPrashanth Katti 1329e8c0d88SNaman Navin Hegde Run Keyword If ${login_host} == ${1} 1339e8c0d88SNaman Navin Hegde ... Login To OS Host ${os_host} ${os_username} ${os_password} 134ae7c2281SPrashanth Katti Check If IPMI Tool Exist 135ae7c2281SPrashanth Katti 1363ef2e92cSMichael Walsh ${ipmi_cmd}= Catenate ${IPMI_INBAND_CMD} ${command} 1373ef2e92cSMichael Walsh Qprint Issuing ${ipmi_cmd} 1383ef2e92cSMichael Walsh ${stdout} ${stderr}= Execute Command ${ipmi_cmd} return_stderr=True 13920f3bf73SRahul Maheshwari Return From Keyword If ${fail_on_err} == ${0} ${stderr} 140ae7c2281SPrashanth Katti Should Be Empty ${stderr} msg=${stdout} 141ae7c2281SPrashanth Katti [Return] ${stdout} 142ae7c2281SPrashanth Katti 1437a212a09SRahul Maheshwari 1447a212a09SRahul MaheshwariRun External IPMI Standard Command 1453ef2e92cSMichael Walsh [Documentation] Run the external IPMI standard command. 146d0e58e73SMichael Walsh [Arguments] ${command} ${fail_on_err}=${1} ${expected_rc}=${0} &{options} 14702651f0cSGeorge Keishing 14802651f0cSGeorge Keishing # Description of argument(s): 1493ef2e92cSMichael Walsh # command The IPMI command string to be executed 1503ef2e92cSMichael Walsh # (e.g. "power status"). Note that if 1513ef2e92cSMichael Walsh # ${IPMI_USER_OPTIONS} has a value (e.g. 1523ef2e92cSMichael Walsh # "-vvv"), it will be pre-pended to this 1533ef2e92cSMichael Walsh # command string. 1543ef2e92cSMichael Walsh # fail_on_err Fail if the IPMI command execution fails. 155d0e58e73SMichael Walsh # expected_rc The expected return code from the ipmi 156d0e58e73SMichael Walsh # command (e.g. ${0}, ${1}, etc.). 1573ef2e92cSMichael Walsh # options Additional ipmitool command options (e.g. 1583ef2e92cSMichael Walsh # -C=3, -I=lanplus, etc.). 159a7913898SMichael Walsh 1603ef2e92cSMichael Walsh ${command_string}= Process IPMI User Options ${command} 1613ef2e92cSMichael Walsh ${ipmi_cmd}= Create IPMI Ext Command String ${command_string} &{options} 1623ef2e92cSMichael Walsh Qprint Issuing ${ipmi_cmd} 16304a2204bSRahul Maheshwari ${rc} ${output}= Run And Return RC and Output ${ipmi_cmd} 16402651f0cSGeorge Keishing Return From Keyword If ${fail_on_err} == ${0} ${output} 165d0e58e73SMichael Walsh Should Be Equal ${rc} ${expected_rc} msg=${output} 166c9ea9368SGunnar Mills [Return] ${output} 1677a212a09SRahul Maheshwari 1683ef2e92cSMichael Walsh 1693ef2e92cSMichael WalshRun External IPMI Raw Command 1703ef2e92cSMichael Walsh [Documentation] Run the external IPMI raw command. 1713ef2e92cSMichael Walsh [Arguments] ${command} ${fail_on_err}=${1} &{options} 1723ef2e92cSMichael Walsh 1733ef2e92cSMichael Walsh # This keyword is a wrapper for 'Run External IPMI Standard Command'. See 1743ef2e92cSMichael Walsh # that keyword's prolog for argument details. This keyword will pre-pend 1753ef2e92cSMichael Walsh # the word "raw" plus a space to command prior to calling 'Run External 1763ef2e92cSMichael Walsh # IPMI Standard Command'. 1773ef2e92cSMichael Walsh 1783ef2e92cSMichael Walsh ${output}= Run External IPMI Standard Command 1793ef2e92cSMichael Walsh ... raw ${command} ${fail_on_err} &{options} 1803ef2e92cSMichael Walsh [Return] ${output} 1813ef2e92cSMichael Walsh 1823ef2e92cSMichael Walsh 183ae7c2281SPrashanth KattiCheck If IPMI Tool Exist 184ae7c2281SPrashanth Katti [Documentation] Check if IPMI Tool installed or not. 185ae7c2281SPrashanth Katti ${output}= Execute Command which ipmitool 186ae7c2281SPrashanth Katti Should Not Be Empty ${output} msg=ipmitool not installed. 1877a212a09SRahul Maheshwari 18804a2204bSRahul Maheshwari 18904a2204bSRahul MaheshwariActivate SOL Via IPMI 19004a2204bSRahul Maheshwari [Documentation] Start SOL using IPMI and route output to a file. 19126206721SGeorge Keishing [Arguments] ${file_path}=${IPMI_SOL_LOG_FILE} 1923ef2e92cSMichael Walsh 19304a2204bSRahul Maheshwari # Description of argument(s): 1943ef2e92cSMichael Walsh # file_path The file path on the local machine (vs. 1953ef2e92cSMichael Walsh # OBMC) to collect SOL output. By default 1963ef2e92cSMichael Walsh # SOL output is collected at 19726206721SGeorge Keishing # logs/sol_<BMC_IP> else user input location. 19804a2204bSRahul Maheshwari 1993ef2e92cSMichael Walsh ${ipmi_cmd}= Create IPMI Ext Command String sol activate usesolkeepalive 2003ef2e92cSMichael Walsh Qprint Issuing ${ipmi_cmd} 2012102f6bfSGeorge Keishing Start Process ${ipmi_cmd} shell=True stdout=${file_path} 2024f360843SRahul Maheshwari ... alias=sol_proc 20304a2204bSRahul Maheshwari 20404a2204bSRahul Maheshwari 20504a2204bSRahul MaheshwariDeactivate SOL Via IPMI 20604a2204bSRahul Maheshwari [Documentation] Stop SOL using IPMI and return SOL output. 20726206721SGeorge Keishing [Arguments] ${file_path}=${IPMI_SOL_LOG_FILE} 2083ef2e92cSMichael Walsh 20904a2204bSRahul Maheshwari # Description of argument(s): 2103ef2e92cSMichael Walsh # file_path The file path on the local machine to copy 2113ef2e92cSMichael Walsh # SOL output collected by above "Activate 2123ef2e92cSMichael Walsh # SOL Via IPMI" keyword. By default it 21326206721SGeorge Keishing # copies log from logs/sol_<BMC_IP>. 21404a2204bSRahul Maheshwari 2153ef2e92cSMichael Walsh ${ipmi_cmd}= Create IPMI Ext Command String sol deactivate 2163ef2e92cSMichael Walsh Qprint Issuing ${ipmi_cmd} 21704a2204bSRahul Maheshwari ${rc} ${output}= Run and Return RC and Output ${ipmi_cmd} 2184f360843SRahul Maheshwari Run Keyword If ${rc} > 0 Run Keywords 2197f48a2c6SRahul Maheshwari ... Run Keyword And Ignore Error Terminate Process sol_proc 2207f48a2c6SRahul Maheshwari ... AND Return From Keyword ${output} 22104a2204bSRahul Maheshwari 222aec8b879SGeorge Keishing ${output}= OperatingSystem.Get File ${file_path} encoding_errors=ignore 22304a2204bSRahul Maheshwari 22404a2204bSRahul Maheshwari # Logging SOL output for debug purpose. 22504a2204bSRahul Maheshwari Log ${output} 22604a2204bSRahul Maheshwari 22704a2204bSRahul Maheshwari [Return] ${output} 22804a2204bSRahul Maheshwari 22904a2204bSRahul Maheshwari 230a2dab3c8SSivas SRRByte Conversion 231a2dab3c8SSivas SRR [Documentation] Byte Conversion method receives IPMI RAW commands as 232a2dab3c8SSivas SRR ... argument in string format. 233a2dab3c8SSivas SRR ... Sample argument is as follows 234a2dab3c8SSivas SRR ... "0x04 0x30 9 0x01 0x00 0x35 0x00 0x00 0x00 0x00 0x00 235a2dab3c8SSivas SRR ... 0x00" 236a2dab3c8SSivas SRR ... IPMI RAW command format is as follows 237a2dab3c8SSivas SRR ... <netfn Byte> <cmd Byte> <Data Bytes..> 238a2dab3c8SSivas SRR ... This method converts IPMI command format into 239a2dab3c8SSivas SRR ... dbus command format as follows 240a2dab3c8SSivas SRR ... <byte:seq-id> <byte:netfn> <byte:lun> <byte:cmd> 241a2dab3c8SSivas SRR ... <array:byte:data> 242a2dab3c8SSivas SRR ... Sample dbus Host IPMI Received Message argument 243a2dab3c8SSivas SRR ... byte:0x00 byte:0x04 byte:0x00 byte:0x30 244a2dab3c8SSivas SRR ... array:byte:9,0x01,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00 24538032805SGunnar Mills [Arguments] ${args} 246a2dab3c8SSivas SRR ${argLength}= Get Length ${args} 247a2dab3c8SSivas SRR Set Global Variable ${arrayByte} array:byte: 248a2dab3c8SSivas SRR @{listargs}= Split String ${args} 249a2dab3c8SSivas SRR ${index}= Set Variable ${0} 25020ccfc71SMarissa Garza FOR ${word} IN @{listargs} 25120ccfc71SMarissa Garza Run Keyword if ${index} == 0 Set NetFn Byte ${word} 25220ccfc71SMarissa Garza Run Keyword if ${index} == 1 Set Cmd Byte ${word} 25320ccfc71SMarissa Garza Run Keyword if ${index} > 1 Set Array Byte ${word} 25420ccfc71SMarissa Garza ${index}= Set Variable ${index + 1} 25520ccfc71SMarissa Garza END 256a2dab3c8SSivas SRR ${length}= Get Length ${arrayByte} 257a2dab3c8SSivas SRR ${length}= Evaluate ${length} - 1 258a2dab3c8SSivas SRR ${arrayByteLocal}= Get Substring ${arrayByte} 0 ${length} 259a2dab3c8SSivas SRR Set Global Variable ${arrayByte} ${arrayByteLocal} 260a2dab3c8SSivas SRR ${valueinBytesWithArray}= Catenate byte:0x00 ${netfnByte} byte:0x00 261a2dab3c8SSivas SRR ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${cmdByte} 262a2dab3c8SSivas SRR ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${arrayByte} 263a2dab3c8SSivas SRR ${valueinBytesWithoutArray}= Catenate byte:0x00 ${netfnByte} byte:0x00 264a2dab3c8SSivas SRR ${valueinBytesWithoutArray}= Catenate ${valueinBytesWithoutArray} ${cmdByte} 265a2dab3c8SSivas SRR # To Check scenario for smaller IPMI raw commands with only 2 arguments 266a2dab3c8SSivas SRR # instead of usual 12 arguments. 267a2dab3c8SSivas SRR # Sample small IPMI raw command: Run IPMI command 0x06 0x36 268a2dab3c8SSivas SRR # If IPMI raw argument length is only 9 then return value in bytes without 269a2dab3c8SSivas SRR # array population. 270a2dab3c8SSivas SRR # Equivalent dbus-send argument for smaller IPMI raw command: 271a2dab3c8SSivas SRR # byte:0x00 byte:0x06 byte:0x00 byte:0x36 272a2dab3c8SSivas SRR Run Keyword if ${argLength} == 9 Return from Keyword ${valueinBytesWithoutArray} 273c9ea9368SGunnar Mills [Return] ${valueinBytesWithArray} 274a2dab3c8SSivas SRR 275a2dab3c8SSivas SRR 276a2dab3c8SSivas SRRSet NetFn Byte 277f4a807bfSJoy Onyerikwu [Documentation] Set the network function byte. 27838032805SGunnar Mills [Arguments] ${word} 279a2dab3c8SSivas SRR ${netfnByteLocal}= Catenate byte:${word} 280a2dab3c8SSivas SRR Set Global Variable ${netfnByte} ${netfnByteLocal} 281a2dab3c8SSivas SRR 2823ef2e92cSMichael Walsh 283a2dab3c8SSivas SRRSet Cmd Byte 284f4a807bfSJoy Onyerikwu [Documentation] Set the command byte. 28538032805SGunnar Mills [Arguments] ${word} 286a2dab3c8SSivas SRR ${cmdByteLocal}= Catenate byte:${word} 287a2dab3c8SSivas SRR Set Global Variable ${cmdByte} ${cmdByteLocal} 288a2dab3c8SSivas SRR 2893ef2e92cSMichael Walsh 290a2dab3c8SSivas SRRSet Array Byte 291f4a807bfSJoy Onyerikwu [Documentation] Set the array byte. 29238032805SGunnar Mills [Arguments] ${word} 293a2dab3c8SSivas SRR ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByte} ${word} 294a2dab3c8SSivas SRR ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByteLocal} , 295a2dab3c8SSivas SRR Set Global Variable ${arrayByte} ${arrayByteLocal} 296a2dab3c8SSivas SRR 2973ef2e92cSMichael Walsh 298b29d2e84SChris AustenCopy ipmitool 299f4a807bfSJoy Onyerikwu [Documentation] Copy the ipmitool to the BMC. 300f4a807bfSJoy Onyerikwu ${ipmitool_error}= Catenate The ipmitool program could not be found in the tools directory. 301f4a807bfSJoy Onyerikwu ... It is not part of the automation code by default. You must manually copy or link the correct openbmc 302f4a807bfSJoy Onyerikwu ... version of the tool in to the tools directory in order to run this test suite. 303f4a807bfSJoy Onyerikwu 304f4a807bfSJoy Onyerikwu OperatingSystem.File Should Exist tools/ipmitool msg=${ipmitool_error} 305b29d2e84SChris Austen 306b29d2e84SChris Austen Import Library SCPLibrary WITH NAME scp 307b29d2e84SChris Austen scp.Open connection ${OPENBMC_HOST} username=${OPENBMC_USERNAME} password=${OPENBMC_PASSWORD} 308b29d2e84SChris Austen scp.Put File tools/ipmitool /tmp 309b29d2e84SChris Austen SSHLibrary.Open Connection ${OPENBMC_HOST} 310f94de719SGeorge Keishing SSHLibrary.Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} 311b29d2e84SChris Austen Execute Command chmod +x /tmp/ipmitool 3120c34f69cSSridevi Ramesh 3133ef2e92cSMichael Walsh 3140c34f69cSSridevi RameshInitiate Host Boot Via External IPMI 3150c34f69cSSridevi Ramesh [Documentation] Initiate host power on using external IPMI. 316982fee42SRahul Maheshwari [Arguments] ${wait}=${1} 3173ef2e92cSMichael Walsh 318982fee42SRahul Maheshwari # Description of argument(s): 3193ef2e92cSMichael Walsh # wait Indicates that this keyword should wait 3203ef2e92cSMichael Walsh # for host running state. 321982fee42SRahul Maheshwari 3220c34f69cSSridevi Ramesh ${output}= Run External IPMI Standard Command chassis power on 3230c34f69cSSridevi Ramesh Should Not Contain ${output} Error 324982fee42SRahul Maheshwari 325982fee42SRahul Maheshwari Run Keyword If '${wait}' == '${0}' Return From Keyword 326982fee42SRahul Maheshwari Wait Until Keyword Succeeds 10 min 10 sec Is Host Running 3270c34f69cSSridevi Ramesh 3283ef2e92cSMichael Walsh 3290c34f69cSSridevi RameshInitiate Host PowerOff Via External IPMI 3300c34f69cSSridevi Ramesh [Documentation] Initiate host power off using external IPMI. 331982fee42SRahul Maheshwari [Arguments] ${wait}=${1} 3323ef2e92cSMichael Walsh 333982fee42SRahul Maheshwari # Description of argument(s): 3343ef2e92cSMichael Walsh # wait Indicates that this keyword should wait 3353ef2e92cSMichael Walsh # for host off state. 336982fee42SRahul Maheshwari 3370c34f69cSSridevi Ramesh ${output}= Run External IPMI Standard Command chassis power off 3380c34f69cSSridevi Ramesh Should Not Contain ${output} Error 339982fee42SRahul Maheshwari 340982fee42SRahul Maheshwari Run Keyword If '${wait}' == '${0}' Return From Keyword 341982fee42SRahul Maheshwari Wait Until Keyword Succeeds 3 min 10 sec Is Host Off 342982fee42SRahul Maheshwari 3433ef2e92cSMichael Walsh 344460778dcSRahul MaheshwariIs Host Off Via IPMI 345460778dcSRahul Maheshwari [Documentation] Verify if the Host is off using IPMI command. 346460778dcSRahul Maheshwari 347460778dcSRahul Maheshwari ${status}= Run External IPMI Standard Command chassis power status 348460778dcSRahul Maheshwari Should Contain ${status} off 349460778dcSRahul Maheshwari 350460778dcSRahul Maheshwari 351982fee42SRahul MaheshwariGet Host State Via External IPMI 352982fee42SRahul Maheshwari [Documentation] Returns host state using external IPMI. 353982fee42SRahul Maheshwari 354982fee42SRahul Maheshwari ${output}= Run External IPMI Standard Command chassis power status 355982fee42SRahul Maheshwari Should Not Contain ${output} Error 356982fee42SRahul Maheshwari ${output}= Fetch From Right ${output} ${SPACE} 357982fee42SRahul Maheshwari 358982fee42SRahul Maheshwari [Return] ${output} 359b4d4a4aeSGeorge Keishing 360b4d4a4aeSGeorge Keishing 361b4d4a4aeSGeorge KeishingSet BMC Network From Host 362b4d4a4aeSGeorge Keishing [Documentation] Set BMC network from host. 363b4d4a4aeSGeorge Keishing [Arguments] ${nw_info} 364b4d4a4aeSGeorge Keishing 365b4d4a4aeSGeorge Keishing # Description of argument(s): 3663ef2e92cSMichael Walsh # nw_info A dictionary containing the network 3673ef2e92cSMichael Walsh # information to apply. 368b4d4a4aeSGeorge Keishing 369b4d4a4aeSGeorge Keishing Run Inband IPMI Standard Command 370b4d4a4aeSGeorge Keishing ... lan set 1 ipaddr ${nw_info['IP Address']} 371b4d4a4aeSGeorge Keishing 372b4d4a4aeSGeorge Keishing Run Inband IPMI Standard Command 373b4d4a4aeSGeorge Keishing ... lan set 1 netmask ${nw_info['Subnet Mask']} 374b4d4a4aeSGeorge Keishing 375b4d4a4aeSGeorge Keishing Run Inband IPMI Standard Command 376b4d4a4aeSGeorge Keishing ... lan set 1 defgw ipaddr ${nw_info['Default Gateway IP']} 377c3d1e968SRahul Maheshwari 378c3d1e968SRahul Maheshwari 379c3d1e968SRahul MaheshwariVerify IPMI Username And Password 380c3d1e968SRahul Maheshwari [Documentation] Verify that user is able to run IPMI command 381c3d1e968SRahul Maheshwari ... with given username and password. 382c3d1e968SRahul Maheshwari [Arguments] ${username} ${password} 383c3d1e968SRahul Maheshwari 384c3d1e968SRahul Maheshwari # Description of argument(s): 385c3d1e968SRahul Maheshwari # username The user name (e.g. "root", "robert", etc.). 386c3d1e968SRahul Maheshwari # password The user password (e.g. "0penBmc", "0penBmc1", etc.). 387c3d1e968SRahul Maheshwari 388f9379e88STony Lee ${output}= Wait Until Keyword Succeeds 15 sec 5 sec Run External IPMI Standard Command 389c3d1e968SRahul Maheshwari ... sel info U=${username} P=${password} 390c3d1e968SRahul Maheshwari Should Contain ${output} SEL Information msg=SEL information not present 39175e91feaSRahul Maheshwari 39275e91feaSRahul Maheshwari 39375e91feaSRahul MaheshwariIPMI Create User 39475e91feaSRahul Maheshwari [Documentation] Create IPMI user with given userid and username. 39575e91feaSRahul Maheshwari [Arguments] ${userid} ${username} 39675e91feaSRahul Maheshwari 39775e91feaSRahul Maheshwari # Description of argument(s): 39875e91feaSRahul Maheshwari # userid The user ID (e.g. "1", "2", etc.). 39975e91feaSRahul Maheshwari # username The user name (e.g. "root", "robert", etc.). 40075e91feaSRahul Maheshwari 40175e91feaSRahul Maheshwari ${ipmi_cmd}= Catenate user set name ${userid} ${username} 40275e91feaSRahul Maheshwari ${resp}= Run IPMI Standard Command ${ipmi_cmd} 40375e91feaSRahul Maheshwari ${user_info}= Get User Info ${userid} 40475e91feaSRahul Maheshwari Should Be Equal ${user_info['user_name']} ${username} 40575e91feaSRahul Maheshwari 40675e91feaSRahul Maheshwari 40775e91feaSRahul MaheshwariSet Channel Access 40875e91feaSRahul Maheshwari [Documentation] Verify that user is able to run IPMI command 40975e91feaSRahul Maheshwari ... with given username and password. 4107c5f4b28STony Lee [Arguments] ${userid} ${options} ${channel_number}=${CHANNEL_NUMBER} 41175e91feaSRahul Maheshwari 41275e91feaSRahul Maheshwari # Description of argument(s): 41375e91feaSRahul Maheshwari # userid The user ID (e.g. "1", "2", etc.). 41475e91feaSRahul Maheshwari # options Set channel command options (e.g. 41575e91feaSRahul Maheshwari # "link=on", "ipmi=on", etc.). 41675e91feaSRahul Maheshwari # channel_number The user's channel number (e.g. "1"). 41775e91feaSRahul Maheshwari 41875e91feaSRahul Maheshwari ${ipmi_cmd}= Catenate SEPARATOR= 4197c5f4b28STony Lee ... channel setaccess${SPACE}${channel_number}${SPACE}${userid} 42075e91feaSRahul Maheshwari ... ${SPACE}${options} 42175e91feaSRahul Maheshwari Run IPMI Standard Command ${ipmi_cmd} 4223e61ce66SRahul Maheshwari 4233e61ce66SRahul Maheshwari 4243e61ce66SRahul MaheshwariDelete All Non Root IPMI User 4253e61ce66SRahul Maheshwari [Documentation] Delete all non-root IPMI user. 4263e61ce66SRahul Maheshwari 42734c79af0SMichael Walsh # Get complete list of user info records. 42834c79af0SMichael Walsh ${user_info}= Get User Info ${EMPTY} 42934c79af0SMichael Walsh # Remove header record. 43034c79af0SMichael Walsh ${user_info}= Filter Struct ${user_info} [('user_name', None)] invert=1 43134c79af0SMichael Walsh ${non_empty_user_info}= Filter Struct ${user_info} [('user_name', '')] invert=1 43234c79af0SMichael Walsh ${non_root_user_info}= Filter Struct ${non_empty_user_info} [('user_name', 'root')] invert=1 43334c79af0SMichael Walsh 43434c79af0SMichael Walsh FOR ${user_record} IN @{non_root_user_info} 43534c79af0SMichael Walsh Run IPMI Standard Command user set name ${user_record['user_id']} "" 436bb3d21c0SRahul Maheshwari Sleep 5s 4373e61ce66SRahul Maheshwari END 4380a8c8787Schithrag 4390a8c8787Schithrag 4400a8c8787SchithragCreate SEL 4410a8c8787Schithrag [Documentation] Create a SEL. 4420a8c8787Schithrag [Arguments] ${sensor_type} ${sensor_number} 4430a8c8787Schithrag 4440a8c8787Schithrag # Create a SEL. 4450a8c8787Schithrag # Example: 4460a8c8787Schithrag # a | 02/14/2020 | 01:16:58 | Sensor_type #0x17 | | Asserted 4470a8c8787Schithrag 4480a8c8787Schithrag # Description of argument(s): 4490a8c8787Schithrag # ${sensor_type} Type of the sensor used in hexadecimal (can be fan, temp etc.,), 4500a8c8787Schithrag # obtained from Sensor Type field in - ipmitool sdr get "sensor_name". 4510a8c8787Schithrag # Example: Sensor Type (Threshold) : Fan (0x04), here 0xHH is sensor type. 4520a8c8787Schithrag 4530a8c8787Schithrag # ${sensor_number} Sensor number of the sensor in hexadecimal. 4540a8c8787Schithrag # obtained from Sensor ID field in - ipmitool sdr get "sensor_name". 4550a8c8787Schithrag # Example: Sensor ID : SENSOR_1 (0xHH), here 0xHH is sensor number. 4560a8c8787Schithrag 4570a8c8787Schithrag ${resp}= Run IPMI Command 4580a8c8787Schithrag ... ${IPMI_RAW_CMD['SEL_entry']['Create_SEL'][0]} 0x${sensor_type} 0x${sensor_number} ${IPMI_RAW_CMD['SEL_entry']['Create_SEL'][1]} 4590a8c8787Schithrag 460*d7e009b6Schithrag Should Not Contain ${resp} 00 00 msg=SEL not created. 461*d7e009b6Schithrag 4620a8c8787Schithrag [Return] ${resp} 4630a8c8787Schithrag 4640a8c8787Schithrag 4650a8c8787SchithragFetch Any Sensor From Sensor List 4660a8c8787Schithrag [Documentation] Find any sensor name randomly from Sensor list. 4670a8c8787Schithrag 4680a8c8787Schithrag ${resp}= Run IPMI Standard Command sensor 4690a8c8787Schithrag 4700a8c8787Schithrag # Find total number of sensor. 4710a8c8787Schithrag ${data}= Split To Lines ${resp} 4720a8c8787Schithrag ${length}= Get Length ${data} 4730a8c8787Schithrag 4740a8c8787Schithrag # Identify any one sensor. 4750a8c8787Schithrag ${sensor_index}= Evaluate random.randint(1, ${length}) modules=random 4760a8c8787Schithrag ${sensor_data}= Set Variable ${data[${sensor_index}-1]} 4770a8c8787Schithrag ${sensor}= Split String ${sensor_data} | 4780a8c8787Schithrag 4790a8c8787Schithrag # Retrieve Sensor Name and return. 4800a8c8787Schithrag ${sensor_name}= Set Variable ${sensor[0]} 4810a8c8787Schithrag ${sensor_name}= Remove Whitespace ${sensor_name} 4820a8c8787Schithrag 4830a8c8787Schithrag [Return] ${sensor_name} 4840a8c8787Schithrag 4850a8c8787Schithrag 4860a8c8787SchithragFetch Sensor Details From SDR 4870a8c8787Schithrag [Documentation] Identify the sensors from sdr get and fetch sensor details required. 4880a8c8787Schithrag [Arguments] ${sensor_name} ${setting} 4890a8c8787Schithrag 4900a8c8787Schithrag # Description of argument(s): 4910a8c8787Schithrag # ${sensor_number} Sensor number of the sensor in hexadecimal. 4920a8c8787Schithrag # obtained sensor name from - 'ipmitool sensor' command. 4930a8c8787Schithrag # Example: a | 02/14/2020 | 01:16:58 | Sensor_type #0x17 | | Asserted 4940a8c8787Schithrag # here, a is the sensor name. 4950a8c8787Schithrag 4960a8c8787Schithrag # ${setting} Field to fetch data. Example : Sensor ID, Sensor Type (Threshold), etc,. 4970a8c8787Schithrag 4980a8c8787Schithrag ${resp}= Run IPMI Standard Command sdr get "${sensor_name}" 4990a8c8787Schithrag 5000a8c8787Schithrag ${setting_line}= Get Lines Containing String ${resp} ${setting} 5010a8c8787Schithrag ... case-insensitive 5020a8c8787Schithrag ${setting_status}= Fetch From Right ${setting_line} :${SPACE} 5030a8c8787Schithrag 5040a8c8787Schithrag [Return] ${setting_status} 5050a8c8787Schithrag 5060a8c8787Schithrag 5070a8c8787SchithragGet Data And Byte From SDR Sensor 5080a8c8787Schithrag [Documentation] Fetch the Field Data and hexadecimal values from given details. 5090a8c8787Schithrag [Arguments] ${sensor_detail} 5100a8c8787Schithrag 5110a8c8787Schithrag # Description of argument(s): 5120a8c8787Schithrag # ${sensor_detail} Requested field and the value from the sdr get ipmi command. 5130a8c8787Schithrag # Example : if Sensor ID is the requesting setting, then, 5140a8c8787Schithrag # ${sensor_detail} will be "Sensor ID : SENSOR_1 (0xHH)" 5150a8c8787Schithrag 5160a8c8787Schithrag ${sensor_detail}= Split String ${sensor_detail} (0x 5170a8c8787Schithrag ${field_data}= Set Variable ${sensor_detail[0]} 5180a8c8787Schithrag ${field_data}= Remove Whitespace ${field_data} 5190a8c8787Schithrag ${sensor_hex}= Replace String ${sensor_detail[1]} ) ${EMPTY} 5200a8c8787Schithrag ${sensor_hex}= Zfill Data ${sensor_hex} 2 5210a8c8787Schithrag 5220a8c8787Schithrag [Return] ${field_data} ${sensor_hex} 5230a8c8787Schithrag 5240a8c8787Schithrag 5250a8c8787SchithragGet Current Date from BMC 5260a8c8787Schithrag [Documentation] Runs the date command from BMC and returns current date and time 5270a8c8787Schithrag 5280a8c8787Schithrag # Get Current Date from BMC 5290a8c8787Schithrag ${date} ${stderr} ${rc}= BMC Execute Command date 5300a8c8787Schithrag 5310a8c8787Schithrag # Split the string and remove first and 2nd last value from the list and join to form %d %b %H:%M:%S %Y date format 5320a8c8787Schithrag ${date}= Split String ${date} 5330a8c8787Schithrag Remove From List ${date} 0 5340a8c8787Schithrag Remove From List ${date} -2 5350a8c8787Schithrag ${date}= Evaluate " ".join(${date}) 5360a8c8787Schithrag 5370a8c8787Schithrag # Convert the date format to %m/%d/%Y %H:%M:%S 5380a8c8787Schithrag ${date}= Convert Date ${date} date_format=%b %d %H:%M:%S %Y result_format=%m/%d/%Y %H:%M:%S exclude_millis=True 5390a8c8787Schithrag 5400a8c8787Schithrag [Return] ${date} 541*d7e009b6Schithrag 542*d7e009b6Schithrag 543*d7e009b6SchithragGet SEL Info Via IPMI 544*d7e009b6Schithrag [Documentation] Get the SEL Info via IPMI raw command 545*d7e009b6Schithrag 546*d7e009b6Schithrag # Get SEL Info response consist of 14 bytes of hexadecimal data. 547*d7e009b6Schithrag 548*d7e009b6Schithrag # Byte 1 - SEL Version, 549*d7e009b6Schithrag # Byte 2 & 3 - Entry bytes - LSB MSB, 550*d7e009b6Schithrag # Byte 4 & 5 - Free Space in bytes, LS Byte first. 551*d7e009b6Schithrag # Byte 6 - 9 - Most recent addition timestamp, 552*d7e009b6Schithrag # Byte 10-13 - Most recent erase timestamp, 553*d7e009b6Schithrag # Byte 14 - Operation Support 554*d7e009b6Schithrag 555*d7e009b6Schithrag # Example: ${resp} will be "51 XX XX XX XX ff ff ff ff ff ff ff ff XX" 556*d7e009b6Schithrag 557*d7e009b6Schithrag ${resp}= Run IPMI Standard Command 558*d7e009b6Schithrag ... raw ${IPMI_RAW_CMD['SEL_entry']['SEL_info'][0]} 559*d7e009b6Schithrag ${resp}= Split String ${resp} 560*d7e009b6Schithrag 561*d7e009b6Schithrag [Return] ${resp} 562