blob: 31db911cb16235ec974e8c15945f62fea6cce58e [file] [log] [blame]
Tony Lee6c998f72020-03-09 18:28:35 +08001*** Settings ***
2Documentation This suite tests IPMI Payload in OpenBMC.
3
4Resource ../lib/ipmi_client.robot
5Resource ../lib/openbmc_ffdc.robot
nagarjunb22a2255de2022-05-25 19:15:10 +05306Resource ../lib/bmc_network_utils.robot
Tony Lee6c998f72020-03-09 18:28:35 +08007Variables ../data/ipmi_raw_cmd_table.py
nagarjunb22a2255de2022-05-25 19:15:10 +05308Library ../lib/ipmi_utils.py
9
nagarjunb765535a2022-06-01 12:59:00 +053010Suite Setup IPMI Payload Setup Execution
nagarjunb22a2255de2022-05-25 19:15:10 +053011Test Teardown FFDC On Test Case Fail
12
George Keishing87dc4422023-10-20 12:56:30 +053013Force Tags IPMI_Payload
nagarjunb22a2255de2022-05-25 19:15:10 +053014
15*** Variables ***
George Keishing87dc4422023-10-20 12:56:30 +053016
nagarjunb2293e6e242022-06-10 21:36:19 +053017${user_priv} 2
18${operator_priv} 3
19${admin_level_priv} 4
nagarjunb2293e6e242022-06-10 21:36:19 +053020${new_user_passwd} 0penBmc1
21${standard_payload_type_resp} 03 00
22${session_setup_payload_resp} 3f 00
23&{standard_payload_types} ipmi_message=0 sol=1
24&{session_setup_payload_types} RMCP+open_session_request=0x10
25 ... RMCP+open_session_response=0x11
26 ... RAKP_msg_1=0x12
27 ... RAKP_msg_2=0x13
28 ... RAKP_msg_3=0x14
29 ... RAKP_msg_4=0x15
Tony Lee6c998f72020-03-09 18:28:35 +080030
31
32*** Test Cases ***
33
34Test Get Payload Activation Status
35 [Documentation] Test get payload activation status.
36 [Tags] Test_Get_Payload_Activation_Status
37
38 # SOL is the payload currently supported for payload status.
39 # Currently supports only one SOL session.
40 # Response Data
41 # 01 instance 1 is activated.
42 # 00 instance 1 is deactivated.
43 ${payload_status}= Get Payload Activation Status
44 Should Contain Any ${payload_status} 01 00
45
46
47Test Activate Payload
48 [Documentation] Test activate payload via IPMI raw command.
49 [Tags] Test_Activate_Payload
50
51 ${payload_status}= Get Payload Activation Status
52 Run Keyword If '${payload_status}' == '01' Deactivate Payload
53
54 Activate Payload
55
56 ${payload_status}= Get Payload Activation Status
57 Should Contain ${payload_status} 01
58
59
60Test Deactivate Payload
61 [Documentation] Test deactivate payload via IPMI raw command.
62 [Tags] Test_Deactivate_Payload
63
64 ${payload_status}= Get Payload Activation Status
65 Run Keyword If '${payload_status}' == '00' Activate Payload
66
67 Deactivate Payload
68
69 ${payload_status}= Get Payload Activation Status
70 Should Contain ${payload_status} 00
71
72
73Test Get Payload Instance Info
74 [Documentation] Test Get Payload Instance via IPMI raw command.
75 [Tags] Test_Get_Payload_Instance_Info
76
77 ${payload_status}= Get Payload Activation Status
78 Run keyword If '${payload_status}' == '01'
79 ... Deactivate Payload
80
81 # First four bytes should be 00 if given instance is not activated.
82 ${resp}= Run IPMI Command
83 ... ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][0]}
84 Should Contain ${resp} ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][1]}
85 Activate Payload
86
87 # First four bytes should be session ID when payload is activated.
88 ${resp}= Run IPMI Command
89 ... ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][0]}
90 Should Not Contain ${resp} ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][1]}
91
92
nagarjunb22a2255de2022-05-25 19:15:10 +053093Verify Set User Access Payload For Standard Payload SOL
94 [Documentation] Disable standard payload for SOL and verify IPMI sol activate command does not work.
95 [Tags] Verify_Set_User_Access_Payload_For_Standard_Payload_SOL
96 [Teardown] Run Keywords Set User Access Payload For Given User ${user_id_in_hex}
97 ... AND Delete Created User ${userid}
98 ... AND FFDC On Test Case Fail
99
100 ${userid} ${username}= Create And Verify IPMI User
101 ${user_id_in_hex}= Convert To Hex ${userid}
102 ${userid_in_hex_format}= Convert To Hex ${userid} prefix=0x length=2
103
104 # Get default user access payload values.
105 ${default_user_access_payload}= Get User Access Payload For Given Channel ${userid_in_hex_format}
106
107 # Disable Standard payload 1 via set user access payload command.
108 Set User Access Payload For Given User ${user_id_in_hex} Disable
109
110 Verify Standard Payload ${userid_in_hex_format} ${username} Disabled
111
112
113Verify Set User Access Payload For Operator Privileged User
114 [Documentation] Try to set user access payload using operator privileged user and expect error.
115 [Tags] Verify_Set_User_Access_Payload_For_Operator_Privileged_User
116 [Teardown] Run Keywords Delete Created User ${userid} AND FFDC On Test Case Fail
117
118 ${userid} ${username}= Create And Verify IPMI User ${operator_priv} Operator
119
120 ${payload_raw_cmd}= Catenate ${IPMI_RAW_CMD['Payload']['Set_User_Access_Payload'][0]}
121 ... ${CHANNEL_NUMBER} 0x${user_id} 0x02 0x00 0x00 0x00
122
123 Run Keyword and Expect Error *Unable to establish IPMI*
124 ... Run External IPMI Raw Command ${payload_raw_cmd} U=${userid} P=${new_user_passwd} L=Operator
125
126
nagarjunb765535a2022-06-01 12:59:00 +0530127Verify Set User Access Payload For Invalid User
128 [Documentation] Verify set user access payload IPMI command for invalid user.
129 [Tags] Verify_Set_User_Access_Payload_For_Invalid_User
130
131 # Get Random invalid user ID.
132 ${invalid_userid}= Get Invalid User ID
133
134 ${raw_cmd}= Catenate ${IPMI_RAW_CMD['Payload']['Set_User_Access_Payload'][0]}
135 ... ${CHANNEL_NUMBER} ${invalid_userid} 0x02 0x00 0x00 0x00
136
137 Verify Invalid IPMI Command ${raw_cmd} 0xcc
138
139
140Verify Set User Access Payload For Invalid Channel Number
141 [Documentation] Verify set user access payload IPMI command for invalid channel number.
George Keishingf6b4d532022-07-08 07:07:54 -0500142 [Tags] Verify_Set_User_Access_Payload_For_Invalid_Channel_Number
nagarjunb765535a2022-06-01 12:59:00 +0530143 [Teardown] Delete Created User ${userid}
144
145 ${userid} ${username}= Create And Verify IPMI User
146
147 FOR ${channel} IN @{inactive_channel_list}
148
149 Verify Set User Access Payload For Invalid Channel ${userid} ${channel}
150 END
151
152
153Verify Get User Access Payload For User Access privilege
154 [Documentation] Verify get user access payload for user access(Read-only) privileged user.
155 [Tags] Verify_Get_User_Access_Payload_For_User_Access_privilege
156 [Teardown] Delete Created User ${userid}
157
158 ${userid} ${username}= Create And Verify IPMI User ${user_priv} User
159
160 ${raw_command}= Catenate ${IPMI_RAW_CMD['Payload']['Get_User_Access_Payload'][0]}
161 ... ${CHANNEL_NUMBER} ${user_id}
162
163 Run Keyword and Expect Error *Unable to establish IPMI*
164 ... Run External IPMI Raw Command ${raw_command} U=${userid} P=${new_user_passwd} L=User
165
166
167Verify Get User Access Payload For Invalid User
168 [Documentation] Verify get user access payload IPMI command for invalid user.
169 [Tags] Verify_Get_User_Access_Payload_For_Invalid_User
170
171 ${invalid_userid}= Get Invalid User ID
172
173 Verify Get User Access Payload For Invalid User Or Channel ${invalid_userid} ${CHANNEL_NUMBER}
174
175
176Verify Get User Access Payload For Invalid Channel Number
177 [Documentation] Verify get user access payload IPMI command for invalid channel number.
178 [Tags] Verify_Get_User_Access_Payload_For_Invalid_Channel_Number
179 [Teardown] Delete Created User ${userid}
180
181 ${userid} ${username}= Create And Verify IPMI User
182 #${invalid_channels}= Get Invalid Channel Number
183
184 FOR ${channel} IN @{inactive_channel_list}
185 Verify Get User Access Payload For Invalid User Or Channel ${userid} ${channel}
186 END
187
188
nagarjunb2293e6e242022-06-10 21:36:19 +0530189Verify Get Channel Payload Version
190 [Documentation] Verify payload version for all supported payload type in
191 ... all active channels.
192 [Tags] Verify_Get_Channel_Payload_Version
193 [Template] Verify Payload Version
194
195 FOR ${channel} IN @{active_channel_list}
196 # Input Channel.
197 ${channel}
198 END
199
200Verify Get Channel Payload Version For Invalid Channel
201 [Documentation] Verify get channel payload version IPMI command for invalid channel.
202 [Tags] Verify_Get_Channel_Payload_Version_For_Invalid_Channel
203 [Template] Verify Payload Version For Invalid Channel
204
205 FOR ${invalid_channel_number} IN @{inactive_channel_list}
206 # channel number payload types.
207 ${invalid_channel_number} &{standard_payload_types}
208 ${invalid_channel_number} &{session_setup_payload_types}
209 END
210
211
212Verify Get Channel Payload Support
213 [Documentation] Verify get channel payload support IPMI command for active channels.
214 [Tags] Verify_Get_Channel_Payload_Support
215 [Template] Verify Payload Support
216
217 FOR ${channel} IN @{active_channel_list}
218 # Input channel.
219 ${channel}
220 END
221
222Verify Get Channel Payload Support For Invalid Channel
223 [Documentation] Verify get channel payload support IPMI command for invalid channels.
224 [Tags] Verify_Get_Channel_Payload_Support_For_Invalid_Channel
225 [Template] Verify Payload Support
226
227 FOR ${channel} IN @{inactive_channel_list}
228 # Input channel. Invalid channel intimation.
229 ${channel} ${1}
230 END
231
232
Tony Lee6c998f72020-03-09 18:28:35 +0800233*** Keywords ***
234
nagarjunb765535a2022-06-01 12:59:00 +0530235IPMI Payload Setup Execution
236 [Documentation] Get active and inactive/invalid channels from channel_config.json file
237 ... in list type and set it as suite variable.
238
239 # Get active channel list and set as a suite variable.
240 @{active_channel_list}= Get Active Ethernet Channel List current_channel=1
241 Set Suite Variable @{active_channel_list}
242
243 # Get Inactive/Invalid channel list and set as a suite variable.
244 @{inactive_channel_list}= Get Invalid Channel Number List
245 Set Suite Variable @{inactive_channel_list}
246
247
Tony Lee6c998f72020-03-09 18:28:35 +0800248Get Payload Activation Status
249 [Documentation] Get payload activation status.
250
251 ${resp}= Run IPMI Command
252 ... ${IPMI_RAW_CMD['Payload']['Get_Payload_Activation_Status'][0]}
253
254 @{resp}= Split String ${resp}
255
256 ${payload_status}= Set Variable ${resp[1]}
257
258 [return] ${payload_status}
259
260
261Activate Payload
262 [Documentation] Activate Payload.
263
264 ${resp}= Run IPMI Command
265 ... ${IPMI_RAW_CMD['Payload']['Activate_Payload'][0]}
266 Should Contain ${resp} ${IPMI_RAW_CMD['Payload']['Activate_Payload'][1]}
267
268
269Deactivate Payload
270 [Documentation] Deactivate Payload.
271
272 ${resp}= Run IPMI Command
273 ... ${IPMI_RAW_CMD['Payload']['Deactivate_Payload'][0]}
274 Should Be Empty ${resp}
nagarjunb22a2255de2022-05-25 19:15:10 +0530275
276
277Get User Access Payload For Given Channel
278 [Documentation] Execute get user access payload IPMI command for given channel
279 ... and return response.
280 [Arguments] ${user_id} ${channel_number}=${CHANNEL_NUMBER}
281
282 # Description of argument(s):
283 # user_id The user ID (e.g. "1", "2", etc.).
284 # channel_number Input channel number(e.g. "1", "2").
285
286 ${raw_command}= Catenate ${IPMI_RAW_CMD['Payload']['Get_User_Access_Payload'][0]}
287 ... ${channel_number} ${user_id}
288 ${resp}= Run External IPMI Raw Command ${raw_command}
289 [Return] ${resp}
290
291
292Create And Verify IPMI User
293 [Documentation] Create IPMI User, set password, set privilege and enable the user.
294 [Arguments] ${user_privilege_level}=${admin_level_priv} ${privilege}=Administrator
295
296 # Description of argument(s):
297 # user_privilege_level User Privilege level in integer.
298 # (e.g. 4-Administrator, 3-Operator, 2-Readonly).
299 # privilege User Privilege in Wordings.
300 # (e.g. "Administrator", "Operator", "ReadOnly").
301
302 ${random_user_id} ${random_user_name}= Create Random IPMI User
303 Set User Password ${random_user_id} ${new_user_passwd} 16
304 Set And Verify User Access Privilege ${random_user_id} ${user_privilege_level}
305 Verify Username And Password ${random_user_name} ${new_user_passwd} L=${privilege}
306
307 [Return] ${random_user_id} ${random_user_name}
308
309
310Set User Password
311 [Documentation] Set user password for given user ID.
312 [Arguments] ${user_id} ${password} ${password_option}
313
314 # Description of argument(s):
315 # user_id The user ID (e.g. "1", "2", etc.).
316 # password The user password (e.g. "0penBmc", "0penBmc1", etc.).
317 # password_option Password length option to be given in IPMI command (e.g. "16", "20").
318
319 Run IPMI Standard Command user set password ${user_id} ${password} ${password_option}
320
321Set And Verify User Access Privilege
322 [Documentation] Set User Access Privilege, enable and verify user for given user ID.
323 [Arguments] ${user_id} ${privilege_level}
324
325 # Description of argument(s):
326 # user_id The user ID (e.g. "1", "2", etc.).
327 # privilege_level User Privilege level in hex value.
328 # (e.g. 0x04-Administrator, 0x03-Operator, 0x02-Readonly).
329
330 Set Channel Access ${_user_id} ipmi=on privilege=${privilege_level}
331
332 # Delay added for user privilege to get set.
333 Sleep 5s
334
335 Enable IPMI User And Verify ${user_id}
336
337
338Verify Username And Password
339 [Documentation] Verify that newly created user is able to run IPMI command
340 ... with given username and password.
341 [Arguments] ${username} ${password} &{options}
342
343 # Description of argument(s):
344 # username The user name (e.g. "root", "robert", etc.).
345 # password The user password (e.g. "0penBmc", "0penBmc1", etc.).
346 # options Additional ipmitool command options (e.g "-L=Operator","-C=3").
347
348 Wait Until Keyword Succeeds 15 sec 5 sec Run External IPMI Raw Command
349 ... ${IPMI_RAW_CMD['Device GUID']['Get'][0]} U=${username} P=${password} &{options}
350
351
352Verify Standard Payload
353 [Documentation] Verify standard payload is disabled or enabled.
354 [Arguments] ${user_id} ${user_name} ${standard_payload}=Enabled
355
356 # Description of argument(s):
357 # user_id The user ID (e.g. "1", "2", etc.).
358 # username The user name (e.g. "root", "robert", etc.).
359 # standard_payload Enabled or Disabled.
360
361 # Verify the standard payload 1 (sol) is disabled.
362 ${get_user_access_payload}= Get User Access Payload For Given Channel ${user_id}
363 @{get_user_access_cmd_resp_list}= Split String ${get_user_access_payload}
364
365 Run Keyword If '${standard_payload}' == 'Disabled'
366 ... Should Be Equal ${get_user_access_cmd_resp_list}[0] 00
367 ... ELSE
368 ... Should Be Equal ${get_user_access_cmd_resp_list}[0] 02
369
370 Run Keyword If '${standard_payload}' == 'Disabled'
371 ... Verify Sol Activate Disabled ${user_name}
372
373
374Verify Sol Activate Disabled
375 [Documentation] Verify SOL activate IPMI command is not working.
376 [Arguments] ${user_name}
377
378 # Description of argument(s):
379 # username The user name (e.g. "root", "robert", etc.).
380
381 ${resp}= Run External IPMI Standard Command
382 ... sol activate expected_rc=${1} U=${username} P=${new_user_passwd}
383
384 Should Contain ${resp} SOL payload disabled
385
386
387Set User Access Payload For Given User
388 [Documentation] Set the user access payload on given user, channel and return response.
George Keishinga91601b2023-03-21 09:35:49 +0530389 [Arguments] ${user_id} ${operation_mode}=Enable ${oempayload_value}=0x00
390 ... ${standard_payload_value}=0x02
nagarjunb22a2255de2022-05-25 19:15:10 +0530391
392 # Description of argument(s):
393 # user_id The user ID (e.g. "1", "2", etc.).
394 # operation_mode Enable or Disable payload type.
395 # oempayload_value Oempayload in hex (e.g. "0x00", "0x01", "0x02", "0x04" etc).
396 # standard_payload_value Standard payload type IPMI or SOL.
397 # (e.g. 0x01 - IPMI, 0x02- SOL).
398
399 # If operation mode is disable 2nd byte of raw command is 4${user_id}.
400 # (e.g) 2n byte will be 0x4a (if user_id is a).
401 # If operation mode is enable 2nd byte of raw command is 0${user_id}.
402 # (e.g.) 3rd byte will be 0x0a (if user_id is a).
403 # 0x02- standard payload for SOL, 0x01 standard payload for IPMI.
404 # 3rd byte represent standard payload enables 1 (SOL).
405 # 4th to 6th byte represent standard payload enables 2 and OEM payload 1 & 2 respectively.
406
407 ${operation_mode_value}= Set Variable If '${operation_mode}' == 'Enable'
408 ... 0 4
409 ${set_cmd}= Catenate ${IPMI_RAW_CMD['Payload']['Set_User_Access_Payload'][0]}
410 ... ${CHANNEL_NUMBER} 0x${operation_mode_value}${user_id} ${standard_payload_value} 0x00 ${oempayload_value} 0x00
411
412 ${resp}= Run IPMI Command ${set_cmd}
413
nagarjunb765535a2022-06-01 12:59:00 +0530414 [Return] ${resp}
415
416
417Get Invalid User ID
418 [Documentation] Get random invalid user ID using "channel getaccess" IPMI standard command.
419
420 # Python module: get_user_info(userid, channel_number=1)
Nagarjun B26499142023-02-16 15:20:14 +0530421 ${user_info}= Get User Info ${EMPTY} ${CHANNEL_NUMBER}
nagarjunb765535a2022-06-01 12:59:00 +0530422 ${user_info}= Filter Struct ${user_info} [('user_name', None)] invert=1
423 ${empty_user_info}= Filter Struct ${user_info} [('user_name', '')]
424 @{invalid_userid_list}= Create List
425 FOR ${user_record} IN @{empty_user_info}
426 Append To List ${invalid_userid_list} ${user_record['user_id']}
427 END
428 ${invalid_user_id}= Evaluate random.choice(${invalid_userid_list}) random
429
430 [Return] ${invalid_user_id}
431
432
433Verify Set User Access Payload For Invalid Channel
434 [Documentation] Verify set user payload command for invalid channels.
435 [Arguments] ${user_id} ${channel_number}
436
437 # Description of argument(s):
438 # user_id The user ID (e.g. "1", "2", etc.).
439 # channel_number Input channel number.
440
441 ${channel_number}= Convert To Hex ${channel_number} prefix=0x
442 ${user_id}= Convert To Hex ${user_id} prefix=0x
443 ${raw_cmd}= Catenate ${IPMI_RAW_CMD['Payload']['Set_User_Access_Payload'][0]}
444 ... ${channel_number} ${user_id} 0x02 0x00 0x00 0x00
445
446 Verify Invalid IPMI Command ${raw_cmd} 0xcc
447
448
449Verify Get User Access Payload For Invalid User Or Channel
450 [Documentation] Verify get user payload command for invalid userid or invalid channels.
451 [Arguments] ${user_id} ${channel_number}
452
453 # Description of argument(s):
454 # user_id The user ID (e.g. "1", "2", etc.).
455 # channel_number Input channel number.
456
457 ${channel_number}= Convert To Hex ${channel_number} prefix=0x
458 ${user_id}= Convert To Hex ${user_id} prefix=0x
459 ${raw_cmd}= Catenate ${IPMI_RAW_CMD['Payload']['Get_User_Access_Payload'][0]}
460 ... ${channel_number} ${user_id}
461
George Keishingf6b4d532022-07-08 07:07:54 -0500462 Verify Invalid IPMI Command ${raw_cmd} 0xcc
nagarjunb2293e6e242022-06-10 21:36:19 +0530463
464
465Verify Payload Type Version
466 [Documentation] Verify supported payload version.
467 [Arguments] ${channel_number} &{payload_type_dict}
468
469 # Description of argument(s):
470 # channel_number Input channel number.
471 # payload_type_dict Supported payload type in dictionary type.
472 # standard_payload_types and session_setup_payload_types which we use
473 # in this keyword are defined in variable section.
474
475 FOR ${payload_type_name} ${payload_type_number} IN &{payload_type_dict}
476 ${get_cmd}= Catenate ${IPMI_RAW_CMD['Payload']['Get_Channel_Payload_Version'][0]}
477 ... ${channel_number} ${payload_type_number}
478
479 ${resp}= Run External IPMI Raw Command ${get_cmd}
480 ${resp}= Strip String ${resp}
481 Should Be Equal ${resp} 10
482 END
483
484
485Verify Payload Version For Invalid Channel
486 [Documentation] Verify payload version for invalid channel.
487 [Arguments] ${channel_number} &{payload_type_dict}
488
489 # Description of argument(s):
490 # channel_number Input channel number.
491 # payload_type_dict Supported payload type in dictionary type.
492 # standard_payload_types and session_setup_payload_types which we use
493 # in this keyword are defined in variable section.
494
495 ${channel_number}= Convert To Hex ${channel_number} prefix=0x
496 FOR ${payload_type_name} ${payload_type_number} IN &{payload_type_dict}
497 ${get_cmd}= Catenate ${IPMI_RAW_CMD['Payload']['Get_Channel_Payload_Version'][0]}
498 ... ${channel_number} ${payload_type_number}
499
500 Verify Invalid IPMI Command ${get_cmd} 0xcc
501 END
502
503
504Verify Payload Version
505 [Documentation] Verify supported payload version on given channel number.
506 [Arguments] ${channel_number}
507
508 # Description of argument(s):
509 # channel_number Input channel number.
510
511 Verify Payload Type Version ${channel_number} &{standard_payload_types}
512 Verify Payload Type Version ${channel_number} &{session_setup_payload_types}
513
514
515Verify Payload Support
516 [Documentation] Verify payload support on given channel number.
517 [Arguments] ${channel_number} ${invalid_channel}=${0}
518
519 # Description of argument(s):
520 # channel_number Input channel number.
521 # invalid_channel This argument indicates whether we checking payload support command
522 # for Invalid channel or not.
523 # (e.g. 1 indicates checking for invalid channel, 0 indicates valid channel).
524
525 ${channel_number}= Convert To Hex ${channel_number} prefix=0x
526 ${raw_cmd}= Catenate ${IPMI_RAW_CMD['Payload']['Get_Channel_Payload_Support'][0]} ${channel_number}
527
528 Run Keyword And Return If '${invalid_channel}' == '${1}'
529 ... Verify Invalid IPMI Command ${raw_cmd} 0xcc
530
531 # will be executed only if invalid_channel == 0.
532 ${resp}= Run External IPMI Raw Command ${raw_cmd}
533
534 ${resp}= Strip String ${resp}
535 ${expected_resp}= Catenate ${standard_payload_type_resp} ${session_setup_payload_resp} 00 00 00 00
536 Should Be Equal ${expected_resp} ${resp}