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