blob: 47f0744667ec71774039125da3d260ba8e9b70ea [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
George Keishing4d6c1da2016-07-15 05:51:22 -05002Documentation This module is for IPMI client for copying ipmitool to
Sivas SRRa2dab3c2016-07-25 05:08:18 -05003... openbmc box and execute ipmitool IPMI standard
4... command. IPMI raw command will use dbus-send command
Sandhya Somashekar839a0c22019-01-31 05:05:43 -06005Resource ../lib/resource.robot
George Keishing4d6c1da2016-07-15 05:51:22 -05006Resource ../lib/connection_client.robot
Prashanth Kattiae7c2282017-03-15 07:43:46 -05007Resource ../lib/utils.robot
8Resource ../lib/state_manager.robot
9
Sivas SRRa2dab3c2016-07-25 05:08:18 -050010Library String
Michael Walsh19621ba2018-12-03 17:16:02 -060011Library ipmi_client.py
Sivas SRRa2dab3c2016-07-25 05:08:18 -050012
13*** Variables ***
George Keishingd7f11f72017-01-04 10:58:19 -060014${dbusHostIpmicmd1}= dbus-send --system ${OPENBMC_BASE_URI}HostIpmi/1
15${dbusHostIpmiCmdReceivedMsg}= ${OPENBMC_BASE_DBUS}.HostIpmi.ReceivedMessage
Gunnar Mills59204d22016-12-06 11:05:19 -060016${netfnByte}= ${EMPTY}
George Keishingd7f11f72017-01-04 10:58:19 -060017${cmdByte}= ${EMPTY}
Gunnar Mills59204d22016-12-06 11:05:19 -060018${arrayByte}= array:byte:
Michael Walsha7913892017-04-20 16:29:01 -050019${IPMI_USER_OPTIONS} ${EMPTY}
George Keishing39967eb2018-04-30 11:36:23 -050020${IPMI_INBAND_CMD}= ipmitool -C ${IPMI_CIPHER_LEVEL}
Gunnar Mills59204d22016-12-06 11:05:19 -060021${HOST}= -H
22${RAW}= raw
Chris Austenb29d2e82016-06-07 12:25:35 -050023
24*** Keywords ***
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050025
Chris Austenb29d2e82016-06-07 12:25:35 -050026Run IPMI Command
Michael Walsh3ef2e922019-01-23 10:40:16 -060027 [Documentation] Run the raw IPMI command.
28 [Arguments] ${command} ${fail_on_err}=${1} &{options}
29
30 # Description of argument(s):
31 # command The IPMI command string to be executed
32 # (e.g. "power status").
33 # fail_on_err Fail if the IPMI command execution fails.
34 # options Additional ipmitool command options (e.g.
35 # -C=3, -I=lanplus, etc.). Currently, only
36 # used for external IPMI commands.
37
Prashanth Kattiae7c2282017-03-15 07:43:46 -050038 ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External'
Michael Walsh3ef2e922019-01-23 10:40:16 -060039 ... Run External IPMI Raw Command ${command} ${fail_on_err} &{options}
Prashanth Kattiae7c2282017-03-15 07:43:46 -050040 ... ELSE IF '${IPMI_COMMAND}' == 'Inband'
Michael Walsh3ef2e922019-01-23 10:40:16 -060041 ... Run Inband IPMI Raw Command ${command}
Prashanth Kattiae7c2282017-03-15 07:43:46 -050042 ... ELSE IF '${IPMI_COMMAND}' == 'Dbus'
Michael Walsh3ef2e922019-01-23 10:40:16 -060043 ... Run Dbus IPMI RAW Command ${command}
44 ... ELSE Fail msg=Invalid IPMI Command type provided: ${IPMI_COMMAND}
Prashanth Kattiae7c2282017-03-15 07:43:46 -050045 [Return] ${resp}
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050046
Michael Walsh3ef2e922019-01-23 10:40:16 -060047
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050048Run IPMI Standard Command
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -050049 [Documentation] Run the standard IPMI command.
Michael Walshd0e58e72019-05-14 11:07:14 -050050 [Arguments] ${command} ${fail_on_err}=${1} ${expected_rc}=${0} &{options}
Rahul Maheshwari20f3bf72018-12-18 04:24:20 -060051
52 # Description of argument(s):
Michael Walsh3ef2e922019-01-23 10:40:16 -060053 # command The IPMI command string to be executed
54 # (e.g. "0x06 0x36").
55 # fail_on_err Fail if the IPMI command execution fails.
Michael Walshd0e58e72019-05-14 11:07:14 -050056 # expected_rc The expected return code from the ipmi
57 # command (e.g. ${0}, ${1}, etc.).
Michael Walsh3ef2e922019-01-23 10:40:16 -060058 # options Additional ipmitool command options (e.g.
59 # -C=3, -I=lanplus, etc.). Currently, only
60 # used for external IPMI commands.
Rahul Maheshwari20f3bf72018-12-18 04:24:20 -060061
Prashanth Kattiae7c2282017-03-15 07:43:46 -050062 ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External'
Michael Walshd0e58e72019-05-14 11:07:14 -050063 ... Run External IPMI Standard Command ${command} ${fail_on_err} ${expected_rc} &{options}
Prashanth Kattiae7c2282017-03-15 07:43:46 -050064 ... ELSE IF '${IPMI_COMMAND}' == 'Inband'
Michael Walsh3ef2e922019-01-23 10:40:16 -060065 ... Run Inband IPMI Standard Command ${command} ${fail_on_err}
Prashanth Kattiae7c2282017-03-15 07:43:46 -050066 ... ELSE IF '${IPMI_COMMAND}' == 'Dbus'
Michael Walsh3ef2e922019-01-23 10:40:16 -060067 ... Run Dbus IPMI Standard Command ${command}
Prashanth Kattiae7c2282017-03-15 07:43:46 -050068 ... ELSE Fail msg=Invalid IPMI Command type provided : ${IPMI_COMMAND}
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050069
Prashanth Kattiae7c2282017-03-15 07:43:46 -050070 [Return] ${resp}
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050071
Michael Walsh3ef2e922019-01-23 10:40:16 -060072
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050073Run Dbus IPMI RAW Command
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -050074 [Documentation] Run the raw IPMI command through dbus.
Michael Walsh3ef2e922019-01-23 10:40:16 -060075 [Arguments] ${command}
76 ${valueinBytes}= Byte Conversion ${command}
Gunnar Mills59204d22016-12-06 11:05:19 -060077 ${cmd}= Catenate ${dbushostipmicmd1} ${dbusHostIpmiCmdReceivedMsg}
78 ${cmd}= Catenate ${cmd} ${valueinBytes}
Sivas SRRa2dab3c2016-07-25 05:08:18 -050079 ${output} ${stderr}= Execute Command ${cmd} return_stderr=True
80 Should Be Empty ${stderr}
Chris Austenb29d2e82016-06-07 12:25:35 -050081 set test variable ${OUTPUT} "${output}"
82
Michael Walsh3ef2e922019-01-23 10:40:16 -060083
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050084Run Dbus IPMI Standard Command
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -050085 [Documentation] Run the standard IPMI command through dbus.
Michael Walsh3ef2e922019-01-23 10:40:16 -060086 [Arguments] ${command}
George Keishing4d6c1da2016-07-15 05:51:22 -050087 Copy ipmitool
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050088 ${stdout} ${stderr} ${output}= Execute Command
Michael Walsh3ef2e922019-01-23 10:40:16 -060089 ... /tmp/ipmitool -I dbus ${command} return_stdout=True
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050090 ... return_stderr= True return_rc=True
Chris Austenb29d2e82016-06-07 12:25:35 -050091 Should Be Equal ${output} ${0} msg=${stderr}
Gunnar Millsc9ea9362016-12-13 16:21:13 -060092 [Return] ${stdout}
Chris Austenb29d2e82016-06-07 12:25:35 -050093
Michael Walsh3ef2e922019-01-23 10:40:16 -060094
Prashanth Kattiae7c2282017-03-15 07:43:46 -050095Run Inband IPMI Raw Command
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -050096 [Documentation] Run the raw IPMI command in-band.
Michael Walsh3ef2e922019-01-23 10:40:16 -060097 [Arguments] ${command} ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
Prashanth Kattiae7c2282017-03-15 07:43:46 -050098 ... ${os_password}=${OS_PASSWORD}
99
Michael Walsh3ef2e922019-01-23 10:40:16 -0600100 # Description of argument(s):
101 # command The IPMI command string to be executed
102 # (e.g. "0x06 0x36").
103 # os_host The host name or IP address of the OS Host.
104 # os_username The OS host user name.
105 # os_password The OS host passwrd.
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500106
107 Login To OS Host ${os_host} ${os_username} ${os_password}
108 Check If IPMI Tool Exist
109
Michael Walsh3ef2e922019-01-23 10:40:16 -0600110 ${ipmi_cmd}= Catenate ${IPMI_INBAND_CMD} ${RAW} ${command}
111 Qprint Issuing ${ipmi_cmd}
112 ${stdout} ${stderr}= Execute Command ${ipmi_cmd} return_stderr=True
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500113 Should Be Empty ${stderr} msg=${stdout}
114 [Return] ${stdout}
115
Michael Walsh3ef2e922019-01-23 10:40:16 -0600116
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500117Run Inband IPMI Standard Command
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500118 [Documentation] Run the standard IPMI command in-band.
Michael Walsh3ef2e922019-01-23 10:40:16 -0600119 [Arguments] ${command} ${fail_on_err}=${1} ${os_host}=${OS_HOST}
Rahul Maheshwari20f3bf72018-12-18 04:24:20 -0600120 ... ${os_username}=${OS_USERNAME} ${os_password}=${OS_PASSWORD}
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500121
Michael Walsh3ef2e922019-01-23 10:40:16 -0600122 # Description of argument(s):
123 # command The IPMI command string to be executed
124 # (e.g. "power status").
125 # os_host The host name or IP address of the OS Host.
126 # os_username The OS host user name.
127 # os_password The OS host passwrd.
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500128
129 Login To OS Host ${os_host} ${os_username} ${os_password}
130 Check If IPMI Tool Exist
131
Michael Walsh3ef2e922019-01-23 10:40:16 -0600132 ${ipmi_cmd}= Catenate ${IPMI_INBAND_CMD} ${command}
133 Qprint Issuing ${ipmi_cmd}
134 ${stdout} ${stderr}= Execute Command ${ipmi_cmd} return_stderr=True
Rahul Maheshwari20f3bf72018-12-18 04:24:20 -0600135 Return From Keyword If ${fail_on_err} == ${0} ${stderr}
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500136 Should Be Empty ${stderr} msg=${stdout}
137 [Return] ${stdout}
138
Rahul Maheshwari7a212a02016-09-05 21:17:30 -0500139
140Run External IPMI Standard Command
Michael Walsh3ef2e922019-01-23 10:40:16 -0600141 [Documentation] Run the external IPMI standard command.
Michael Walshd0e58e72019-05-14 11:07:14 -0500142 [Arguments] ${command} ${fail_on_err}=${1} ${expected_rc}=${0} &{options}
George Keishing02651f02018-04-11 02:07:16 -0500143
144 # Description of argument(s):
Michael Walsh3ef2e922019-01-23 10:40:16 -0600145 # command The IPMI command string to be executed
146 # (e.g. "power status"). Note that if
147 # ${IPMI_USER_OPTIONS} has a value (e.g.
148 # "-vvv"), it will be pre-pended to this
149 # command string.
150 # fail_on_err Fail if the IPMI command execution fails.
Michael Walshd0e58e72019-05-14 11:07:14 -0500151 # expected_rc The expected return code from the ipmi
152 # command (e.g. ${0}, ${1}, etc.).
Michael Walsh3ef2e922019-01-23 10:40:16 -0600153 # options Additional ipmitool command options (e.g.
154 # -C=3, -I=lanplus, etc.).
Michael Walsha7913892017-04-20 16:29:01 -0500155
Michael Walsh3ef2e922019-01-23 10:40:16 -0600156 ${command_string}= Process IPMI User Options ${command}
157 ${ipmi_cmd}= Create IPMI Ext Command String ${command_string} &{options}
158 Qprint Issuing ${ipmi_cmd}
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500159 ${rc} ${output}= Run And Return RC and Output ${ipmi_cmd}
George Keishing02651f02018-04-11 02:07:16 -0500160 Return From Keyword If ${fail_on_err} == ${0} ${output}
Michael Walshd0e58e72019-05-14 11:07:14 -0500161 Should Be Equal ${rc} ${expected_rc} msg=${output}
Michael Walsha7913892017-04-20 16:29:01 -0500162 [Return] ${output}
Rahul Maheshwari7a212a02016-09-05 21:17:30 -0500163
Michael Walsh3ef2e922019-01-23 10:40:16 -0600164
165Run External IPMI Raw Command
166 [Documentation] Run the external IPMI raw command.
167 [Arguments] ${command} ${fail_on_err}=${1} &{options}
168
169 # This keyword is a wrapper for 'Run External IPMI Standard Command'. See
170 # that keyword's prolog for argument details. This keyword will pre-pend
171 # the word "raw" plus a space to command prior to calling 'Run External
172 # IPMI Standard Command'.
173
174 ${output}= Run External IPMI Standard Command
175 ... raw ${command} ${fail_on_err} &{options}
176 [Return] ${output}
177
178
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500179Check If IPMI Tool Exist
180 [Documentation] Check if IPMI Tool installed or not.
181 ${output}= Execute Command which ipmitool
182 Should Not Be Empty ${output} msg=ipmitool not installed.
Rahul Maheshwari7a212a02016-09-05 21:17:30 -0500183
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500184
185Activate SOL Via IPMI
186 [Documentation] Start SOL using IPMI and route output to a file.
187 [Arguments] ${file_path}=/tmp/sol_${OPENBMC_HOST}
Michael Walsh3ef2e922019-01-23 10:40:16 -0600188
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500189 # Description of argument(s):
Michael Walsh3ef2e922019-01-23 10:40:16 -0600190 # file_path The file path on the local machine (vs.
191 # OBMC) to collect SOL output. By default
192 # SOL output is collected at
193 # /tmp/sol_<BMC_IP> else user input location.
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500194
Michael Walsh3ef2e922019-01-23 10:40:16 -0600195 ${ipmi_cmd}= Create IPMI Ext Command String sol activate usesolkeepalive
196 Qprint Issuing ${ipmi_cmd}
George Keishing2102f6b2017-06-06 08:30:10 -0500197 Start Process ${ipmi_cmd} shell=True stdout=${file_path}
Rahul Maheshwari4f360842017-06-06 15:05:01 -0500198 ... alias=sol_proc
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500199
200
201Deactivate SOL Via IPMI
202 [Documentation] Stop SOL using IPMI and return SOL output.
203 [Arguments] ${file_path}=/tmp/sol_${OPENBMC_HOST}
Michael Walsh3ef2e922019-01-23 10:40:16 -0600204
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500205 # Description of argument(s):
Michael Walsh3ef2e922019-01-23 10:40:16 -0600206 # file_path The file path on the local machine to copy
207 # SOL output collected by above "Activate
208 # SOL Via IPMI" keyword. By default it
209 # copies log from /tmp/sol_<BMC_IP>.
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500210
Michael Walsh3ef2e922019-01-23 10:40:16 -0600211 ${ipmi_cmd}= Create IPMI Ext Command String sol deactivate
212 Qprint Issuing ${ipmi_cmd}
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500213 ${rc} ${output}= Run and Return RC and Output ${ipmi_cmd}
Rahul Maheshwari4f360842017-06-06 15:05:01 -0500214 Run Keyword If ${rc} > 0 Run Keywords
Rahul Maheshwari7f48a2c2017-06-16 04:00:26 -0500215 ... Run Keyword And Ignore Error Terminate Process sol_proc
216 ... AND Return From Keyword ${output}
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500217
George Keishingaec8b872019-07-08 23:44:08 -0500218 ${output}= OperatingSystem.Get File ${file_path} encoding_errors=ignore
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500219
220 # Logging SOL output for debug purpose.
221 Log ${output}
222
223 [Return] ${output}
224
225
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500226Byte Conversion
227 [Documentation] Byte Conversion method receives IPMI RAW commands as
228 ... argument in string format.
229 ... Sample argument is as follows
230 ... "0x04 0x30 9 0x01 0x00 0x35 0x00 0x00 0x00 0x00 0x00
231 ... 0x00"
232 ... IPMI RAW command format is as follows
233 ... <netfn Byte> <cmd Byte> <Data Bytes..>
234 ... This method converts IPMI command format into
235 ... dbus command format as follows
236 ... <byte:seq-id> <byte:netfn> <byte:lun> <byte:cmd>
237 ... <array:byte:data>
238 ... Sample dbus Host IPMI Received Message argument
239 ... byte:0x00 byte:0x04 byte:0x00 byte:0x30
240 ... array:byte:9,0x01,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00
Gunnar Mills38032802016-12-12 13:43:40 -0600241 [Arguments] ${args}
Gunnar Mills59204d22016-12-06 11:05:19 -0600242 ${argLength}= Get Length ${args}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500243 Set Global Variable ${arrayByte} array:byte:
Gunnar Mills59204d22016-12-06 11:05:19 -0600244 @{listargs}= Split String ${args}
245 ${index}= Set Variable ${0}
George Keishing9a089442018-12-10 09:38:50 -0600246 :FOR ${word} IN @{listargs}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500247 \ Run Keyword if ${index} == 0 Set NetFn Byte ${word}
248 \ Run Keyword if ${index} == 1 Set Cmd Byte ${word}
249 \ Run Keyword if ${index} > 1 Set Array Byte ${word}
Gunnar Mills59204d22016-12-06 11:05:19 -0600250 \ ${index}= Set Variable ${index + 1}
251 ${length}= Get Length ${arrayByte}
252 ${length}= Evaluate ${length} - 1
253 ${arrayByteLocal}= Get Substring ${arrayByte} 0 ${length}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500254 Set Global Variable ${arrayByte} ${arrayByteLocal}
Gunnar Mills59204d22016-12-06 11:05:19 -0600255 ${valueinBytesWithArray}= Catenate byte:0x00 ${netfnByte} byte:0x00
256 ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${cmdByte}
257 ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${arrayByte}
258 ${valueinBytesWithoutArray}= Catenate byte:0x00 ${netfnByte} byte:0x00
259 ${valueinBytesWithoutArray}= Catenate ${valueinBytesWithoutArray} ${cmdByte}
Michael Walsh3ef2e922019-01-23 10:40:16 -0600260 # To Check scenario for smaller IPMI raw commands with only 2 arguments
261 # instead of usual 12 arguments.
262 # Sample small IPMI raw command: Run IPMI command 0x06 0x36
263 # If IPMI raw argument length is only 9 then return value in bytes without
264 # array population.
265 # Equivalent dbus-send argument for smaller IPMI raw command:
266 # byte:0x00 byte:0x06 byte:0x00 byte:0x36
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500267 Run Keyword if ${argLength} == 9 Return from Keyword ${valueinBytesWithoutArray}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600268 [Return] ${valueinBytesWithArray}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500269
270
271Set NetFn Byte
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500272 [Documentation] Set the network function byte.
273 [Arguments] ${word}
274 ${netfnByteLocal}= Catenate byte:${word}
275 Set Global Variable ${netfnByte} ${netfnByteLocal}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500276
Michael Walsh3ef2e922019-01-23 10:40:16 -0600277
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500278Set Cmd Byte
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500279 [Documentation] Set the command byte.
280 [Arguments] ${word}
281 ${cmdByteLocal}= Catenate byte:${word}
282 Set Global Variable ${cmdByte} ${cmdByteLocal}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500283
Michael Walsh3ef2e922019-01-23 10:40:16 -0600284
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500285Set Array Byte
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500286 [Documentation] Set the array byte.
287 [Arguments] ${word}
288 ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByte} ${word}
289 ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByteLocal} ,
290 Set Global Variable ${arrayByte} ${arrayByteLocal}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500291
Michael Walsh3ef2e922019-01-23 10:40:16 -0600292
Chris Austenb29d2e82016-06-07 12:25:35 -0500293Copy ipmitool
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500294 [Documentation] Copy the ipmitool to the BMC.
295 ${ipmitool_error}= Catenate The ipmitool program could not be found in the tools directory.
296 ... It is not part of the automation code by default. You must manually copy or link the correct openbmc
297 ... version of the tool in to the tools directory in order to run this test suite.
298
299 OperatingSystem.File Should Exist tools/ipmitool msg=${ipmitool_error}
Chris Austenb29d2e82016-06-07 12:25:35 -0500300
301 Import Library SCPLibrary WITH NAME scp
302 scp.Open connection ${OPENBMC_HOST} username=${OPENBMC_USERNAME} password=${OPENBMC_PASSWORD}
303 scp.Put File tools/ipmitool /tmp
304 SSHLibrary.Open Connection ${OPENBMC_HOST}
305 Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
306 Execute Command chmod +x /tmp/ipmitool
Sridevi Ramesh0c34f692017-04-25 02:40:32 -0500307
Michael Walsh3ef2e922019-01-23 10:40:16 -0600308
Sridevi Ramesh0c34f692017-04-25 02:40:32 -0500309Initiate Host Boot Via External IPMI
310 [Documentation] Initiate host power on using external IPMI.
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500311 [Arguments] ${wait}=${1}
Michael Walsh3ef2e922019-01-23 10:40:16 -0600312
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500313 # Description of argument(s):
Michael Walsh3ef2e922019-01-23 10:40:16 -0600314 # wait Indicates that this keyword should wait
315 # for host running state.
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500316
Sridevi Ramesh0c34f692017-04-25 02:40:32 -0500317 ${output}= Run External IPMI Standard Command chassis power on
318 Should Not Contain ${output} Error
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500319
320 Run Keyword If '${wait}' == '${0}' Return From Keyword
321 Wait Until Keyword Succeeds 10 min 10 sec Is Host Running
Sridevi Ramesh0c34f692017-04-25 02:40:32 -0500322
Michael Walsh3ef2e922019-01-23 10:40:16 -0600323
Sridevi Ramesh0c34f692017-04-25 02:40:32 -0500324Initiate Host PowerOff Via External IPMI
325 [Documentation] Initiate host power off using external IPMI.
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500326 [Arguments] ${wait}=${1}
Michael Walsh3ef2e922019-01-23 10:40:16 -0600327
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500328 # Description of argument(s):
Michael Walsh3ef2e922019-01-23 10:40:16 -0600329 # wait Indicates that this keyword should wait
330 # for host off state.
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500331
Sridevi Ramesh0c34f692017-04-25 02:40:32 -0500332 ${output}= Run External IPMI Standard Command chassis power off
333 Should Not Contain ${output} Error
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500334
335 Run Keyword If '${wait}' == '${0}' Return From Keyword
336 Wait Until Keyword Succeeds 3 min 10 sec Is Host Off
337
Michael Walsh3ef2e922019-01-23 10:40:16 -0600338
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500339Get Host State Via External IPMI
340 [Documentation] Returns host state using external IPMI.
341
342 ${output}= Run External IPMI Standard Command chassis power status
343 Should Not Contain ${output} Error
344 ${output}= Fetch From Right ${output} ${SPACE}
345
346 [Return] ${output}
George Keishingb4d4a4a2018-08-27 13:35:39 -0500347
348
349Set BMC Network From Host
350 [Documentation] Set BMC network from host.
351 [Arguments] ${nw_info}
352
353 # Description of argument(s):
Michael Walsh3ef2e922019-01-23 10:40:16 -0600354 # nw_info A dictionary containing the network
355 # information to apply.
George Keishingb4d4a4a2018-08-27 13:35:39 -0500356
357 Run Inband IPMI Standard Command
358 ... lan set 1 ipaddr ${nw_info['IP Address']}
359
360 Run Inband IPMI Standard Command
361 ... lan set 1 netmask ${nw_info['Subnet Mask']}
362
363 Run Inband IPMI Standard Command
364 ... lan set 1 defgw ipaddr ${nw_info['Default Gateway IP']}
Rahul Maheshwaric3d1e962019-03-06 23:53:21 -0600365
366
367Verify IPMI Username And Password
368 [Documentation] Verify that user is able to run IPMI command
369 ... with given username and password.
370 [Arguments] ${username} ${password}
371
372 # Description of argument(s):
373 # username The user name (e.g. "root", "robert", etc.).
374 # password The user password (e.g. "0penBmc", "0penBmc1", etc.).
375
376 ${output}= Run External IPMI Standard Command
377 ... sel info U=${username} P=${password}
378 Should Contain ${output} SEL Information msg=SEL information not present
Rahul Maheshwari75e91fe2019-03-29 05:32:28 -0500379
380
381IPMI Create User
382 [Documentation] Create IPMI user with given userid and username.
383 [Arguments] ${userid} ${username}
384
385 # Description of argument(s):
386 # userid The user ID (e.g. "1", "2", etc.).
387 # username The user name (e.g. "root", "robert", etc.).
388
389 ${ipmi_cmd}= Catenate user set name ${userid} ${username}
390 ${resp}= Run IPMI Standard Command ${ipmi_cmd}
391 ${user_info}= Get User Info ${userid}
392 Should Be Equal ${user_info['user_name']} ${username}
393
394
395Set Channel Access
396 [Documentation] Verify that user is able to run IPMI command
397 ... with given username and password.
398 [Arguments] ${userid} ${options} ${channel}=1
399
400 # Description of argument(s):
401 # userid The user ID (e.g. "1", "2", etc.).
402 # options Set channel command options (e.g.
403 # "link=on", "ipmi=on", etc.).
404 # channel_number The user's channel number (e.g. "1").
405
406 ${ipmi_cmd}= Catenate SEPARATOR=
407 ... channel setaccess${SPACE}${channel}${SPACE}${userid}
408 ... ${SPACE}${options}
409 Run IPMI Standard Command ${ipmi_cmd}
Rahul Maheshwari3e61ce62019-06-18 02:09:01 -0500410
411
412Delete All Non Root IPMI User
413 [Documentation] Delete all non-root IPMI user.
414
415 FOR ${userid} IN RANGE 2 16
416 ${user_info}= Get User Info ${userid}
417 Run Keyword If "${user_info['user_name']}" != ""
418 ... Run IPMI Standard Command user set name ${userid} ""
Rahul Maheshwaribb3d21c2019-07-23 01:08:19 -0500419 Sleep 5s
Rahul Maheshwari3e61ce62019-06-18 02:09:01 -0500420 END