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
13*** Variables ***
14# Maps for correlating redfish data values to IPMI data values.
15# The redfish values are obtained with Redfish.Get or Redfish.Get Properties.
16# The corresponding IPMI values are obtained with the "chassis bootparam get
17# 5" IPMI command.
18
19# This dictionary maps the redfish 'BootSourceOverrideEnabled' value to the
20# corresponding IPMI output value.
21&{redfish_ipmi_enabled_map}  Once=Options apply to only next boot
22...                          Continuous=Options apply to all future boots
23...                          Disabled=Boot Flag Invalid
24
25# This dictionary maps the redfish 'BootSourceOverrideTarget' value to the
26# corresponding IPMI output value.
27&{redfish_ipmi_target_map}  Hdd=Force Boot from default Hard-Drive
28...                         Pxe=Force PXE
29...                         Diags=Force Boot from default Hard-Drive, request Safe-Mode
30...                         Cd=Force Boot from CD/DVD
31...                         BiosSetup=Force Boot into BIOS Setup
32...                         None=No override
33
34# This dictionary maps the redfish 'BootSourceOverrideMode' value to the
35# corresponding IPMI output value.
36&{redfish_ipmi_mode_map}  Legacy=BIOS PC Compatible (legacy) boot
37...                       UEFI=BIOS EFI boot
38
39*** Test Cases ***
40
41Verify BMC Redfish Boot Source Override with Enabled Mode As Once
42    [Documentation]  Verify BMC Redfish Boot Source Override with Enabled Mode As Once.
43    [Tags]           Verify_BMC_Redfish_Boot_Source_Override_with_Enabled_Mode_As_Once
44    [Template]  Set And Verify Boot Source Override
45
46    #BootSourceOverrideEnabled    BootSourceOverrideTarget    BootSourceOverrideMode
47    Once                          Hdd                         UEFI
48    Once                          Pxe                         UEFI
49    Once                          Diags                       UEFI
50    Once                          Cd                          UEFI
51    Once                          BiosSetup                   UEFI
52    Once                          None                        UEFI
53    Once                          Hdd                         Legacy
54    Once                          Pxe                         Legacy
55    Once                          Diags                       Legacy
56    Once                          Cd                          Legacy
57    Once                          BiosSetup                   Legacy
58    Once                          None                        Legacy
59
60
61Verify BMC Redfish Boot Source Override with Enabled Mode As Continuous
62    [Documentation]  Verify BMC Redfish Boot Source Override with Enabled Mode As Continuous.
63    [Tags]           Verify_BMC_Redfish_Boot_Source_Override_with_Enabled_Mode_As_Continuous
64    [Template]  Set And Verify Boot Source Override
65
66    #BootSourceOverrideEnabled    BootSourceOverrideTarget    BootSourceOverrideMode
67    Continuous                    Hdd                         UEFI
68    Continuous                    Pxe                         UEFI
69    Continuous                    Diags                       UEFI
70    Continuous                    Cd                          UEFI
71    Continuous                    BiosSetup                   UEFI
72    Continuous                    None                        UEFI
73    Continuous                    Hdd                         Legacy
74    Continuous                    Pxe                         Legacy
75    Continuous                    Diags                       Legacy
76    Continuous                    Cd                          Legacy
77    Continuous                    BiosSetup                   Legacy
78    Continuous                    None                        Legacy
79
80
81Verify BMC Redfish Boot Source Override with Enabled Mode As Disabled
82    [Documentation]  Verify BMC Redfish Boot Source Override with Enabled Mode As Disabled.
83    [Tags]           Verify_BMC_Redfish_Boot_Source_Override_with_Enabled_Mode_As_Disabled
84    [Template]  Set And Verify Boot Source Override
85
86    #BootSourceOverrideEnabled    BootSourceOverrideTarget    BootSourceOverrideMode
87    Disabled                      Hdd                         UEFI
88    Disabled                      Pxe                         UEFI
89    Disabled                      Diags                       UEFI
90    Disabled                      Cd                          UEFI
91    Disabled                      BiosSetup                   UEFI
92    Disabled                      None                        UEFI
93    Disabled                      Hdd                         Legacy
94    Disabled                      Pxe                         Legacy
95    Disabled                      Diags                       Legacy
96    Disabled                      Cd                          Legacy
97    Disabled                      BiosSetup                   Legacy
98    Disabled                      None                        Legacy
99
100
101*** Keywords ***
102
103Set And Verify Boot Source Override
104    [Documentation]  Set and Verify Boot source override
105    [Arguments]      ${override_enabled}  ${override_target}  ${override_mode}=UEFI
106
107    # Description of argument(s):
108    # override_enabled    Boot source override enable type.
109    #                     ('Once', 'Continuous', 'Disabled').
110    # override_target     Boot source override target.
111    #                     ('Pxe', 'Cd', 'Hdd', 'Diags', 'BiosSetup', 'None').
112    # override_mode       Boot source override mode (relevant only for x86 arch).
113    #                     ('Legacy', 'UEFI').
114
115    # Example:
116    # "Boot": {
117    # "BootSourceOverrideEnabled": "Disabled",
118    # "BootSourceOverrideMode": "Legacy",
119    # "BootSourceOverrideTarget": "None",
120    # "BootSourceOverrideTarget@Redfish.AllowableValues": [
121    # "None",
122    # "Pxe",
123    # "Hdd",
124    # "Cd",
125    # "Diags",
126    # "BiosSetup"]}
127
128    # The values set using Redfish are verified via IPMI using the command:
129    # chassis bootparam get 5
130    # Option 5 returns the boot parameters.
131    #
132    # Sample output:
133    # Boot parameter version: 1
134    # Boot parameter 5 is valid/unlocked
135    # Boot parameter data: c000000000
136    # Boot Flags :
137    # - Boot Flag Valid
138    # - Options apply to all future boots
139    # - BIOS PC Compatible (legacy) boot
140    # - Boot Device Selector : No override
141    # - Console Redirection control : System Default
142    # - BIOS verbosity : Console redirection occurs per BIOS configuration
143    #   setting (default)
144    # - BIOS Mux Control Override : BIOS uses recommended setting of the mux at
145    #   the end of POST
146
147    Redfish Set Boot Default  ${override_enabled}  ${override_target}  ${override_mode}
148
149    ${output}=  Run IPMI Standard Command  chassis bootparam get 5
150    Should Contain  ${output}  ${redfish_ipmi_enabled_map['${override_enabled}']}
151    Should Contain  ${output}  ${redfish_ipmi_target_map['${override_target}']}
152    Run Keyword If  '${PLATFORM_ARCH_TYPE}' == 'x86'
153    ...  Should Contain  ${output}  ${redfish_ipmi_mode_map['${override_mode}']}
154
155
156Suite Teardown Execution
157    [Documentation]  Do the post suite teardown.
158
159    Redfish.Login
160    Set And Verify Boot Source Override  Disabled  None  UEFI
161    Redfish.Logout
162
163
164Test Setup Execution
165    [Documentation]  Do test case setup tasks.
166
167    Redfish.Login
168
169
170Test Teardown Execution
171    [Documentation]  Do the post test teardown.
172
173    FFDC On Test Case Fail
174    Redfish.Logout
175