blob: b97beab5571a28a78f890dbc8ac7c8bda01abecc [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 Walsh34c79af2019-12-09 11:46:48 -060011Library var_funcs.py
Michael Walsh19621ba2018-12-03 17:16:02 -060012Library ipmi_client.py
Sivas SRRa2dab3c2016-07-25 05:08:18 -050013
14*** Variables ***
George Keishingd7f11f72017-01-04 10:58:19 -060015${dbusHostIpmicmd1}= dbus-send --system ${OPENBMC_BASE_URI}HostIpmi/1
16${dbusHostIpmiCmdReceivedMsg}= ${OPENBMC_BASE_DBUS}.HostIpmi.ReceivedMessage
Gunnar Mills59204d22016-12-06 11:05:19 -060017${netfnByte}= ${EMPTY}
George Keishingd7f11f72017-01-04 10:58:19 -060018${cmdByte}= ${EMPTY}
Gunnar Mills59204d22016-12-06 11:05:19 -060019${arrayByte}= array:byte:
Michael Walsha7913892017-04-20 16:29:01 -050020${IPMI_USER_OPTIONS} ${EMPTY}
George Keishinge33ad1d2019-12-09 11:17:36 -060021${IPMI_INBAND_CMD}= ipmitool -C ${IPMI_CIPHER_LEVEL} -p ${IPMI_PORT}
Gunnar Mills59204d22016-12-06 11:05:19 -060022${HOST}= -H
23${RAW}= raw
Chris Austenb29d2e82016-06-07 12:25:35 -050024
25*** Keywords ***
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050026
Chris Austenb29d2e82016-06-07 12:25:35 -050027Run IPMI Command
Michael Walsh3ef2e922019-01-23 10:40:16 -060028 [Documentation] Run the raw IPMI command.
29 [Arguments] ${command} ${fail_on_err}=${1} &{options}
30
31 # Description of argument(s):
32 # command The IPMI command string to be executed
33 # (e.g. "power status").
34 # fail_on_err Fail if the IPMI command execution fails.
35 # options Additional ipmitool command options (e.g.
36 # -C=3, -I=lanplus, etc.). Currently, only
37 # used for external IPMI commands.
38
Prashanth Kattiae7c2282017-03-15 07:43:46 -050039 ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External'
Michael Walsh3ef2e922019-01-23 10:40:16 -060040 ... Run External IPMI Raw Command ${command} ${fail_on_err} &{options}
Prashanth Kattiae7c2282017-03-15 07:43:46 -050041 ... ELSE IF '${IPMI_COMMAND}' == 'Inband'
Michael Walsh3ef2e922019-01-23 10:40:16 -060042 ... Run Inband IPMI Raw Command ${command}
Prashanth Kattiae7c2282017-03-15 07:43:46 -050043 ... ELSE IF '${IPMI_COMMAND}' == 'Dbus'
Michael Walsh3ef2e922019-01-23 10:40:16 -060044 ... Run Dbus IPMI RAW Command ${command}
45 ... ELSE Fail msg=Invalid IPMI Command type provided: ${IPMI_COMMAND}
Prashanth Kattiae7c2282017-03-15 07:43:46 -050046 [Return] ${resp}
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050047
Michael Walsh3ef2e922019-01-23 10:40:16 -060048
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050049Run IPMI Standard Command
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -050050 [Documentation] Run the standard IPMI command.
Michael Walshd0e58e72019-05-14 11:07:14 -050051 [Arguments] ${command} ${fail_on_err}=${1} ${expected_rc}=${0} &{options}
Rahul Maheshwari20f3bf72018-12-18 04:24:20 -060052
53 # Description of argument(s):
Michael Walsh3ef2e922019-01-23 10:40:16 -060054 # command The IPMI command string to be executed
55 # (e.g. "0x06 0x36").
56 # fail_on_err Fail if the IPMI command execution fails.
Michael Walshd0e58e72019-05-14 11:07:14 -050057 # expected_rc The expected return code from the ipmi
58 # command (e.g. ${0}, ${1}, etc.).
Michael Walsh3ef2e922019-01-23 10:40:16 -060059 # options Additional ipmitool command options (e.g.
60 # -C=3, -I=lanplus, etc.). Currently, only
61 # used for external IPMI commands.
Rahul Maheshwari20f3bf72018-12-18 04:24:20 -060062
Prashanth Kattiae7c2282017-03-15 07:43:46 -050063 ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External'
Michael Walshd0e58e72019-05-14 11:07:14 -050064 ... Run External IPMI Standard Command ${command} ${fail_on_err} ${expected_rc} &{options}
Prashanth Kattiae7c2282017-03-15 07:43:46 -050065 ... ELSE IF '${IPMI_COMMAND}' == 'Inband'
Michael Walsh3ef2e922019-01-23 10:40:16 -060066 ... Run Inband IPMI Standard Command ${command} ${fail_on_err}
Prashanth Kattiae7c2282017-03-15 07:43:46 -050067 ... ELSE IF '${IPMI_COMMAND}' == 'Dbus'
Michael Walsh3ef2e922019-01-23 10:40:16 -060068 ... Run Dbus IPMI Standard Command ${command}
Prashanth Kattiae7c2282017-03-15 07:43:46 -050069 ... ELSE Fail msg=Invalid IPMI Command type provided : ${IPMI_COMMAND}
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}
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -0500121 ... ${login_host}=${1}
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500122
Michael Walsh3ef2e922019-01-23 10:40:16 -0600123 # Description of argument(s):
124 # command The IPMI command string to be executed
125 # (e.g. "power status").
126 # os_host The host name or IP address of the OS Host.
127 # os_username The OS host user name.
128 # os_password The OS host passwrd.
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -0500129 # login_host Indicates that this keyword should login to host OS.
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500130
Naman Navin Hegde9e8c0d82019-08-11 15:22:44 -0500131 Run Keyword If ${login_host} == ${1}
132 ... Login To OS Host ${os_host} ${os_username} ${os_password}
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500133 Check If IPMI Tool Exist
134
Michael Walsh3ef2e922019-01-23 10:40:16 -0600135 ${ipmi_cmd}= Catenate ${IPMI_INBAND_CMD} ${command}
136 Qprint Issuing ${ipmi_cmd}
137 ${stdout} ${stderr}= Execute Command ${ipmi_cmd} return_stderr=True
Rahul Maheshwari20f3bf72018-12-18 04:24:20 -0600138 Return From Keyword If ${fail_on_err} == ${0} ${stderr}
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500139 Should Be Empty ${stderr} msg=${stdout}
140 [Return] ${stdout}
141
Rahul Maheshwari7a212a02016-09-05 21:17:30 -0500142
143Run External IPMI Standard Command
Michael Walsh3ef2e922019-01-23 10:40:16 -0600144 [Documentation] Run the external IPMI standard command.
Michael Walshd0e58e72019-05-14 11:07:14 -0500145 [Arguments] ${command} ${fail_on_err}=${1} ${expected_rc}=${0} &{options}
George Keishing02651f02018-04-11 02:07:16 -0500146
147 # Description of argument(s):
Michael Walsh3ef2e922019-01-23 10:40:16 -0600148 # command The IPMI command string to be executed
149 # (e.g. "power status"). Note that if
150 # ${IPMI_USER_OPTIONS} has a value (e.g.
151 # "-vvv"), it will be pre-pended to this
152 # command string.
153 # fail_on_err Fail if the IPMI command execution fails.
Michael Walshd0e58e72019-05-14 11:07:14 -0500154 # expected_rc The expected return code from the ipmi
155 # command (e.g. ${0}, ${1}, etc.).
Michael Walsh3ef2e922019-01-23 10:40:16 -0600156 # options Additional ipmitool command options (e.g.
157 # -C=3, -I=lanplus, etc.).
Michael Walsha7913892017-04-20 16:29:01 -0500158
Michael Walsh3ef2e922019-01-23 10:40:16 -0600159 ${command_string}= Process IPMI User Options ${command}
160 ${ipmi_cmd}= Create IPMI Ext Command String ${command_string} &{options}
161 Qprint Issuing ${ipmi_cmd}
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500162 ${rc} ${output}= Run And Return RC and Output ${ipmi_cmd}
George Keishing02651f02018-04-11 02:07:16 -0500163 Return From Keyword If ${fail_on_err} == ${0} ${output}
Michael Walshd0e58e72019-05-14 11:07:14 -0500164 Should Be Equal ${rc} ${expected_rc} msg=${output}
Michael Walsha7913892017-04-20 16:29:01 -0500165 [Return] ${output}
Rahul Maheshwari7a212a02016-09-05 21:17:30 -0500166
Michael Walsh3ef2e922019-01-23 10:40:16 -0600167
168Run External IPMI Raw Command
169 [Documentation] Run the external IPMI raw command.
170 [Arguments] ${command} ${fail_on_err}=${1} &{options}
171
172 # This keyword is a wrapper for 'Run External IPMI Standard Command'. See
173 # that keyword's prolog for argument details. This keyword will pre-pend
174 # the word "raw" plus a space to command prior to calling 'Run External
175 # IPMI Standard Command'.
176
177 ${output}= Run External IPMI Standard Command
178 ... raw ${command} ${fail_on_err} &{options}
179 [Return] ${output}
180
181
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500182Check If IPMI Tool Exist
183 [Documentation] Check if IPMI Tool installed or not.
184 ${output}= Execute Command which ipmitool
185 Should Not Be Empty ${output} msg=ipmitool not installed.
Rahul Maheshwari7a212a02016-09-05 21:17:30 -0500186
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500187
188Activate SOL Via IPMI
189 [Documentation] Start SOL using IPMI and route output to a file.
190 [Arguments] ${file_path}=/tmp/sol_${OPENBMC_HOST}
Michael Walsh3ef2e922019-01-23 10:40:16 -0600191
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500192 # Description of argument(s):
Michael Walsh3ef2e922019-01-23 10:40:16 -0600193 # file_path The file path on the local machine (vs.
194 # OBMC) to collect SOL output. By default
195 # SOL output is collected at
196 # /tmp/sol_<BMC_IP> else user input location.
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500197
Michael Walsh3ef2e922019-01-23 10:40:16 -0600198 ${ipmi_cmd}= Create IPMI Ext Command String sol activate usesolkeepalive
199 Qprint Issuing ${ipmi_cmd}
George Keishing2102f6b2017-06-06 08:30:10 -0500200 Start Process ${ipmi_cmd} shell=True stdout=${file_path}
Rahul Maheshwari4f360842017-06-06 15:05:01 -0500201 ... alias=sol_proc
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500202
203
204Deactivate SOL Via IPMI
205 [Documentation] Stop SOL using IPMI and return SOL output.
206 [Arguments] ${file_path}=/tmp/sol_${OPENBMC_HOST}
Michael Walsh3ef2e922019-01-23 10:40:16 -0600207
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500208 # Description of argument(s):
Michael Walsh3ef2e922019-01-23 10:40:16 -0600209 # file_path The file path on the local machine to copy
210 # SOL output collected by above "Activate
211 # SOL Via IPMI" keyword. By default it
212 # copies log from /tmp/sol_<BMC_IP>.
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500213
Michael Walsh3ef2e922019-01-23 10:40:16 -0600214 ${ipmi_cmd}= Create IPMI Ext Command String sol deactivate
215 Qprint Issuing ${ipmi_cmd}
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500216 ${rc} ${output}= Run and Return RC and Output ${ipmi_cmd}
Rahul Maheshwari4f360842017-06-06 15:05:01 -0500217 Run Keyword If ${rc} > 0 Run Keywords
Rahul Maheshwari7f48a2c2017-06-16 04:00:26 -0500218 ... Run Keyword And Ignore Error Terminate Process sol_proc
219 ... AND Return From Keyword ${output}
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500220
George Keishingaec8b872019-07-08 23:44:08 -0500221 ${output}= OperatingSystem.Get File ${file_path} encoding_errors=ignore
Rahul Maheshwari04a22042017-05-02 01:54:31 -0500222
223 # Logging SOL output for debug purpose.
224 Log ${output}
225
226 [Return] ${output}
227
228
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500229Byte Conversion
230 [Documentation] Byte Conversion method receives IPMI RAW commands as
231 ... argument in string format.
232 ... Sample argument is as follows
233 ... "0x04 0x30 9 0x01 0x00 0x35 0x00 0x00 0x00 0x00 0x00
234 ... 0x00"
235 ... IPMI RAW command format is as follows
236 ... <netfn Byte> <cmd Byte> <Data Bytes..>
237 ... This method converts IPMI command format into
238 ... dbus command format as follows
239 ... <byte:seq-id> <byte:netfn> <byte:lun> <byte:cmd>
240 ... <array:byte:data>
241 ... Sample dbus Host IPMI Received Message argument
242 ... byte:0x00 byte:0x04 byte:0x00 byte:0x30
243 ... array:byte:9,0x01,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00
Gunnar Mills38032802016-12-12 13:43:40 -0600244 [Arguments] ${args}
Gunnar Mills59204d22016-12-06 11:05:19 -0600245 ${argLength}= Get Length ${args}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500246 Set Global Variable ${arrayByte} array:byte:
Gunnar Mills59204d22016-12-06 11:05:19 -0600247 @{listargs}= Split String ${args}
248 ${index}= Set Variable ${0}
George Keishing9a089442018-12-10 09:38:50 -0600249 :FOR ${word} IN @{listargs}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500250 \ Run Keyword if ${index} == 0 Set NetFn Byte ${word}
251 \ Run Keyword if ${index} == 1 Set Cmd Byte ${word}
252 \ Run Keyword if ${index} > 1 Set Array Byte ${word}
Gunnar Mills59204d22016-12-06 11:05:19 -0600253 \ ${index}= Set Variable ${index + 1}
254 ${length}= Get Length ${arrayByte}
255 ${length}= Evaluate ${length} - 1
256 ${arrayByteLocal}= Get Substring ${arrayByte} 0 ${length}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500257 Set Global Variable ${arrayByte} ${arrayByteLocal}
Gunnar Mills59204d22016-12-06 11:05:19 -0600258 ${valueinBytesWithArray}= Catenate byte:0x00 ${netfnByte} byte:0x00
259 ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${cmdByte}
260 ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${arrayByte}
261 ${valueinBytesWithoutArray}= Catenate byte:0x00 ${netfnByte} byte:0x00
262 ${valueinBytesWithoutArray}= Catenate ${valueinBytesWithoutArray} ${cmdByte}
Michael Walsh3ef2e922019-01-23 10:40:16 -0600263 # To Check scenario for smaller IPMI raw commands with only 2 arguments
264 # instead of usual 12 arguments.
265 # Sample small IPMI raw command: Run IPMI command 0x06 0x36
266 # If IPMI raw argument length is only 9 then return value in bytes without
267 # array population.
268 # Equivalent dbus-send argument for smaller IPMI raw command:
269 # byte:0x00 byte:0x06 byte:0x00 byte:0x36
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500270 Run Keyword if ${argLength} == 9 Return from Keyword ${valueinBytesWithoutArray}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600271 [Return] ${valueinBytesWithArray}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500272
273
274Set NetFn Byte
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500275 [Documentation] Set the network function byte.
276 [Arguments] ${word}
277 ${netfnByteLocal}= Catenate byte:${word}
278 Set Global Variable ${netfnByte} ${netfnByteLocal}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500279
Michael Walsh3ef2e922019-01-23 10:40:16 -0600280
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500281Set Cmd Byte
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500282 [Documentation] Set the command byte.
283 [Arguments] ${word}
284 ${cmdByteLocal}= Catenate byte:${word}
285 Set Global Variable ${cmdByte} ${cmdByteLocal}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500286
Michael Walsh3ef2e922019-01-23 10:40:16 -0600287
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500288Set Array Byte
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500289 [Documentation] Set the array byte.
290 [Arguments] ${word}
291 ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByte} ${word}
292 ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByteLocal} ,
293 Set Global Variable ${arrayByte} ${arrayByteLocal}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500294
Michael Walsh3ef2e922019-01-23 10:40:16 -0600295
Chris Austenb29d2e82016-06-07 12:25:35 -0500296Copy ipmitool
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500297 [Documentation] Copy the ipmitool to the BMC.
298 ${ipmitool_error}= Catenate The ipmitool program could not be found in the tools directory.
299 ... It is not part of the automation code by default. You must manually copy or link the correct openbmc
300 ... version of the tool in to the tools directory in order to run this test suite.
301
302 OperatingSystem.File Should Exist tools/ipmitool msg=${ipmitool_error}
Chris Austenb29d2e82016-06-07 12:25:35 -0500303
304 Import Library SCPLibrary WITH NAME scp
305 scp.Open connection ${OPENBMC_HOST} username=${OPENBMC_USERNAME} password=${OPENBMC_PASSWORD}
306 scp.Put File tools/ipmitool /tmp
307 SSHLibrary.Open Connection ${OPENBMC_HOST}
308 Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
309 Execute Command chmod +x /tmp/ipmitool
Sridevi Ramesh0c34f692017-04-25 02:40:32 -0500310
Michael Walsh3ef2e922019-01-23 10:40:16 -0600311
Sridevi Ramesh0c34f692017-04-25 02:40:32 -0500312Initiate Host Boot Via External IPMI
313 [Documentation] Initiate host power on using external IPMI.
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500314 [Arguments] ${wait}=${1}
Michael Walsh3ef2e922019-01-23 10:40:16 -0600315
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500316 # Description of argument(s):
Michael Walsh3ef2e922019-01-23 10:40:16 -0600317 # wait Indicates that this keyword should wait
318 # for host running state.
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500319
Sridevi Ramesh0c34f692017-04-25 02:40:32 -0500320 ${output}= Run External IPMI Standard Command chassis power on
321 Should Not Contain ${output} Error
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500322
323 Run Keyword If '${wait}' == '${0}' Return From Keyword
324 Wait Until Keyword Succeeds 10 min 10 sec Is Host Running
Sridevi Ramesh0c34f692017-04-25 02:40:32 -0500325
Michael Walsh3ef2e922019-01-23 10:40:16 -0600326
Sridevi Ramesh0c34f692017-04-25 02:40:32 -0500327Initiate Host PowerOff Via External IPMI
328 [Documentation] Initiate host power off using external IPMI.
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500329 [Arguments] ${wait}=${1}
Michael Walsh3ef2e922019-01-23 10:40:16 -0600330
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500331 # Description of argument(s):
Michael Walsh3ef2e922019-01-23 10:40:16 -0600332 # wait Indicates that this keyword should wait
333 # for host off state.
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500334
Sridevi Ramesh0c34f692017-04-25 02:40:32 -0500335 ${output}= Run External IPMI Standard Command chassis power off
336 Should Not Contain ${output} Error
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500337
338 Run Keyword If '${wait}' == '${0}' Return From Keyword
339 Wait Until Keyword Succeeds 3 min 10 sec Is Host Off
340
Michael Walsh3ef2e922019-01-23 10:40:16 -0600341
Rahul Maheshwari982fee42017-05-03 00:33:15 -0500342Get Host State Via External IPMI
343 [Documentation] Returns host state using external IPMI.
344
345 ${output}= Run External IPMI Standard Command chassis power status
346 Should Not Contain ${output} Error
347 ${output}= Fetch From Right ${output} ${SPACE}
348
349 [Return] ${output}
George Keishingb4d4a4a2018-08-27 13:35:39 -0500350
351
352Set BMC Network From Host
353 [Documentation] Set BMC network from host.
354 [Arguments] ${nw_info}
355
356 # Description of argument(s):
Michael Walsh3ef2e922019-01-23 10:40:16 -0600357 # nw_info A dictionary containing the network
358 # information to apply.
George Keishingb4d4a4a2018-08-27 13:35:39 -0500359
360 Run Inband IPMI Standard Command
361 ... lan set 1 ipaddr ${nw_info['IP Address']}
362
363 Run Inband IPMI Standard Command
364 ... lan set 1 netmask ${nw_info['Subnet Mask']}
365
366 Run Inband IPMI Standard Command
367 ... lan set 1 defgw ipaddr ${nw_info['Default Gateway IP']}
Rahul Maheshwaric3d1e962019-03-06 23:53:21 -0600368
369
370Verify IPMI Username And Password
371 [Documentation] Verify that user is able to run IPMI command
372 ... with given username and password.
373 [Arguments] ${username} ${password}
374
375 # Description of argument(s):
376 # username The user name (e.g. "root", "robert", etc.).
377 # password The user password (e.g. "0penBmc", "0penBmc1", etc.).
378
Tony Leef9379e82020-01-08 18:20:38 +0800379 ${output}= Wait Until Keyword Succeeds 15 sec 5 sec Run External IPMI Standard Command
Rahul Maheshwaric3d1e962019-03-06 23:53:21 -0600380 ... sel info U=${username} P=${password}
381 Should Contain ${output} SEL Information msg=SEL information not present
Rahul Maheshwari75e91fe2019-03-29 05:32:28 -0500382
383
384IPMI Create User
385 [Documentation] Create IPMI user with given userid and username.
386 [Arguments] ${userid} ${username}
387
388 # Description of argument(s):
389 # userid The user ID (e.g. "1", "2", etc.).
390 # username The user name (e.g. "root", "robert", etc.).
391
392 ${ipmi_cmd}= Catenate user set name ${userid} ${username}
393 ${resp}= Run IPMI Standard Command ${ipmi_cmd}
394 ${user_info}= Get User Info ${userid}
395 Should Be Equal ${user_info['user_name']} ${username}
396
397
398Set Channel Access
399 [Documentation] Verify that user is able to run IPMI command
400 ... with given username and password.
Tony Lee7c5f4b22019-12-06 17:21:31 +0800401 [Arguments] ${userid} ${options} ${channel_number}=${CHANNEL_NUMBER}
Rahul Maheshwari75e91fe2019-03-29 05:32:28 -0500402
403 # Description of argument(s):
404 # userid The user ID (e.g. "1", "2", etc.).
405 # options Set channel command options (e.g.
406 # "link=on", "ipmi=on", etc.).
407 # channel_number The user's channel number (e.g. "1").
408
409 ${ipmi_cmd}= Catenate SEPARATOR=
Tony Lee7c5f4b22019-12-06 17:21:31 +0800410 ... channel setaccess${SPACE}${channel_number}${SPACE}${userid}
Rahul Maheshwari75e91fe2019-03-29 05:32:28 -0500411 ... ${SPACE}${options}
412 Run IPMI Standard Command ${ipmi_cmd}
Rahul Maheshwari3e61ce62019-06-18 02:09:01 -0500413
414
415Delete All Non Root IPMI User
416 [Documentation] Delete all non-root IPMI user.
417
Michael Walsh34c79af2019-12-09 11:46:48 -0600418 # Get complete list of user info records.
419 ${user_info}= Get User Info ${EMPTY}
420 # Remove header record.
421 ${user_info}= Filter Struct ${user_info} [('user_name', None)] invert=1
422 ${non_empty_user_info}= Filter Struct ${user_info} [('user_name', '')] invert=1
423 ${non_root_user_info}= Filter Struct ${non_empty_user_info} [('user_name', 'root')] invert=1
424
425 FOR ${user_record} IN @{non_root_user_info}
426 Run IPMI Standard Command user set name ${user_record['user_id']} ""
427 Sleep 5s
Sushma M M1cc21272020-01-05 23:47:46 -0600428 END