xref: /openbmc/openbmc-test-automation/lib/ipmi_client.robot (revision 20f3bf739b0ab1818813eb895739ce06265fcb87)
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
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:
1919621bacSMichael Walsh${IPMI_EXT_CMD}        ${EMPTY}
20a7913898SMichael Walsh${IPMI_USER_OPTIONS}   ${EMPTY}
2139967ebcSGeorge Keishing${IPMI_INBAND_CMD}=    ipmitool -C ${IPMI_CIPHER_LEVEL}
227a212a09SRahul Maheshwari${HOST}=               -H
237a212a09SRahul Maheshwari${RAW}=                raw
24b29d2e84SChris Austen
25b29d2e84SChris Austen*** Keywords ***
267a212a09SRahul Maheshwari
27b29d2e84SChris AustenRun IPMI Command
28f4a807bfSJoy Onyerikwu    [Documentation]  Run the given IPMI command.
2938032805SGunnar Mills    [Arguments]  ${args}
307a212a09SRahul Maheshwari    ${resp}=  Run Keyword If  '${IPMI_COMMAND}' == 'External'
31b4d4a4aeSGeorge Keishing    ...  Run External IPMI Raw Command  ${args}
32ae7c2281SPrashanth Katti    ...  ELSE IF  '${IPMI_COMMAND}' == 'Inband'
33b4d4a4aeSGeorge Keishing    ...  Run Inband IPMI Raw Command  ${args}
347a212a09SRahul Maheshwari    ...  ELSE IF  '${IPMI_COMMAND}' == 'Dbus'
357a212a09SRahul Maheshwari    ...  Run Dbus IPMI RAW Command  ${args}
36ae7c2281SPrashanth Katti    ...  ELSE  Fail  msg=Invalid IPMI Command type provided : ${IPMI_COMMAND}
37c9ea9368SGunnar Mills    [Return]  ${resp}
387a212a09SRahul Maheshwari
397a212a09SRahul MaheshwariRun IPMI Standard Command
40f4a807bfSJoy Onyerikwu    [Documentation]  Run the standard IPMI command.
41*20f3bf73SRahul Maheshwari    [Arguments]  ${args}  ${fail_on_err}=${1}
42*20f3bf73SRahul Maheshwari
43*20f3bf73SRahul Maheshwari    # Description of argument(s):
44*20f3bf73SRahul Maheshwari    # args         IPMI command to be executed.
45*20f3bf73SRahul Maheshwari    # fail_on_err  Fail if keyword the IPMI command fails
46*20f3bf73SRahul Maheshwari
477a212a09SRahul Maheshwari    ${resp}=  Run Keyword If  '${IPMI_COMMAND}' == 'External'
48*20f3bf73SRahul Maheshwari    ...  Run External IPMI Standard Command  ${args}  ${fail_on_err}
49ae7c2281SPrashanth Katti    ...  ELSE IF  '${IPMI_COMMAND}' == 'Inband'
50*20f3bf73SRahul Maheshwari    ...  Run Inband IPMI Standard Command  ${args}  ${fail_on_err}
517a212a09SRahul Maheshwari    ...  ELSE IF  '${IPMI_COMMAND}' == 'Dbus'
527a212a09SRahul Maheshwari    ...  Run Dbus IPMI Standard Command  ${args}
53ae7c2281SPrashanth Katti    ...  ELSE  Fail  msg=Invalid IPMI Command type provided : ${IPMI_COMMAND}
547a212a09SRahul Maheshwari
55c9ea9368SGunnar Mills    [Return]  ${resp}
567a212a09SRahul Maheshwari
577a212a09SRahul MaheshwariRun Dbus IPMI RAW Command
58f4a807bfSJoy Onyerikwu    [Documentation]  Run the raw IPMI command through dbus.
5938032805SGunnar Mills    [Arguments]    ${args}
60a2dab3c8SSivas SRR    ${valueinBytes}=   Byte Conversion  ${args}
61a2dab3c8SSivas SRR    ${cmd}=   Catenate   ${dbushostipmicmd1} ${dbusHostIpmiCmdReceivedMsg}
62a2dab3c8SSivas SRR    ${cmd}=   Catenate   ${cmd} ${valueinBytes}
63a2dab3c8SSivas SRR    ${output}   ${stderr}=  Execute Command  ${cmd}  return_stderr=True
64b29d2e84SChris Austen    Should Be Empty      ${stderr}
65b29d2e84SChris Austen    set test variable    ${OUTPUT}     "${output}"
66b29d2e84SChris Austen
677a212a09SRahul MaheshwariRun Dbus IPMI Standard Command
68f4a807bfSJoy Onyerikwu    [Documentation]  Run the standard IPMI command through dbus.
6938032805SGunnar Mills    [Arguments]    ${args}
704d6c1dabSGeorge Keishing    Copy ipmitool
717a212a09SRahul Maheshwari    ${stdout}    ${stderr}    ${output}=  Execute Command
727a212a09SRahul Maheshwari    ...    /tmp/ipmitool -I dbus ${args}    return_stdout=True
737a212a09SRahul Maheshwari    ...    return_stderr= True    return_rc=True
74b29d2e84SChris Austen    Should Be Equal    ${output}    ${0}    msg=${stderr}
75c9ea9368SGunnar Mills    [Return]    ${stdout}
76b29d2e84SChris Austen
77ae7c2281SPrashanth KattiRun Inband IPMI Raw Command
78f4a807bfSJoy Onyerikwu    [Documentation]  Run the raw IPMI command in-band.
79ae7c2281SPrashanth Katti    [Arguments]  ${args}  ${os_host}=${OS_HOST}  ${os_username}=${OS_USERNAME}
80ae7c2281SPrashanth Katti    ...          ${os_password}=${OS_PASSWORD}
81ae7c2281SPrashanth Katti
8228e403b8SGunnar Mills    # Description of arguments:
83ae7c2281SPrashanth Katti    # ${args}  parameters to IPMI command.
84ae7c2281SPrashanth Katti    # ${os_host} IP address of the OS Host.
85ae7c2281SPrashanth Katti    # ${os_username}  OS Host Login user name.
86ae7c2281SPrashanth Katti    # ${os_password}  OS Host Login passwrd.
87ae7c2281SPrashanth Katti
88ae7c2281SPrashanth Katti    Login To OS Host  ${os_host}  ${os_username}  ${os_password}
89ae7c2281SPrashanth Katti    Check If IPMI Tool Exist
90ae7c2281SPrashanth Katti
91ae7c2281SPrashanth Katti    ${inband_raw_cmd}=  Catenate  ${IPMI_INBAND_CMD}  ${RAW}  ${args}
92ae7c2281SPrashanth Katti    ${stdout}  ${stderr}=  Execute Command  ${inband_raw_cmd}  return_stderr=True
93ae7c2281SPrashanth Katti    Should Be Empty  ${stderr}  msg=${stdout}
94ae7c2281SPrashanth Katti    [Return]  ${stdout}
95ae7c2281SPrashanth Katti
96ae7c2281SPrashanth KattiRun Inband IPMI Standard Command
97f4a807bfSJoy Onyerikwu    [Documentation]  Run the standard IPMI command in-band.
98*20f3bf73SRahul Maheshwari    [Arguments]  ${args}  ${fail_on_err}=${1}  ${os_host}=${OS_HOST}
99*20f3bf73SRahul Maheshwari    ...          ${os_username}=${OS_USERNAME}  ${os_password}=${OS_PASSWORD}
100ae7c2281SPrashanth Katti
10128e403b8SGunnar Mills    # Description of arguments:
102ae7c2281SPrashanth Katti    # ${args}  parameters to IPMI command.
103ae7c2281SPrashanth Katti    # ${os_host} IP address of the OS Host.
104ae7c2281SPrashanth Katti    # ${os_username}  OS Host Login user name.
105ae7c2281SPrashanth Katti    # ${os_password}  OS Host Login passwrd.
106ae7c2281SPrashanth Katti
107ae7c2281SPrashanth Katti    Login To OS Host  ${os_host}  ${os_username}  ${os_password}
108ae7c2281SPrashanth Katti    Check If IPMI Tool Exist
109ae7c2281SPrashanth Katti
110ae7c2281SPrashanth Katti    ${inband_std_cmd}=  Catenate  ${IPMI_INBAND_CMD}  ${args}
111ae7c2281SPrashanth Katti    ${stdout}  ${stderr}=  Execute Command  ${inband_std_cmd}  return_stderr=True
112*20f3bf73SRahul Maheshwari    Return From Keyword If  ${fail_on_err} == ${0}  ${stderr}
113ae7c2281SPrashanth Katti    Should Be Empty  ${stderr}  msg=${stdout}
114ae7c2281SPrashanth Katti    [Return]  ${stdout}
115ae7c2281SPrashanth Katti
116b4d4a4aeSGeorge KeishingRun External IPMI Raw Command
117f4a807bfSJoy Onyerikwu    [Documentation]  Run the raw IPMI command externally.
11838032805SGunnar Mills    [Arguments]    ${args}
11919621bacSMichael Walsh
1207a212a09SRahul Maheshwari    ${ipmi_raw_cmd}=   Catenate  SEPARATOR=
121a7913898SMichael Walsh    ...    ${IPMI_EXT_CMD} -P${SPACE}${IPMI_PASSWORD}${SPACE}
1227a212a09SRahul Maheshwari    ...    ${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${RAW}${SPACE}${args}
1237a212a09SRahul Maheshwari    ${rc}    ${output}=    Run and Return RC and Output    ${ipmi_raw_cmd}
1247a212a09SRahul Maheshwari    Should Be Equal    ${rc}    ${0}    msg=${output}
125c9ea9368SGunnar Mills    [Return]    ${output}
1267a212a09SRahul Maheshwari
1277a212a09SRahul MaheshwariRun External IPMI Standard Command
128f4a807bfSJoy Onyerikwu    [Documentation]  Run the standard IPMI command in-band.
12902651f0cSGeorge Keishing    [Arguments]  ${args}  ${fail_on_err}=${1}
13002651f0cSGeorge Keishing
13102651f0cSGeorge Keishing    # Description of argument(s):
13202651f0cSGeorge Keishing    # args         IPMI command to be executed.
13302651f0cSGeorge Keishing    # fail_on_err  Fail if keyword the IPMI command fails
134a7913898SMichael Walsh
1357a212a09SRahul Maheshwari    ${ipmi_cmd}=  Catenate  SEPARATOR=
136a7913898SMichael Walsh    ...  ${IPMI_EXT_CMD} ${IPMI_USER_OPTIONS} -P${SPACE}${IPMI_PASSWORD}
137a7913898SMichael Walsh    ...  ${SPACE}${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${args}
13804a2204bSRahul Maheshwari    ${rc}  ${output}=  Run And Return RC and Output  ${ipmi_cmd}
13902651f0cSGeorge Keishing    Return From Keyword If  ${fail_on_err} == ${0}  ${output}
1407a212a09SRahul Maheshwari    Should Be Equal  ${rc}  ${0}  msg=${output}
141c9ea9368SGunnar Mills    [Return]  ${output}
1427a212a09SRahul Maheshwari
143ae7c2281SPrashanth KattiCheck If IPMI Tool Exist
144ae7c2281SPrashanth Katti    [Documentation]  Check if IPMI Tool installed or not.
145ae7c2281SPrashanth Katti    ${output}=  Execute Command  which ipmitool
146ae7c2281SPrashanth Katti    Should Not Be Empty  ${output}  msg=ipmitool not installed.
1477a212a09SRahul Maheshwari
14804a2204bSRahul Maheshwari
14904a2204bSRahul MaheshwariActivate SOL Via IPMI
15004a2204bSRahul Maheshwari    [Documentation]  Start SOL using IPMI and route output to a file.
15104a2204bSRahul Maheshwari    [Arguments]  ${file_path}=/tmp/sol_${OPENBMC_HOST}
15204a2204bSRahul Maheshwari    # Description of argument(s):
15304a2204bSRahul Maheshwari    # file_path  The file path on the local machine (vs OBMC) to collect SOL
15404a2204bSRahul Maheshwari    #            output. By default SOL output is collected at
15504a2204bSRahul Maheshwari    #            /tmp/sol_<BMC_IP> else user input location.
15604a2204bSRahul Maheshwari
15704a2204bSRahul Maheshwari    ${ipmi_cmd}=  Catenate  SEPARATOR=
158c8470881SRahul Maheshwari    ...  ${IPMI_EXT_CMD} -P${SPACE}${IPMI_PASSWORD}${SPACE}${HOST}
159c8470881SRahul Maheshwari    ...  ${SPACE}${OPENBMC_HOST}${SPACE}sol activate usesolkeepalive
16004a2204bSRahul Maheshwari
1612102f6bfSGeorge Keishing    Start Process  ${ipmi_cmd}  shell=True  stdout=${file_path}
1624f360843SRahul Maheshwari    ...  alias=sol_proc
16304a2204bSRahul Maheshwari
16404a2204bSRahul Maheshwari
16504a2204bSRahul MaheshwariDeactivate SOL Via IPMI
16604a2204bSRahul Maheshwari    [Documentation]  Stop SOL using IPMI and return SOL output.
16704a2204bSRahul Maheshwari    [Arguments]  ${file_path}=/tmp/sol_${OPENBMC_HOST}
16804a2204bSRahul Maheshwari    # Description of argument(s):
16904a2204bSRahul Maheshwari    # file_path  The file path on the local machine to copy SOL output
17004a2204bSRahul Maheshwari    #            collected by above "Activate SOL Via IPMI" keyword.
17104a2204bSRahul Maheshwari    #            By default it copies log from /tmp/sol_<BMC_IP>.
17204a2204bSRahul Maheshwari
17304a2204bSRahul Maheshwari    ${ipmi_cmd}=  Catenate  SEPARATOR=
17404a2204bSRahul Maheshwari    ...  ${IPMI_EXT_CMD} -P${SPACE}${IPMI_PASSWORD}${SPACE}
17504a2204bSRahul Maheshwari    ...  ${HOST}${SPACE}${OPENBMC_HOST}${SPACE}sol deactivate
17604a2204bSRahul Maheshwari
17704a2204bSRahul Maheshwari    ${rc}  ${output}=  Run and Return RC and Output  ${ipmi_cmd}
1784f360843SRahul Maheshwari    Run Keyword If  ${rc} > 0  Run Keywords
1797f48a2c6SRahul Maheshwari    ...  Run Keyword And Ignore Error  Terminate Process  sol_proc
1807f48a2c6SRahul Maheshwari    ...  AND  Return From Keyword  ${output}
18104a2204bSRahul Maheshwari
18204a2204bSRahul Maheshwari    ${rc}  ${output}=  Run and Return RC and Output  cat ${file_path}
18304a2204bSRahul Maheshwari    Should Be Equal  ${rc}  ${0}  msg=${output}
18404a2204bSRahul Maheshwari
18504a2204bSRahul Maheshwari    # Logging SOL output for debug purpose.
18604a2204bSRahul Maheshwari    Log  ${output}
18704a2204bSRahul Maheshwari
18804a2204bSRahul Maheshwari    [Return]  ${output}
18904a2204bSRahul Maheshwari
19004a2204bSRahul Maheshwari
191a2dab3c8SSivas SRRByte Conversion
192a2dab3c8SSivas SRR    [Documentation]   Byte Conversion method receives IPMI RAW commands as
193a2dab3c8SSivas SRR    ...               argument in string format.
194a2dab3c8SSivas SRR    ...               Sample argument is as follows
195a2dab3c8SSivas SRR    ...               "0x04 0x30 9 0x01 0x00 0x35 0x00 0x00 0x00 0x00 0x00
196a2dab3c8SSivas SRR    ...               0x00"
197a2dab3c8SSivas SRR    ...               IPMI RAW command format is as follows
198a2dab3c8SSivas SRR    ...               <netfn Byte> <cmd Byte> <Data Bytes..>
199a2dab3c8SSivas SRR    ...               This method converts IPMI command format into
200a2dab3c8SSivas SRR    ...               dbus command format  as follows
201a2dab3c8SSivas SRR    ...               <byte:seq-id> <byte:netfn> <byte:lun> <byte:cmd>
202a2dab3c8SSivas SRR    ...               <array:byte:data>
203a2dab3c8SSivas SRR    ...               Sample dbus  Host IPMI Received Message argument
204a2dab3c8SSivas SRR    ...               byte:0x00 byte:0x04 byte:0x00 byte:0x30
205a2dab3c8SSivas SRR    ...               array:byte:9,0x01,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00
20638032805SGunnar Mills    [Arguments]     ${args}
207a2dab3c8SSivas SRR    ${argLength}=   Get Length  ${args}
208a2dab3c8SSivas SRR    Set Global Variable  ${arrayByte}   array:byte:
209a2dab3c8SSivas SRR    @{listargs}=   Split String  ${args}
210a2dab3c8SSivas SRR    ${index}=   Set Variable   ${0}
2119a08944dSGeorge Keishing    :FOR  ${word}  IN  @{listargs}
212a2dab3c8SSivas SRR    \    Run Keyword if   ${index} == 0   Set NetFn Byte  ${word}
213a2dab3c8SSivas SRR    \    Run Keyword if   ${index} == 1   Set Cmd Byte    ${word}
214a2dab3c8SSivas SRR    \    Run Keyword if   ${index} > 1    Set Array Byte  ${word}
215a2dab3c8SSivas SRR    \    ${index}=    Set Variable    ${index + 1}
216a2dab3c8SSivas SRR    ${length}=   Get Length  ${arrayByte}
217a2dab3c8SSivas SRR    ${length}=   Evaluate  ${length} - 1
218a2dab3c8SSivas SRR    ${arrayByteLocal}=  Get Substring  ${arrayByte}  0   ${length}
219a2dab3c8SSivas SRR    Set Global Variable  ${arrayByte}   ${arrayByteLocal}
220a2dab3c8SSivas SRR    ${valueinBytesWithArray}=   Catenate  byte:0x00   ${netfnByte}  byte:0x00
221a2dab3c8SSivas SRR    ${valueinBytesWithArray}=   Catenate  ${valueinBytesWithArray}  ${cmdByte}
222a2dab3c8SSivas SRR    ${valueinBytesWithArray}=   Catenate  ${valueinBytesWithArray} ${arrayByte}
223a2dab3c8SSivas SRR    ${valueinBytesWithoutArray}=   Catenate  byte:0x00 ${netfnByte}  byte:0x00
224a2dab3c8SSivas SRR    ${valueinBytesWithoutArray}=   Catenate  ${valueinBytesWithoutArray} ${cmdByte}
225a2dab3c8SSivas SRR#   To Check scenario for smaller IPMI raw commands with only 2 arguments
226a2dab3c8SSivas SRR#   instead of usual 12 arguments.
227a2dab3c8SSivas SRR#   Sample small IPMI raw command: Run IPMI command 0x06 0x36
228a2dab3c8SSivas SRR#   If IPMI raw argument length is only 9 then return value in bytes without
229a2dab3c8SSivas SRR#   array population.
230a2dab3c8SSivas SRR#   Equivalent dbus-send argument for smaller IPMI raw command:
231a2dab3c8SSivas SRR#   byte:0x00 byte:0x06 byte:0x00 byte:0x36
232a2dab3c8SSivas SRR    Run Keyword if   ${argLength} == 9     Return from Keyword    ${valueinBytesWithoutArray}
233c9ea9368SGunnar Mills    [Return]    ${valueinBytesWithArray}
234a2dab3c8SSivas SRR
235a2dab3c8SSivas SRR
236a2dab3c8SSivas SRRSet NetFn Byte
237f4a807bfSJoy Onyerikwu    [Documentation]  Set the network function byte.
23838032805SGunnar Mills    [Arguments]    ${word}
239a2dab3c8SSivas SRR    ${netfnByteLocal}=  Catenate   byte:${word}
240a2dab3c8SSivas SRR    Set Global Variable  ${netfnByte}  ${netfnByteLocal}
241a2dab3c8SSivas SRR
242a2dab3c8SSivas SRRSet Cmd Byte
243f4a807bfSJoy Onyerikwu    [Documentation]  Set the command byte.
24438032805SGunnar Mills    [Arguments]    ${word}
245a2dab3c8SSivas SRR    ${cmdByteLocal}=  Catenate   byte:${word}
246a2dab3c8SSivas SRR    Set Global Variable  ${cmdByte}  ${cmdByteLocal}
247a2dab3c8SSivas SRR
248a2dab3c8SSivas SRRSet Array Byte
249f4a807bfSJoy Onyerikwu    [Documentation]  Set the array byte.
25038032805SGunnar Mills    [Arguments]    ${word}
251a2dab3c8SSivas SRR    ${arrayByteLocal}=   Catenate   SEPARATOR=  ${arrayByte}  ${word}
252a2dab3c8SSivas SRR    ${arrayByteLocal}=   Catenate   SEPARATOR=  ${arrayByteLocal}   ,
253a2dab3c8SSivas SRR    Set Global Variable  ${arrayByte}   ${arrayByteLocal}
254a2dab3c8SSivas SRR
255b29d2e84SChris AustenCopy ipmitool
256f4a807bfSJoy Onyerikwu    [Documentation]  Copy the ipmitool to the BMC.
257f4a807bfSJoy Onyerikwu    ${ipmitool_error}=  Catenate  The ipmitool program could not be found in the tools directory.
258f4a807bfSJoy Onyerikwu    ...  It is not part of the automation code by default. You must manually copy or link the correct openbmc
259f4a807bfSJoy Onyerikwu    ...  version of the tool in to the tools directory in order to run this test suite.
260f4a807bfSJoy Onyerikwu
261f4a807bfSJoy Onyerikwu    OperatingSystem.File Should Exist  tools/ipmitool  msg=${ipmitool_error}
262b29d2e84SChris Austen
263b29d2e84SChris Austen    Import Library      SCPLibrary      WITH NAME       scp
264b29d2e84SChris Austen    scp.Open connection     ${OPENBMC_HOST}     username=${OPENBMC_USERNAME}      password=${OPENBMC_PASSWORD}
265b29d2e84SChris Austen    scp.Put File    tools/ipmitool   /tmp
266b29d2e84SChris Austen    SSHLibrary.Open Connection     ${OPENBMC_HOST}
267b29d2e84SChris Austen    Login   ${OPENBMC_USERNAME}    ${OPENBMC_PASSWORD}
268b29d2e84SChris Austen    Execute Command     chmod +x /tmp/ipmitool
2690c34f69cSSridevi Ramesh
2700c34f69cSSridevi RameshInitiate Host Boot Via External IPMI
2710c34f69cSSridevi Ramesh    [Documentation]  Initiate host power on using external IPMI.
272982fee42SRahul Maheshwari    [Arguments]  ${wait}=${1}
273982fee42SRahul Maheshwari    # Description of argument(s):
274982fee42SRahul Maheshwari    # wait  Indicates that this keyword should wait for host running state.
275982fee42SRahul Maheshwari
2760c34f69cSSridevi Ramesh    ${output}=  Run External IPMI Standard Command  chassis power on
2770c34f69cSSridevi Ramesh    Should Not Contain  ${output}  Error
278982fee42SRahul Maheshwari
279982fee42SRahul Maheshwari    Run Keyword If  '${wait}' == '${0}'  Return From Keyword
280982fee42SRahul Maheshwari    Wait Until Keyword Succeeds  10 min  10 sec  Is Host Running
2810c34f69cSSridevi Ramesh
2820c34f69cSSridevi RameshInitiate Host PowerOff Via External IPMI
2830c34f69cSSridevi Ramesh    [Documentation]  Initiate host power off using external IPMI.
284982fee42SRahul Maheshwari    [Arguments]  ${wait}=${1}
285982fee42SRahul Maheshwari    # Description of argument(s):
286982fee42SRahul Maheshwari    # wait  Indicates that this keyword should wait for host off state.
287982fee42SRahul Maheshwari
2880c34f69cSSridevi Ramesh    ${output}=  Run External IPMI Standard Command  chassis power off
2890c34f69cSSridevi Ramesh    Should Not Contain  ${output}  Error
290982fee42SRahul Maheshwari
291982fee42SRahul Maheshwari    Run Keyword If  '${wait}' == '${0}'  Return From Keyword
292982fee42SRahul Maheshwari    Wait Until Keyword Succeeds  3 min  10 sec  Is Host Off
293982fee42SRahul Maheshwari
294982fee42SRahul MaheshwariGet Host State Via External IPMI
295982fee42SRahul Maheshwari    [Documentation]  Returns host state using external IPMI.
296982fee42SRahul Maheshwari
297982fee42SRahul Maheshwari    ${output}=  Run External IPMI Standard Command  chassis power status
298982fee42SRahul Maheshwari    Should Not Contain  ${output}  Error
299982fee42SRahul Maheshwari    ${output}=  Fetch From Right  ${output}  ${SPACE}
300982fee42SRahul Maheshwari
301982fee42SRahul Maheshwari    [Return]  ${output}
302b4d4a4aeSGeorge Keishing
303b4d4a4aeSGeorge Keishing
304b4d4a4aeSGeorge KeishingSet BMC Network From Host
305b4d4a4aeSGeorge Keishing    [Documentation]  Set BMC network from host.
306b4d4a4aeSGeorge Keishing    [Arguments]  ${nw_info}
307b4d4a4aeSGeorge Keishing
308b4d4a4aeSGeorge Keishing    # Description of argument(s):
309b4d4a4aeSGeorge Keishing    # nw_info    A dictionary containing the network information to apply.
310b4d4a4aeSGeorge Keishing
311b4d4a4aeSGeorge Keishing    Run Inband IPMI Standard Command
312b4d4a4aeSGeorge Keishing    ...  lan set 1 ipaddr ${nw_info['IP Address']}
313b4d4a4aeSGeorge Keishing
314b4d4a4aeSGeorge Keishing    Run Inband IPMI Standard Command
315b4d4a4aeSGeorge Keishing    ...  lan set 1 netmask ${nw_info['Subnet Mask']}
316b4d4a4aeSGeorge Keishing
317b4d4a4aeSGeorge Keishing    Run Inband IPMI Standard Command
318b4d4a4aeSGeorge Keishing    ...  lan set 1 defgw ipaddr ${nw_info['Default Gateway IP']}
319