1*** Settings ***
2Documentation    This suite test various boot types with boot source.
3Resource         ../../lib/resource.robot
4Resource         ../../lib/bmc_redfish_resource.robot
5Resource         ../../lib/common_utils.robot
6Resource         ../../lib/openbmc_ffdc.robot
7Resource         ../../lib/ipmi_client.robot
8
9Test Setup       Test Setup Execution
10Test Teardown    Test Teardown Execution
11Suite Teardown   Suite Teardown Execution
12
13Force Tags       Boot_Devices
14
15*** Variables ***
16# Maps for correlating redfish data values to IPMI data values.
17# The redfish values are obtained with Redfish.Get or Redfish.Get Properties.
18# The corresponding IPMI values are obtained with the "chassis bootparam get
19# 5" IPMI command.
20
21# This dictionary maps the redfish 'BootSourceOverrideEnabled' value to the
22# corresponding IPMI output value.
23&{redfish_ipmi_enabled_map}  Once=Options apply to only next boot
24...                          Continuous=Options apply to all future boots
25...                          Disabled=Boot Flag Invalid
26
27# This dictionary maps the redfish 'BootSourceOverrideTarget' value to the
28# corresponding IPMI output value.
29&{redfish_ipmi_target_map}  Hdd=Force Boot from default Hard-Drive
30...                         Pxe=Force PXE
31...                         Diags=Force Boot from default Hard-Drive, request Safe-Mode
32...                         Cd=Force Boot from CD/DVD
33...                         BiosSetup=Force Boot into BIOS Setup
34...                         None=No override
35
36# This dictionary maps the redfish 'BootSourceOverrideMode' value to the
37# corresponding IPMI output value.
38&{redfish_ipmi_mode_map}  Legacy=BIOS PC Compatible (legacy) boot
39...                       UEFI=BIOS EFI boot
40
41${loop_count}             2
42
43*** Test Cases ***
44
45Verify BMC Redfish Boot Source Override with Enabled Mode As Once
46    [Documentation]  Verify BMC Redfish Boot Source Override with Enabled Mode As Once.
47    [Tags]           Verify_BMC_Redfish_Boot_Source_Override_with_Enabled_Mode_As_Once
48    [Template]  Set And Verify Boot Source Override
49
50    #BootSourceOverrideEnabled    BootSourceOverrideTarget    BootSourceOverrideMode
51    Once                          Hdd                         UEFI
52    Once                          Pxe                         UEFI
53    Once                          Diags                       UEFI
54    Once                          Cd                          UEFI
55    Once                          BiosSetup                   UEFI
56    Once                          None                        UEFI
57    Once                          Hdd                         Legacy
58    Once                          Pxe                         Legacy
59    Once                          Diags                       Legacy
60    Once                          Cd                          Legacy
61    Once                          BiosSetup                   Legacy
62    Once                          None                        Legacy
63
64
65Verify BMC Redfish Boot Source Override with Enabled Mode As Continuous
66    [Documentation]  Verify BMC Redfish Boot Source Override with Enabled Mode As Continuous.
67    [Tags]           Verify_BMC_Redfish_Boot_Source_Override_with_Enabled_Mode_As_Continuous
68    [Template]  Set And Verify Boot Source Override
69
70    #BootSourceOverrideEnabled    BootSourceOverrideTarget    BootSourceOverrideMode
71    Continuous                    Hdd                         UEFI
72    Continuous                    Pxe                         UEFI
73    Continuous                    Diags                       UEFI
74    Continuous                    Cd                          UEFI
75    Continuous                    BiosSetup                   UEFI
76    Continuous                    None                        UEFI
77    Continuous                    Hdd                         Legacy
78    Continuous                    Pxe                         Legacy
79    Continuous                    Diags                       Legacy
80    Continuous                    Cd                          Legacy
81    Continuous                    BiosSetup                   Legacy
82    Continuous                    None                        Legacy
83
84
85Verify BMC Redfish Boot Source Override with Enabled Mode As Disabled
86    [Documentation]  Verify BMC Redfish Boot Source Override with Enabled Mode As Disabled.
87    [Tags]           Verify_BMC_Redfish_Boot_Source_Override_with_Enabled_Mode_As_Disabled
88    [Template]  Set And Verify Boot Source Override
89
90    #BootSourceOverrideEnabled    BootSourceOverrideTarget    BootSourceOverrideMode
91    Disabled                      Hdd                         UEFI
92    Disabled                      Pxe                         UEFI
93    Disabled                      Diags                       UEFI
94    Disabled                      Cd                          UEFI
95    Disabled                      BiosSetup                   UEFI
96    Disabled                      None                        UEFI
97    Disabled                      Hdd                         Legacy
98    Disabled                      Pxe                         Legacy
99    Disabled                      Diags                       Legacy
100    Disabled                      Cd                          Legacy
101    Disabled                      BiosSetup                   Legacy
102    Disabled                      None                        Legacy
103
104
105Verify Boot Source Override Policy Persistency With Enabled Mode As Once After BMC Reboot
106    [Documentation]  Verify Boot Source Override Policy Persistency with Enabled Mode As Once After BMC Reboot.
107    [Tags]           Verify_Boot_Source_Override_Policy_Persistency_With_Enabled_Mode_As_Once_After_BMC_Reboot
108    [Template]  Verify Boot Source Override After BMC Reboot
109
110    #BootSourceOverrideEnabled    BootSourceOverrideTarget    BootSourceOverrideMode
111    Once                          Hdd                         UEFI
112    Once                          Pxe                         UEFI
113    Once                          Diags                       UEFI
114    Once                          Cd                          UEFI
115    Once                          BiosSetup                   UEFI
116    Once                          None                        UEFI
117    Once                          Hdd                         Legacy
118    Once                          Pxe                         Legacy
119    Once                          Diags                       Legacy
120    Once                          Cd                          Legacy
121    Once                          BiosSetup                   Legacy
122    Once                          None                        Legacy
123
124
125Verify Boot Source Override Policy Persistency With Enabled Mode As Continuous After BMC Reboot
126    [Documentation]  Verify Boot Source Override Policy Persistency with Enabled Mode As Continuous After BMC Reboot.
127    [Tags]           Verify_Boot_Source_Override_Policy_Persistency_With_Enabled_Mode_As_Continuous_After_BMC_Reboot
128    [Template]  Verify Boot Source Override After BMC Reboot
129
130    #BootSourceOverrideEnabled    BootSourceOverrideTarget    BootSourceOverrideMode
131    Continuous                    Hdd                         UEFI
132    Continuous                    Pxe                         UEFI
133    Continuous                    Diags                       UEFI
134    Continuous                    Cd                          UEFI
135    Continuous                    BiosSetup                   UEFI
136    Continuous                    None                        UEFI
137    Continuous                    Hdd                         Legacy
138    Continuous                    Pxe                         Legacy
139    Continuous                    Diags                       Legacy
140    Continuous                    Cd                          Legacy
141    Continuous                    BiosSetup                   Legacy
142    Continuous                    None                        Legacy
143
144
145Verify Boot Source Override Policy With Enabled Mode As Once After Host Reboot
146    [Documentation]  Verify Boot Source Override Policy with Enabled Mode As Once After Host Reboot.
147    [Tags]           Verify_Boot_Source_Override_Policy_With_Enabled_Mode_As_Once_After_Host_Reboot
148    [Template]  Verify Boot Source Override with Enabled Mode As Once After Host Reboot
149
150    #BootSourceOverrideTarget    BootSourceOverrideMode
151    Hdd                         UEFI
152    Pxe                         UEFI
153    Diags                       UEFI
154    Cd                          UEFI
155    None                        UEFI
156    Hdd                         Legacy
157    Pxe                         Legacy
158    Diags                       Legacy
159    Cd                          Legacy
160    None                        Legacy
161
162
163Verify Boot Source Override Policy With Enabled Mode As Continuous After Host Reboot
164    [Documentation]  Verify Boot Source Override Policy With Enabled Mode As Continuous After Host Reboot.
165    [Tags]           Verify_Boot_Source_Override_Policy_With_Enabled_Mode_As_Continuous_After_Host_Reboot
166    [Template]  Verify Boot Source Override with Enabled Mode As Continuous After Host Reboot
167
168    #BootSourceOverrideTarget    BootSourceOverrideMode
169    Hdd                         UEFI
170    Pxe                         UEFI
171    Diags                       UEFI
172    Cd                          UEFI
173    None                        UEFI
174    Hdd                         Legacy
175    Pxe                         Legacy
176    Diags                       Legacy
177    Cd                          Legacy
178    None                        Legacy
179
180
181Verify Boot Source Override With Enabled Mode As Once After Host Reboot For Bios Setup
182    [Documentation]  Verify Boot Source Override with Enabled Mode As Once After Host Reboot For Bios Setup.
183    [Tags]           Verify_Boot_Source_Override_With_Enabled_Mode_As_Once_After_Host_Reboot_For_Bios_Setup
184    [Template]  Verify Boot Source Override with Enabled Mode As Once After Host Reboot
185
186    #BootSourceOverrideTarget   BootSourceOverrideMode   Biosflag
187    BiosSetup                   UEFI                     True
188    BiosSetup                   Legacy                   True
189
190
191Verify Boot Source Override With Enabled Mode As Continuous After Host Reboot For Bios Setup
192    [Documentation]  Verify Boot Source Override with Enabled Mode As Continuous After Host Reboot For Bios Setup.
193    [Tags]           Verify_Boot_Source_Override_With_Enabled_Mode_As_Continuous_After_Host_Reboot_For_Bios_Setup
194    [Template]  Verify Boot Source Override with Enabled Mode As Continuous After Host Reboot
195
196    #BootSourceOverrideTarget   BootSourceOverrideMode   Biosflag
197    BiosSetup                   UEFI                     True
198    BiosSetup                   Legacy                   True
199
200
201*** Keywords ***
202
203Set And Verify Boot Source Override
204    [Documentation]  Set and Verify Boot source override.
205    [Arguments]      ${override_enabled}  ${override_target}  ${override_mode}=UEFI
206
207    # Description of argument(s):
208    # override_enabled    Boot source override enable type.
209    #                     ('Once', 'Continuous', 'Disabled').
210    # override_target     Boot source override target.
211    #                     ('Pxe', 'Cd', 'Hdd', 'Diags', 'BiosSetup', 'None').
212    # override_mode       Boot source override mode (relevant only for x86 arch).
213    #                     ('Legacy', 'UEFI').
214
215    # Example:
216    # "Boot": {
217    # "BootSourceOverrideEnabled": "Disabled",
218    # "BootSourceOverrideMode": "Legacy",
219    # "BootSourceOverrideTarget": "None",
220    # "BootSourceOverrideTarget@Redfish.AllowableValues": [
221    # "None",
222    # "Pxe",
223    # "Hdd",
224    # "Cd",
225    # "Diags",
226    # "BiosSetup"]}
227
228    # The values set using Redfish are verified via IPMI using the command:
229    # chassis bootparam get 5
230    # Option 5 returns the boot parameters.
231    #
232    # Sample output:
233    # Boot parameter version: 1
234    # Boot parameter 5 is valid/unlocked
235    # Boot parameter data: c000000000
236    # Boot Flags :
237    # - Boot Flag Valid
238    # - Options apply to all future boots
239    # - BIOS PC Compatible (legacy) boot
240    # - Boot Device Selector : No override
241    # - Console Redirection control : System Default
242    # - BIOS verbosity : Console redirection occurs per BIOS configuration
243    #   setting (default)
244    # - BIOS Mux Control Override : BIOS uses recommended setting of the mux at
245    #   the end of POST
246
247    Redfish Set Boot Default  ${override_enabled}  ${override_target}  ${override_mode}
248
249    ${output}=  Run IPMI Standard Command  chassis bootparam get 5
250    Should Contain  ${output}  ${redfish_ipmi_enabled_map['${override_enabled}']}
251    Should Contain  ${output}  ${redfish_ipmi_target_map['${override_target}']}
252    Run Keyword If  '${PLATFORM_ARCH_TYPE}' == 'x86'
253    ...  Should Contain  ${output}  ${redfish_ipmi_mode_map['${override_mode}']}
254
255
256Verify Boot Source Override After BMC Reboot
257    [Documentation]  Verify Boot Source Override After BMC Reboot.
258    [Arguments]      ${override_enabled}  ${override_target}  ${override_mode}=UEFI
259
260    # Description of argument(s):
261    # override_enabled    Boot source override enable type.
262    #                     ('Once', 'Continuous', 'Disabled').
263    # override_target     Boot source override target.
264    #                     ('Pxe', 'Cd', 'Hdd', 'Diags', 'BiosSetup', 'None').
265    # override_mode       Boot source override mode (relevant only for x86 arch).
266    #                     ('Legacy', 'UEFI').
267
268    # Example:
269    # "Boot": {
270    # "BootSourceOverrideEnabled": "Disabled",
271    # "BootSourceOverrideMode": "Legacy",
272    # "BootSourceOverrideTarget": "None",
273    # "BootSourceOverrideTarget@Redfish.AllowableValues": [
274    # "None",
275    # "Pxe",
276    # "Hdd",
277    # "Cd",
278    # "Diags",
279    # "BiosSetup"]}
280
281    # The values set using Redfish are verified via IPMI using the command:
282    # chassis bootparam get 5
283    # Option 5 returns the boot parameters.
284    #
285    # Sample output:
286    # Boot parameter version: 1
287    # Boot parameter 5 is valid/unlocked
288    # Boot parameter data: c000000000
289    # Boot Flags :
290    # - Boot Flag Valid
291    # - Options apply to all future boots
292    # - BIOS PC Compatible (legacy) boot
293    # - Boot Device Selector : No override
294    # - Console Redirection control : System Default
295    # - BIOS verbosity : Console redirection occurs per BIOS configuration
296    #   setting (default)
297    # - BIOS Mux Control Override : BIOS uses recommended setting of the mux at
298    #   the end of POST
299
300    Redfish Set Boot Default  ${override_enabled}  ${override_target}  ${override_mode}
301
302    Redfish OBMC Reboot (run)
303
304    ${output}=  Run IPMI Standard Command  chassis bootparam get 5
305    Should Contain  ${output}  ${redfish_ipmi_enabled_map['${override_enabled}']}
306    Should Contain  ${output}  ${redfish_ipmi_target_map['${override_target}']}
307    Run Keyword If  '${PLATFORM_ARCH_TYPE}' == 'x86'
308    ...  Should Contain  ${output}  ${redfish_ipmi_mode_map['${override_mode}']}
309
310
311Verify Boot Source Override with Enabled Mode As Once After Host Reboot
312    [Documentation]  Verify Boot Source Override with Enabled Mode As Once After Host Reboot.
313    [Arguments]      ${override_target}  ${override_mode}=UEFI  ${is_bios_setup}=False
314
315    # Description of argument(s):
316    # override_enabled    Boot source override enable type.
317    #                     ('Once', 'Continuous', 'Disabled').
318    # override_target     Boot source override target.
319    #                     ('Pxe', 'Cd', 'Hdd', 'Diags', 'BiosSetup', 'None').
320    # override_mode       Boot source override mode (relevant only for x86 arch).
321    #                     ('Legacy', 'UEFI').
322
323    # Example:
324    # "Boot": {
325    # "BootSourceOverrideEnabled": "Disabled",
326    # "BootSourceOverrideMode": "Legacy",
327    # "BootSourceOverrideTarget": "None",
328    # "BootSourceOverrideTarget@Redfish.AllowableValues": [
329    # "None",
330    # "Pxe",
331    # "Hdd",
332    # "Cd",
333    # "Diags",
334    # "BiosSetup"]}
335
336    # The values set using Redfish are verified via IPMI using the command:
337    # chassis bootparam get 5
338    # Option 5 returns the boot parameters.
339    #
340    # Sample output:
341    # Boot parameter version: 1
342    # Boot parameter 5 is valid/unlocked
343    # Boot parameter data: c000000000
344    # Boot Flags :
345    # - Boot Flag Valid
346    # - Options apply to all future boots
347    # - BIOS PC Compatible (legacy) boot
348    # - Boot Device Selector : No override
349    # - Console Redirection control : System Default
350    # - BIOS verbosity : Console redirection occurs per BIOS configuration
351    #   setting (default)
352    # - BIOS Mux Control Override : BIOS uses recommended setting of the mux at
353    #   the end of POST
354
355    Redfish Set Boot Default  Once  ${override_target}  ${override_mode}
356
357    IF  '${is_bios_setup}' == 'True'
358         Repeat Keyword  ${loop_count} times  Host Reboot For Bios Setup
359    ELSE
360         RF SYS GracefulRestart
361         ${output}=  Run IPMI Standard Command  chassis bootparam get 5
362         Should Contain  ${output}  ${redfish_ipmi_enabled_map['Once']}
363         Should Contain  ${output}  ${redfish_ipmi_target_map['None']}
364         IF  '${PLATFORM_ARCH_TYPE}' == 'x86'
365             Should Contain  ${output}  ${redfish_ipmi_mode_map['Legacy']}
366         END
367    END
368
369    ${resp}=  Redfish.Get Attribute  /redfish/v1/Systems/system  Boot
370    Should Be Equal As Strings  ${resp["BootSourceOverrideEnabled"]}  Disabled
371    Should Be Equal As Strings  ${resp["BootSourceOverrideTarget"]}  None
372    Run Keyword If  '${PLATFORM_ARCH_TYPE}' == 'x86'
373    ...  Should Be Equal As Strings  ${resp["BootSourceOverrideMode"]}  Legacy
374
375
376Verify Boot Source Override with Enabled Mode As Continuous After Host Reboot
377    [Documentation]  Verify Boot Source Override with Enabled Mode As Continuous After Host Reboot.
378    [Arguments]      ${override_target}  ${override_mode}=UEFI  ${is_bios_setup}=False
379
380    # Description of argument(s):
381    # override_enabled    Boot source override enable type.
382    #                     ('Once', 'Continuous', 'Disabled').
383    # override_target     Boot source override target.
384    #                     ('Pxe', 'Cd', 'Hdd', 'Diags', 'BiosSetup', 'None').
385    # override_mode       Boot source override mode (relevant only for x86 arch).
386    #                     ('Legacy', 'UEFI').
387
388    # Example:
389    # "Boot": {
390    # "BootSourceOverrideEnabled": "Disabled",
391    # "BootSourceOverrideMode": "Legacy",
392    # "BootSourceOverrideTarget": "None",
393    # "BootSourceOverrideTarget@Redfish.AllowableValues": [
394    # "None",
395    # "Pxe",
396    # "Hdd",
397    # "Cd",
398    # "Diags",
399    # "BiosSetup"]}
400
401    # The values set using Redfish are verified via IPMI using the command:
402    # chassis bootparam get 5
403    # Option 5 returns the boot parameters.
404    #
405    # Sample output:
406    # Boot parameter version: 1
407    # Boot parameter 5 is valid/unlocked
408    # Boot parameter data: c000000000
409    # Boot Flags :
410    # - Boot Flag Valid
411    # - Options apply to all future boots
412    # - BIOS PC Compatible (legacy) boot
413    # - Boot Device Selector : No override
414    # - Console Redirection control : System Default
415    # - BIOS verbosity : Console redirection occurs per BIOS configuration
416    #   setting (default)
417    # - BIOS Mux Control Override : BIOS uses recommended setting of the mux at
418    #   the end of POST
419
420    Redfish Set Boot Default  Continuous  ${override_target}  ${override_mode}
421
422    IF  '${is_bios_setup}' == 'True'
423         Repeat Keyword  ${loop_count} times  Host Reboot For Bios Setup
424    ELSE
425         RF SYS GracefulRestart
426         ${output}=  Run IPMI Standard Command  chassis bootparam get 5
427         Should Contain  ${output}  ${redfish_ipmi_enabled_map['Continuous']}
428         Should Contain  ${output}  ${redfish_ipmi_target_map['${override_target}']}
429         IF  '${PLATFORM_ARCH_TYPE}' == 'x86'
430             Should Contain  ${output}  ${redfish_ipmi_mode_map['${override_mode}']}
431         END
432    END
433
434    ${resp}=  Redfish.Get Attribute  /redfish/v1/Systems/system  Boot
435    Should Be Equal As Strings  ${resp["BootSourceOverrideEnabled"]}  Continuous
436    Should Be Equal As Strings  ${resp["BootSourceOverrideTarget"]}  ${override_target}
437    Run Keyword If  '${PLATFORM_ARCH_TYPE}' == 'x86'
438    ...  Should Be Equal As Strings  ${resp["BootSourceOverrideMode"]}  ${override_mode}
439
440
441Host Reboot For Bios Setup
442    [Documentation]  Rebooting Host without checking Host state.
443
444    Redfish Power Operation  GracefulRestart
445
446    Sleep  1min
447
448
449Suite Teardown Execution
450    [Documentation]  Do the post suite teardown.
451
452    Redfish.Login
453    Set And Verify Boot Source Override  Disabled  None  UEFI
454    Redfish.Logout
455
456
457Test Setup Execution
458    [Documentation]  Do test case setup tasks.
459
460    Redfish.Login
461
462
463Test Teardown Execution
464    [Documentation]  Do the post test teardown.
465
466    FFDC On Test Case Fail
467    Redfish.Logout
468