1*** Settings ***
2Documentation            Update firmware on a target Host via Redifsh.
3
4# Test Parameters:
5# IMAGE_FILE_PATH        The path to the Host image file.
6#
7# Firmware update states:
8#     Enabled            Image is installed and either functional or active.
9#     Disabled           Image installation failed or ready for activation.
10#     Updating           Image installation currently in progress.
11
12Resource                 ../../lib/resource.robot
13Resource                 ../../lib/bmc_redfish_resource.robot
14Resource                 ../../lib/boot_utils.robot
15Resource                 ../../lib/openbmc_ffdc.robot
16Resource                 ../../lib/common_utils.robot
17Resource                 ../../lib/code_update_utils.robot
18Resource                 ../../lib/dump_utils.robot
19Resource                 ../../lib/logging_utils.robot
20Resource                 ../../lib/redfish_code_update_utils.robot
21Resource                 ../../lib/utils.robot
22Library                  ../../lib/gen_robot_valid.py
23Library                  ../../lib/tftp_update_utils.py
24
25Suite Setup              Suite Setup Execution
26Suite Teardown           Redfish.Logout
27Test Setup               Printn
28Test Teardown            FFDC On Test Case Fail
29
30Test Tags               Redfish_Host_Code_Update
31
32*** Test Cases ***
33
34Redfish Host Code Update With ApplyTime OnReset
35    [Documentation]  Update the firmware image with ApplyTime of OnReset.
36    [Tags]  Redfish_Host_Code_Update_With_ApplyTime_OnReset
37    [Template]  Redfish Update Firmware
38
39    # policy
40    OnReset
41
42
43Redfish Host Code Update With ApplyTime Immediate
44    [Documentation]  Update the firmware image with ApplyTime of Immediate.
45    [Tags]  Redfish_Host_Code_Update_With_ApplyTime_Immediate
46    [Template]  Redfish Update Firmware
47
48    # policy
49    Immediate
50
51
52BMC Reboot When PNOR Update Goes On
53    [Documentation]  Trigger PNOR update and do BMC reboot.
54    [Tags]  BMC_Reboot_When_PNOR_Update_Goes_On
55
56    ${bios_version_before}=  Redfish.Get Attribute  /redfish/v1/Systems/${SYSTEM_ID}/  BiosVersion
57    Redfish Firmware Update And Do BMC Reboot
58    ${bios_version_after}=  Redfish.Get Attribute  /redfish/v1/Systems/${SYSTEM_ID}/  BiosVersion
59    Valid Value  bios_version_after  ['${bios_version_before}']
60
61
62*** Keywords ***
63
64Suite Setup Execution
65    [Documentation]  Do the suite setup.
66
67    Valid File Path  IMAGE_FILE_PATH
68    Redfish.Login
69    Run Keyword And Ignore Error  Redfish Delete All BMC Dumps
70    Run Keyword And Ignore Error  Redfish Purge Event Log
71    Redfish Power Off  stack_mode=skip
72
73
74Redfish Update Firmware
75    [Documentation]  Update the Host firmware via redfish interface.
76    [Arguments]  ${apply_time}
77
78    # Description of argument(s):
79    # policy     ApplyTime allowed values (e.g. "OnReset", "Immediate").
80
81    Redfish.Login
82    ${post_code_update_actions}=  Get Post Boot Action
83    Set ApplyTime  policy=${apply_Time}
84
85    # URI : /redfish/v1/UpdateService
86    # "HttpPushUri": "/redfish/v1/UpdateService/update",
87
88    Redfish Upload Image And Check Progress State
89    Run Key  ${post_code_update_actions['Host image']['${apply_time}']}
90    Redfish.Login
91    Redfish Verify Host Version  ${IMAGE_FILE_PATH}
92    Verify Get ApplyTime  ${apply_time}
93
94
95Redfish Firmware Update And Do BMC Reboot
96    [Documentation]  Update the firmware via redfish interface and do BMC reboot.
97
98    Set ApplyTime  policy="Immediate"
99
100     # URI : /redfish/v1/UpdateService
101     # "HttpPushUri": "/redfish/v1/UpdateService/update",
102
103    ${redfish_update_uri}=  Get Redfish Update Service URI
104    Redfish Upload Image  ${redfish_update_uri}  ${IMAGE_FILE_PATH}
105    ${image_id}=  Get Latest Image ID
106    Wait Until Keyword Succeeds  1 min  10 sec
107    ...  Check Image Update Progress State  match_state='Updating'  image_id=${image_id}
108
109    # BMC reboot while PNOR update is in progress.
110    Redfish OBMC Reboot (off)
111