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 11Resource ../../lib/external_intf/management_console_utils.robot 12 13Suite Setup Suite Setup Execution 14Test Teardown Test Teardown Execution 15Suite Teardown Suite Teardown Execution 16 17*** Variables *** 18 19${MAXIMUM_FILE_SIZE_MESSAGE} File size exceeds maximum allowed size[25MB] 20${MAXIMUM_DIR_SIZE_MESSAGE} 21... File size does not fit in the savearea directory maximum allowed size[25MB] 22${FILE_UPLOAD_MESSAGE} File Created 23${FILE_DELETED_MESSAGE} File Deleted 24${FILE_UPDATED_MESSAGE} File Updated 25${FORBIDDEN_MESSAGE} Forbidden 26${ERROR_MESSAGE} Error while creating the file 27${RESOURCE_NOT_FOUND_MESSAGE} Resource Not Found 28${MINIMUM_FILE_SIZE_MESSAGE} File size is less than minimum allowed size[100B] 29${MAXIMUM_FILE_NAME_MESSAGE} Filename must be maximum 20 characters 30${UNSUPPORTED_FILE_NAME_MESSAGE} Unsupported character in filename 31 32${content-1} Sample Content to test partition file upload 33... Sample Content to test partition file upload 34... Sample Content to test partition file upload 35${content-2} Sample Content to test partition file upload after reboot 36... Sample Content to test partition file upload after reboot 37... Sample Content to test partition file upload after reboot 38 39${LOOP_COUNT} 10 40 41*** Test Cases *** 42 43Redfish Upload Lower Limit Partition File To BMC 44 [Documentation] Upload lower limit of allowed partition file to BMC using Redfish. 45 [Tags] Redfish_Upload_Lower_Limit_Partition_File_To_BMC 46 [Template] Redfish Upload Partition File 47 48 # file_name 49 100-file 50 51 52Redfish Upload Partition File To BMC 53 [Documentation] Upload partition file to BMC using Redfish. 54 [Tags] Redfish_Upload_Partition_File_To_BMC 55 [Template] Redfish Upload Partition File 56 57 # file_name 58 500KB-file 59 2000KB-file 60 10000KB-file 61 25000KB-file 62 63 64Test Upload Lower Limit Partition File To BMC And Expect Failure 65 [Documentation] Fail to upload partition file to BMC with file size 66 ... below the lower limit of allowed partition file size using Redfish. 67 [Tags] Test_Upload_Lower_Limit_Partition_File_To_BMC_And_Expect_Failure 68 [Template] Redfish Fail To Upload Partition File 69 70 # file_name status_code partition_status response_message 71 99-file ${HTTP_BAD_REQUEST} 0 ${MINIMUM_FILE_SIZE_MESSAGE} 72 73 74Test Upload Upper Limit Partition File To BMC And Expect Failure 75 [Documentation] Fail to upload partition file to BMC with file size 76 ... more than upper limit of allowed partition file size using Redfish. 77 [Tags] Test_Upload_Upper_Limit_Partition_File_To_BMC_And_Expect_Failure 78 [Template] Redfish Fail To Upload Partition File 79 80 # file_name status_code partition_status response_message 81 25001KB-file ${HTTP_BAD_REQUEST} 0 ${MAXIMUM_FILE_SIZE_MESSAGE} 82 83 84Redfish Upload Multiple Partition File To BMC 85 [Documentation] Upload multiple partition file to BMC using Redfish. 86 [Tags] Redfish_Upload_Multiple_Partition_File_To_BMC 87 [Template] Redfish Upload Partition File 88 89 # file_name 90 250KB-file,500KB-file 91 92 93Test Upload Partition File When BMC Space Reach Max And Expect Failure 94 [Documentation] Fail to upload multiple partition file to BMC 95 ... as BMC directory reach to upper limit using Redfish. 96 [Tags] Test_Upload_Partition_File_When_BMC_Space_Reach_Max_And_Expect_Failure 97 [Template] Redfish Fail To Upload Partition File 98 99 # file_name status_code partition_status response_message 100 15000KB-file ${HTTP_OK} 1 ${FILE_UPLOAD_MESSAGE} 101 16000KB-file ${HTTP_BAD_REQUEST} 0 ${MAXIMUM_DIR_SIZE_MESSAGE} 102 25000KB-file ${HTTP_OK} 1 ${FILE_UPLOAD_MESSAGE} 103 100-file ${HTTP_BAD_REQUEST} 0 ${MAXIMUM_DIR_SIZE_MESSAGE} 104 105 106Redfish Upload Same Partition File To BMC In Loop 107 [Documentation] Upload same partition file to BMC using Redfish in loop. 108 [Tags] Redfish_Upload_Same_Partition_File_To_BMC_In_Loop 109 [Template] Redfish Upload Partition File In Loop 110 111 # file_name 112 500KB-file 113 114 115Redfish Upload And Delete Same Partition File To BMC In Loop 116 [Documentation] Upload same partition file to BMC using Redfish in loop. 117 [Tags] Redfish_Upload_And_Delete_Same_Partition_File_To_BMC_In_Loop 118 [Template] Redfish Upload And Delete Partition File In Loop 119 120 # file_name 121 500KB-file 122 123 124Redfish Partition File Upload Post BMC Reboot 125 [Documentation] Upload partition file to BMC using Redfish, after the BMC reboot. 126 [Tags] Redfish_Partition_File_Upload_Post_BMC_Reboot 127 [Template] Verify Partition File Upload Post BMC Reboot 128 129 # file_name 130 500KB-file 131 132 133Redfish Partition File Persistency On BMC Reboot 134 [Documentation] Upload partition file to BMC using Redfish and is same after reboot. 135 [Tags] Redfish_Partition_File_Persistency_On_BMC_Reboot 136 [Template] Redfish Partition File Persistency 137 138 # file_name 139 500KB-file 140 141 142Redfish Multiple Partition File Persistency On BMC Reboot 143 [Documentation] Upload multiple partition file to BMC using Redfish and is same after reboot. 144 [Tags] Redfish_Multiple_Partition_File_Persistency_On_BMC_Reboot 145 [Template] Redfish Partition File Persistency 146 147 # file_name 148 250KB-file,500KB-file 149 150 151Redfish Read Partition File From BMC 152 [Documentation] Upload partition file to BMC using Redfish and verify the content. 153 [Tags] Redfish_Read_Partition_File_From_BMC 154 [Template] Redfish Read Partition File 155 156 # file_name reboot_flag 157 testfile01-file False 158 testfile01-file,testfile02-file False 159 160 161Redfish Read Partition File Post BMC Reboot 162 [Documentation] Upload partition file to BMC using Redfish and verify the content after reboot. 163 [Tags] Redfish_Read_Partition_File_Post_BMC_Reboot 164 [Template] Redfish Read Partition File 165 166 # file_name reboot_flag 167 testfile01-file True 168 testfile01-file,testfile02-file True 169 170 171Redfish Update Partition File On BMC 172 [Documentation] Upload partition file to BMC using Redfish and verify the content. 173 [Tags] Redfish_Update_Partition_File_On_BMC 174 [Template] Redfish Update Partition File With Different Content 175 176 # file_name reboot_flag 177 testfile01-file False 178 179 180Redfish Update Partition File On BMC Reboot 181 [Documentation] Upload partition file to BMC using Redfish and verify the content after the reboot. 182 [Tags] Redfish_Update_Partition_File_On_BMC_Reboot 183 [Template] Redfish Update Partition File With Different Content 184 185 # file_name reboot_flag 186 testfile01-file True 187 188 189Redfish Persistency Update Partition File On BMC 190 [Documentation] Upload partition file to BMC using Redfish and verify the content. 191 [Tags] Redfish_Persistency_Update_Partition_File_On_BMC 192 [Template] Redfish Update Partition File With Same Content 193 194 # file_name reboot_flag 195 testfile01-file False 196 197 198Redfish Delete Non Existence Of Partition File 199 [Documentation] Delete the partition file if do not exists. 200 [Tags] Redfish_Delete_Non_Existence_Of_Partition_File 201 [Template] Redfish Delete Non Existence Partition File 202 203 # file_name 204 testfile01-file 205 206 207Verify One Thousand Partitions File Upload 208 [Documentation] Upload 1000 partition file to BMC. 209 [Tags] Verify_One_Thousand_Partitions_File_Upload 210 [Template] Redfish Upload Partition File With Range 211 212 # range 213 1000 214 215 216Non Admin Users Fail To Upload Partition File 217 [Documentation] Non admin user will fail to upload the partition file. 218 [Tags] Non_Admin_Users_Fail_To_Upload_Partition_File 219 [Template] Non Admin User To Upload Partition File 220 221 # file_name username password role_id 222 500KB-file operator_user TestPwd123 Operator 223 224 225Non Admin User Delete Non Existence Of Partition File 226 [Documentation] Delete the partition file if does not exists. 227 [Tags] Non_Admin_User_Delete_Non_Existence_Of_Partition_File 228 [Template] Non Admin Delete Non Existence Partition File 229 230 # file_name username password role_id 231 500KB-file operator_user TestPwd123 Operator 232 233 234Redfish Update Wrong Partition File To BMC 235 [Documentation] Upload partition file to BMC by wrong URI using Redfish. 236 [Tags] Redfish_Update_Wrong_Partition_File_To_BMC 237 [Template] Verify Update Wrong Partition File To BMC 238 239 # file_name 240 500KB-file 241 242 243Test Redfish Upload Partition File Name With Character Limit To BMC 244 [Documentation] Upload partition file to BMC with file name character allowed limit 245 ... and above allowed limit using Redfish. 246 [Tags] Test_Redfish_Upload_Partition_File_Name_With_Character_Limit_To_BMC 247 [Template] Check Redfish Upload Partition File Name With Character Limit To BMC 248 249 # file_name status_code message 250 50KB-testfilesavfile ${HTTP_OK} ${FILE_UPLOAD_MESSAGE} 251 50KB-testsaveareafile ${HTTP_BAD_REQUEST} ${MAXIMUM_FILE_NAME_MESSAGE} 252 253 254Test Redfish Fail To Upload Partition File Name With Special Character To BMC 255 [Documentation] Upload partition file to BMC with special character file name and 256 ... Redfish through an error. 257 [Tags] Test_Redfish_Fail_To_Upload_Partition_File_Name_With_Special_Character_To_BMC 258 [Template] Check Redfish Fail To Upload Partition File Name With Special Character To BMC 259 260 # file_name status_code message 261 1KB-*filename ${HTTP_BAD_REQUEST} ${UNSUPPORTED_FILE_NAME_MESSAGE} 262 1KB-!filename ${HTTP_BAD_REQUEST} ${UNSUPPORTED_FILE_NAME_MESSAGE} 263 1KB-@filename ${HTTP_BAD_REQUEST} ${UNSUPPORTED_FILE_NAME_MESSAGE} 264 265 266Redfish Persistency Update Partition File Post BMC Reboot 267 [Documentation] Upload partition file to BMC using Redfish and verify the content after the reboot. 268 [Tags] Redfish_Persistency_Update_Partition_File_Post_BMC_Reboot 269 [Template] Redfish Update Partition File With Same Content 270 271 # file_name reboot_flag 272 testfile01-file True 273 274 275Redfish Upload Validated Partition File From Path To BMC 276 [Documentation] Upload valid partition file to BMC from file path define by user in loop. 277 ... By default loop count values is 10 times. 278 [Tags] Redfish_Upload_Validated_Partition_File_From_Path_To_BMC 279 280 Log To Console ${EMPTY} 281 FOR ${count} IN RANGE 1 ${LOOP_COUNT} + 1 282 Log To Console ************************************** 283 Log To Console * The Current Loop Count is ${count} of ${LOOP_COUNT} * 284 Log To Console ************************************** 285 286 Redfish Upload Partition File From Path ${PARTITION_FILE_PATH} 287 END 288 289*** Keywords *** 290 291Suite Setup Execution 292 [Documentation] Suite setup execution. 293 294 Redfish.Login 295 296 297Test Teardown Execution 298 [Documentation] Test teardown execution. 299 300 Delete All BMC Partition File ${HTTP_OK} 301 FFDC On Test Case Fail 302 303 304Suite Teardown Execution 305 [Documentation] Suite teardown execution. 306 307 Delete All Sessions 308 309 310Delete Local Partition File 311 [Documentation] Delete local partition file. 312 [Arguments] ${file_name} 313 314 # Description of argument(s): 315 # file_name Partition file name. 316 317 FOR ${conf_file} IN @{file_name} 318 ${file_exist}= Run Keyword And Return Status OperatingSystem.File Should Exist ${conf_file} 319 Run Keyword If 'True' == '${file_exist}' Remove File ${conf_file} 320 END 321 322 323Delete Local Server Partition File 324 [Documentation] Local partition files which is getting uploaded to BMC, 325 ... will get deleted after the uploads. If partition file name consist 326 ... of “-file” then partition file gets deleted. 327 328 @{conf_file_list} = OperatingSystem.List Files In Directory ${EXECDIR} 329 ${match_conf_file_list}= Get Matches ${conf_file_list} regexp=.*-file case_insensitive=${True} 330 331 ${num_records}= Get Length ${match_conf_file_list} 332 Return From Keyword If ${num_records} == ${0} ${EMPTY} 333 334 FOR ${conf_file} IN @{match_conf_file_list} 335 ${file_exist}= Run Keyword And Return Status OperatingSystem.File Should Exist ${conf_file} 336 Run Keyword If 'True' == '${file_exist}' Remove File ${conf_file} 337 END 338 339 340Create Partition File 341 [Documentation] Create Partition file. 342 [Arguments] ${file_name} 343 344 # Description of argument(s): 345 # file_name Partition file name. 346 347 Delete Local Partition File ${file_name} 348 349 FOR ${conf_file} IN @{file_name} 350 @{words}= Split String ${conf_file} - 351 Run dd if=/dev/zero of=${conf_file} bs=${words}[-0] count=1 352 OperatingSystem.File Should Exist ${conf_file} 353 END 354 355 356Delete BMC Partition File 357 [Documentation] Delete single partition file on BMC via Redfish. 358 [Arguments] ${file_name} ${status_code} ${expected_message} 359 360 # Description of argument(s): 361 # file_name Partition file name. 362 # status_code HTTPS status code. 363 # expected_message Expected message of URI. 364 365 FOR ${conf_file} IN @{file_name} 366 ${data}= Create Dictionary 367 ${headers}= Create Dictionary X-Auth-Token=${XAUTH_TOKEN} 368 Set To Dictionary ${data} headers ${headers} 369 370 ${resp}= DELETE On Session openbmc /ibm/v1/Host/ConfigFiles/${conf_file} &{data} 371 ... expected_status=any 372 Should Be Equal As Strings ${resp.status_code} ${status_code} 373 374 ${description}= Return Description Of Response ${resp.text} 375 Should Be Equal As Strings ${description} ${expected_message} 376 END 377 378 379Delete All BMC Partition File 380 [Documentation] Delete multiple partition file on BMC via Redfish. 381 [Arguments] ${status_code} 382 383 # Description of argument(s): 384 # status_code HTTPS status code. 385 386 Initialize OpenBMC 387 ${data}= Create Dictionary 388 ${headers}= Create Dictionary X-Auth-Token=${XAUTH_TOKEN} 389 Set To Dictionary ${data} headers ${headers} 390 391 ${resp}= POST On Session openbmc /ibm/v1/Host/ConfigFiles/Actions/IBMConfigFiles.DeleteAll &{data} 392 ... expected_status=any 393 Should Be Equal As Strings ${resp.status_code} ${status_code} 394 395 396Return Description Of Response 397 [Documentation] Return description of REST response. 398 [Arguments] ${resp_text} 399 400 # Description of argument(s): 401 # resp_text REST response body. 402 403 # resp_text after successful partition file upload looks like: 404 # { 405 # "Description": "File Created" 406 # } 407 408 ${status}= Run Keyword And Return Status Evaluate isinstance(${resp_text}, dict) 409 Return From Keyword If '${status}' == 'False' ${resp_text} 410 ${message}= Evaluate json.loads('''${resp_text}''') json 411 412 [Return] ${message["Description"]} 413 414 415Upload Partition File To BMC 416 [Documentation] Upload partition file to BMC. 417 [Arguments] ${file_name} ${status_code} ${expected_message} ${flag}=${True} ${path}=${EMPTY} 418 419 # Description of argument(s): 420 # file_name Partition file name. 421 # status_code HTTPS status code. 422 # expected_message Expected message of URI. 423 # flag If True run part of program, else skip. 424 # path Partition file path. 425 426 Run Keyword If '${flag}' == '${True}' Initialize OpenBMC 427 FOR ${conf_file} IN @{file_name} 428 # Get the content of the file and upload to BMC. 429 ${image_data}= OperatingSystem.Get Binary File ${path}${conf_file} 430 ${headers}= Create Dictionary X-Auth-Token=${XAUTH_TOKEN} Content-Type=application/octet-stream 431 432 ${kwargs}= Create Dictionary data=${image_data} 433 Set To Dictionary ${kwargs} headers ${headers} 434 ${resp}= PUT On Session openbmc /ibm/v1/Host/ConfigFiles/${conf_file} &{kwargs} timeout=10 435 ... expected_status=any 436 Should Be Equal As Strings ${resp.status_code} ${status_code} 437 438 ${description}= Return Description Of Response ${resp.text} 439 Should Be Equal As Strings ${description} ${expected_message} 440 END 441 442 443Verify Partition File On BMC 444 [Documentation] Verify partition file on BMC. 445 [Arguments] ${file_name} ${Partition_status} 446 447 # Description of argument(s): 448 # file_name Partition file name. 449 # Partition_status Partition file status on BMC. 450 451 FOR ${conf_file} IN @{file_name} 452 ${status} ${stderr} ${rc}= BMC Execute Command 453 ... ls -l /var/lib/bmcweb/ibm-management-console/configfiles/${conf_file} | wc -l 454 Valid Value ${status} [${Partition_status}] 455 END 456 457 458Redfish Upload Partition File 459 [Documentation] Upload the partition file. 460 [Arguments] ${file_name} ${file_size}=${EMPTY} 461 462 # Description of argument(s): 463 # file_name Partition file name. 464 # file_size By Default is set to EMPTY, 465 # if user pass small_file_size the create file with small 466 # size keyword gets executed. 467 468 @{Partition_file_list} = Split String ${file_name} , 469 ${num_records}= Get Length ${Partition_file_list} 470 471 Create Partition File ${Partition_file_list} 472 473 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPLOAD_MESSAGE} 474 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 475 Run Keyword If ${num_records} == ${1} 476 ... Delete BMC Partition File ${Partition_file_list} ${HTTP_OK} ${FILE_DELETED_MESSAGE} 477 ... ELSE 478 ... Delete All BMC Partition File ${HTTP_OK} 479 Delete Local Partition File ${Partition_file_list} 480 481 482Redfish Fail To Upload Partition File 483 [Documentation] Fail to upload the partition file. 484 [Arguments] ${file_name} ${status_code} ${partition_status} ${response_message}=${EMPTY} 485 486 # Description of argument(s): 487 # file_name Partition file name. 488 # status_code HTTPS status code. 489 # partition_status Partition status. 490 # response_message By default is set to EMPTY, 491 # else user provide the information when user upload the partition with file size 492 # below lower linit of allowed partition or more than of large allowed partition. 493 494 @{Partition_file_list} = Split String ${file_name} , 495 496 Create Partition File ${Partition_file_list} 497 Upload Partition File To BMC ${Partition_file_list} ${status_code} ${response_message} 498 Verify Partition File On BMC ${Partition_file_list} Partition_status=${partition_status} 499 500 Run Keyword If ${partition_status} == 0 501 ... Run Keywords 502 ... Delete BMC Partition File 503 ... ${Partition_file_list} ${HTTP_NOT_FOUND} ${RESOURCE_NOT_FOUND_MESSAGE} AND 504 ... Delete All BMC Partition File ${HTTP_OK} AND 505 ... Delete Local Server Partition File 506 507 Delete Local Partition File ${Partition_file_list} 508 509 510Redfish Upload Partition File In Loop 511 [Documentation] Upload the same partition file multiple times in loop to BMC. 512 [Arguments] ${file_name} 513 514 # Description of argument(s): 515 # file_name Partition file name. 516 517 @{Partition_file_list} = Split String ${file_name} , 518 Create Partition File ${Partition_file_list} 519 520 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPLOAD_MESSAGE} 521 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 522 523 FOR ${count} IN RANGE 1 11 524 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPDATED_MESSAGE} 525 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 526 END 527 528 Initialize OpenBMC 529 Delete BMC Partition File ${Partition_file_list} ${HTTP_OK} ${FILE_DELETED_MESSAGE} 530 Delete Local Partition File ${Partition_file_list} 531 532 533Redfish Upload And Delete Partition File In Loop 534 [Documentation] Upload the same partition file multiple times in loop to BMC. 535 [Arguments] ${file_name} 536 537 # Description of argument(s): 538 # file_name Partition file name. 539 540 FOR ${count} IN RANGE 1 11 541 Redfish Upload Partition File ${file_name} 542 END 543 544 545Verify Partition File Upload Post BMC Reboot 546 [Documentation] Upload the partition file, after BMC reboot. 547 [Arguments] ${file_name} 548 549 # Description of argument(s): 550 # file_name Partition file name. 551 552 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN} 553 Redfish BMC Reset Operation 554 Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} 555 556 Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled 557 Is BMC Standby 558 559 Redfish Upload Partition File ${file_name} 560 561 562Redfish Partition File Persistency 563 [Documentation] Upload the partition file and check for persistency after reboot. 564 [Arguments] ${file_name} 565 566 # Description of argument(s): 567 # file_name Partition file name. 568 569 @{Partition_file_list} = Split String ${file_name} , 570 ${num_records}= Get Length ${Partition_file_list} 571 Create Partition File ${Partition_file_list} 572 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPLOAD_MESSAGE} 573 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 574 575 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN} 576 Redfish BMC Reset Operation 577 Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} 578 579 Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled 580 Is BMC Standby 581 582 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 583 Initialize OpenBMC 584 Run Keyword If ${num_records} == ${1} 585 ... Delete BMC Partition File ${Partition_file_list} ${HTTP_OK} ${FILE_DELETED_MESSAGE} 586 ... ELSE 587 ... Delete All BMC Partition File ${HTTP_OK} 588 Delete Local Partition File ${Partition_file_list} 589 590 591Verify Redfish Partition File Content 592 [Documentation] Verify partition file content. 593 [Arguments] ${file_name} ${content_dict} ${status_code} 594 595 # Description of argument(s): 596 # file_name Partition file name. 597 # content_dict Dict contain the content. 598 # status_code HTTPS status code. 599 600 FOR ${conf_file} IN @{file_name} 601 ${resp}= GET On Session openbmc /ibm/v1/Host/ConfigFiles/${conf_file} 602 ... expected_status=any 603 Should Be Equal As Strings ${resp.status_code} ${status_code} 604 605 ${Partition_file_data}= Remove String ${resp.text} \\n 606 ${Partition_file_data}= Evaluate json.loads('''${Partition_file_data}''') json 607 Should Be Equal As Strings ${Partition_file_data["Data"]} ${content_dict['${conf_file}']} 608 END 609 610 611Add Content To Files 612 [Documentation] Add defined content in partition file. 613 [Arguments] ${file_name} ${index}=${0} 614 615 # Description of argument(s): 616 # file_name Partition file name. 617 # index Index 618 619 ${num_records}= Get Length ${file_name} 620 &{content_dict}= Create Dictionary 621 622 FOR ${conf_file} IN @{file_name} 623 ${index}= Get Index From List ${file_name} ${conf_file} 624 ${index}= Evaluate ${index} + 1 625 626 Run echo "${content-${index}}" > ${conf_file} 627 OperatingSystem.File Should Exist ${conf_file} 628 629 Set To Dictionary ${content_dict} ${conf_file} ${content-${index}} 630 END 631 632 [Return] &{content_dict} 633 634 635Redfish Read Partition File 636 [Documentation] Read partition file content. 637 [Arguments] ${file_name} ${reboot_flag}=False 638 639 # Description of argument(s): 640 # file_name Partition file name. 641 # reboot_flag Reboot flag. 642 643 @{Partition_file_list} = Split String ${file_name} , 644 ${content_dict}= Add Content To Files ${Partition_file_list} 645 646 ${num_records}= Get Length ${Partition_file_list} 647 648 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPLOAD_MESSAGE} 649 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 650 Verify Redfish Partition File Content ${Partition_file_list} ${content_dict} ${HTTP_OK} 651 652 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN} 653 654 Run Keyword If ${True} == ${reboot_flag} 655 ... Run Keywords Redfish BMC Reset Operation AND 656 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND 657 ... Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled AND 658 ... Is BMC Standby AND 659 ... Initialize OpenBMC AND 660 ... Verify Redfish Partition File Content ${Partition_file_list} ${content_dict} ${HTTP_OK} 661 662 Run Keyword If ${num_records} == ${1} 663 ... Delete BMC Partition File ${Partition_file_list} ${HTTP_OK} ${FILE_DELETED_MESSAGE} 664 ... ELSE 665 ... Delete All BMC Partition File ${HTTP_OK} 666 667 Delete Local Partition File ${Partition_file_list} 668 669 670Redfish Update Partition File With Same Content 671 [Documentation] Update partition file with same content. 672 [Arguments] ${file_name} ${reboot_flag}=False 673 674 # Description of argument(s): 675 # file_name Partition file name. 676 # reboot_flag Reboot flag. 677 678 @{Partition_file_list} = Split String ${file_name} , 679 ${content_dict}= Add Content To Files ${Partition_file_list} ${0} 680 681 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPLOAD_MESSAGE} 682 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 683 Verify Redfish Partition File Content ${Partition_file_list} ${content_dict} ${HTTP_OK} 684 685 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN} 686 687 Run Keyword If ${True} == ${reboot_flag} 688 ... Run Keywords Redfish BMC Reset Operation AND 689 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND 690 ... Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled AND 691 ... Is BMC Standby AND 692 ... Initialize OpenBMC 693 694 ${content_dict}= Add Content To Files ${Partition_file_list} ${0} 695 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPDATED_MESSAGE} 696 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 697 Verify Redfish Partition File Content ${Partition_file_list} ${content_dict} ${HTTP_OK} 698 699 Delete BMC Partition File ${Partition_file_list} ${HTTP_OK} ${FILE_DELETED_MESSAGE} 700 Delete Local Partition File ${Partition_file_list} 701 702 703Redfish Update Partition File With Different Content 704 [Documentation] Update partition file with different content. 705 [Arguments] ${file_name} ${reboot_flag}=False 706 707 # Description of argument(s): 708 # file_name Partition file name. 709 # reboot_flag Reboot flag. 710 711 @{Partition_file_list} = Split String ${file_name} , 712 ${content_dict}= Add Content To Files ${Partition_file_list} ${0} 713 714 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPLOAD_MESSAGE} 715 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 716 Verify Redfish Partition File Content ${Partition_file_list} ${content_dict} ${HTTP_OK} 717 718 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN} 719 720 Run Keyword If ${True} == ${reboot_flag} 721 ... Run Keywords Redfish BMC Reset Operation AND 722 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND 723 ... Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled AND 724 ... Is BMC Standby AND 725 ... Initialize OpenBMC 726 727 ${content_dict}= Add Content To Files ${Partition_file_list} ${1} 728 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPDATED_MESSAGE} 729 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 730 Verify Redfish Partition File Content ${Partition_file_list} ${content_dict} ${HTTP_OK} 731 732 Delete BMC Partition File ${Partition_file_list} ${HTTP_OK} ${FILE_DELETED_MESSAGE} 733 Delete Local Partition File ${Partition_file_list} 734 735 736Create File Names 737 [Documentation] Create partition file names. 738 [Arguments] ${range} 739 740 # Description of argument(s): 741 # range Range in numbers. 742 743 @{file_name_list}= Create List 744 Set Test Variable ${file_name} rangefile 745 FOR ${count} IN RANGE ${range} 746 Append To List ${file_name_list} 1KB-file${count} 747 END 748 [Return] ${file_name_list} 749 750 751Redfish Upload Partition File With Range 752 [Documentation] Upload the partition file with the range of files. 753 [Arguments] ${range} 754 755 # Description of argument(s): 756 # range Range in numbers. 757 758 ${Partition_file_list}= Create File Names ${range} 759 Delete Local Partition File ${Partition_file_list} 760 Create Partition File ${Partition_file_list} 761 Upload Partition File To BMC ${Partition_file_list} ${HTTP_OK} ${FILE_UPLOAD_MESSAGE} 762 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 763 Delete All BMC Partition File ${HTTP_OK} 764 Delete Local Partition File ${Partition_file_list} 765 766 767Redfish Delete Non Existence Partition File 768 [Documentation] Delete the partition file if do not exists. 769 [Arguments] ${file_name} 770 771 # Description of argument(s): 772 # file_name Partition file name. 773 774 @{Partition_file_list} = Split String ${file_name} , 775 Delete BMC Partition File ${Partition_file_list} ${HTTP_NOT_FOUND} ${RESOURCE_NOT_FOUND_MESSAGE} 776 777 778Non Admin User To Upload Partition File 779 [Documentation] Non admin user to upload the partition file. 780 [Arguments] ${file_name} ${username} ${password} ${role} ${enabled}=${True} 781 782 # Description of argument(s): 783 # file_name Partition file name. 784 # username Username. 785 # password Password. 786 # role Role of user. 787 # enabled Value can be True or False. 788 789 Redfish Create User ${username} ${password} ${role} ${enabled} 790 Delete All Sessions 791 Initialize OpenBMC rest_username=${username} rest_password=${password} 792 @{Partition_file_list} = Split String ${file_name} , 793 Create Partition File ${Partition_file_list} 794 Upload Partition File To BMC ${Partition_file_list} ${HTTP_FORBIDDEN} ${FORBIDDEN_MESSAGE} ${False} 795 Delete Local Partition File ${Partition_file_list} 796 Redfish.Delete /redfish/v1/AccountService/Accounts/${username} 797 798 799Non Admin Delete Non Existence Partition File 800 [Documentation] Non admin user to upload the partition file. 801 [Arguments] ${file_name} ${username} ${password} ${role} ${enabled}=${True} 802 803 # Description of argument(s): 804 # file_name Partition file name. 805 # username Username. 806 # password Password. 807 # role Role of user. 808 # enabled Value can be True or False. 809 810 Redfish Create User ${username} ${password} ${role} ${enabled} 811 Delete All Sessions 812 Initialize OpenBMC rest_username=${username} rest_password=${password} 813 @{Partition_file_list} = Split String ${file_name} , 814 Delete BMC Partition File ${Partition_file_list} ${HTTP_FORBIDDEN} ${FORBIDDEN_MESSAGE} 815 816 817Verify Update Wrong Partition File To BMC 818 [Documentation] Upload the wrong partition file to BMC. 819 [Arguments] ${file_name} 820 821 # Description of argument(s): 822 # file_name Partition file name. 823 824 Redfish.Login 825 ${resp}= Run Keyword And Return Status 826 ... Redfish.Put /ibm/v1/Host/ConfigFiles/../../../../../etc/resolv.conf body={"data": "test string"} 827 Should Be Equal As Strings ${resp} False 828 829 830Check Redfish Upload Partition File Name With Character Limit To BMC 831 [Documentation] Upload the partition file to BMC with file name character limit. 832 [Arguments] ${file_name} ${status_code} ${message} 833 834 # Description of argument(s): 835 # file_name Partition file name. 836 # status_code HTTPS status code. 837 # message Expected message of from upload partition file URI. 838 839 @{Partition_file_list} = Split String ${file_name} , 840 ${num_records}= Get Length ${Partition_file_list} 841 Create Partition File ${Partition_file_list} 842 843 ${file_name_length}= Get Length ${Partition_file_list}[0] 844 845 Run Keyword If ${file_name_length} == 20 846 ... Run Keywords 847 ... Upload Partition File To BMC ${Partition_file_list} ${status_code} ${message} AND 848 ... Verify Partition File On BMC ${Partition_file_list} Partition_status=1 AND 849 ... Delete BMC Partition File ${Partition_file_list} ${HTTP_OK} ${FILE_DELETED_MESSAGE} 850 ... ELSE 851 ... Upload Partition File To BMC ${Partition_file_list} ${status_code} ${message} 852 853 Delete Local Partition File ${Partition_file_list} 854 855 856Check Redfish Fail To Upload Partition File Name With Special Character To BMC 857 [Documentation] Upload the partition file to BMC with special character file name. 858 [Arguments] ${file_name} ${status_code} ${message} 859 860 # Description of argument(s): 861 # file_name Partition file name. 862 # status_code HTTPS status code. 863 # message Expected message from upload partition file URI. 864 865 @{Partition_file_list} = Split String ${file_name} , 866 ${num_records}= Get Length ${Partition_file_list} 867 868 Create Partition File ${Partition_file_list} 869 870 Upload Partition File To BMC ${Partition_file_list} ${status_code} ${message} 871 872 ${status}= Run Keyword And Return Status 873 ... Verify Partition File On BMC ${Partition_file_list} Partition_status=1 874 Should Be Equal As Strings ${status} False 875 876 Delete Local Partition File ${Partition_file_list} 877 878 879Redfish Upload Partition File From Path 880 [Documentation] Upload the partition file to BMC from file path. 881 [Arguments] ${PARTITION_FILE_PATH} 882 883 # Description of argument(s): 884 # PARTITION_FILE_PATH Partition file path. 885 886 ${file_list} = OperatingSystem.List Files In Directory ${PARTITION_FILE_PATH} 887 888 ${num_records}= Get Length ${file_list} 889 Should Not Be Equal As Integers ${num_records} 0 890 891 FOR ${file_name} IN @{file_list} 892 @{Partition_file_list} = Split String ${file_name} , 893 ${num_records}= Get Length ${Partition_file_list} 894 Upload Partition File To BMC file_name=${Partition_file_list} 895 ... status_code=${HTTP_OK} expected_message=${FILE_UPLOAD_MESSAGE} path=${PARTITION_FILE_PATH} 896 Verify Partition File On BMC ${Partition_file_list} Partition_status=1 897 Delete BMC Partition File ${Partition_file_list} ${HTTP_OK} ${FILE_DELETED_MESSAGE} 898 END 899 900