xref: /openbmc/openbmc-test-automation/lib/ipmi_client.robot (revision 839a0c27645bbf73fcbafb4e2e6eaf1ed1df5d4a)
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
5*839a0c27SSandhya 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
1119621bacSMichael WalshLibrary         ipmi_client.py
12a2dab3c8SSivas SRR
13a2dab3c8SSivas SRR*** Variables ***
14d7f11f70SGeorge Keishing${dbusHostIpmicmd1}=   dbus-send --system  ${OPENBMC_BASE_URI}HostIpmi/1
15d7f11f70SGeorge Keishing${dbusHostIpmiCmdReceivedMsg}=   ${OPENBMC_BASE_DBUS}.HostIpmi.ReceivedMessage
16a2dab3c8SSivas SRR${netfnByte}=          ${EMPTY}
17a2dab3c8SSivas SRR${cmdByte}=            ${EMPTY}
18a2dab3c8SSivas SRR${arrayByte}=          array:byte:
19a7913898SMichael Walsh${IPMI_USER_OPTIONS}   ${EMPTY}
2039967ebcSGeorge Keishing${IPMI_INBAND_CMD}=    ipmitool -C ${IPMI_CIPHER_LEVEL}
217a212a09SRahul Maheshwari${HOST}=               -H
227a212a09SRahul Maheshwari${RAW}=                raw
23b29d2e84SChris Austen
24b29d2e84SChris Austen*** Keywords ***
257a212a09SRahul Maheshwari
26b29d2e84SChris AustenRun IPMI Command
273ef2e92cSMichael Walsh    [Documentation]  Run the raw IPMI command.
283ef2e92cSMichael Walsh    [Arguments]  ${command}  ${fail_on_err}=${1}  &{options}
293ef2e92cSMichael Walsh
303ef2e92cSMichael Walsh    # Description of argument(s):
313ef2e92cSMichael Walsh    # command                       The IPMI command string to be executed
323ef2e92cSMichael Walsh    #                               (e.g. "power status").
333ef2e92cSMichael Walsh    # fail_on_err                   Fail if the IPMI command execution fails.
343ef2e92cSMichael Walsh    # options                       Additional ipmitool command options (e.g.
353ef2e92cSMichael Walsh    #                               -C=3, -I=lanplus, etc.).  Currently, only
363ef2e92cSMichael Walsh    #                               used for external IPMI commands.
373ef2e92cSMichael Walsh
387a212a09SRahul Maheshwari    ${resp}=  Run Keyword If  '${IPMI_COMMAND}' == 'External'
393ef2e92cSMichael Walsh    ...    Run External IPMI Raw Command  ${command}  ${fail_on_err}  &{options}
40ae7c2281SPrashanth Katti    ...  ELSE IF  '${IPMI_COMMAND}' == 'Inband'
413ef2e92cSMichael Walsh    ...    Run Inband IPMI Raw Command  ${command}
427a212a09SRahul Maheshwari    ...  ELSE IF  '${IPMI_COMMAND}' == 'Dbus'
433ef2e92cSMichael Walsh    ...    Run Dbus IPMI RAW Command  ${command}
44ae7c2281SPrashanth Katti    ...  ELSE  Fail  msg=Invalid IPMI Command type provided: ${IPMI_COMMAND}
45c9ea9368SGunnar Mills    [Return]  ${resp}
467a212a09SRahul Maheshwari
473ef2e92cSMichael Walsh
487a212a09SRahul MaheshwariRun IPMI Standard Command
49f4a807bfSJoy Onyerikwu    [Documentation]  Run the standard IPMI command.
503ef2e92cSMichael Walsh    [Arguments]  ${command}  ${fail_on_err}=${1}  &{options}
5120f3bf73SRahul Maheshwari
5220f3bf73SRahul Maheshwari    # Description of argument(s):
533ef2e92cSMichael Walsh    # command                       The IPMI command string to be executed
543ef2e92cSMichael Walsh    #                               (e.g. "0x06 0x36").
553ef2e92cSMichael Walsh    # fail_on_err                   Fail if the IPMI command execution fails.
563ef2e92cSMichael Walsh    # options                       Additional ipmitool command options (e.g.
573ef2e92cSMichael Walsh    #                               -C=3, -I=lanplus, etc.).  Currently, only
583ef2e92cSMichael Walsh    #                               used for external IPMI commands.
5920f3bf73SRahul Maheshwari
607a212a09SRahul Maheshwari    ${resp}=  Run Keyword If  '${IPMI_COMMAND}' == 'External'
613ef2e92cSMichael Walsh    ...    Run External IPMI Standard Command  ${command}  ${fail_on_err}  &{options}
62ae7c2281SPrashanth Katti    ...  ELSE IF  '${IPMI_COMMAND}' == 'Inband'
633ef2e92cSMichael Walsh    ...    Run Inband IPMI Standard Command  ${command}  ${fail_on_err}
647a212a09SRahul Maheshwari    ...  ELSE IF  '${IPMI_COMMAND}' == 'Dbus'
653ef2e92cSMichael Walsh    ...    Run Dbus IPMI Standard Command  ${command}
66ae7c2281SPrashanth Katti    ...  ELSE  Fail  msg=Invalid IPMI Command type provided : ${IPMI_COMMAND}
677a212a09SRahul Maheshwari
68c9ea9368SGunnar Mills    [Return]  ${resp}
697a212a09SRahul Maheshwari
703ef2e92cSMichael Walsh
717a212a09SRahul MaheshwariRun Dbus IPMI RAW Command
72f4a807bfSJoy Onyerikwu    [Documentation]  Run the raw IPMI command through dbus.
733ef2e92cSMichael Walsh    [Arguments]    ${command}
743ef2e92cSMichael Walsh    ${valueinBytes}=   Byte Conversion  ${command}
75a2dab3c8SSivas SRR    ${cmd}=   Catenate   ${dbushostipmicmd1} ${dbusHostIpmiCmdReceivedMsg}
76a2dab3c8SSivas SRR    ${cmd}=   Catenate   ${cmd} ${valueinBytes}
77a2dab3c8SSivas SRR    ${output}   ${stderr}=  Execute Command  ${cmd}  return_stderr=True
78b29d2e84SChris Austen    Should Be Empty      ${stderr}
79b29d2e84SChris Austen    set test variable    ${OUTPUT}     "${output}"
80b29d2e84SChris Austen
813ef2e92cSMichael Walsh
827a212a09SRahul MaheshwariRun Dbus IPMI Standard Command
83f4a807bfSJoy Onyerikwu    [Documentation]  Run the standard IPMI command through dbus.
843ef2e92cSMichael Walsh    [Arguments]    ${command}
854d6c1dabSGeorge Keishing    Copy ipmitool
867a212a09SRahul Maheshwari    ${stdout}    ${stderr}    ${output}=  Execute Command
873ef2e92cSMichael Walsh    ...    /tmp/ipmitool -I dbus ${command}    return_stdout=True
887a212a09SRahul Maheshwari    ...    return_stderr= True    return_rc=True
89b29d2e84SChris Austen    Should Be Equal    ${output}    ${0}    msg=${stderr}
90c9ea9368SGunnar Mills    [Return]    ${stdout}
91b29d2e84SChris Austen
923ef2e92cSMichael Walsh
93ae7c2281SPrashanth KattiRun Inband IPMI Raw Command
94f4a807bfSJoy Onyerikwu    [Documentation]  Run the raw IPMI command in-band.
953ef2e92cSMichael Walsh    [Arguments]  ${command}  ${os_host}=${OS_HOST}  ${os_username}=${OS_USERNAME}
96ae7c2281SPrashanth Katti    ...          ${os_password}=${OS_PASSWORD}
97ae7c2281SPrashanth Katti
983ef2e92cSMichael Walsh    # Description of argument(s):
993ef2e92cSMichael Walsh    # command                       The IPMI command string to be executed
1003ef2e92cSMichael Walsh    #                               (e.g. "0x06 0x36").
1013ef2e92cSMichael Walsh    # os_host                       The host name or IP address of the OS Host.
1023ef2e92cSMichael Walsh    # os_username                   The OS host user name.
1033ef2e92cSMichael Walsh    # os_password                   The OS host passwrd.
104ae7c2281SPrashanth Katti
105ae7c2281SPrashanth Katti    Login To OS Host  ${os_host}  ${os_username}  ${os_password}
106ae7c2281SPrashanth Katti    Check If IPMI Tool Exist
107ae7c2281SPrashanth Katti
1083ef2e92cSMichael Walsh    ${ipmi_cmd}=  Catenate  ${IPMI_INBAND_CMD}  ${RAW}  ${command}
1093ef2e92cSMichael Walsh    Qprint Issuing  ${ipmi_cmd}
1103ef2e92cSMichael Walsh    ${stdout}  ${stderr}=  Execute Command  ${ipmi_cmd}  return_stderr=True
111ae7c2281SPrashanth Katti    Should Be Empty  ${stderr}  msg=${stdout}
112ae7c2281SPrashanth Katti    [Return]  ${stdout}
113ae7c2281SPrashanth Katti
1143ef2e92cSMichael Walsh
115ae7c2281SPrashanth KattiRun Inband IPMI Standard Command
116f4a807bfSJoy Onyerikwu    [Documentation]  Run the standard IPMI command in-band.
1173ef2e92cSMichael Walsh    [Arguments]  ${command}  ${fail_on_err}=${1}  ${os_host}=${OS_HOST}
11820f3bf73SRahul Maheshwari    ...          ${os_username}=${OS_USERNAME}  ${os_password}=${OS_PASSWORD}
119ae7c2281SPrashanth Katti
1203ef2e92cSMichael Walsh    # Description of argument(s):
1213ef2e92cSMichael Walsh    # command                       The IPMI command string to be executed
1223ef2e92cSMichael Walsh    #                               (e.g. "power status").
1233ef2e92cSMichael Walsh    # os_host                       The host name or IP address of the OS Host.
1243ef2e92cSMichael Walsh    # os_username                   The OS host user name.
1253ef2e92cSMichael Walsh    # os_password                   The OS host passwrd.
126ae7c2281SPrashanth Katti
127ae7c2281SPrashanth Katti    Login To OS Host  ${os_host}  ${os_username}  ${os_password}
128ae7c2281SPrashanth Katti    Check If IPMI Tool Exist
129ae7c2281SPrashanth Katti
1303ef2e92cSMichael Walsh    ${ipmi_cmd}=  Catenate  ${IPMI_INBAND_CMD}  ${command}
1313ef2e92cSMichael Walsh    Qprint Issuing  ${ipmi_cmd}
1323ef2e92cSMichael Walsh    ${stdout}  ${stderr}=  Execute Command  ${ipmi_cmd}  return_stderr=True
13320f3bf73SRahul Maheshwari    Return From Keyword If  ${fail_on_err} == ${0}  ${stderr}
134ae7c2281SPrashanth Katti    Should Be Empty  ${stderr}  msg=${stdout}
135ae7c2281SPrashanth Katti    [Return]  ${stdout}
136ae7c2281SPrashanth Katti
1377a212a09SRahul Maheshwari
1387a212a09SRahul MaheshwariRun External IPMI Standard Command
1393ef2e92cSMichael Walsh    [Documentation]  Run the external IPMI standard command.
1403ef2e92cSMichael Walsh    [Arguments]  ${command}  ${fail_on_err}=${1}  &{options}
14102651f0cSGeorge Keishing
14202651f0cSGeorge Keishing    # Description of argument(s):
1433ef2e92cSMichael Walsh    # command                       The IPMI command string to be executed
1443ef2e92cSMichael Walsh    #                               (e.g. "power status").  Note that if
1453ef2e92cSMichael Walsh    #                               ${IPMI_USER_OPTIONS} has a value (e.g.
1463ef2e92cSMichael Walsh    #                               "-vvv"), it will be pre-pended to this
1473ef2e92cSMichael Walsh    #                               command string.
1483ef2e92cSMichael Walsh    # fail_on_err                   Fail if the IPMI command execution fails.
1493ef2e92cSMichael Walsh    # options                       Additional ipmitool command options (e.g.
1503ef2e92cSMichael Walsh    #                               -C=3, -I=lanplus, etc.).
151a7913898SMichael Walsh
1523ef2e92cSMichael Walsh    ${command_string}=  Process IPMI User Options  ${command}
1533ef2e92cSMichael Walsh    ${ipmi_cmd}=  Create IPMI Ext Command String  ${command_string}  &{options}
1543ef2e92cSMichael Walsh    Qprint Issuing  ${ipmi_cmd}
15504a2204bSRahul Maheshwari    ${rc}  ${output}=  Run And Return RC and Output  ${ipmi_cmd}
15602651f0cSGeorge Keishing    Return From Keyword If  ${fail_on_err} == ${0}  ${output}
1577a212a09SRahul Maheshwari    Should Be Equal  ${rc}  ${0}  msg=${output}
158c9ea9368SGunnar Mills    [Return]  ${output}
1597a212a09SRahul Maheshwari
1603ef2e92cSMichael Walsh
1613ef2e92cSMichael WalshRun External IPMI Raw Command
1623ef2e92cSMichael Walsh    [Documentation]  Run the external IPMI raw command.
1633ef2e92cSMichael Walsh    [Arguments]  ${command}  ${fail_on_err}=${1}  &{options}
1643ef2e92cSMichael Walsh
1653ef2e92cSMichael Walsh    # This keyword is a wrapper for 'Run External IPMI Standard Command'. See
1663ef2e92cSMichael Walsh    # that keyword's prolog for argument details.  This keyword will pre-pend
1673ef2e92cSMichael Walsh    # the word "raw" plus a space to command prior to calling 'Run External
1683ef2e92cSMichael Walsh    # IPMI Standard Command'.
1693ef2e92cSMichael Walsh
1703ef2e92cSMichael Walsh    ${output}=  Run External IPMI Standard Command
1713ef2e92cSMichael Walsh    ...  raw ${command}  ${fail_on_err}  &{options}
1723ef2e92cSMichael Walsh    [Return]  ${output}
1733ef2e92cSMichael Walsh
1743ef2e92cSMichael Walsh
175ae7c2281SPrashanth KattiCheck If IPMI Tool Exist
176ae7c2281SPrashanth Katti    [Documentation]  Check if IPMI Tool installed or not.
177ae7c2281SPrashanth Katti    ${output}=  Execute Command  which ipmitool
178ae7c2281SPrashanth Katti    Should Not Be Empty  ${output}  msg=ipmitool not installed.
1797a212a09SRahul Maheshwari
18004a2204bSRahul Maheshwari
18104a2204bSRahul MaheshwariActivate SOL Via IPMI
18204a2204bSRahul Maheshwari    [Documentation]  Start SOL using IPMI and route output to a file.
18304a2204bSRahul Maheshwari    [Arguments]  ${file_path}=/tmp/sol_${OPENBMC_HOST}
1843ef2e92cSMichael Walsh
18504a2204bSRahul Maheshwari    # Description of argument(s):
1863ef2e92cSMichael Walsh    # file_path                     The file path on the local machine (vs.
1873ef2e92cSMichael Walsh    #                               OBMC) to collect SOL output. By default
1883ef2e92cSMichael Walsh    #                               SOL output is collected at
18904a2204bSRahul Maheshwari    #                               /tmp/sol_<BMC_IP> else user input location.
19004a2204bSRahul Maheshwari
1913ef2e92cSMichael Walsh    ${ipmi_cmd}=  Create IPMI Ext Command String  sol activate usesolkeepalive
1923ef2e92cSMichael Walsh    Qprint Issuing  ${ipmi_cmd}
1932102f6bfSGeorge Keishing    Start Process  ${ipmi_cmd}  shell=True  stdout=${file_path}
1944f360843SRahul Maheshwari    ...  alias=sol_proc
19504a2204bSRahul Maheshwari
19604a2204bSRahul Maheshwari
19704a2204bSRahul MaheshwariDeactivate SOL Via IPMI
19804a2204bSRahul Maheshwari    [Documentation]  Stop SOL using IPMI and return SOL output.
19904a2204bSRahul Maheshwari    [Arguments]  ${file_path}=/tmp/sol_${OPENBMC_HOST}
2003ef2e92cSMichael Walsh
20104a2204bSRahul Maheshwari    # Description of argument(s):
2023ef2e92cSMichael Walsh    # file_path                     The file path on the local machine to copy
2033ef2e92cSMichael Walsh    #                               SOL output collected by above "Activate
2043ef2e92cSMichael Walsh    #                               SOL Via IPMI" keyword.  By default it
2053ef2e92cSMichael Walsh    #                               copies log from /tmp/sol_<BMC_IP>.
20604a2204bSRahul Maheshwari
2073ef2e92cSMichael Walsh    ${ipmi_cmd}=  Create IPMI Ext Command String  sol deactivate
2083ef2e92cSMichael Walsh    Qprint Issuing  ${ipmi_cmd}
20904a2204bSRahul Maheshwari    ${rc}  ${output}=  Run and Return RC and Output  ${ipmi_cmd}
2104f360843SRahul Maheshwari    Run Keyword If  ${rc} > 0  Run Keywords
2117f48a2c6SRahul Maheshwari    ...  Run Keyword And Ignore Error  Terminate Process  sol_proc
2127f48a2c6SRahul Maheshwari    ...  AND  Return From Keyword  ${output}
21304a2204bSRahul Maheshwari
21404a2204bSRahul Maheshwari    ${rc}  ${output}=  Run and Return RC and Output  cat ${file_path}
21504a2204bSRahul Maheshwari    Should Be Equal  ${rc}  ${0}  msg=${output}
21604a2204bSRahul Maheshwari
21704a2204bSRahul Maheshwari    # Logging SOL output for debug purpose.
21804a2204bSRahul Maheshwari    Log  ${output}
21904a2204bSRahul Maheshwari
22004a2204bSRahul Maheshwari    [Return]  ${output}
22104a2204bSRahul Maheshwari
22204a2204bSRahul Maheshwari
223a2dab3c8SSivas SRRByte Conversion
224a2dab3c8SSivas SRR    [Documentation]   Byte Conversion method receives IPMI RAW commands as
225a2dab3c8SSivas SRR    ...               argument in string format.
226a2dab3c8SSivas SRR    ...               Sample argument is as follows
227a2dab3c8SSivas SRR    ...               "0x04 0x30 9 0x01 0x00 0x35 0x00 0x00 0x00 0x00 0x00
228a2dab3c8SSivas SRR    ...               0x00"
229a2dab3c8SSivas SRR    ...               IPMI RAW command format is as follows
230a2dab3c8SSivas SRR    ...               <netfn Byte> <cmd Byte> <Data Bytes..>
231a2dab3c8SSivas SRR    ...               This method converts IPMI command format into
232a2dab3c8SSivas SRR    ...               dbus command format  as follows
233a2dab3c8SSivas SRR    ...               <byte:seq-id> <byte:netfn> <byte:lun> <byte:cmd>
234a2dab3c8SSivas SRR    ...               <array:byte:data>
235a2dab3c8SSivas SRR    ...               Sample dbus  Host IPMI Received Message argument
236a2dab3c8SSivas SRR    ...               byte:0x00 byte:0x04 byte:0x00 byte:0x30
237a2dab3c8SSivas SRR    ...               array:byte:9,0x01,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00
23838032805SGunnar Mills    [Arguments]     ${args}
239a2dab3c8SSivas SRR    ${argLength}=   Get Length  ${args}
240a2dab3c8SSivas SRR    Set Global Variable  ${arrayByte}   array:byte:
241a2dab3c8SSivas SRR    @{listargs}=   Split String  ${args}
242a2dab3c8SSivas SRR    ${index}=   Set Variable   ${0}
2439a08944dSGeorge Keishing    :FOR  ${word}  IN  @{listargs}
244a2dab3c8SSivas SRR    \    Run Keyword if   ${index} == 0   Set NetFn Byte  ${word}
245a2dab3c8SSivas SRR    \    Run Keyword if   ${index} == 1   Set Cmd Byte    ${word}
246a2dab3c8SSivas SRR    \    Run Keyword if   ${index} > 1    Set Array Byte  ${word}
247a2dab3c8SSivas SRR    \    ${index}=    Set Variable    ${index + 1}
248a2dab3c8SSivas SRR    ${length}=   Get Length  ${arrayByte}
249a2dab3c8SSivas SRR    ${length}=   Evaluate  ${length} - 1
250a2dab3c8SSivas SRR    ${arrayByteLocal}=  Get Substring  ${arrayByte}  0   ${length}
251a2dab3c8SSivas SRR    Set Global Variable  ${arrayByte}   ${arrayByteLocal}
252a2dab3c8SSivas SRR    ${valueinBytesWithArray}=   Catenate  byte:0x00   ${netfnByte}  byte:0x00
253a2dab3c8SSivas SRR    ${valueinBytesWithArray}=   Catenate  ${valueinBytesWithArray}  ${cmdByte}
254a2dab3c8SSivas SRR    ${valueinBytesWithArray}=   Catenate  ${valueinBytesWithArray} ${arrayByte}
255a2dab3c8SSivas SRR    ${valueinBytesWithoutArray}=   Catenate  byte:0x00 ${netfnByte}  byte:0x00
256a2dab3c8SSivas SRR    ${valueinBytesWithoutArray}=   Catenate  ${valueinBytesWithoutArray} ${cmdByte}
257a2dab3c8SSivas SRR    #   To Check scenario for smaller IPMI raw commands with only 2 arguments
258a2dab3c8SSivas SRR    #   instead of usual 12 arguments.
259a2dab3c8SSivas SRR    #   Sample small IPMI raw command: Run IPMI command 0x06 0x36
260a2dab3c8SSivas SRR    #   If IPMI raw argument length is only 9 then return value in bytes without
261a2dab3c8SSivas SRR    #   array population.
262a2dab3c8SSivas SRR    #   Equivalent dbus-send argument for smaller IPMI raw command:
263a2dab3c8SSivas SRR    #   byte:0x00 byte:0x06 byte:0x00 byte:0x36
264a2dab3c8SSivas SRR    Run Keyword if   ${argLength} == 9     Return from Keyword    ${valueinBytesWithoutArray}
265c9ea9368SGunnar Mills    [Return]    ${valueinBytesWithArray}
266a2dab3c8SSivas SRR
267a2dab3c8SSivas SRR
268a2dab3c8SSivas SRRSet NetFn Byte
269f4a807bfSJoy Onyerikwu    [Documentation]  Set the network function byte.
27038032805SGunnar Mills    [Arguments]    ${word}
271a2dab3c8SSivas SRR    ${netfnByteLocal}=  Catenate   byte:${word}
272a2dab3c8SSivas SRR    Set Global Variable  ${netfnByte}  ${netfnByteLocal}
273a2dab3c8SSivas SRR
2743ef2e92cSMichael Walsh
275a2dab3c8SSivas SRRSet Cmd Byte
276f4a807bfSJoy Onyerikwu    [Documentation]  Set the command byte.
27738032805SGunnar Mills    [Arguments]    ${word}
278a2dab3c8SSivas SRR    ${cmdByteLocal}=  Catenate   byte:${word}
279a2dab3c8SSivas SRR    Set Global Variable  ${cmdByte}  ${cmdByteLocal}
280a2dab3c8SSivas SRR
2813ef2e92cSMichael Walsh
282a2dab3c8SSivas SRRSet Array Byte
283f4a807bfSJoy Onyerikwu    [Documentation]  Set the array byte.
28438032805SGunnar Mills    [Arguments]    ${word}
285a2dab3c8SSivas SRR    ${arrayByteLocal}=   Catenate   SEPARATOR=  ${arrayByte}  ${word}
286a2dab3c8SSivas SRR    ${arrayByteLocal}=   Catenate   SEPARATOR=  ${arrayByteLocal}   ,
287a2dab3c8SSivas SRR    Set Global Variable  ${arrayByte}   ${arrayByteLocal}
288a2dab3c8SSivas SRR
2893ef2e92cSMichael Walsh
290b29d2e84SChris AustenCopy ipmitool
291f4a807bfSJoy Onyerikwu    [Documentation]  Copy the ipmitool to the BMC.
292f4a807bfSJoy Onyerikwu    ${ipmitool_error}=  Catenate  The ipmitool program could not be found in the tools directory.
293f4a807bfSJoy Onyerikwu    ...  It is not part of the automation code by default. You must manually copy or link the correct openbmc
294f4a807bfSJoy Onyerikwu    ...  version of the tool in to the tools directory in order to run this test suite.
295f4a807bfSJoy Onyerikwu
296f4a807bfSJoy Onyerikwu    OperatingSystem.File Should Exist  tools/ipmitool  msg=${ipmitool_error}
297b29d2e84SChris Austen
298b29d2e84SChris Austen    Import Library      SCPLibrary      WITH NAME       scp
299b29d2e84SChris Austen    scp.Open connection     ${OPENBMC_HOST}     username=${OPENBMC_USERNAME}      password=${OPENBMC_PASSWORD}
300b29d2e84SChris Austen    scp.Put File    tools/ipmitool   /tmp
301b29d2e84SChris Austen    SSHLibrary.Open Connection     ${OPENBMC_HOST}
302b29d2e84SChris Austen    Login   ${OPENBMC_USERNAME}    ${OPENBMC_PASSWORD}
303b29d2e84SChris Austen    Execute Command     chmod +x /tmp/ipmitool
3040c34f69cSSridevi Ramesh
3053ef2e92cSMichael Walsh
3060c34f69cSSridevi RameshInitiate Host Boot Via External IPMI
3070c34f69cSSridevi Ramesh    [Documentation]  Initiate host power on using external IPMI.
308982fee42SRahul Maheshwari    [Arguments]  ${wait}=${1}
3093ef2e92cSMichael Walsh
310982fee42SRahul Maheshwari    # Description of argument(s):
3113ef2e92cSMichael Walsh    # wait                          Indicates that this keyword should wait
3123ef2e92cSMichael Walsh    #                               for host running state.
313982fee42SRahul Maheshwari
3140c34f69cSSridevi Ramesh    ${output}=  Run External IPMI Standard Command  chassis power on
3150c34f69cSSridevi Ramesh    Should Not Contain  ${output}  Error
316982fee42SRahul Maheshwari
317982fee42SRahul Maheshwari    Run Keyword If  '${wait}' == '${0}'  Return From Keyword
318982fee42SRahul Maheshwari    Wait Until Keyword Succeeds  10 min  10 sec  Is Host Running
3190c34f69cSSridevi Ramesh
3203ef2e92cSMichael Walsh
3210c34f69cSSridevi RameshInitiate Host PowerOff Via External IPMI
3220c34f69cSSridevi Ramesh    [Documentation]  Initiate host power off using external IPMI.
323982fee42SRahul Maheshwari    [Arguments]  ${wait}=${1}
3243ef2e92cSMichael Walsh
325982fee42SRahul Maheshwari    # Description of argument(s):
3263ef2e92cSMichael Walsh    # wait                          Indicates that this keyword should wait
3273ef2e92cSMichael Walsh    #                               for host off state.
328982fee42SRahul Maheshwari
3290c34f69cSSridevi Ramesh    ${output}=  Run External IPMI Standard Command  chassis power off
3300c34f69cSSridevi Ramesh    Should Not Contain  ${output}  Error
331982fee42SRahul Maheshwari
332982fee42SRahul Maheshwari    Run Keyword If  '${wait}' == '${0}'  Return From Keyword
333982fee42SRahul Maheshwari    Wait Until Keyword Succeeds  3 min  10 sec  Is Host Off
334982fee42SRahul Maheshwari
3353ef2e92cSMichael Walsh
336982fee42SRahul MaheshwariGet Host State Via External IPMI
337982fee42SRahul Maheshwari    [Documentation]  Returns host state using external IPMI.
338982fee42SRahul Maheshwari
339982fee42SRahul Maheshwari    ${output}=  Run External IPMI Standard Command  chassis power status
340982fee42SRahul Maheshwari    Should Not Contain  ${output}  Error
341982fee42SRahul Maheshwari    ${output}=  Fetch From Right  ${output}  ${SPACE}
342982fee42SRahul Maheshwari
343982fee42SRahul Maheshwari    [Return]  ${output}
344b4d4a4aeSGeorge Keishing
345b4d4a4aeSGeorge Keishing
346b4d4a4aeSGeorge KeishingSet BMC Network From Host
347b4d4a4aeSGeorge Keishing    [Documentation]  Set BMC network from host.
348b4d4a4aeSGeorge Keishing    [Arguments]  ${nw_info}
349b4d4a4aeSGeorge Keishing
350b4d4a4aeSGeorge Keishing    # Description of argument(s):
3513ef2e92cSMichael Walsh    # nw_info                       A dictionary containing the network
3523ef2e92cSMichael Walsh    #                               information to apply.
353b4d4a4aeSGeorge Keishing
354b4d4a4aeSGeorge Keishing    Run Inband IPMI Standard Command
355b4d4a4aeSGeorge Keishing    ...  lan set 1 ipaddr ${nw_info['IP Address']}
356b4d4a4aeSGeorge Keishing
357b4d4a4aeSGeorge Keishing    Run Inband IPMI Standard Command
358b4d4a4aeSGeorge Keishing    ...  lan set 1 netmask ${nw_info['Subnet Mask']}
359b4d4a4aeSGeorge Keishing
360b4d4a4aeSGeorge Keishing    Run Inband IPMI Standard Command
361b4d4a4aeSGeorge Keishing    ...  lan set 1 defgw ipaddr ${nw_info['Default Gateway IP']}
362