1*** Settings *** 2 3Documentation Test Save Area feature of Management Console on BMC. 4 5Resource ../../lib/rest_client.robot 6Resource ../../lib/openbmc_ffdc.robot 7Resource ../../lib/resource.robot 8Resource ../../lib/bmc_redfish_utils.robot 9Resource ../../lib/utils.robot 10Resource ../../lib/bmc_redfish_resource.robot 11 12Suite Setup Suite Setup Execution 13Test Teardown Test Teardown Execution 14Suite Teardown Suite Teardown Execution 15 16*** Variables *** 17 18${MAXIMUM_SIZE_MESSAGE} File size exceeds maximum allowed size[500KB] 19${FILE_UPLOAD_MESSAGE} File Created 20${FILE_DELETED_MESSAGE} File Deleted 21${FILE_UPDATED} File Updated 22${FORBIDDEN_MESSAGE} Forbidden 23${ERROR_MESSAGE} Error while creating the file 24${RESOURCE_NOT_FOUND} Resource Not Found 25 26*** Test Cases *** 27 28Redfish Upload Partition File To BMC 29 [Documentation] Upload partition file to BMC using redfish. 30 [Tags] Redfish_Upload_Partition_File_To_BMC 31 [Template] Redfish Upload Partition File 32 33 # file_name 34 500KB_file 35 36 37Redfish Fail To Upload Partition File To BMC 38 [Documentation] Fail to upload partition file to BMC using redfish. 39 [Tags] Redfish_Fail_To_Upload_Partition_File_To_BMC 40 [Template] Redfish Fail To Upload Partition File 41 42 # file_name 43 501KB_file 44 45 46Redfish Upload Multiple Partition File To BMC 47 [Documentation] Upload multiple partition file to BMC using redfish. 48 [Tags] Redfish_Upload_Multiple_Partition_File_To_BMC 49 [Template] Redfish Upload Partition File 50 51 # file_name 52 250KB_file,500KB_file 53 54 55Redfish Fail To Upload Multiple Partition File To BMC 56 [Documentation] Fail to upload multiple partition file to BMC using redfish. 57 [Tags] Redfish_Fail_To_Upload_Multiple_Partition_File_To_BMC 58 [Template] Redfish Fail To Upload Partition File 59 60 # file_name 61 650KB_file,501KB_file 62 63 64Redfish Partition File Upload Post BMC Reboot 65 [Documentation] Upload partition file to BMC using redfish, after the BMC reboot. 66 [Tags] Redfish_Partition_File_Upload_Post_BMC_Reboot 67 [Template] Verify Partition File Upload Post BMC Reboot 68 69 # file_name 70 500KB_file 71 72 73Redfish Partition File Persistency On BMC Reboot 74 [Documentation] Upload partition file to BMC using redfish and is same after reboot. 75 [Tags] Redfish_Partition_File_Persistency_On_BMC_Reboot 76 [Template] Redfish Partition File Persistency 77 78 # file_name 79 500KB_file 80 81 82Redfish Multiple Partition File Persistency On BMC Reboot 83 [Documentation] Upload partition file to BMC using redfish and is same after reboot. 84 [Tags] Redfish_Multiple_Partition_File_Persistency_On_BMC_Reboot 85 [Template] Redfish Partition File Persistency 86 87 # file_name 88 250KB_file,500KB_file 89 90 91Redfish Read Partition File On BMC 92 [Documentation] Upload partition file to BMC using redfish and verify the content. 93 [Tags] Redfish_Read_Partition_File_On_BMC 94 [Template] Redfish Read Partition File 95 96 # file_name reboot_flag 97 testfile False 98 testfile01,testfile02 False 99 100 101Redfish Read Partition File On BMC Reboot 102 [Documentation] Upload partition file to BMC using redfish and verify the content after reboot. 103 [Tags] Check_Redfish_Read_Partition_File_On_BMC_Reboot 104 [Template] Redfish Read Partition File 105 106 # file_name reboot_flag 107 testfile True 108 testfile01,testfile02 True 109 110 111Redfish Update Partition File On BMC 112 [Documentation] Upload partition file to BMC using redfish and verify the content. 113 [Tags] Redfish_Update_Partition_File_On_BMC 114 [Template] Redfish Update Partition File With Different Content 115 116 # file_name reboot_flag 117 testfile01 False 118 119 120Redfish Update Partition File On BMC Reboot 121 [Documentation] Upload partition file to BMC using redfish and verify the content after the reboot. 122 [Tags] Redfish_Update_Partition_File_On_BMC_Reboot 123 [Template] Redfish Update Partition File With Different Content 124 125 # file_name reboot_flag 126 testfile01 True 127 128 129Redfish Persistency Update Partition File On BMC 130 [Documentation] Upload partition file to BMC using redfish and verify the content. 131 [Tags] Redfish_Persistency_Update_Partition_File_On_BMC 132 [Template] Redfish Update Partition File With Same Content 133 134 # file_name reboot_flag 135 testfile01 False 136 137 138Redfish Persistency Update Partition File On BMC Reboot 139 [Documentation] Upload partition file to BMC using redfish and verify the content after the reboot. 140 [Tags] Redfish_Persistency_Update_Partition_File_On_BMC_Reboot 141 [Template] Redfish Update Partition File With Same Content 142 143 # file_name reboot_flag 144 testfile01 True 145 146 147Redfish Delete Non Existence Of Partition File 148 [Documentation] Delete the partition file if do not exists. 149 [Tags] Redfish_Delete_Non_Existence_Of_Partition_File 150 [Template] Redfish Delete Non Existence Partition File 151 152 # file_name 153 testfile01 154 155 156Verify One Thousand Partitions File Upload 157 [Documentation] Upload 1000 partition file to BMC. 158 [Tags] Verify_One_Thousand_Partitions_File_Upload 159 [Template] Redfish Upload Partition File With Range 160 161 # range 162 1000 163 164 165Non Admin Users Fail To Upload Partition File 166 [Documentation] Non admin user will fail to upload the partition file. 167 [Tags] Non_Admin_Users_Fail_To_Upload_Partition_File 168 [Template] Non Admin User To Upload Partition File 169 170 # file_name username password role_id 171 500KB_file operator_user TestPwd123 Operator 172 173 174Non Admin User Delete Non Existence Of Partition File 175 [Documentation] Delete the partion file if does not exists. 176 [Tags] Non_Admin_User_Delete_Non_Existence_Of_Partition_File 177 [Template] Non Admin Delete Non Existence Partition File 178 179 # file_name username password role_id 180 500KB_file operator_user TestPwd123 Operator 181 182 183Redfish Update Wrong Partition File To BMC 184 [Documentation] Upload partition file to BMC by wrong URI using redfish. 185 [Tags] Redfish_Update_Wrong_Partition_File_To_BMC 186 [Template] Verify Update Wrong Partition File To BMC 187 188 # file_name 189 500KB_file 190 191*** Keywords *** 192 193Suite Setup Execution 194 [Documentation] Suite setup execution. 195 196 Redfish.Login 197 198 199Test Teardown Execution 200 [Documentation] Test teardown execution. 201 202 Delete All BMC Partition File ${HTTP_OK} 203 FFDC On Test Case Fail 204 205 206Suite Teardown Execution 207 [Documentation] Suite teardown execution. 208 209 Delete All Sessions 210 211 212Delete Local Partition File 213 [Documentation] Delete local partition file. 214 [Arguments] ${file_name} 215 216 # Description of argument(s): 217 # file_name Partition file name. 218 219 FOR ${conf_file} IN @{file_name} 220 ${file_exist}= Run Keyword And Return Status OperatingSystem.File Should Exist ${conf_file} 221 Run Keyword If 'True' == '${file_exist}' Remove File ${conf_file} 222 END 223 224 225Create Partition File 226 [Documentation] Create Partition file. 227 [Arguments] ${file_name} 228 229 # Description of argument(s): 230 # file_name Partition file name. 231 232 Delete Local Partition File ${file_name} 233 234 FOR ${conf_file} IN @{file_name} 235 @{words}= Split String ${conf_file} _ 236 Run dd if=/dev/zero of=${conf_file} bs=1 count=0 seek=${words}[-0] 237 OperatingSystem.File Should Exist ${conf_file} 238 END 239 240 241Delete BMC Partition File 242 [Documentation] Delete single partition file on BMC via redfish. 243 [Arguments] ${file_name} ${status_code} ${expected_message} 244 245 # Description of argument(s): 246 # file_name Partition file name. 247 # status_code HTTPS status code. 248 # expected_message Expected message of URI. 249 250 FOR ${conf_file} IN @{file_name} 251 ${data}= Create Dictionary 252 ${headers}= Create Dictionary X-Auth-Token=${XAUTH_TOKEN} 253 Set To Dictionary ${data} headers ${headers} 254 255 ${resp}= Delete Request openbmc /ibm/v1/Host/ConfigFiles/${conf_file} &{data} 256 Should Be Equal As Strings ${resp.status_code} ${status_code} 257 258 Run Keyword If ${resp.status_code} == ${HTTP_FORBIDDEN} 259 ... Should Be Equal As Strings ${resp.text} ${expected_message} 260 ${description}= Run Keyword If ${resp.status_code} == ${HTTP_OK} 261 ... Return Description Of Response ${resp.text} 262 Run Keyword If '${description}' != 'None' 263 ... Should Be Equal As Strings ${description} ${expected_message} 264 END 265 266 267Delete All BMC Partition File 268 [Documentation] Delete multiple partition file on BMC via redfish. 269 [Arguments] ${status_code} 270 271 # Description of argument(s): 272 # status_code HTTPS status code. 273 274 Initialize OpenBMC 275 ${data}= Create Dictionary 276 ${headers}= Create Dictionary X-Auth-Token=${XAUTH_TOKEN} 277 Set To Dictionary ${data} headers ${headers} 278 279 ${resp}= Post Request openbmc /ibm/v1/Host/ConfigFiles/Actions/IBMConfigFiles.DeleteAll &{data} 280 Should Be Equal As Strings ${resp.status_code} ${status_code} 281 282 283Return Description Of Response 284 [Documentation] Return description of REST response. 285 [Arguments] ${resp_text} 286 287 # Description of argument(s): 288 # resp_text REST response body. 289 290 # resp_text after successful partition file upload looks like: 291 # { 292 # "Description": "File Created" 293 # } 294 295 ${message}= Evaluate json.loads('''${resp_text}''') json 296 297 [Return] ${message["Description"]} 298 299 300Upload Partition File To BMC 301 [Documentation] Upload partition file to BMC. 302 [Arguments] ${file_name} ${status_code} ${expected_message} ${flag}=${True} 303 304 # Description of argument(s): 305 # file_name Partition file name. 306 # status_code HTTPS status code. 307 # expected_message Expected message of URI. 308 # flag If True run part of program, else skip. 309 310 Run Keyword If '${flag}' == '${True}' Initialize OpenBMC 311 FOR ${conf_file} IN @{file_name} 312 # Get the content of the file and upload to BMC. 313 ${image_data}= OperatingSystem.Get Binary File ${conf_file} 314 ${data}= Create Dictionary data ${image_data} 315 ${headers}= Create Dictionary X-Auth-Token=${XAUTH_TOKEN} 316 Set To Dictionary ${data} headers ${headers} 317 318 ${resp}= Put Request openbmc /ibm/v1/Host/ConfigFiles/${conf_file} &{data} 319 Should Be Equal As Strings ${resp.status_code} ${status_code} 320 321 Run Keyword If ${resp.status_code} == ${HTTP_FORBIDDEN} 322 ... Should Be Equal As Strings ${resp.text} ${expected_message} 323 ${description}= Run Keyword If ${resp.status_code} == ${HTTP_OK} 324 ... Return Description Of Response ${resp.text} 325 Run Keyword If '${description}' != 'None' 326 ... Should Be Equal As Strings ${description} ${expected_message} 327 END 328 329 330Verify Partition File On BMC 331 [Documentation] Verify partition file on BMC. 332 [Arguments] ${file_name} ${Partition_status} 333 334 # Description of argument(s): 335 # file_name Partition file name. 336 # Partition_status Partition file status on BMC. 337 338 FOR ${conf_file} IN @{file_name} 339 ${status} ${stderr} ${rc}= BMC Execute Command 340 ... ls -l /var/lib/obmc/bmc-console-mgmt/save-area/${conf_file} | wc -l 341 Valid Value ${status} [${Partition_status}] 342 END 343 344 345Redfish Upload Partition File 346 [Documentation] Upload the partition file. 347 [Arguments] ${file_name} 348 349 # Description of argument(s): 350 # file_name Partition file name. 351 352 @{Partition_file_list} = Split String ${file_name} , 353 ${num_records}= Get Length ${Partition_file_list} 354 Create Partition File ${Partition_file_list} 355 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPLOAD_MESSAGE} 356 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 357 Run Keyword If ${num_records} == ${1} 358 ... Delete BMC Partition File ${Partition_file_list} ${HTTP_OK} ${FILE_DELETED_MESSAGE} 359 ... ELSE 360 ... Delete All BMC Partition File ${HTTP_OK} 361 Delete Local Partition File ${Partition_file_list} 362 363 364Redfish Fail To Upload Partition File 365 [Documentation] Fail to uplaod the partition file. 366 [Arguments] ${file_name} 367 368 # Description of argument(s): 369 # file_name Partition file name. 370 371 @{Partition_file_list} = Split String ${file_name} , 372 Create Partition File ${Partition_file_list} 373 Upload Partition File To BMC ${Partition_file_list} ${HTTP_BAD_REQUEST} ${MAXIMUM_SIZE_MESSAGE} 374 Verify Partition File On BMC ${Partition_file_list} Partition_status=0 375 Delete BMC Partition File ${Partition_file_list} ${HTTP_NOT_FOUND} ${RESOURCE_NOT_FOUND} 376 Delete Local Partition File ${Partition_file_list} 377 378 379Verify Partition File Upload Post BMC Reboot 380 [Documentation] Upload the partition file, after BMC reboot. 381 [Arguments] ${file_name} 382 383 # Description of argument(s): 384 # file_name Partition file name. 385 386 Redfish OBMC Reboot (off) 387 388 Redfish Upload Partition File ${file_name} 389 390 391Redfish Partition File Persistency 392 [Documentation] Upload the partition file and check for persistency after reboot. 393 [Arguments] ${file_name} 394 395 # Description of argument(s): 396 # file_name Partition file name. 397 398 @{Partition_file_list} = Split String ${file_name} , 399 ${num_records}= Get Length ${Partition_file_list} 400 Create Partition File ${Partition_file_list} 401 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPLOAD_MESSAGE} 402 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 403 Redfish OBMC Reboot (off) 404 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 405 Initialize OpenBMC 406 Run Keyword If ${num_records} == ${1} 407 ... Delete BMC Partition File ${Partition_file_list} ${HTTP_OK} ${FILE_DELETED_MESSAGE} 408 ... ELSE 409 ... Delete All BMC Partition File ${HTTP_OK} 410 Delete Local Partition File ${Partition_file_list} 411 412 413Verify Redfish Partition File Content 414 [Documentation] Verify partition file content. 415 [Arguments] ${file_name} ${content_dict} ${status_code} 416 417 # Description of argument(s): 418 # file_name Partition file name. 419 # content_dict Dict contain the content. 420 # status_code HTTPS status code. 421 422 FOR ${conf_file} IN @{file_name} 423 ${resp}= Get Request openbmc /ibm/v1/Host/ConfigFiles/${conf_file} 424 Should Be Equal As Strings ${resp.status_code} ${status_code} 425 426 ${Partition_file_data}= Remove String ${resp.text} \\n 427 ${Partition_file_data}= Evaluate json.loads('''${Partition_file_data}''') json 428 Should Be Equal As Strings ${Partition_file_data["Data"]} ${content_dict['${conf_file}']} 429 END 430 431 432Add Content To Files 433 [Documentation] Add defined content in partition file. 434 [Arguments] ${file_name} ${index}=${0} 435 436 # Description of argument(s): 437 # file_name Partition file name. 438 # index Index 439 440 ${num_records}= Get Length ${file_name} 441 Set Test Variable ${content-1} Sample Content to test partition file upload 442 Set Test Variable ${content-2} Sample Content to test partition file upload after reboot 443 &{content_dict}= Create Dictionary 444 FOR ${conf_file} IN @{file_name} 445 ${index}= Get Index From List ${file_name} ${conf_file} 446 ${index}= Evaluate ${index} + 1 447 448 Run echo "${content-${index}}" > ${conf_file} 449 OperatingSystem.File Should Exist ${conf_file} 450 451 Set To Dictionary ${content_dict} ${conf_file} ${content-${index}} 452 END 453 454 [Return] &{content_dict} 455 456 457Redfish Read Partition File 458 [Documentation] Read partition file content. 459 [Arguments] ${file_name} ${reboot_flag}=False 460 461 # Description of argument(s): 462 # file_name Partition file name. 463 # reboot_flag Reboot flag. 464 465 @{Partition_file_list} = Split String ${file_name} , 466 ${content_dict}= Add Content To Files ${Partition_file_list} 467 468 ${num_records}= Get Length ${Partition_file_list} 469 470 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPLOAD_MESSAGE} 471 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 472 Verify Redfish Partition File Content ${Partition_file_list} ${content_dict} ${HTTP_OK} 473 474 Run Keyword If ${True} == ${reboot_flag} 475 ... Run Keywords Redfish OBMC Reboot (off) AND 476 ... Initialize OpenBMC AND 477 ... Verify Redfish Partition File Content ${Partition_file_list} ${content_dict} ${HTTP_OK} 478 Run Keyword If ${num_records} == ${1} 479 ... Delete BMC Partition File ${Partition_file_list} ${HTTP_OK} ${FILE_DELETED_MESSAGE} 480 ... ELSE 481 ... Delete All BMC Partition File ${HTTP_OK} 482 Delete Local Partition File ${Partition_file_list} 483 484 485Redfish Update Partition File With Same Content 486 [Documentation] Update partition file with same content. 487 [Arguments] ${file_name} ${reboot_flag}=False 488 489 # Description of argument(s): 490 # file_name Partition file name. 491 # reboot_flag Reboot flag. 492 493 @{Partition_file_list} = Split String ${file_name} , 494 ${content_dict}= Add Content To Files ${Partition_file_list} ${0} 495 496 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPLOAD_MESSAGE} 497 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 498 Verify Redfish Partition File Content ${Partition_file_list} ${content_dict} ${HTTP_OK} 499 500 Run Keyword If ${True} == ${reboot_flag} 501 ... Run Keywords Redfish OBMC Reboot (off) AND 502 ... Initialize OpenBMC 503 504 ${content_dict}= Add Content To Files ${Partition_file_list} ${0} 505 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPDATED} 506 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 507 Verify Redfish Partition File Content ${Partition_file_list} ${content_dict} ${HTTP_OK} 508 509 Delete BMC Partition File ${Partition_file_list} ${HTTP_OK} ${FILE_DELETED_MESSAGE} 510 Delete Local Partition File ${Partition_file_list} 511 512 513Redfish Update Partition File With Different Content 514 [Documentation] Update partition file with different content. 515 [Arguments] ${file_name} ${reboot_flag}=False 516 517 # Description of argument(s): 518 # file_name Partition file name. 519 # reboot_flag Reboot flag. 520 521 @{Partition_file_list} = Split String ${file_name} , 522 ${content_dict}= Add Content To Files ${Partition_file_list} ${0} 523 524 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPLOAD_MESSAGE} 525 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 526 Verify Redfish Partition File Content ${Partition_file_list} ${content_dict} ${HTTP_OK} 527 528 Run Keyword If ${True} == ${reboot_flag} 529 ... Run Keywords Redfish OBMC Reboot (off) AND 530 ... Initialize OpenBMC 531 532 ${content_dict}= Add Content To Files ${Partition_file_list} ${1} 533 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPDATED} 534 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 535 Verify Redfish Partition File Content ${Partition_file_list} ${content_dict} ${HTTP_OK} 536 537 Delete BMC Partition File ${Partition_file_list} ${HTTP_OK} ${FILE_DELETED_MESSAGE} 538 Delete Local Partition File ${Partition_file_list} 539 540 541Create File Names 542 [Documentation] Create partition file names. 543 [Arguments] ${range} 544 545 # Description of argument(s): 546 # range Range in numbers. 547 548 @{file_name_list}= Create List 549 Set Test Variable ${file_name} rangefile 550 FOR ${count} IN RANGE ${range} 551 Append To List ${file_name_list} 200KB_file${count} 552 END 553 [Return] ${file_name_list} 554 555 556Redfish Upload Partition File With Range 557 [Documentation] Upload the partition file with the range of files. 558 [Arguments] ${range} 559 560 # Description of argument(s): 561 # range Range in numbers. 562 563 ${Partition_file_list}= Create File Names ${range} 564 Create Partition File ${Partition_file_list} 565 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPLOAD_MESSAGE} 566 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 567 Delete All BMC Partition File ${HTTP_OK} 568 Delete Local Partition File ${Partition_file_list} 569 570 571Redfish Delete Non Existence Partition File 572 [Documentation] Delete the partition file if do not exists. 573 [Arguments] ${file_name} 574 575 # Description of argument(s): 576 # file_name Partition file name. 577 578 @{Partition_file_list} = Split String ${file_name} , 579 Delete BMC Partition File ${Partition_file_list} ${HTTP_NOT_FOUND} ${RESOURCE_NOT_FOUND} 580 581 582Non Admin User To Upload Partition File 583 [Documentation] Non admin user to uplaod the partition file. 584 [Arguments] ${file_name} ${username} ${password} ${role} ${enabled}=${True} 585 586 # Description of argument(s): 587 # file_name Partition file name. 588 # username Username. 589 # password Password. 590 # role Role of user. 591 # enabled Value can be True or False. 592 593 Redfish Create User ${username} ${password} ${role} ${enabled} 594 Delete All Sessions 595 Initialize OpenBMC rest_username=${username} rest_password=${password} 596 @{Partition_file_list} = Split String ${file_name} , 597 Create Partition File ${Partition_file_list} 598 Upload Partition File To BMC ${Partition_file_list} ${HTTP_FORBIDDEN} ${FORBIDDEN_MESSAGE} ${False} 599 Delete Local Partition File ${Partition_file_list} 600 Redfish.Delete /redfish/v1/AccountService/Accounts/${username} 601 602 603Non Admin Delete Non Existence Partition File 604 [Documentation] Non admin user to uplaod the partition file. 605 [Arguments] ${file_name} ${username} ${password} ${role} ${enabled}=${True} 606 607 # Description of argument(s): 608 # file_name Partition file name. 609 # username Username. 610 # password Password. 611 # role Role of user. 612 # enabled Value can be True or False. 613 614 Redfish Create User ${username} ${password} ${role} ${enabled} 615 Delete All Sessions 616 Initialize OpenBMC rest_username=${username} rest_password=${password} 617 @{Partition_file_list} = Split String ${file_name} , 618 Delete BMC Partition File ${Partition_file_list} ${HTTP_FORBIDDEN} ${FORBIDDEN_MESSAGE} 619 620 621Verify Update Wrong Partition File To BMC 622 [Documentation] Upload the wrong partition file to BMC. 623 [Arguments] ${file_name} 624 625 # Description of argument(s): 626 # file_name Partition file name. 627 628 Redfish.Login 629 ${resp}= Run Keyword And Return Status 630 ... Redfish.Put /ibm/v1/Host/ConfigFiles/../../../../../etc/resolv.conf body={"data": "test string"} 631 Should Be Equal As Strings ${resp} False 632