blob: ebec8a7e3df7541524a4bec36fb5c01d55b671e7 [file] [log] [blame]
Sushil Singh87dcee12019-08-07 13:13:13 -05001*** 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
Sushil Singh6624ce52020-01-22 00:53:41 -060018Resource ../../lib/utils.robot
Sushil Singh87dcee12019-08-07 13:13:13 -050019Library ../../lib/gen_robot_valid.py
20Library ../../lib/var_funcs.py
Sushil Singh8f48c8f2020-01-16 04:36:25 -060021Library ../../lib/gen_robot_keyword.py
Sushil Singh87dcee12019-08-07 13:13:13 -050022
Sushil Singhb2162d82019-09-27 07:22:04 -050023Suite Setup Suite Setup Execution
24Suite Teardown Redfish.Logout
25Test Setup Printn
26Test Teardown FFDC On Test Case Fail
Sushil Singh87dcee12019-08-07 13:13:13 -050027
Sushil Singhb2162d82019-09-27 07:22:04 -050028Force Tags BMC_Code_Update
Sushil Singh87dcee12019-08-07 13:13:13 -050029
Sushil Singh65878cb2020-02-27 03:43:44 -060030*** Variables ***
31
32${FORCE_UPDATE} ${0}
33
34
Sushil Singh87dcee12019-08-07 13:13:13 -050035*** Test Cases ***
36
37Redfish BMC Code Update
38 [Documentation] Update the firmware image.
39 [Tags] Redfish_BMC_Code_Update
40
41 ${image_version}= Get Version Tar ${IMAGE_FILE_PATH}
42 Rprint Vars image_version
43
George Keishingfedd5ce2020-07-24 02:25:08 -050044 ${bmc_release_info}= Get BMC Release Info
45 ${functional_version}= Set Variable ${bmc_release_info['version_id']}
46 Rprint Vars functional_version
47
George Keishing78903952020-07-24 07:04:53 -050048 # Check if the existing firmware is functional.
49 Pass Execution If '${functional_version}' == '${image_version}'
50 ... The existing ${image_version} firmware is already functional.
51
Sushil Singh87dcee12019-08-07 13:13:13 -050052 Run Keyword If not ${FORCE_UPDATE}
53 ... Activate Existing Firmware ${image_version}
54 Redfish Update Firmware
55
56*** Keywords ***
57
58Suite Setup Execution
59 [Documentation] Do the suite setup.
60
61 Redfish.Login
Sushil Singh87dcee12019-08-07 13:13:13 -050062 # Delete BMC dump and Error logs.
63 Delete All BMC Dump
George Keishing2dac8122020-07-24 02:11:47 -050064 Run Keyword And Ignore Error Redfish Purge Event Log
Sushil Singh87dcee12019-08-07 13:13:13 -050065 # Checking for file existence.
66 Valid File Path IMAGE_FILE_PATH
67
Sushil Singh87dcee12019-08-07 13:13:13 -050068Activate Existing Firmware
69 [Documentation] Set fimware image to lower priority.
70 [Arguments] ${image_version}
71
72 # Description of argument(s):
73 # image_version Version of image.
74
75 ${software_inventory_record}= Get Software Inventory State By Version
76 ... ${image_version}
77 ${num_keys}= Get Length ${software_inventory_record}
78
79 Rprint Vars software_inventory_record
80
81 # If no software inventory record was found, there is no existing
82 # firmware for the given version and therefore no action to be taken.
83 Return From Keyword If not ${num_keys}
84
85 # Check if the existing firmware is functional.
86 Pass Execution If ${software_inventory_record['functional']}
87 ... The existing ${image_version} firmware is already functional.
88
89 # If existing firmware is not functional, then set the priority to least.
90 Print Timen The existing ${image_version} firmware is not yet functional.
91 Set BMC Image Priority To Least ${image_version} ${software_inventory_record}
92
93 Pass Execution The existing ${image_version} firmware is now functional.
94
95
96Get Image Priority
97 [Documentation] Get Current Image Priority.
98 [Arguments] ${image_version}
99
100 # Description of argument(s):
George Keishing19700762020-01-22 12:32:53 -0600101 # image_version The Fimware image version (e.g. 2.8.0-dev-1107-g512028d95).
Sushil Singh87dcee12019-08-07 13:13:13 -0500102
103 ${software_info}= Read Properties
104 ... ${SOFTWARE_VERSION_URI}/enumerate quiet=1
105 # Get only the record associated with our image_version.
106
107 ${software_info}= Filter Struct
108 ... ${software_info} [('Version', '${image_version}')]
109 # Convert from dict to list.
110 ${software_info}= Get Dictionary Values ${software_info}
111
112 [Return] ${software_info[0]['Priority']}
113
114
115Set BMC Image Priority To Least
116 [Documentation] Set BMC image priority to least value.
117 [Arguments] ${image_version} ${software_inventory}
118
119 # Description of argument(s):
George Keishing19700762020-01-22 12:32:53 -0600120 # image_version The Fimware image version (e.g. 2.8.0-dev-1107-g512028d95).
Sushil Singh87dcee12019-08-07 13:13:13 -0500121 # software_inventory Software inventory details.
122
123 ${least_priority}= Get Least Value Priority Image ${VERSION_PURPOSE_BMC}
124 ${cur_priority}= Get Image Priority ${image_version}
125 Rprint Vars least_priority cur_priority
126
127 Return From Keyword If '${least_priority}' == ${cur_priority}
128 Set Host Software Property
129 ... ${SOFTWARE_VERSION_URI}${software_inventory['image_id']}
130 ... Priority ${least_priority}
131
Sushil Singh87dcee12019-08-07 13:13:13 -0500132 Redfish OBMC Reboot (off)
Sushil Singh87dcee12019-08-07 13:13:13 -0500133
134
135Redfish Update Firmware
136 [Documentation] Update the BMC firmware via redfish interface.
137
Sushil Singh6624ce52020-01-22 00:53:41 -0600138 ${post_code_update_actions}= Get Post Boot Action
Sushil Singh87dcee12019-08-07 13:13:13 -0500139 ${state}= Get Pre Reboot State
140 Rprint Vars state
Sushil Singh090eedc2019-11-05 02:04:59 -0600141 Run Keyword And Ignore Error Set ApplyTime policy=OnReset
Sushil Singh6f86f172019-10-30 11:36:25 -0500142 Redfish Upload Image And Check Progress State
Sushil Singh8f48c8f2020-01-16 04:36:25 -0600143 ${tar_version}= Get Version Tar ${IMAGE_FILE_PATH}
144 ${image_info}= Get Software Inventory State By Version ${tar_version}
Sushil Singh8f48c8f2020-01-16 04:36:25 -0600145 Run Key ${post_code_update_actions['${image_info["image_type"]}']['OnReset']}
146 Redfish.Login
147 Redfish Verify BMC Version ${IMAGE_FILE_PATH}
Sushil Singh87dcee12019-08-07 13:13:13 -0500148