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