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*** Test Cases ***
35
36Verify BMC Redfish Boot Types With BootSource As Once
37    [Documentation]  Verify BMC Redfish Boot Types With BootSource As Once.
38    [Tags]           Verify_BMC_Redfish_Boot_Types_With_BootSource_As_Once
39    [Template]  Set And Verify BootSource And BootType
40
41    #BootSourceEnableType    BootTargetType
42    Once                     Hdd
43    Once                     Pxe
44    Once                     Diags
45    Once                     Cd
46    Once                     BiosSetup
47
48Verify BMC Redfish Boot Types With BootSource As Continuous
49    [Documentation]  Verify BMC Redfish Boot Types With BootSource As Continuous.
50    [Tags]           Verify_BMC_Redfish_Boot_Types_With_BootSource_As_Continuous
51    [Template]  Set And Verify BootSource And BootType
52
53    #BootSourceEnable    BootTargetType
54    Continuous           Hdd
55    Continuous           Pxe
56    Continuous           Diags
57    Continuous           Cd
58    Continuous           BiosSetup
59
60*** Keywords ***
61
62Set And Verify BootSource And BootType
63    [Documentation]  Set And Verify BootSource And BootType.
64    [Arguments]      ${override_enabled}  ${override_target}
65
66    # Description of argument(s):
67    # override_enabled    Boot source enable type.
68    #                     ('Once', 'Continuous', 'Disabled').
69    # override_target     Boot target type.
70    #                     ('Pxe', 'Cd', 'Hdd', 'Diags', 'BiosSetup', 'None').
71
72    # Example:
73    # "Boot": {
74    # "BootSourceOverrideEnabled": "Disabled",
75    # "BootSourceOverrideMode": "Legacy",
76    # "BootSourceOverrideTarget": "None",
77    # "BootSourceOverrideTarget@Redfish.AllowableValues": [
78    # "None",
79    # "Pxe",
80    # "Hdd",
81    # "Cd",
82    # "Diags",
83    # "BiosSetup"]}
84
85    # The values set using Redfish are verified via IPMI using the command:
86    # chassis bootparam get 5
87    # Option 5 returns the boot parameters.
88    #
89    # Sample output:
90    # Boot parameter version: 1
91    # Boot parameter 5 is valid/unlocked
92    # Boot parameter data: c000000000
93    # Boot Flags :
94    # - Boot Flag Valid
95    # - Options apply to all future boots
96    # - BIOS PC Compatible (legacy) boot
97    # - Boot Device Selector : No override
98    # - Console Redirection control : System Default
99    # - BIOS verbosity : Console redirection occurs per BIOS configuration
100    #   setting (default)
101    # - BIOS Mux Control Override : BIOS uses recommended setting of the mux at
102    #   the end of POST
103
104    ${data}=  Create Dictionary  BootSourceOverrideEnabled=${override_enabled}
105    ...  BootSourceOverrideTarget=${override_target}
106    ${payload}=  Create Dictionary  Boot=${data}
107
108    Redfish.Patch  /redfish/v1/Systems/system  body=&{payload}
109    ...  valid_status_codes=[${HTTP_OK},${HTTP_NO_CONTENT}]
110
111    ${resp}=  Redfish.Get  /redfish/v1/Systems/system
112    Should Be Equal As Strings  ${resp.dict["Boot"]["BootSourceOverrideEnabled"]}
113    ...  ${override_enabled}
114    Should Be Equal As Strings  ${resp.dict["Boot"]["BootSourceOverrideTarget"]}
115    ...  ${override_target}
116    ${output}=  Run IPMI Standard Command  chassis bootparam get 5
117    Should Contain  ${output}  ${redfish_ipmi_enabled_map['${override_enabled}']}
118    Should Contain  ${output}  ${redfish_ipmi_target_map['${override_target}']}
119
120Suite Teardown Execution
121    [Documentation]  Do the post suite teardown.
122
123    Redfish.Login
124    Set And Verify BootSource And BootType  Disabled  None
125    Redfish.Logout
126
127
128Test Setup Execution
129    [Documentation]  Do test case setup tasks.
130
131    Redfish.Login
132
133
134Test Teardown Execution
135    [Documentation]  Do the post test teardown.
136
137    FFDC On Test Case Fail
138    Redfish.Logout
139