xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_savearea_management.robot (revision 6fb70d98f2f1cb9273ba912deaa2cebe3c23ea86)
1fcdadc54SVijay*** Settings ***
2fcdadc54SVijay
3fcdadc54SVijayDocumentation     Test Save Area feature of Management Console on BMC.
4fcdadc54SVijay
5fcdadc54SVijayResource          ../../lib/rest_client.robot
6fcdadc54SVijayResource          ../../lib/openbmc_ffdc.robot
7fcdadc54SVijayResource          ../../lib/resource.robot
809839e2eSVijayResource          ../../lib/bmc_redfish_utils.robot
9fcdadc54SVijayResource          ../../lib/utils.robot
10cbbce6acSSushil SinghResource          ../../lib/bmc_redfish_resource.robot
11177b459aSSushil SinghResource          ../../lib/external_intf/management_console_utils.robot
12fcdadc54SVijay
13fcdadc54SVijaySuite Setup       Suite Setup Execution
14fcdadc54SVijayTest Teardown     Test Teardown Execution
1539373158SVijaySuite Teardown    Suite Teardown Execution
16fcdadc54SVijay
17*6fb70d98SMatt FischerTest Tags        Savearea_Management
187c32f30fSGeorge Keishing
19fcdadc54SVijay*** Variables ***
20fcdadc54SVijay
21de1347d3SSushil Singh${MAXIMUM_FILE_SIZE_MESSAGE}        File size exceeds maximum allowed size[25MB]
221544c5efSSushil Singh${MAXIMUM_DIR_SIZE_MESSAGE}
23de1347d3SSushil Singh...   File size does not fit in the savearea directory maximum allowed size[25MB]
24cbbce6acSSushil Singh${FILE_UPLOAD_MESSAGE}              File Created
25cbbce6acSSushil Singh${FILE_DELETED_MESSAGE}             File Deleted
26251a0bc9SSushil Singh${FILE_UPDATED_MESSAGE}             File Updated
27cbbce6acSSushil Singh${FORBIDDEN_MESSAGE}                Forbidden
28cbbce6acSSushil Singh${ERROR_MESSAGE}                    Error while creating the file
29251a0bc9SSushil Singh${RESOURCE_NOT_FOUND_MESSAGE}       Resource Not Found
30251a0bc9SSushil Singh${MINIMUM_FILE_SIZE_MESSAGE}        File size is less than minimum allowed size[100B]
31251a0bc9SSushil Singh${MAXIMUM_FILE_NAME_MESSAGE}        Filename must be maximum 20 characters
32251a0bc9SSushil Singh${UNSUPPORTED_FILE_NAME_MESSAGE}    Unsupported character in filename
33fcdadc54SVijay
347aa3cc4bSSushil Singh${content-1}                        Sample Content to test partition file upload
3585c381c2SSushil Singh...  Sample Content to test partition file upload
3685c381c2SSushil Singh...  Sample Content to test partition file upload
377aa3cc4bSSushil Singh${content-2}                        Sample Content to test partition file upload after reboot
3885c381c2SSushil Singh...  Sample Content to test partition file upload after reboot
3985c381c2SSushil Singh...  Sample Content to test partition file upload after reboot
4085c381c2SSushil Singh
4144b8cf33SSushil Singh${LOOP_COUNT}                       10
4244b8cf33SSushil Singh
43fcdadc54SVijay*** Test Cases ***
44fcdadc54SVijay
45251a0bc9SSushil SinghRedfish Upload Lower Limit Partition File To BMC
46251a0bc9SSushil Singh    [Documentation]  Upload lower limit of allowed partition file to BMC using Redfish.
47251a0bc9SSushil Singh    [Tags]  Redfish_Upload_Lower_Limit_Partition_File_To_BMC
48251a0bc9SSushil Singh    [Template]  Redfish Upload Partition File
49251a0bc9SSushil Singh
50255ec639SSushil Singh    # file_name
51255ec639SSushil Singh    100-file
52251a0bc9SSushil Singh
53251a0bc9SSushil Singh
54cbbce6acSSushil SinghRedfish Upload Partition File To BMC
55251a0bc9SSushil Singh    [Documentation]  Upload partition file to BMC using Redfish.
56cbbce6acSSushil Singh    [Tags]  Redfish_Upload_Partition_File_To_BMC
57cbbce6acSSushil Singh    [Template]  Redfish Upload Partition File
58fcdadc54SVijay
59cbbce6acSSushil Singh    # file_name
6085c381c2SSushil Singh    500KB-file
61de1347d3SSushil Singh    2000KB-file
621544c5efSSushil Singh    10000KB-file
63de1347d3SSushil Singh    25000KB-file
64fcdadc54SVijay
65fcdadc54SVijay
66255ec639SSushil SinghTest Upload Lower Limit Partition File To BMC And Expect Failure
67255ec639SSushil Singh    [Documentation]  Fail to upload partition file to BMC with file size
68255ec639SSushil Singh    ...  below the lower limit of allowed partition file size using Redfish.
69255ec639SSushil Singh    [Tags]  Test_Upload_Lower_Limit_Partition_File_To_BMC_And_Expect_Failure
70255ec639SSushil Singh    [Template]  Redfish Fail To Upload Partition File
71255ec639SSushil Singh
721544c5efSSushil Singh    # file_name    status_code            partition_status    response_message
731544c5efSSushil Singh    99-file        ${HTTP_BAD_REQUEST}    0                   ${MINIMUM_FILE_SIZE_MESSAGE}
74255ec639SSushil Singh
75255ec639SSushil Singh
76298d15d8SSushil SinghTest Upload Upper Limit Partition File To BMC And Expect Failure
77298d15d8SSushil Singh    [Documentation]  Fail to upload partition file to BMC with file size
78298d15d8SSushil Singh    ...  more than upper limit of allowed partition file size using Redfish.
79298d15d8SSushil Singh    [Tags]  Test_Upload_Upper_Limit_Partition_File_To_BMC_And_Expect_Failure
80cbbce6acSSushil Singh    [Template]  Redfish Fail To Upload Partition File
81fcdadc54SVijay
821544c5efSSushil Singh    # file_name     status_code            partition_status    response_message
83de1347d3SSushil Singh    25001KB-file    ${HTTP_BAD_REQUEST}    0                   ${MAXIMUM_FILE_SIZE_MESSAGE}
84fcdadc54SVijay
85fcdadc54SVijay
86cbbce6acSSushil SinghRedfish Upload Multiple Partition File To BMC
87251a0bc9SSushil Singh    [Documentation]  Upload multiple partition file to BMC using Redfish.
88cbbce6acSSushil Singh    [Tags]  Redfish_Upload_Multiple_Partition_File_To_BMC
89cbbce6acSSushil Singh    [Template]  Redfish Upload Partition File
90fcdadc54SVijay
91cbbce6acSSushil Singh    # file_name
9285c381c2SSushil Singh    250KB-file,500KB-file
93fcdadc54SVijay
94fcdadc54SVijay
95f9eeec7bSSushil SinghTest Upload Partition File When BMC Space Reach Max And Expect Failure
96f9eeec7bSSushil Singh    [Documentation]  Fail to upload multiple partition file to BMC
97f9eeec7bSSushil Singh    ...  as BMC directory reach to upper limit using Redfish.
98f9eeec7bSSushil Singh    [Tags]  Test_Upload_Partition_File_When_BMC_Space_Reach_Max_And_Expect_Failure
99cbbce6acSSushil Singh    [Template]  Redfish Fail To Upload Partition File
10009839e2eSVijay
1011544c5efSSushil Singh    # file_name     status_code            partition_status    response_message
102de1347d3SSushil Singh    15000KB-file    ${HTTP_OK}             1                   ${FILE_UPLOAD_MESSAGE}
103de1347d3SSushil Singh    16000KB-file    ${HTTP_BAD_REQUEST}    0                   ${MAXIMUM_DIR_SIZE_MESSAGE}
104de1347d3SSushil Singh    25000KB-file    ${HTTP_OK}             1                   ${FILE_UPLOAD_MESSAGE}
1051544c5efSSushil Singh    100-file        ${HTTP_BAD_REQUEST}    0                   ${MAXIMUM_DIR_SIZE_MESSAGE}
10609839e2eSVijay
10709839e2eSVijay
108df6ba520SSushil SinghRedfish Upload Same Partition File To BMC In Loop
109251a0bc9SSushil Singh    [Documentation]  Upload same partition file to BMC using Redfish in loop.
110df6ba520SSushil Singh    [Tags]  Redfish_Upload_Same_Partition_File_To_BMC_In_Loop
111df6ba520SSushil Singh    [Template]  Redfish Upload Partition File In Loop
112df6ba520SSushil Singh
113df6ba520SSushil Singh    # file_name
11485c381c2SSushil Singh    500KB-file
115df6ba520SSushil Singh
116df6ba520SSushil Singh
117f39629cbSSushil SinghRedfish Upload And Delete Same Partition File To BMC In Loop
118251a0bc9SSushil Singh    [Documentation]  Upload same partition file to BMC using Redfish in loop.
119f39629cbSSushil Singh    [Tags]  Redfish_Upload_And_Delete_Same_Partition_File_To_BMC_In_Loop
120f39629cbSSushil Singh    [Template]  Redfish Upload And Delete Partition File In Loop
121f39629cbSSushil Singh
122f39629cbSSushil Singh    # file_name
12385c381c2SSushil Singh    500KB-file
124f39629cbSSushil Singh
125f39629cbSSushil Singh
1265d0782f0SSushil SinghRedfish Partition File Upload Post BMC Reboot
127251a0bc9SSushil Singh    [Documentation]  Upload partition file to BMC using Redfish, after the BMC reboot.
1285d0782f0SSushil Singh    [Tags]  Redfish_Partition_File_Upload_Post_BMC_Reboot
1295d0782f0SSushil Singh    [Template]  Verify Partition File Upload Post BMC Reboot
1305d0782f0SSushil Singh
1315d0782f0SSushil Singh    # file_name
13285c381c2SSushil Singh    500KB-file
1335d0782f0SSushil Singh
1345d0782f0SSushil Singh
135cbbce6acSSushil SinghRedfish Partition File Persistency On BMC Reboot
136251a0bc9SSushil Singh    [Documentation]  Upload partition file to BMC using Redfish and is same after reboot.
137cbbce6acSSushil Singh    [Tags]  Redfish_Partition_File_Persistency_On_BMC_Reboot
138cbbce6acSSushil Singh    [Template]  Redfish Partition File Persistency
13909839e2eSVijay
140cbbce6acSSushil Singh    # file_name
14185c381c2SSushil Singh    500KB-file
14209839e2eSVijay
14309839e2eSVijay
144cbbce6acSSushil SinghRedfish Multiple Partition File Persistency On BMC Reboot
145251a0bc9SSushil Singh    [Documentation]  Upload multiple partition file to BMC using Redfish and is same after reboot.
146cbbce6acSSushil Singh    [Tags]  Redfish_Multiple_Partition_File_Persistency_On_BMC_Reboot
147cbbce6acSSushil Singh    [Template]  Redfish Partition File Persistency
14809839e2eSVijay
149cbbce6acSSushil Singh    # file_name
15085c381c2SSushil Singh    250KB-file,500KB-file
15109839e2eSVijay
15209839e2eSVijay
153b22e4b6eSSushil SinghRedfish Read Partition File From BMC
154251a0bc9SSushil Singh    [Documentation]  Upload partition file to BMC using Redfish and verify the content.
155b22e4b6eSSushil Singh    [Tags]  Redfish_Read_Partition_File_From_BMC
156cbbce6acSSushil Singh    [Template]  Redfish Read Partition File
15709839e2eSVijay
158cbbce6acSSushil Singh    # file_name                      reboot_flag
15985c381c2SSushil Singh    testfile01-file                  False
16085c381c2SSushil Singh    testfile01-file,testfile02-file  False
16109839e2eSVijay
16209839e2eSVijay
163b22e4b6eSSushil SinghRedfish Read Partition File Post BMC Reboot
164251a0bc9SSushil Singh    [Documentation]  Upload partition file to BMC using Redfish and verify the content after reboot.
165b22e4b6eSSushil Singh    [Tags]  Redfish_Read_Partition_File_Post_BMC_Reboot
166cbbce6acSSushil Singh    [Template]  Redfish Read Partition File
16709839e2eSVijay
168cbbce6acSSushil Singh    # file_name                      reboot_flag
16985c381c2SSushil Singh    testfile01-file                  True
17085c381c2SSushil Singh    testfile01-file,testfile02-file  True
17109839e2eSVijay
17209839e2eSVijay
173cbbce6acSSushil SinghRedfish Update Partition File On BMC
174251a0bc9SSushil Singh    [Documentation]  Upload partition file to BMC using Redfish and verify the content.
175cbbce6acSSushil Singh    [Tags]  Redfish_Update_Partition_File_On_BMC
176cbbce6acSSushil Singh    [Template]  Redfish Update Partition File With Different Content
17709839e2eSVijay
178cbbce6acSSushil Singh    # file_name                 reboot_flag
17985c381c2SSushil Singh    testfile01-file             False
180cbbce6acSSushil Singh
181cbbce6acSSushil Singh
182cbbce6acSSushil SinghRedfish Update Partition File On BMC Reboot
183251a0bc9SSushil Singh    [Documentation]  Upload partition file to BMC using Redfish and verify the content after the reboot.
184cbbce6acSSushil Singh    [Tags]  Redfish_Update_Partition_File_On_BMC_Reboot
185cbbce6acSSushil Singh    [Template]  Redfish Update Partition File With Different Content
186cbbce6acSSushil Singh
187cbbce6acSSushil Singh    # file_name                 reboot_flag
18885c381c2SSushil Singh    testfile01-file             True
189cbbce6acSSushil Singh
190cbbce6acSSushil Singh
191cbbce6acSSushil SinghRedfish Persistency Update Partition File On BMC
192251a0bc9SSushil Singh    [Documentation]  Upload partition file to BMC using Redfish and verify the content.
193cbbce6acSSushil Singh    [Tags]  Redfish_Persistency_Update_Partition_File_On_BMC
194cbbce6acSSushil Singh    [Template]  Redfish Update Partition File With Same Content
195cbbce6acSSushil Singh
196cbbce6acSSushil Singh    # file_name                 reboot_flag
19785c381c2SSushil Singh    testfile01-file             False
198cbbce6acSSushil Singh
199cbbce6acSSushil Singh
200cbbce6acSSushil SinghRedfish Delete Non Existence Of Partition File
201cbbce6acSSushil Singh    [Documentation]  Delete the partition file if do not exists.
202cbbce6acSSushil Singh    [Tags]  Redfish_Delete_Non_Existence_Of_Partition_File
203cbbce6acSSushil Singh    [Template]  Redfish Delete Non Existence Partition File
204cbbce6acSSushil Singh
205cbbce6acSSushil Singh    # file_name
20685c381c2SSushil Singh    testfile01-file
20709839e2eSVijay
20809839e2eSVijay
20909839e2eSVijayVerify One Thousand Partitions File Upload
210cbbce6acSSushil Singh    [Documentation]  Upload 1000 partition file to BMC.
21109839e2eSVijay    [Tags]  Verify_One_Thousand_Partitions_File_Upload
212cbbce6acSSushil Singh    [Template]  Redfish Upload Partition File With Range
21309839e2eSVijay
214cbbce6acSSushil Singh    # range
215cbbce6acSSushil Singh    1000
21609839e2eSVijay
21709839e2eSVijay
218cbbce6acSSushil SinghNon Admin Users Fail To Upload Partition File
219cbbce6acSSushil Singh    [Documentation]  Non admin user will fail to upload the partition file.
220cbbce6acSSushil Singh    [Tags]  Non_Admin_Users_Fail_To_Upload_Partition_File
221cbbce6acSSushil Singh    [Template]  Non Admin User To Upload Partition File
22209839e2eSVijay
223cbbce6acSSushil Singh    # file_name    username         password       role_id
22485c381c2SSushil Singh    500KB-file     operator_user    TestPwd123     Operator
22509839e2eSVijay
22609839e2eSVijay
227cbbce6acSSushil SinghNon Admin User Delete Non Existence Of Partition File
22816b3c7bfSGeorge Keishing    [Documentation]  Delete the partition file if does not exists.
229cbbce6acSSushil Singh    [Tags]  Non_Admin_User_Delete_Non_Existence_Of_Partition_File
230cbbce6acSSushil Singh    [Template]  Non Admin Delete Non Existence Partition File
231cbbce6acSSushil Singh
232cbbce6acSSushil Singh    # file_name    username         password       role_id
23385c381c2SSushil Singh    500KB-file     operator_user    TestPwd123     Operator
234cbbce6acSSushil Singh
235cbbce6acSSushil Singh
236cbbce6acSSushil SinghRedfish Update Wrong Partition File To BMC
237251a0bc9SSushil Singh    [Documentation]  Upload partition file to BMC by wrong URI using Redfish.
238cbbce6acSSushil Singh    [Tags]  Redfish_Update_Wrong_Partition_File_To_BMC
239cbbce6acSSushil Singh    [Template]  Verify Update Wrong Partition File To BMC
240cbbce6acSSushil Singh
241cbbce6acSSushil Singh    # file_name
24285c381c2SSushil Singh    500KB-file
243cbbce6acSSushil Singh
2449942df51SSushil Singh
2459942df51SSushil SinghTest Redfish Upload Partition File Name With Character Limit To BMC
2469942df51SSushil Singh    [Documentation]  Upload partition file to BMC with file name character allowed limit
2479942df51SSushil Singh    ...  and above allowed limit using Redfish.
2489942df51SSushil Singh    [Tags]  Test_Redfish_Upload_Partition_File_Name_With_Character_Limit_To_BMC
2499942df51SSushil Singh    [Template]  Check Redfish Upload Partition File Name With Character Limit To BMC
2509942df51SSushil Singh
2519942df51SSushil Singh    # file_name              status_code            message
2529942df51SSushil Singh    50KB-testfilesavfile     ${HTTP_OK}             ${FILE_UPLOAD_MESSAGE}
2539942df51SSushil Singh    50KB-testsaveareafile    ${HTTP_BAD_REQUEST}    ${MAXIMUM_FILE_NAME_MESSAGE}
2549942df51SSushil Singh
2552dbcbdebSSushil Singh
2562dbcbdebSSushil SinghTest Redfish Fail To Upload Partition File Name With Special Character To BMC
2572dbcbdebSSushil Singh    [Documentation]  Upload partition file to BMC with special character file name and
2582dbcbdebSSushil Singh    ...  Redfish through an error.
2592dbcbdebSSushil Singh    [Tags]  Test_Redfish_Fail_To_Upload_Partition_File_Name_With_Special_Character_To_BMC
2602dbcbdebSSushil Singh    [Template]  Check Redfish Fail To Upload Partition File Name With Special Character To BMC
2612dbcbdebSSushil Singh
2622dbcbdebSSushil Singh    # file_name      status_code            message
2632dbcbdebSSushil Singh    1KB-*filename    ${HTTP_BAD_REQUEST}    ${UNSUPPORTED_FILE_NAME_MESSAGE}
2642dbcbdebSSushil Singh    1KB-!filename    ${HTTP_BAD_REQUEST}    ${UNSUPPORTED_FILE_NAME_MESSAGE}
2652dbcbdebSSushil Singh    1KB-@filename    ${HTTP_BAD_REQUEST}    ${UNSUPPORTED_FILE_NAME_MESSAGE}
2662dbcbdebSSushil Singh
26744b8cf33SSushil Singh
268404416d1SSushil SinghRedfish Persistency Update Partition File Post BMC Reboot
269404416d1SSushil Singh    [Documentation]  Upload partition file to BMC using Redfish and verify the content after the reboot.
270404416d1SSushil Singh    [Tags]  Redfish_Persistency_Update_Partition_File_Post_BMC_Reboot
271404416d1SSushil Singh    [Template]  Redfish Update Partition File With Same Content
272404416d1SSushil Singh
273404416d1SSushil Singh    # file_name                 reboot_flag
274404416d1SSushil Singh    testfile01-file             True
275404416d1SSushil Singh
276404416d1SSushil Singh
27744b8cf33SSushil SinghRedfish Upload Validated Partition File From Path To BMC
27844b8cf33SSushil Singh   [Documentation]  Upload valid partition file to BMC from file path define by user in loop.
27944b8cf33SSushil Singh   ...  By default loop count values is 10 times.
28044b8cf33SSushil Singh   [Tags]  Redfish_Upload_Validated_Partition_File_From_Path_To_BMC
28144b8cf33SSushil Singh
28244b8cf33SSushil Singh   Log To Console  ${EMPTY}
28344b8cf33SSushil Singh   FOR  ${count}  IN RANGE  1  ${LOOP_COUNT} + 1
28444b8cf33SSushil Singh     Log To Console  **************************************
28544b8cf33SSushil Singh     Log To Console  * The Current Loop Count is ${count} of ${LOOP_COUNT} *
28644b8cf33SSushil Singh     Log To Console  **************************************
28744b8cf33SSushil Singh
28844b8cf33SSushil Singh     Redfish Upload Partition File From Path  ${PARTITION_FILE_PATH}
28944b8cf33SSushil Singh   END
29044b8cf33SSushil Singh
291fcdadc54SVijay*** Keywords ***
292fcdadc54SVijay
293cbbce6acSSushil SinghSuite Setup Execution
294cbbce6acSSushil Singh    [Documentation]  Suite setup execution.
295fcdadc54SVijay
296cbbce6acSSushil Singh    Redfish.Login
297fcdadc54SVijay
298fcdadc54SVijay
299cbbce6acSSushil SinghTest Teardown Execution
300cbbce6acSSushil Singh    [Documentation]  Test teardown execution.
30109839e2eSVijay
302cbbce6acSSushil Singh    Delete All BMC Partition File  ${HTTP_OK}
303cbbce6acSSushil Singh    FFDC On Test Case Fail
304cbbce6acSSushil Singh
305cbbce6acSSushil Singh
306cbbce6acSSushil SinghSuite Teardown Execution
307cbbce6acSSushil Singh    [Documentation]  Suite teardown execution.
30809839e2eSVijay
30909839e2eSVijay    Delete All Sessions
31009839e2eSVijay
31109839e2eSVijay
312cbbce6acSSushil SinghDelete Local Partition File
313cbbce6acSSushil Singh    [Documentation]  Delete local partition file.
314cbbce6acSSushil Singh    [Arguments]  ${file_name}
315fcdadc54SVijay
316fcdadc54SVijay    # Description of argument(s):
317cbbce6acSSushil Singh    # file_name    Partition file name.
31809839e2eSVijay
319cbbce6acSSushil Singh    FOR  ${conf_file}  IN  @{file_name}
320cbbce6acSSushil Singh      ${file_exist}=  Run Keyword And Return Status  OperatingSystem.File Should Exist  ${conf_file}
321cbbce6acSSushil Singh      Run Keyword If  'True' == '${file_exist}'  Remove File  ${conf_file}
322cbbce6acSSushil Singh    END
323fcdadc54SVijay
324fcdadc54SVijay
3251544c5efSSushil SinghDelete Local Server Partition File
3261544c5efSSushil Singh    [Documentation]  Local partition files which is getting uploaded to BMC,
3271544c5efSSushil Singh    ...  will get deleted after the uploads. If partition file name consist
3281544c5efSSushil Singh    ...  of “-file” then partition file gets deleted.
3291544c5efSSushil Singh
3301544c5efSSushil Singh    @{conf_file_list} =  OperatingSystem.List Files In Directory  ${EXECDIR}
3311544c5efSSushil Singh    ${match_conf_file_list}=  Get Matches  ${conf_file_list}  regexp=.*-file  case_insensitive=${True}
3321544c5efSSushil Singh
3331544c5efSSushil Singh    ${num_records}=  Get Length  ${match_conf_file_list}
3341544c5efSSushil Singh    Return From Keyword If  ${num_records} == ${0}  ${EMPTY}
3351544c5efSSushil Singh
3361544c5efSSushil Singh    FOR  ${conf_file}  IN  @{match_conf_file_list}
3371544c5efSSushil Singh      ${file_exist}=  Run Keyword And Return Status  OperatingSystem.File Should Exist  ${conf_file}
3381544c5efSSushil Singh      Run Keyword If  'True' == '${file_exist}'  Remove File  ${conf_file}
3391544c5efSSushil Singh    END
3401544c5efSSushil Singh
3411544c5efSSushil Singh
342cbbce6acSSushil SinghCreate Partition File
343cbbce6acSSushil Singh    [Documentation]  Create Partition file.
344cbbce6acSSushil Singh    [Arguments]  ${file_name}
345cbbce6acSSushil Singh
346cbbce6acSSushil Singh    # Description of argument(s):
347cbbce6acSSushil Singh    # file_name    Partition file name.
348cbbce6acSSushil Singh
349cbbce6acSSushil Singh    Delete Local Partition File  ${file_name}
350cbbce6acSSushil Singh
351cbbce6acSSushil Singh    FOR  ${conf_file}  IN  @{file_name}
35285c381c2SSushil Singh      @{words}=  Split String  ${conf_file}  -
353255ec639SSushil Singh      Run  dd if=/dev/zero of=${conf_file} bs=${words}[-0] count=1
354251a0bc9SSushil Singh      OperatingSystem.File Should Exist  ${conf_file}
355251a0bc9SSushil Singh    END
356251a0bc9SSushil Singh
357251a0bc9SSushil Singh
358cbbce6acSSushil SinghDelete BMC Partition File
359251a0bc9SSushil Singh    [Documentation]  Delete single partition file on BMC via Redfish.
360cbbce6acSSushil Singh    [Arguments]  ${file_name}  ${status_code}  ${expected_message}
361cbbce6acSSushil Singh
362cbbce6acSSushil Singh    # Description of argument(s):
363cbbce6acSSushil Singh    # file_name           Partition file name.
364cbbce6acSSushil Singh    # status_code         HTTPS status code.
365cbbce6acSSushil Singh    # expected_message    Expected message of URI.
366cbbce6acSSushil Singh
367cbbce6acSSushil Singh    FOR  ${conf_file}  IN  @{file_name}
368cbbce6acSSushil Singh      ${data}=  Create Dictionary
369fcdadc54SVijay      ${headers}=  Create Dictionary  X-Auth-Token=${XAUTH_TOKEN}
370fcdadc54SVijay      Set To Dictionary  ${data}  headers  ${headers}
371fcdadc54SVijay
372fbd67007SGeorge Keishing      ${resp}=  DELETE On Session  openbmc  /ibm/v1/Host/ConfigFiles/${conf_file}  &{data}
373fbd67007SGeorge Keishing      ...  expected_status=any
374cbbce6acSSushil Singh      Should Be Equal As Strings  ${resp.status_code}  ${status_code}
37509839e2eSVijay
3767aa3cc4bSSushil Singh      ${description}=  Return Description Of Response  ${resp.text}
3777aa3cc4bSSushil Singh      Should Be Equal As Strings  ${description}  ${expected_message}
378cbbce6acSSushil Singh    END
37909839e2eSVijay
38009839e2eSVijay
381cbbce6acSSushil SinghDelete All BMC Partition File
382251a0bc9SSushil Singh    [Documentation]  Delete multiple partition file on BMC via Redfish.
383cbbce6acSSushil Singh    [Arguments]  ${status_code}
384cbbce6acSSushil Singh
385cbbce6acSSushil Singh    # Description of argument(s):
386cbbce6acSSushil Singh    # status_code       HTTPS status code.
387cbbce6acSSushil Singh
388cbbce6acSSushil Singh    Initialize OpenBMC
389cbbce6acSSushil Singh    ${data}=  Create Dictionary
390cbbce6acSSushil Singh    ${headers}=  Create Dictionary  X-Auth-Token=${XAUTH_TOKEN}
391cbbce6acSSushil Singh    Set To Dictionary  ${data}  headers  ${headers}
392cbbce6acSSushil Singh
393fbd67007SGeorge Keishing    ${resp}=  POST On Session  openbmc  /ibm/v1/Host/ConfigFiles/Actions/IBMConfigFiles.DeleteAll  &{data}
394fbd67007SGeorge Keishing    ...  expected_status=any
395cbbce6acSSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
396cbbce6acSSushil Singh
397cbbce6acSSushil Singh
398cbbce6acSSushil SinghReturn Description Of Response
39909839e2eSVijay    [Documentation]  Return description of REST response.
40009839e2eSVijay    [Arguments]  ${resp_text}
40109839e2eSVijay
40209839e2eSVijay    # Description of argument(s):
40309839e2eSVijay    # resp_text    REST response body.
40409839e2eSVijay
40509839e2eSVijay    # resp_text after successful partition file upload looks like:
40609839e2eSVijay    # {
40709839e2eSVijay    #    "Description": "File Created"
40809839e2eSVijay    # }
40909839e2eSVijay
4107aa3cc4bSSushil Singh    ${status}=  Run Keyword And Return Status  Evaluate  isinstance(${resp_text}, dict)
4117aa3cc4bSSushil Singh    Return From Keyword If  '${status}' == 'False'  ${resp_text}
41209839e2eSVijay    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
41309839e2eSVijay
414409df05dSGeorge Keishing    RETURN  ${message["Description"]}
41509839e2eSVijay
41609839e2eSVijay
417cbbce6acSSushil SinghUpload Partition File To BMC
418cbbce6acSSushil Singh    [Documentation]  Upload partition file to BMC.
41944b8cf33SSushil Singh    [Arguments]  ${file_name}  ${status_code}  ${expected_message}  ${flag}=${True}  ${path}=${EMPTY}
42009839e2eSVijay
42109839e2eSVijay    # Description of argument(s):
422cbbce6acSSushil Singh    # file_name           Partition file name.
423cbbce6acSSushil Singh    # status_code         HTTPS status code.
424cbbce6acSSushil Singh    # expected_message    Expected message of URI.
425cbbce6acSSushil Singh    # flag                If True run part of program, else skip.
42644b8cf33SSushil Singh    # path                Partition file path.
42709839e2eSVijay
428cbbce6acSSushil Singh    Run Keyword If  '${flag}' == '${True}'  Initialize OpenBMC
429cbbce6acSSushil Singh    FOR  ${conf_file}  IN  @{file_name}
430cbbce6acSSushil Singh      # Get the content of the file and upload to BMC.
43144b8cf33SSushil Singh      ${image_data}=  OperatingSystem.Get Binary File  ${path}${conf_file}
43285c381c2SSushil Singh      ${headers}=  Create Dictionary  X-Auth-Token=${XAUTH_TOKEN}  Content-Type=application/octet-stream
43309839e2eSVijay
43485c381c2SSushil Singh      ${kwargs}=  Create Dictionary  data=${image_data}
43585c381c2SSushil Singh      Set To Dictionary  ${kwargs}  headers  ${headers}
436fbd67007SGeorge Keishing      ${resp}=  PUT On Session  openbmc  /ibm/v1/Host/ConfigFiles/${conf_file}  &{kwargs}  timeout=10
437fbd67007SGeorge Keishing      ...  expected_status=any
438cbbce6acSSushil Singh      Should Be Equal As Strings  ${resp.status_code}  ${status_code}
439cbbce6acSSushil Singh
4407aa3cc4bSSushil Singh      ${description}=  Return Description Of Response  ${resp.text}
4417aa3cc4bSSushil Singh      Should Be Equal As Strings  ${description}  ${expected_message}
442cbbce6acSSushil Singh    END
443fcdadc54SVijay
444fcdadc54SVijay
445cbbce6acSSushil SinghVerify Partition File On BMC
446cbbce6acSSushil Singh    [Documentation]  Verify partition file on BMC.
447cbbce6acSSushil Singh    [Arguments]  ${file_name}  ${Partition_status}
448fcdadc54SVijay
449fcdadc54SVijay    # Description of argument(s):
450cbbce6acSSushil Singh    # file_name           Partition file name.
451cbbce6acSSushil Singh    # Partition_status    Partition file status on BMC.
452fcdadc54SVijay
453cbbce6acSSushil Singh    FOR  ${conf_file}  IN  @{file_name}
454fcdadc54SVijay      ${status}  ${stderr}  ${rc}=  BMC Execute Command
455e5f39ee3SSushil Singh      ...  ls -l /var/lib/bmcweb/ibm-management-console/configfiles/${conf_file} | wc -l
456cbbce6acSSushil Singh      Valid Value  ${status}  [${Partition_status}]
457cbbce6acSSushil Singh    END
458fcdadc54SVijay
459fcdadc54SVijay
460cbbce6acSSushil SinghRedfish Upload Partition File
461cbbce6acSSushil Singh    [Documentation]  Upload the partition file.
462251a0bc9SSushil Singh    [Arguments]  ${file_name}  ${file_size}=${EMPTY}
463fcdadc54SVijay
464fcdadc54SVijay    # Description of argument(s):
465cbbce6acSSushil Singh    # file_name    Partition file name.
466251a0bc9SSushil Singh    # file_size    By Default is set to EMPTY,
467251a0bc9SSushil Singh    #              if user pass small_file_size the create file with small
468251a0bc9SSushil Singh    #              size keyword gets executed.
469fcdadc54SVijay
470cbbce6acSSushil Singh    @{Partition_file_list} =  Split String  ${file_name}  ,
471cbbce6acSSushil Singh    ${num_records}=  Get Length  ${Partition_file_list}
472251a0bc9SSushil Singh
473255ec639SSushil Singh    Create Partition File  ${Partition_file_list}
474251a0bc9SSushil Singh
475cbbce6acSSushil Singh    Upload Partition File To BMC  ${Partition_file_list}  ${HTTP_OK}  ${FILE_UPLOAD_MESSAGE}
476cbbce6acSSushil Singh    Verify Partition File On BMC  ${Partition_file_list}  Partition_status=1
477cbbce6acSSushil Singh    Run Keyword If  ${num_records} == ${1}
478cbbce6acSSushil Singh    ...    Delete BMC Partition File  ${Partition_file_list}  ${HTTP_OK}  ${FILE_DELETED_MESSAGE}
479cbbce6acSSushil Singh    ...  ELSE
480cbbce6acSSushil Singh    ...    Delete All BMC Partition File  ${HTTP_OK}
481cbbce6acSSushil Singh    Delete Local Partition File  ${Partition_file_list}
482fcdadc54SVijay
483fcdadc54SVijay
484cbbce6acSSushil SinghRedfish Fail To Upload Partition File
48516b3c7bfSGeorge Keishing    [Documentation]  Fail to upload the partition file.
4861544c5efSSushil Singh    [Arguments]  ${file_name}  ${status_code}  ${partition_status}  ${response_message}=${EMPTY}
48709839e2eSVijay
48809839e2eSVijay    # Description of argument(s):
489cbbce6acSSushil Singh    # file_name           Partition file name.
4901544c5efSSushil Singh    # status_code         HTTPS status code.
4911544c5efSSushil Singh    # partition_status    Partition status.
492255ec639SSushil Singh    # response_message    By default is set to EMPTY,
493255ec639SSushil Singh    #                     else user provide the information when user upload the partition with file size
494255ec639SSushil Singh    #                     below lower linit of allowed partition or more than of large allowed partition.
49509839e2eSVijay
496cbbce6acSSushil Singh    @{Partition_file_list} =  Split String  ${file_name}  ,
497255ec639SSushil Singh
498cbbce6acSSushil Singh    Create Partition File  ${Partition_file_list}
4991544c5efSSushil Singh    Upload Partition File To BMC  ${Partition_file_list}  ${status_code}  ${response_message}
5001544c5efSSushil Singh    Verify Partition File On BMC  ${Partition_file_list}  Partition_status=${partition_status}
501255ec639SSushil Singh
5021544c5efSSushil Singh    Run Keyword If  ${partition_status} == 0
5031544c5efSSushil Singh    ...  Run Keywords
5041544c5efSSushil Singh    ...  Delete BMC Partition File
5051544c5efSSushil Singh    ...  ${Partition_file_list}  ${HTTP_NOT_FOUND}  ${RESOURCE_NOT_FOUND_MESSAGE}  AND
5061544c5efSSushil Singh    ...  Delete All BMC Partition File  ${HTTP_OK}  AND
5071544c5efSSushil Singh    ...  Delete Local Server Partition File
5081544c5efSSushil Singh
509cbbce6acSSushil Singh    Delete Local Partition File  ${Partition_file_list}
51009839e2eSVijay
51109839e2eSVijay
512df6ba520SSushil SinghRedfish Upload Partition File In Loop
513df6ba520SSushil Singh    [Documentation]  Upload the same partition file multiple times in loop to BMC.
514df6ba520SSushil Singh    [Arguments]  ${file_name}
515df6ba520SSushil Singh
516df6ba520SSushil Singh    # Description of argument(s):
517df6ba520SSushil Singh    # file_name    Partition file name.
518df6ba520SSushil Singh
519df6ba520SSushil Singh    @{Partition_file_list} =  Split String  ${file_name}  ,
520df6ba520SSushil Singh    Create Partition File  ${Partition_file_list}
521df6ba520SSushil Singh
522df6ba520SSushil Singh    Upload Partition File To BMC  ${Partition_file_list}  ${HTTP_OK}  ${FILE_UPLOAD_MESSAGE}
523df6ba520SSushil Singh    Verify Partition File On BMC  ${Partition_file_list}  Partition_status=1
524df6ba520SSushil Singh
525df6ba520SSushil Singh    FOR  ${count}  IN RANGE  1  11
526251a0bc9SSushil Singh      Upload Partition File To BMC  ${Partition_file_list}  ${HTTP_OK}  ${FILE_UPDATED_MESSAGE}
527df6ba520SSushil Singh      Verify Partition File On BMC  ${Partition_file_list}  Partition_status=1
528df6ba520SSushil Singh    END
529df6ba520SSushil Singh
530df6ba520SSushil Singh    Initialize OpenBMC
531df6ba520SSushil Singh    Delete BMC Partition File  ${Partition_file_list}  ${HTTP_OK}  ${FILE_DELETED_MESSAGE}
532df6ba520SSushil Singh    Delete Local Partition File  ${Partition_file_list}
533df6ba520SSushil Singh
534df6ba520SSushil Singh
535f39629cbSSushil SinghRedfish Upload And Delete Partition File In Loop
536f39629cbSSushil Singh    [Documentation]  Upload the same partition file multiple times in loop to BMC.
537f39629cbSSushil Singh    [Arguments]  ${file_name}
538f39629cbSSushil Singh
539f39629cbSSushil Singh    # Description of argument(s):
540f39629cbSSushil Singh    # file_name    Partition file name.
541f39629cbSSushil Singh
542f39629cbSSushil Singh    FOR  ${count}  IN RANGE  1  11
543f39629cbSSushil Singh      Redfish Upload Partition File  ${file_name}
544f39629cbSSushil Singh    END
545f39629cbSSushil Singh
546f39629cbSSushil Singh
5475d0782f0SSushil SinghVerify Partition File Upload Post BMC Reboot
5485d0782f0SSushil Singh    [Documentation]  Upload the partition file, after BMC reboot.
5495d0782f0SSushil Singh    [Arguments]  ${file_name}
5505d0782f0SSushil Singh
5515d0782f0SSushil Singh    # Description of argument(s):
5525d0782f0SSushil Singh    # file_name    Partition file name.
5535d0782f0SSushil Singh
55498ebdfa3SSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
55598ebdfa3SSushil Singh    Redfish BMC Reset Operation
55698ebdfa3SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
55798ebdfa3SSushil Singh
558177b459aSSushil Singh    Wait Until Keyword Succeeds  3 min  10 sec  Redfish BMC Match States  match_state=Enabled
55998ebdfa3SSushil Singh    Is BMC Standby
5605d0782f0SSushil Singh
5615d0782f0SSushil Singh    Redfish Upload Partition File  ${file_name}
5625d0782f0SSushil Singh
5635d0782f0SSushil Singh
564cbbce6acSSushil SinghRedfish Partition File Persistency
565cbbce6acSSushil Singh    [Documentation]  Upload the partition file and check for persistency after reboot.
566cbbce6acSSushil Singh    [Arguments]  ${file_name}
567fcdadc54SVijay
568cbbce6acSSushil Singh    # Description of argument(s):
569cbbce6acSSushil Singh    # file_name    Partition file name.
570cbbce6acSSushil Singh
571cbbce6acSSushil Singh    @{Partition_file_list} =  Split String  ${file_name}  ,
572cbbce6acSSushil Singh    ${num_records}=  Get Length  ${Partition_file_list}
573cbbce6acSSushil Singh    Create Partition File  ${Partition_file_list}
574cbbce6acSSushil Singh    Upload Partition File To BMC  ${Partition_file_list}  ${HTTP_OK}  ${FILE_UPLOAD_MESSAGE}
575cbbce6acSSushil Singh    Verify Partition File On BMC  ${Partition_file_list}  Partition_status=1
57698ebdfa3SSushil Singh
57798ebdfa3SSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
57898ebdfa3SSushil Singh    Redfish BMC Reset Operation
57998ebdfa3SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
58098ebdfa3SSushil Singh
581177b459aSSushil Singh    Wait Until Keyword Succeeds  3 min  10 sec  Redfish BMC Match States  match_state=Enabled
58298ebdfa3SSushil Singh    Is BMC Standby
58398ebdfa3SSushil Singh
584cbbce6acSSushil Singh    Verify Partition File On BMC  ${Partition_file_list}  Partition_status=1
585fcdadc54SVijay    Initialize OpenBMC
586cbbce6acSSushil Singh    Run Keyword If  ${num_records} == ${1}
587cbbce6acSSushil Singh    ...    Delete BMC Partition File  ${Partition_file_list}  ${HTTP_OK}  ${FILE_DELETED_MESSAGE}
588cbbce6acSSushil Singh    ...  ELSE
589cbbce6acSSushil Singh    ...    Delete All BMC Partition File  ${HTTP_OK}
590cbbce6acSSushil Singh    Delete Local Partition File  ${Partition_file_list}
591fcdadc54SVijay
592fcdadc54SVijay
593cbbce6acSSushil SinghVerify Redfish Partition File Content
594cbbce6acSSushil Singh    [Documentation]  Verify partition file content.
595cbbce6acSSushil Singh    [Arguments]  ${file_name}  ${content_dict}  ${status_code}
596fcdadc54SVijay
597cbbce6acSSushil Singh    # Description of argument(s):
598cbbce6acSSushil Singh    # file_name       Partition file name.
599cbbce6acSSushil Singh    # content_dict    Dict contain the content.
600cbbce6acSSushil Singh    # status_code     HTTPS status code.
601cbbce6acSSushil Singh
602cbbce6acSSushil Singh    FOR  ${conf_file}  IN  @{file_name}
603fbd67007SGeorge Keishing      ${resp}=  GET On Session  openbmc  /ibm/v1/Host/ConfigFiles/${conf_file}
604fbd67007SGeorge Keishing      ...  expected_status=any
605cbbce6acSSushil Singh      Should Be Equal As Strings  ${resp.status_code}  ${status_code}
606cbbce6acSSushil Singh
607cbbce6acSSushil Singh      ${Partition_file_data}=  Remove String  ${resp.text}  \\n
608cbbce6acSSushil Singh      ${Partition_file_data}=  Evaluate  json.loads('''${Partition_file_data}''')  json
609cbbce6acSSushil Singh      Should Be Equal As Strings  ${Partition_file_data["Data"]}  ${content_dict['${conf_file}']}
610cbbce6acSSushil Singh    END
611fcdadc54SVijay
61239373158SVijay
613cbbce6acSSushil SinghAdd Content To Files
614cbbce6acSSushil Singh    [Documentation]  Add defined content in partition file.
615cbbce6acSSushil Singh    [Arguments]  ${file_name}  ${index}=${0}
61639373158SVijay
617cbbce6acSSushil Singh    # Description of argument(s):
618cbbce6acSSushil Singh    # file_name    Partition file name.
619cbbce6acSSushil Singh    # index        Index
620cbbce6acSSushil Singh
621cbbce6acSSushil Singh    ${num_records}=  Get Length  ${file_name}
622cbbce6acSSushil Singh    &{content_dict}=  Create Dictionary
62385c381c2SSushil Singh
624cbbce6acSSushil Singh    FOR  ${conf_file}  IN  @{file_name}
625cbbce6acSSushil Singh       ${index}=  Get Index From List  ${file_name}  ${conf_file}
626cbbce6acSSushil Singh       ${index}=  Evaluate  ${index} + 1
627cbbce6acSSushil Singh
628cbbce6acSSushil Singh       Run  echo "${content-${index}}" > ${conf_file}
629cbbce6acSSushil Singh       OperatingSystem.File Should Exist  ${conf_file}
630cbbce6acSSushil Singh
631cbbce6acSSushil Singh       Set To Dictionary  ${content_dict}  ${conf_file}  ${content-${index}}
632cbbce6acSSushil Singh    END
633cbbce6acSSushil Singh
634409df05dSGeorge Keishing    RETURN  &{content_dict}
635cbbce6acSSushil Singh
636cbbce6acSSushil Singh
637cbbce6acSSushil SinghRedfish Read Partition File
638cbbce6acSSushil Singh    [Documentation]  Read partition file content.
639cbbce6acSSushil Singh    [Arguments]  ${file_name}  ${reboot_flag}=False
640cbbce6acSSushil Singh
641cbbce6acSSushil Singh    # Description of argument(s):
642cbbce6acSSushil Singh    # file_name      Partition file name.
643cbbce6acSSushil Singh    # reboot_flag    Reboot flag.
644cbbce6acSSushil Singh
645cbbce6acSSushil Singh    @{Partition_file_list} =  Split String  ${file_name}  ,
646cbbce6acSSushil Singh    ${content_dict}=  Add Content To Files  ${Partition_file_list}
647cbbce6acSSushil Singh
648cbbce6acSSushil Singh    ${num_records}=  Get Length  ${Partition_file_list}
649cbbce6acSSushil Singh
650cbbce6acSSushil Singh    Upload Partition File To BMC  ${Partition_file_list}  ${HTTP_OK}  ${FILE_UPLOAD_MESSAGE}
651cbbce6acSSushil Singh    Verify Partition File On BMC  ${Partition_file_list}  Partition_status=1
652cbbce6acSSushil Singh    Verify Redfish Partition File Content  ${Partition_file_list}  ${content_dict}  ${HTTP_OK}
653cbbce6acSSushil Singh
65498ebdfa3SSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
65598ebdfa3SSushil Singh
656cbbce6acSSushil Singh    Run Keyword If  ${True} == ${reboot_flag}
65798ebdfa3SSushil Singh    ...  Run Keywords  Redfish BMC Reset Operation  AND
65898ebdfa3SSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
659177b459aSSushil Singh    ...  Wait Until Keyword Succeeds  3 min  10 sec  Redfish BMC Match States  match_state=Enabled  AND
66098ebdfa3SSushil Singh    ...  Is BMC Standby  AND
661cbbce6acSSushil Singh    ...  Initialize OpenBMC  AND
662cbbce6acSSushil Singh    ...  Verify Redfish Partition File Content  ${Partition_file_list}  ${content_dict}  ${HTTP_OK}
66398ebdfa3SSushil Singh
664cbbce6acSSushil Singh    Run Keyword If  ${num_records} == ${1}
665cbbce6acSSushil Singh    ...    Delete BMC Partition File  ${Partition_file_list}  ${HTTP_OK}  ${FILE_DELETED_MESSAGE}
666cbbce6acSSushil Singh    ...  ELSE
667cbbce6acSSushil Singh    ...    Delete All BMC Partition File  ${HTTP_OK}
66898ebdfa3SSushil Singh
669cbbce6acSSushil Singh    Delete Local Partition File  ${Partition_file_list}
670cbbce6acSSushil Singh
671cbbce6acSSushil Singh
672cbbce6acSSushil SinghRedfish Update Partition File With Same Content
673cbbce6acSSushil Singh    [Documentation]  Update partition file with same content.
674cbbce6acSSushil Singh    [Arguments]  ${file_name}  ${reboot_flag}=False
675cbbce6acSSushil Singh
676cbbce6acSSushil Singh    # Description of argument(s):
677cbbce6acSSushil Singh    # file_name      Partition file name.
678cbbce6acSSushil Singh    # reboot_flag    Reboot flag.
679cbbce6acSSushil Singh
680cbbce6acSSushil Singh    @{Partition_file_list} =  Split String  ${file_name}  ,
681cbbce6acSSushil Singh    ${content_dict}=  Add Content To Files  ${Partition_file_list}  ${0}
682cbbce6acSSushil Singh
683cbbce6acSSushil Singh    Upload Partition File To BMC  ${Partition_file_list}  ${HTTP_OK}  ${FILE_UPLOAD_MESSAGE}
684cbbce6acSSushil Singh    Verify Partition File On BMC  ${Partition_file_list}  Partition_status=1
685cbbce6acSSushil Singh    Verify Redfish Partition File Content  ${Partition_file_list}  ${content_dict}  ${HTTP_OK}
686cbbce6acSSushil Singh
68798ebdfa3SSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
68898ebdfa3SSushil Singh
689cbbce6acSSushil Singh    Run Keyword If  ${True} == ${reboot_flag}
69098ebdfa3SSushil Singh    ...  Run Keywords  Redfish BMC Reset Operation  AND
69198ebdfa3SSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
692177b459aSSushil Singh    ...  Wait Until Keyword Succeeds  3 min  10 sec  Redfish BMC Match States  match_state=Enabled  AND
69398ebdfa3SSushil Singh    ...  Is BMC Standby  AND
694cbbce6acSSushil Singh    ...  Initialize OpenBMC
695cbbce6acSSushil Singh
696cbbce6acSSushil Singh    ${content_dict}=  Add Content To Files  ${Partition_file_list}  ${0}
697251a0bc9SSushil Singh    Upload Partition File To BMC  ${Partition_file_list}  ${HTTP_OK}  ${FILE_UPDATED_MESSAGE}
698cbbce6acSSushil Singh    Verify Partition File On BMC  ${Partition_file_list}  Partition_status=1
699cbbce6acSSushil Singh    Verify Redfish Partition File Content  ${Partition_file_list}  ${content_dict}  ${HTTP_OK}
700cbbce6acSSushil Singh
701cbbce6acSSushil Singh    Delete BMC Partition File  ${Partition_file_list}  ${HTTP_OK}  ${FILE_DELETED_MESSAGE}
702cbbce6acSSushil Singh    Delete Local Partition File  ${Partition_file_list}
703cbbce6acSSushil Singh
704cbbce6acSSushil Singh
705cbbce6acSSushil SinghRedfish Update Partition File With Different Content
706cbbce6acSSushil Singh    [Documentation]  Update partition file with different content.
707cbbce6acSSushil Singh    [Arguments]  ${file_name}  ${reboot_flag}=False
708cbbce6acSSushil Singh
709cbbce6acSSushil Singh    # Description of argument(s):
710cbbce6acSSushil Singh    # file_name      Partition file name.
711cbbce6acSSushil Singh    # reboot_flag    Reboot flag.
712cbbce6acSSushil Singh
713cbbce6acSSushil Singh    @{Partition_file_list} =  Split String  ${file_name}  ,
714cbbce6acSSushil Singh    ${content_dict}=  Add Content To Files  ${Partition_file_list}  ${0}
715cbbce6acSSushil Singh
716cbbce6acSSushil Singh    Upload Partition File To BMC  ${Partition_file_list}  ${HTTP_OK}  ${FILE_UPLOAD_MESSAGE}
717cbbce6acSSushil Singh    Verify Partition File On BMC  ${Partition_file_list}  Partition_status=1
718cbbce6acSSushil Singh    Verify Redfish Partition File Content  ${Partition_file_list}  ${content_dict}  ${HTTP_OK}
719cbbce6acSSushil Singh
72098ebdfa3SSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
72198ebdfa3SSushil Singh
722cbbce6acSSushil Singh    Run Keyword If  ${True} == ${reboot_flag}
72398ebdfa3SSushil Singh    ...  Run Keywords  Redfish BMC Reset Operation  AND
72498ebdfa3SSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
725177b459aSSushil Singh    ...  Wait Until Keyword Succeeds  3 min  10 sec  Redfish BMC Match States  match_state=Enabled  AND
72698ebdfa3SSushil Singh    ...  Is BMC Standby  AND
727cbbce6acSSushil Singh    ...  Initialize OpenBMC
728cbbce6acSSushil Singh
729cbbce6acSSushil Singh    ${content_dict}=  Add Content To Files  ${Partition_file_list}  ${1}
730251a0bc9SSushil Singh    Upload Partition File To BMC  ${Partition_file_list}  ${HTTP_OK}  ${FILE_UPDATED_MESSAGE}
731cbbce6acSSushil Singh    Verify Partition File On BMC  ${Partition_file_list}  Partition_status=1
732cbbce6acSSushil Singh    Verify Redfish Partition File Content  ${Partition_file_list}  ${content_dict}  ${HTTP_OK}
733cbbce6acSSushil Singh
734cbbce6acSSushil Singh    Delete BMC Partition File  ${Partition_file_list}  ${HTTP_OK}  ${FILE_DELETED_MESSAGE}
735cbbce6acSSushil Singh    Delete Local Partition File  ${Partition_file_list}
736cbbce6acSSushil Singh
737cbbce6acSSushil Singh
738cbbce6acSSushil SinghCreate File Names
739cbbce6acSSushil Singh    [Documentation]  Create partition file names.
740cbbce6acSSushil Singh    [Arguments]  ${range}
741cbbce6acSSushil Singh
742cbbce6acSSushil Singh    # Description of argument(s):
743cbbce6acSSushil Singh    # range    Range in numbers.
744cbbce6acSSushil Singh
745cbbce6acSSushil Singh    @{file_name_list}=  Create List
746cbbce6acSSushil Singh    Set Test Variable  ${file_name}  rangefile
747cbbce6acSSushil Singh    FOR  ${count}  IN RANGE  ${range}
74885c381c2SSushil Singh      Append To List  ${file_name_list}  1KB-file${count}
749cbbce6acSSushil Singh    END
750409df05dSGeorge Keishing    RETURN  ${file_name_list}
751cbbce6acSSushil Singh
752cbbce6acSSushil Singh
753cbbce6acSSushil SinghRedfish Upload Partition File With Range
754cbbce6acSSushil Singh    [Documentation]  Upload the partition file with the range of files.
755cbbce6acSSushil Singh    [Arguments]  ${range}
756cbbce6acSSushil Singh
757cbbce6acSSushil Singh    # Description of argument(s):
758cbbce6acSSushil Singh    # range    Range in numbers.
759cbbce6acSSushil Singh
760cbbce6acSSushil Singh    ${Partition_file_list}=  Create File Names  ${range}
76185c381c2SSushil Singh    Delete Local Partition File  ${Partition_file_list}
762cbbce6acSSushil Singh    Create Partition File  ${Partition_file_list}
763cbbce6acSSushil Singh    Upload Partition File To BMC  ${Partition_file_list}  ${HTTP_OK}  ${FILE_UPLOAD_MESSAGE}
764cbbce6acSSushil Singh    Verify Partition File On BMC  ${Partition_file_list}  Partition_status=1
765cbbce6acSSushil Singh    Delete All BMC Partition File  ${HTTP_OK}
766cbbce6acSSushil Singh    Delete Local Partition File  ${Partition_file_list}
767cbbce6acSSushil Singh
768cbbce6acSSushil Singh
769cbbce6acSSushil SinghRedfish Delete Non Existence Partition File
770cbbce6acSSushil Singh    [Documentation]  Delete the partition file if do not exists.
771cbbce6acSSushil Singh    [Arguments]  ${file_name}
772cbbce6acSSushil Singh
773cbbce6acSSushil Singh    # Description of argument(s):
774cbbce6acSSushil Singh    # file_name    Partition file name.
775cbbce6acSSushil Singh
776cbbce6acSSushil Singh    @{Partition_file_list} =  Split String  ${file_name}  ,
777251a0bc9SSushil Singh    Delete BMC Partition File  ${Partition_file_list}  ${HTTP_NOT_FOUND}  ${RESOURCE_NOT_FOUND_MESSAGE}
778cbbce6acSSushil Singh
779cbbce6acSSushil Singh
780cbbce6acSSushil SinghNon Admin User To Upload Partition File
78116b3c7bfSGeorge Keishing    [Documentation]  Non admin user to upload the partition file.
782cbbce6acSSushil Singh    [Arguments]  ${file_name}  ${username}  ${password}  ${role}  ${enabled}=${True}
783cbbce6acSSushil Singh
784cbbce6acSSushil Singh    # Description of argument(s):
785cbbce6acSSushil Singh    # file_name    Partition file name.
786cbbce6acSSushil Singh    # username     Username.
787cbbce6acSSushil Singh    # password     Password.
788cbbce6acSSushil Singh    # role         Role of user.
789cbbce6acSSushil Singh    # enabled      Value can be True or False.
790cbbce6acSSushil Singh
791cbbce6acSSushil Singh    Redfish Create User  ${username}  ${password}  ${role}  ${enabled}
79239373158SVijay    Delete All Sessions
793cbbce6acSSushil Singh    Initialize OpenBMC  rest_username=${username}  rest_password=${password}
794cbbce6acSSushil Singh    @{Partition_file_list} =  Split String  ${file_name}  ,
795cbbce6acSSushil Singh    Create Partition File  ${Partition_file_list}
796cbbce6acSSushil Singh    Upload Partition File To BMC  ${Partition_file_list}  ${HTTP_FORBIDDEN}  ${FORBIDDEN_MESSAGE}  ${False}
797cbbce6acSSushil Singh    Delete Local Partition File  ${Partition_file_list}
798cbbce6acSSushil Singh    Redfish.Delete  /redfish/v1/AccountService/Accounts/${username}
799cbbce6acSSushil Singh
800cbbce6acSSushil Singh
801cbbce6acSSushil SinghNon Admin Delete Non Existence Partition File
80216b3c7bfSGeorge Keishing    [Documentation]  Non admin user to upload the partition file.
803cbbce6acSSushil Singh    [Arguments]  ${file_name}  ${username}  ${password}  ${role}  ${enabled}=${True}
804cbbce6acSSushil Singh
805cbbce6acSSushil Singh    # Description of argument(s):
806cbbce6acSSushil Singh    # file_name    Partition file name.
807cbbce6acSSushil Singh    # username     Username.
808cbbce6acSSushil Singh    # password     Password.
809cbbce6acSSushil Singh    # role         Role of user.
810cbbce6acSSushil Singh    # enabled      Value can be True or False.
811cbbce6acSSushil Singh
812cbbce6acSSushil Singh    Redfish Create User  ${username}  ${password}  ${role}  ${enabled}
813cbbce6acSSushil Singh    Delete All Sessions
814cbbce6acSSushil Singh    Initialize OpenBMC  rest_username=${username}  rest_password=${password}
815cbbce6acSSushil Singh    @{Partition_file_list} =  Split String  ${file_name}  ,
816cbbce6acSSushil Singh    Delete BMC Partition File  ${Partition_file_list}  ${HTTP_FORBIDDEN}  ${FORBIDDEN_MESSAGE}
817cbbce6acSSushil Singh
818cbbce6acSSushil Singh
819cbbce6acSSushil SinghVerify Update Wrong Partition File To BMC
820cbbce6acSSushil Singh    [Documentation]  Upload the wrong partition file to BMC.
821cbbce6acSSushil Singh    [Arguments]  ${file_name}
822cbbce6acSSushil Singh
823cbbce6acSSushil Singh    # Description of argument(s):
824cbbce6acSSushil Singh    # file_name    Partition file name.
825cbbce6acSSushil Singh
826cbbce6acSSushil Singh    Redfish.Login
827cbbce6acSSushil Singh    ${resp}=  Run Keyword And Return Status
828cbbce6acSSushil Singh    ...  Redfish.Put  /ibm/v1/Host/ConfigFiles/../../../../../etc/resolv.conf  body={"data": "test string"}
829cbbce6acSSushil Singh    Should Be Equal As Strings  ${resp}  False
8309942df51SSushil Singh
8319942df51SSushil Singh
8329942df51SSushil SinghCheck Redfish Upload Partition File Name With Character Limit To BMC
8339942df51SSushil Singh    [Documentation]  Upload the partition file to BMC with file name character limit.
8349942df51SSushil Singh    [Arguments]  ${file_name}  ${status_code}  ${message}
8359942df51SSushil Singh
8369942df51SSushil Singh    # Description of argument(s):
8379942df51SSushil Singh    # file_name       Partition file name.
8389942df51SSushil Singh    # status_code     HTTPS status code.
8399942df51SSushil Singh    # message         Expected message of from upload partition file URI.
8409942df51SSushil Singh
8419942df51SSushil Singh    @{Partition_file_list} =  Split String  ${file_name}  ,
8429942df51SSushil Singh    ${num_records}=  Get Length  ${Partition_file_list}
8439942df51SSushil Singh    Create Partition File  ${Partition_file_list}
8449942df51SSushil Singh
8459942df51SSushil Singh    ${file_name_length}=  Get Length  ${Partition_file_list}[0]
8469942df51SSushil Singh
8479942df51SSushil Singh    Run Keyword If  ${file_name_length} == 20
8489942df51SSushil Singh    ...  Run Keywords
8499942df51SSushil Singh    ...    Upload Partition File To BMC  ${Partition_file_list}  ${status_code}  ${message}  AND
8509942df51SSushil Singh    ...    Verify Partition File On BMC  ${Partition_file_list}  Partition_status=1  AND
8519942df51SSushil Singh    ...    Delete BMC Partition File  ${Partition_file_list}  ${HTTP_OK}  ${FILE_DELETED_MESSAGE}
8529942df51SSushil Singh    ...  ELSE
8539942df51SSushil Singh    ...    Upload Partition File To BMC  ${Partition_file_list}  ${status_code}  ${message}
8549942df51SSushil Singh
8559942df51SSushil Singh    Delete Local Partition File  ${Partition_file_list}
8562dbcbdebSSushil Singh
8572dbcbdebSSushil Singh
8582dbcbdebSSushil SinghCheck Redfish Fail To Upload Partition File Name With Special Character To BMC
8592dbcbdebSSushil Singh    [Documentation]  Upload the partition file to BMC with special character file name.
8602dbcbdebSSushil Singh    [Arguments]  ${file_name}  ${status_code}  ${message}
8612dbcbdebSSushil Singh
8622dbcbdebSSushil Singh    # Description of argument(s):
8632dbcbdebSSushil Singh    # file_name       Partition file name.
8642dbcbdebSSushil Singh    # status_code     HTTPS status code.
8652dbcbdebSSushil Singh    # message         Expected message from upload partition file URI.
8662dbcbdebSSushil Singh
8672dbcbdebSSushil Singh    @{Partition_file_list} =  Split String  ${file_name}  ,
8682dbcbdebSSushil Singh    ${num_records}=  Get Length  ${Partition_file_list}
8692dbcbdebSSushil Singh
8702dbcbdebSSushil Singh    Create Partition File  ${Partition_file_list}
8712dbcbdebSSushil Singh
8722dbcbdebSSushil Singh    Upload Partition File To BMC  ${Partition_file_list}  ${status_code}  ${message}
8732dbcbdebSSushil Singh
8742dbcbdebSSushil Singh    ${status}=  Run Keyword And Return Status
8752dbcbdebSSushil Singh    ...  Verify Partition File On BMC  ${Partition_file_list}  Partition_status=1
8762dbcbdebSSushil Singh    Should Be Equal As Strings  ${status}  False
8772dbcbdebSSushil Singh
8782dbcbdebSSushil Singh    Delete Local Partition File  ${Partition_file_list}
87944b8cf33SSushil Singh
88044b8cf33SSushil Singh
88144b8cf33SSushil SinghRedfish Upload Partition File From Path
88244b8cf33SSushil Singh    [Documentation]  Upload the partition file to BMC from file path.
88344b8cf33SSushil Singh    [Arguments]  ${PARTITION_FILE_PATH}
88444b8cf33SSushil Singh
88544b8cf33SSushil Singh    # Description of argument(s):
88644b8cf33SSushil Singh    # PARTITION_FILE_PATH    Partition file path.
88744b8cf33SSushil Singh
88844b8cf33SSushil Singh    ${file_list} =  OperatingSystem.List Files In Directory  ${PARTITION_FILE_PATH}
88944b8cf33SSushil Singh
89044b8cf33SSushil Singh    ${num_records}=  Get Length  ${file_list}
89144b8cf33SSushil Singh    Should Not Be Equal As Integers  ${num_records}  0
89244b8cf33SSushil Singh
89344b8cf33SSushil Singh    FOR  ${file_name}  IN  @{file_list}
89444b8cf33SSushil Singh      @{Partition_file_list} =  Split String  ${file_name}  ,
89544b8cf33SSushil Singh      ${num_records}=  Get Length  ${Partition_file_list}
896538f1743SGeorge Keishing      Upload Partition File To BMC  file_name=${Partition_file_list}
897538f1743SGeorge Keishing      ...  status_code=${HTTP_OK}  expected_message=${FILE_UPLOAD_MESSAGE}  path=${PARTITION_FILE_PATH}
89844b8cf33SSushil Singh      Verify Partition File On BMC  ${Partition_file_list}  Partition_status=1
89944b8cf33SSushil Singh      Delete BMC Partition File  ${Partition_file_list}  ${HTTP_OK}  ${FILE_DELETED_MESSAGE}
90044b8cf33SSushil Singh    END
90144b8cf33SSushil Singh
902