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