1*** Settings ***
2Documentation            Update firmware on a target BMC via Redifsh.
3
4# Test Parameters:
5# IMAGE_FILE_PATH        The path to the BMC 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/openbmc_ffdc.robot
15Resource                 ../../lib/common_utils.robot
16Resource                 ../../lib/code_update_utils.robot
17Resource                 ../../lib/dump_utils.robot
18Resource                 ../../lib/logging_utils.robot
19Resource                 ../../lib/redfish_code_update_utils.robot
20Resource                 ../../lib/utils.robot
21Library                  ../../lib/gen_robot_valid.py
22Library                  ../../lib/tftp_update_utils.py
23Library                  ../../lib/gen_robot_keyword.py
24
25Suite Setup              Suite Setup Execution
26Suite Teardown           Redfish.Logout
27Test Setup               Printn
28Test Teardown            FFDC On Test Case Fail
29
30Force Tags               BMC_Code_Update
31
32*** Test Cases ***
33
34Redfish Code Update With ApplyTime OnReset
35    [Documentation]  Update the firmaware image with ApplyTime of OnReset.
36    [Tags]  Redfish_Code_Update_With_ApplyTime_OnReset
37    [Template]  Redfish Update Firmware
38
39    # policy
40    OnReset
41
42
43Redfish Code Update With ApplyTime Immediate
44    [Documentation]  Update the firmaware image with ApplyTime of Immediate.
45    [Tags]  Redfish_Code_Update_With_ApplyTime_Immediate
46    [Template]  Redfish Update Firmware
47
48    # policy
49    Immediate
50
51
52Redfish Code Update With Multiple Firmware
53    [Documentation]  Update the firmaware image with ApplyTime of Immediate.
54    [Tags]  Redfish_Code_Update_With_Multiple_Firmware
55    [Template]  Redfish Multiple Upload Image And Check Progress State
56
57    # policy   image_file_path     alternate_image_file_path
58    Immediate  ${IMAGE_FILE_PATH}  ${ALTERNATE_IMAGE_FILE_PATH}
59
60
61*** Keywords ***
62
63Suite Setup Execution
64    [Documentation]  Do the suite setup.
65
66    Valid File Path  IMAGE_FILE_PATH
67    Redfish.Login
68    Delete All BMC Dump
69    Redfish Purge Event Log
70
71
72Redfish Update Firmware
73    [Documentation]  Update the BMC firmware via redfish interface.
74    [Arguments]  ${apply_time}
75
76    # Description of argument(s):
77    # policy     ApplyTime allowed values (e.g. "OnReset", "Immediate").
78
79    ${post_code_update_actions}=  Get Post Boot Action
80    ${state}=  Get Pre Reboot State
81    Rprint Vars  state
82    Set ApplyTime  policy=${apply_Time}
83    Redfish Upload Image And Check Progress State
84    Run Key  ${post_code_update_actions['BMC image']['${apply_time}']}
85    Redfish.Login
86    Redfish Verify BMC Version  ${IMAGE_FILE_PATH}
87    Verify Get ApplyTime  ${apply_time}
88
89
90Redfish Multiple Upload Image And Check Progress State
91    [Documentation]  Update multiple BMC firmware via redfish interface and check status.
92    [Arguments]  ${apply_time}  ${IMAGE_FILE_PATH}  ${ALTERNATE_IMAGE_FILE_PATH}
93
94    # Description of argument(s):
95    # apply_time                 ApplyTime allowed values (e.g. "OnReset", "Immediate").
96    # IMAGE_FILE_PATH            The path to BMC image file.
97    # ALTERNATE_IMAGE_FILE_PATH  The path to alternate BMC image file.
98
99    ${post_code_update_actions}=  Get Post Boot Action
100    Valid File Path  ALTERNATE_IMAGE_FILE_PATH
101    ${state}=  Get Pre Reboot State
102    Rprint Vars  state
103
104    Set ApplyTime  policy=${apply_time}
105    Redfish Upload Image  ${REDFISH_BASE_URI}UpdateService  ${IMAGE_FILE_PATH}
106
107    ${first_image_id}=  Get Latest Image ID
108    Rprint Vars  first_image_id
109    Sleep  5s
110    Redfish Upload Image  ${REDFISH_BASE_URI}UpdateService  ${ALTERNATE_IMAGE_FILE_PATH}
111
112    ${second_image_id}=  Get Latest Image ID
113    Rprint Vars  second_image_id
114
115    Check Image Update Progress State
116    ...  match_state='Updating', 'Disabled'  image_id=${second_image_id}
117
118    Check Image Update Progress State
119    ...  match_state='Updating'  image_id=${first_image_id}
120
121    Wait Until Keyword Succeeds  8 min  20 sec
122    ...  Check Image Update Progress State
123    ...    match_state='Enabled'  image_id=${first_image_id}
124    Run Key  ${post_code_update_actions['BMC image']['${apply_time}']}
125    Redfish.Login
126    Redfish Verify BMC Version  ${IMAGE_FILE_PATH}
127