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