xref: /openbmc/openbmc-test-automation/redfish/extended/redfish_host_code_update.robot (revision 7916eb3fd577eedd3ef934e45bf8b557197c9907)
1*** Settings ***
2Documentation            Update the BMC code 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/redfish_code_update_utils.robot
18Resource                 ../../lib/utils.robot
19Library                  ../../lib/gen_robot_valid.py
20Library                  ../../lib/var_funcs.py
21Library                  ../../lib/gen_robot_keyword.py
22Library                  ../../lib/code_update_utils.py
23
24Suite Setup              Suite Setup Execution
25Suite Teardown           Redfish.Logout
26Test Setup               Printn
27Test Teardown            FFDC On Test Case Fail
28
29# Force the test to timedout to prevent test hanging.
30Test Timeout             30 minutes
31
32Test Tags                Host_Code_Update
33
34*** Test Cases ***
35
36Redfish Host Code Update
37    [Documentation]  Update the firmware image.
38    [Tags]  Redfish_Host_Code_Update
39
40    ${image_version}=  Get Version Tar  ${IMAGE_FILE_PATH}
41    Rprint Vars  image_version
42
43    ${sw_inv}=  Get Functional Firmware  Host image
44    ${functional_sw_inv}=  Get Non Functional Firmware  ${sw_inv}  True
45
46    ${num_records}=  Get Length  ${functional_sw_inv}
47
48    IF  ${num_records} != 0
49        Pass Execution If  '${functional_sw_inv['version']}' == '${image_version}'
50        ...  The existing ${image_version} firmware is already functional.
51    END
52
53    ${post_code_update_actions}=  Get Post Boot Action
54    ${state}=  Get Pre Reboot State
55    Rprint Vars  state
56
57   Print Timen  Performing firmware update ${image_version}.
58
59   Redfish Update Firmware
60
61
62*** Keywords ***
63
64Suite Setup Execution
65    [Documentation]  Do the suite setup.
66
67    Redfish.Login
68    # Delete BMC dump and Error logs.
69    Run Keyword And Ignore Error  Redfish Delete All BMC Dumps
70    Run Keyword And Ignore Error  Redfish Purge Event Log
71    # Checking for file existence.
72    Valid File Path  IMAGE_FILE_PATH
73
74
75Redfish Update Firmware
76    [Documentation]  Update the BMC firmware via redfish interface.
77
78    Redfish.Login
79    ${post_code_update_actions}=  Get Post Boot Action
80    Rprint Vars  post_code_update_actions
81    Run Keyword And Ignore Error  Set ApplyTime  policy=OnReset
82    Redfish Upload Image And Check Progress State
83    ${tar_version}=  Get Version Tar  ${IMAGE_FILE_PATH}
84    ${image_info}=  Get Software Inventory State By Version  ${tar_version}
85    Run Key  ${post_code_update_actions['${image_info["image_type"]}']['OnReset']}
86    Redfish.Login
87    Redfish Verify Host Version  ${IMAGE_FILE_PATH}
88
89