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