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
30Force Tags               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/  BiosVersion
57    Redfish Firmware Update And Do BMC Reboot
58    ${bios_version_after}=  Redfish.Get Attribute  /redfish/v1/Systems/system/  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 BMC 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    Redfish Upload Image And Check Progress State
85    Run Key  ${post_code_update_actions['Host image']['${apply_time}']}
86    Redfish.Login
87    Redfish Verify Host Version  ${IMAGE_FILE_PATH}
88    Verify Get ApplyTime  ${apply_time}
89
90
91Redfish Firmware Update And Do BMC Reboot
92    [Documentation]  Update the firmware via redfish interface and do BMC reboot.
93
94    Set ApplyTime  policy="Immediate"
95    Redfish Upload Image  ${REDFISH_BASE_URI}UpdateService  ${IMAGE_FILE_PATH}
96    ${image_id}=  Get Latest Image ID
97    Wait Until Keyword Succeeds  1 min  10 sec
98    ...  Check Image Update Progress State  match_state='Updating'  image_id=${image_id}
99
100    # BMC reboot while PNOR update is in progress.
101    Redfish OBMC Reboot (off)
102