George Keishing | 27bf693 | 2017-08-07 14:30:40 -0500 | [diff] [blame] | 1 | *** Settings *** |
Sushil Singh | c51eee7 | 2019-09-01 11:13:37 -0500 | [diff] [blame] | 2 | Documentation BMC and PNOR update utilities keywords. |
George Keishing | 27bf693 | 2017-08-07 14:30:40 -0500 | [diff] [blame] | 3 | |
Sushil Singh | c51eee7 | 2019-09-01 11:13:37 -0500 | [diff] [blame] | 4 | Library code_update_utils.py |
| 5 | Library OperatingSystem |
| 6 | Library String |
| 7 | Library utilities.py |
| 8 | Library gen_robot_valid.py |
| 9 | Variables ../data/variables.py |
| 10 | Resource boot_utils.robot |
| 11 | Resource rest_client.robot |
| 12 | Resource openbmc_ffdc.robot |
| 13 | |
| 14 | *** Variables *** |
| 15 | ${ignore_err} ${0} |
George Keishing | 27bf693 | 2017-08-07 14:30:40 -0500 | [diff] [blame] | 16 | |
| 17 | *** Keywords *** |
| 18 | |
| 19 | Get Software Objects |
| 20 | [Documentation] Get the host software objects and return as a list. |
| 21 | [Arguments] ${version_type}=${VERSION_PURPOSE_HOST} |
| 22 | |
| 23 | # Description of argument(s): |
| 24 | # version_type Either BMC or host version purpose. |
| 25 | # By default host version purpose string. |
| 26 | # (e.g. "xyz.openbmc_project.Software.Version.VersionPurpose.BMC" |
| 27 | # "xyz.openbmc_project.Software.Version.VersionPurpose.Host"). |
| 28 | |
| 29 | # Example: |
| 30 | # "data": [ |
| 31 | # "/xyz/openbmc_project/software/f3b29aa8", |
| 32 | # "/xyz/openbmc_project/software/e49bc78e", |
| 33 | # ], |
| 34 | # Iterate the list and return the host object name path list. |
| 35 | |
| 36 | ${host_list}= Create List |
| 37 | ${sw_list}= Read Properties ${SOFTWARE_VERSION_URI} |
| 38 | |
Sushil Singh | 8d8ce96 | 2020-06-05 09:43:33 -0500 | [diff] [blame] | 39 | FOR ${index} IN @{sw_list} |
| 40 | ${attr_purpose}= Read Software Attribute ${index} Purpose |
| 41 | Continue For Loop If '${attr_purpose}' != '${version_type}' |
| 42 | Append To List ${host_list} ${index} |
| 43 | END |
George Keishing | 27bf693 | 2017-08-07 14:30:40 -0500 | [diff] [blame] | 44 | |
George Keishing | d62db0f | 2017-09-13 08:50:33 -0500 | [diff] [blame] | 45 | [Return] ${host_list} |
| 46 | |
| 47 | |
| 48 | Read Software Attribute |
| 49 | [Documentation] Return software attribute data. |
| 50 | [Arguments] ${software_object} ${attribute_name} |
| 51 | |
| 52 | # Description of argument(s): |
| 53 | # software_object Software object path. |
| 54 | # (e.g. "/xyz/openbmc_project/software/f3b29aa8"). |
| 55 | # attribute_name Software object attribute name. |
| 56 | |
| 57 | ${resp}= OpenBMC Get Request ${software_object}/attr/${attribute_name} |
| 58 | ... quiet=${1} |
| 59 | Return From Keyword If ${resp.status_code} != ${HTTP_OK} |
| 60 | ${content}= To JSON ${resp.content} |
| 61 | [Return] ${content["data"]} |
George Keishing | 27bf693 | 2017-08-07 14:30:40 -0500 | [diff] [blame] | 62 | |
| 63 | |
George Keishing | fe4ebd2 | 2017-09-12 06:05:22 -0500 | [diff] [blame] | 64 | Get Software Objects Id |
| 65 | [Documentation] Get the software objects id and return as a list. |
| 66 | [Arguments] ${version_type}=${VERSION_PURPOSE_HOST} |
| 67 | |
| 68 | # Description of argument(s): |
| 69 | # version_type Either BMC or host version purpose. |
| 70 | # By default host version purpose string. |
| 71 | # (e.g. "xyz.openbmc_project.Software.Version.VersionPurpose.BMC" |
| 72 | # "xyz.openbmc_project.Software.Version.VersionPurpose.Host"). |
| 73 | |
| 74 | ${sw_id_list}= Create List |
| 75 | ${sw_list}= Get Software Objects ${version_type} |
| 76 | |
Marissa Garza | 20ccfc7 | 2020-06-19 12:51:10 -0500 | [diff] [blame] | 77 | FOR ${index} IN @{sw_list} |
| 78 | Append To List ${sw_id_list} ${index.rsplit('/', 1)[1]} |
| 79 | END |
George Keishing | fe4ebd2 | 2017-09-12 06:05:22 -0500 | [diff] [blame] | 80 | [Return] ${sw_id_list} |
| 81 | |
| 82 | |
George Keishing | 27bf693 | 2017-08-07 14:30:40 -0500 | [diff] [blame] | 83 | Get Host Software Property |
| 84 | [Documentation] Return a dictionary of host software properties. |
| 85 | [Arguments] ${host_object} |
| 86 | |
| 87 | # Description of argument(s): |
| 88 | # host_object Host software object path. |
| 89 | # (e.g. "/xyz/openbmc_project/software/f3b29aa8"). |
| 90 | |
| 91 | ${sw_attributes}= Read Properties ${host_object} |
| 92 | [return] ${sw_attributes} |
| 93 | |
Sweta Potthuri | cd96634 | 2017-09-06 03:41:32 -0500 | [diff] [blame] | 94 | Get Host Software Objects Details |
| 95 | [Documentation] Return software object details as a list of dictionaries. |
| 96 | [Arguments] ${quiet}=${QUIET} |
| 97 | |
| 98 | ${software}= Create List |
| 99 | |
| 100 | ${pnor_details}= Get Software Objects ${VERSION_PURPOSE_HOST} |
Marissa Garza | 20ccfc7 | 2020-06-19 12:51:10 -0500 | [diff] [blame] | 101 | FOR ${pnor} IN @{pnor_details} |
| 102 | ${resp}= OpenBMC Get Request ${pnor} quiet=${1} |
| 103 | ${json}= To JSON ${resp.content} |
| 104 | Append To List ${software} ${json["data"]} |
| 105 | END |
Sweta Potthuri | cd96634 | 2017-09-06 03:41:32 -0500 | [diff] [blame] | 106 | [Return] ${software} |
George Keishing | 27bf693 | 2017-08-07 14:30:40 -0500 | [diff] [blame] | 107 | |
| 108 | Set Host Software Property |
| 109 | [Documentation] Set the host software properties of a given object. |
| 110 | [Arguments] ${host_object} ${sw_attribute} ${data} |
| 111 | |
| 112 | # Description of argument(s): |
| 113 | # host_object Host software object name. |
| 114 | # sw_attribute Host software attribute name. |
| 115 | # (e.g. "Activation", "Priority", "RequestedActivation" etc). |
| 116 | # data Value to be written. |
| 117 | |
| 118 | ${args}= Create Dictionary data=${data} |
| 119 | Write Attribute ${host_object} ${sw_attribute} data=${args} |
George Keishing | 9ebc052 | 2018-02-06 12:58:22 -0600 | [diff] [blame] | 120 | # Sync time for software updater manager to update. |
George Keishing | 9ebc052 | 2018-02-06 12:58:22 -0600 | [diff] [blame] | 121 | Sleep 10s |
George Keishing | 27bf693 | 2017-08-07 14:30:40 -0500 | [diff] [blame] | 122 | |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 123 | |
| 124 | Set Property To Invalid Value And Verify No Change |
| 125 | [Documentation] Attempt to set a property and check that the value didn't |
| 126 | ... change. |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 127 | [Arguments] ${property} ${version_type} |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 128 | |
| 129 | # Description of argument(s): |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 130 | # property The property to attempt to set. |
| 131 | # version_type Either BMC or host version purpose. |
| 132 | # By default host version purpose string. |
| 133 | # (e.g. "xyz.openbmc_project.Software.Version.VersionPurpose.BMC" |
| 134 | # "xyz.openbmc_project.Software.Version.VersionPurpose.Host"). |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 135 | |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 136 | ${software_objects}= Get Software Objects version_type=${version_type} |
| 137 | ${prev_properties}= Get Host Software Property @{software_objects}[0] |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 138 | Run Keyword And Expect Error 500 != 200 |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 139 | ... Set Host Software Property @{software_objects}[0] ${property} foo |
| 140 | ${cur_properties}= Get Host Software Property @{software_objects}[0] |
| 141 | Should Be Equal As Strings &{prev_properties}[${property}] |
| 142 | ... &{cur_properties}[${property}] |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 143 | |
| 144 | |
Charles Paul Hofer | 42f1746 | 2017-09-12 14:09:32 -0500 | [diff] [blame] | 145 | Set Priority To Invalid Value And Expect Error |
| 146 | [Documentation] Set the priority of an image to an invalid value and |
| 147 | ... check that an error was returned. |
| 148 | [Arguments] ${version_type} ${priority} |
| 149 | |
| 150 | # Description of argument(s): |
| 151 | # version_type Either BMC or host version purpose. |
| 152 | # (e.g. "xyz.openbmc_project.Software.Version.VersionPurpose.BMC" |
| 153 | # "xyz.openbmc_project.Software.Version.VersionPurpose.Host"). |
| 154 | # priority The priority value to set. Should be an integer outside of |
| 155 | # the range of 0 through 255. |
| 156 | |
| 157 | ${images}= Get Software Objects version_type=${version_type} |
| 158 | ${num_images}= Get Length ${images} |
| 159 | Should Be True 0 < ${num_images} |
| 160 | |
| 161 | Run Keyword And Expect Error 403 != 200 |
| 162 | ... Set Host Software Property @{images}[0] Priority ${priority} |
| 163 | |
| 164 | |
Sushil Singh | 5ea86d0 | 2019-07-11 02:05:16 -0500 | [diff] [blame] | 165 | Redfish Upload Image |
| 166 | [Documentation] Upload an image to the BMC via redfish. |
| 167 | [Arguments] ${uri} ${image_file_path} |
| 168 | |
| 169 | # Description of argument(s): |
| 170 | # uri URI for uploading image via redfish. |
| 171 | # image_file_path The path to the image tarball. |
| 172 | |
| 173 | ${image_data}= OperatingSystem.Get Binary File ${image_file_path} |
| 174 | |
George Keishing | 89e12bf | 2020-01-13 03:41:31 -0600 | [diff] [blame] | 175 | Wait Until Keyword Succeeds 2 times 120 sec |
| 176 | ... Upload Image To BMC ${uri} timeout=${90} data=${image_data} |
Sushil Singh | 5ea86d0 | 2019-07-11 02:05:16 -0500 | [diff] [blame] | 177 | |
| 178 | |
| 179 | Redfish Verify BMC Version |
| 180 | [Documentation] Verify that the version on the BMC is the same as the |
| 181 | ... version in the given image via Redfish. |
| 182 | [Arguments] ${image_file_path} |
| 183 | |
| 184 | # Description of argument(s): |
| 185 | # image_file_path Path to the image tarball. |
| 186 | |
| 187 | # Extract the version from the image tarball on our local system. |
| 188 | ${tar_version}= Get Version Tar ${image_file_path} |
| 189 | ${bmc_version}= Redfish Get BMC Version |
| 190 | |
Michael Walsh | e7edb22 | 2019-08-19 17:39:38 -0500 | [diff] [blame] | 191 | Valid Value bmc_version valid_values=['${tar_version}'] |
Sushil Singh | 5ea86d0 | 2019-07-11 02:05:16 -0500 | [diff] [blame] | 192 | |
| 193 | |
| 194 | Redfish Verify Host Version |
| 195 | [Documentation] Verify that the version of the PNOR image that is on the |
| 196 | ... BMC is the same as the one in the given image via Redfish. |
| 197 | [Arguments] ${image_file_path} |
| 198 | |
| 199 | # Description of argument(s): |
| 200 | # image_file_path Path to the image tarball. |
| 201 | |
| 202 | # Extract the version from the image tarball on our local system. |
| 203 | ${tar_version}= Get Version Tar ${image_file_path} |
| 204 | ${host_version}= Redfish Get Host Version |
| 205 | |
Michael Walsh | e7edb22 | 2019-08-19 17:39:38 -0500 | [diff] [blame] | 206 | Valid Value host_version valid_values=['${tar_version}'] |
Sushil Singh | 5ea86d0 | 2019-07-11 02:05:16 -0500 | [diff] [blame] | 207 | |
| 208 | |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 209 | Upload And Activate Image |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 210 | [Documentation] Upload an image to the BMC and activate it with REST. |
Charles Paul Hofer | b7842a5 | 2017-09-22 10:11:33 -0500 | [diff] [blame] | 211 | [Arguments] ${image_file_path} ${wait}=${1} ${skip_if_active}=false |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 212 | |
| 213 | # Description of argument(s): |
George Keishing | 71c24ed | 2017-09-25 13:11:10 -0500 | [diff] [blame] | 214 | # image_file_path The path to the image tarball to upload and activate. |
| 215 | # wait Indicates that this keyword should wait for host or |
| 216 | # BMC activation is completed. |
Charles Paul Hofer | b7842a5 | 2017-09-22 10:11:33 -0500 | [diff] [blame] | 217 | # skip_if_active If set to true, will skip the code update if this |
| 218 | # image is already on the BMC. |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 219 | |
| 220 | OperatingSystem.File Should Exist ${image_file_path} |
| 221 | ${image_version}= Get Version Tar ${image_file_path} |
| 222 | |
| 223 | ${image_data}= OperatingSystem.Get Binary File ${image_file_path} |
Leonel Gonzalez | 6ac206e | 2017-10-12 16:04:23 -0500 | [diff] [blame] | 224 | |
George Keishing | 65a7f16 | 2019-10-30 01:33:28 -0500 | [diff] [blame] | 225 | Wait Until Keyword Succeeds 3 times 120 sec |
| 226 | ... Upload Image To BMC /upload/image timeout=${90} data=${image_data} |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 227 | ${ret} ${version_id}= Verify Image Upload ${image_version} |
| 228 | Should Be True ${ret} |
| 229 | |
Charles Paul Hofer | b7842a5 | 2017-09-22 10:11:33 -0500 | [diff] [blame] | 230 | # Verify the image is 'READY' to be activated or if it's already active, |
| 231 | # set priority to 0 and reboot the BMC. |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 232 | ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id} |
Sushil Singh | ec4ab93 | 2020-06-08 01:32:11 -0500 | [diff] [blame] | 233 | ${activation}= Set Variable ${software_state}[Activation] |
George Keishing | d594985 | 2018-01-31 12:56:55 -0600 | [diff] [blame] | 234 | |
Charles Paul Hofer | b7842a5 | 2017-09-22 10:11:33 -0500 | [diff] [blame] | 235 | Run Keyword If |
| 236 | ... '${skip_if_active}' == 'true' and '${activation}' == '${ACTIVE}' |
Charles Paul Hofer | b420c57 | 2017-10-31 09:24:12 -0500 | [diff] [blame] | 237 | ... Run Keywords |
| 238 | ... Set Host Software Property ${SOFTWARE_VERSION_URI}${version_id} |
| 239 | ... Priority ${0} |
| 240 | ... AND |
| 241 | ... Return From Keyword |
| 242 | |
Sushil Singh | 8d8ce96 | 2020-06-05 09:43:33 -0500 | [diff] [blame] | 243 | Should Be Equal As Strings ${software_state}[Activation] ${READY} |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 244 | |
| 245 | # Request the image to be activated. |
| 246 | ${args}= Create Dictionary data=${REQUESTED_ACTIVE} |
| 247 | Write Attribute ${SOFTWARE_VERSION_URI}${version_id} |
| 248 | ... RequestedActivation data=${args} |
| 249 | ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id} |
Sushil Singh | 8d8ce96 | 2020-06-05 09:43:33 -0500 | [diff] [blame] | 250 | Should Be Equal As Strings ${software_state}[RequestedActivation] |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 251 | ... ${REQUESTED_ACTIVE} |
| 252 | |
George Keishing | 71c24ed | 2017-09-25 13:11:10 -0500 | [diff] [blame] | 253 | # Does caller want to wait for activation to complete? |
Charles Paul Hofer | e0e1780 | 2017-09-21 09:19:33 -0500 | [diff] [blame] | 254 | Return From Keyword If '${wait}' == '${0}' ${version_id} |
George Keishing | 71c24ed | 2017-09-25 13:11:10 -0500 | [diff] [blame] | 255 | |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 256 | # Verify code update was successful and Activation state is Active. |
| 257 | Wait For Activation State Change ${version_id} ${ACTIVATING} |
| 258 | ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id} |
Sushil Singh | 8d8ce96 | 2020-06-05 09:43:33 -0500 | [diff] [blame] | 259 | Should Be Equal As Strings ${software_state}[Activation] ${ACTIVE} |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 260 | |
George Keishing | d594985 | 2018-01-31 12:56:55 -0600 | [diff] [blame] | 261 | # Uploaded and activated image should have priority set to 0. Due to timing |
Gunnar Mills | 948e2e2 | 2018-03-23 12:54:27 -0500 | [diff] [blame] | 262 | # contention, it may take up to 10 seconds to complete updating priority. |
George Keishing | d594985 | 2018-01-31 12:56:55 -0600 | [diff] [blame] | 263 | Wait Until Keyword Succeeds 10 sec 5 sec |
| 264 | ... Check Software Object Attribute ${version_id} Priority ${0} |
| 265 | |
Charles Paul Hofer | e0e1780 | 2017-09-21 09:19:33 -0500 | [diff] [blame] | 266 | [Return] ${version_id} |
| 267 | |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 268 | |
Charles Paul Hofer | e09408d | 2017-10-02 14:42:38 -0500 | [diff] [blame] | 269 | Attempt To Reboot BMC During Image Activation |
| 270 | [Documentation] Attempt to reboot the BMC while an image is activating and |
| 271 | ... check that the BMC ignores the reboot command and finishes |
| 272 | ... activation. |
| 273 | [Arguments] ${image_file_path} |
| 274 | |
| 275 | # Description of argument(s): |
| 276 | # image_file_path Path to the image to update to. |
| 277 | |
| 278 | # Attempt to reboot during activation. |
| 279 | ${version_id}= Upload And Activate Image ${image_file_path} |
| 280 | ... wait=${0} |
George Keishing | fd346d1 | 2017-11-20 23:23:01 -0600 | [diff] [blame] | 281 | ${resp}= OpenBMC Get Request ${SOFTWARE_VERSION_URI}${version_id} |
| 282 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
Charles Paul Hofer | e09408d | 2017-10-02 14:42:38 -0500 | [diff] [blame] | 283 | |
George Keishing | fd346d1 | 2017-11-20 23:23:01 -0600 | [diff] [blame] | 284 | OBMC Reboot (off) |
Charles Paul Hofer | e09408d | 2017-10-02 14:42:38 -0500 | [diff] [blame] | 285 | |
George Keishing | fd346d1 | 2017-11-20 23:23:01 -0600 | [diff] [blame] | 286 | ${resp}= OpenBMC Get Request ${SOFTWARE_VERSION_URI}${version_id} |
| 287 | Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND} |
Charles Paul Hofer | e09408d | 2017-10-02 14:42:38 -0500 | [diff] [blame] | 288 | |
| 289 | |
Charles Paul Hofer | c1fa2bc | 2017-08-18 16:44:03 -0500 | [diff] [blame] | 290 | Activate Image And Verify No Duplicate Priorities |
| 291 | [Documentation] Upload an image, and then check that no images have the |
| 292 | ... same priority. |
| 293 | [Arguments] ${image_file_path} ${image_purpose} |
| 294 | |
| 295 | # Description of argument(s): |
| 296 | # image_file_path The path to the image to upload. |
| 297 | # image_purpose The purpose in the image's MANIFEST file. |
| 298 | |
George Keishing | 72373f8 | 2017-11-20 09:18:41 -0600 | [diff] [blame] | 299 | Upload And Activate Image ${image_file_path} skip_if_active=true |
Charles Paul Hofer | c1fa2bc | 2017-08-18 16:44:03 -0500 | [diff] [blame] | 300 | Verify No Duplicate Image Priorities ${image_purpose} |
| 301 | |
| 302 | |
Charles Paul Hofer | a567316 | 2017-08-30 09:49:16 -0500 | [diff] [blame] | 303 | Set Same Priority For Multiple Images |
| 304 | [Documentation] Find two images, set the priorities to be the same, and |
| 305 | ... verify that the priorities are not the same. |
| 306 | [Arguments] ${version_purpose} |
| 307 | |
| 308 | # Description of argument(s): |
| 309 | # version_purpose Either BMC or host version purpose. |
| 310 | # (e.g. "xyz.openbmc_project.Software.Version.VersionPurpose.BMC" |
| 311 | # "xyz.openbmc_project.Software.Version.VersionPurpose.Host"). |
| 312 | |
| 313 | # Make sure we have more than two images. |
| 314 | ${software_objects}= Get Software Objects version_type=${version_purpose} |
| 315 | ${num_images}= Get Length ${software_objects} |
| 316 | Should Be True 1 < ${num_images} |
| 317 | ... msg=Only found one image on the BMC with purpose ${version_purpose}. |
| 318 | |
| 319 | # Set the priority of the second image to the priority of the first. |
| 320 | ${properties}= Get Host Software Property @{software_objects}[0] |
| 321 | Set Host Software Property @{software_objects}[1] Priority |
| 322 | ... &{properties}[Priority] |
| 323 | Verify No Duplicate Image Priorities ${version_purpose} |
| 324 | |
| 325 | # Set the priority of the first image back to what it was before |
| 326 | Set Host Software Property @{software_objects}[0] Priority |
| 327 | ... &{properties}[Priority] |
| 328 | |
| 329 | |
Charles Paul Hofer | da24d0a | 2017-08-09 15:03:40 -0500 | [diff] [blame] | 330 | Delete Software Object |
| 331 | [Documentation] Deletes an image from the BMC. |
| 332 | [Arguments] ${software_object} |
| 333 | |
| 334 | # Description of argument(s): |
| 335 | # software_object The URI to the software image to delete. |
| 336 | |
| 337 | ${arglist}= Create List |
| 338 | ${args}= Create Dictionary data=${arglist} |
Adriana Kobylak | 2e9d9cf | 2019-08-12 13:48:47 -0500 | [diff] [blame] | 339 | ${resp}= OpenBMC Post Request ${software_object}/action/Delete |
Charles Paul Hofer | da24d0a | 2017-08-09 15:03:40 -0500 | [diff] [blame] | 340 | ... data=${args} |
| 341 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 342 | |
| 343 | |
| 344 | Delete Image And Verify |
| 345 | [Documentation] Delete an image from the BMC and verify that it was |
| 346 | ... removed from software and the /tmp/images directory. |
| 347 | [Arguments] ${software_object} ${version_type} |
| 348 | |
| 349 | # Description of argument(s): |
| 350 | # software_object The URI of the software object to delete. |
| 351 | # version_type The type of the software object, e.g. |
| 352 | # xyz.openbmc_project.Software.Version.VersionPurpose.Host |
| 353 | # or xyz.openbmc_project.Software.Version.VersionPurpose.BMC. |
| 354 | |
Gunnar Mills | 917ba1a | 2018-04-08 16:42:12 -0500 | [diff] [blame] | 355 | Log To Console Deleting ${software_object} |
Charles Paul Hofer | 9f74d3a | 2017-08-18 09:54:28 -0500 | [diff] [blame] | 356 | |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 357 | # Delete the image. |
| 358 | Delete Software Object ${software_object} |
Charles Paul Hofer | cef6199 | 2017-08-18 10:14:18 -0500 | [diff] [blame] | 359 | |
| 360 | # Verify that it's gone from software. |
| 361 | ${software_objects}= Get Software Objects version_type=${version_type} |
| 362 | Should Not Contain ${software_objects} ${software_object} |
| 363 | |
| 364 | # Check that there is no file in the /tmp/images directory. |
| 365 | ${image_id}= Fetch From Right ${software_object} / |
| 366 | BMC Execute Command |
| 367 | ... [ ! -d "/tmp/images/${image_id}" ] |
George Keishing | 0071549 | 2017-08-18 11:46:37 -0500 | [diff] [blame] | 368 | |
| 369 | |
Charles Paul Hofer | e8dc525 | 2017-10-10 13:50:18 -0500 | [diff] [blame] | 370 | Delete All Non Running BMC Images |
| 371 | [Documentation] Delete all BMC images that are not running on the BMC. |
| 372 | |
| 373 | @{datalist}= Create List |
| 374 | ${data}= Create Dictionary data=@{datalist} |
| 375 | Call Method ${SOFTWARE_VERSION_URI} DeleteAll data=${data} |
| 376 | |
| 377 | |
George Keishing | 0071549 | 2017-08-18 11:46:37 -0500 | [diff] [blame] | 378 | Check Error And Collect FFDC |
| 379 | [Documentation] Collect FFDC if error log exists. |
| 380 | |
| 381 | ${status}= Run Keyword And Return Status Error Logs Should Not Exist |
| 382 | Run Keyword If '${status}' == 'False' FFDC |
| 383 | Delete Error Logs |
Charles Paul Hofer | e43fb2f | 2017-09-26 15:36:18 -0500 | [diff] [blame] | 384 | |
| 385 | |
| 386 | Verify Running BMC Image |
| 387 | [Documentation] Verify that the version on the BMC is the same as the |
| 388 | ... version in the given image. |
| 389 | [Arguments] ${image_file_path} |
| 390 | |
| 391 | # Description of argument(s): |
| 392 | # image_file_path Path to the BMC image tarball. |
| 393 | |
| 394 | ${tar_version}= Get Version Tar ${image_file_path} |
| 395 | ${bmc_version}= Get BMC Version |
| 396 | ${bmc_version}= Remove String ${bmc_version} " |
| 397 | Should Be Equal ${tar_version} ${bmc_version} |
| 398 | |
| 399 | |
| 400 | Verify Running Host Image |
| 401 | [Documentation] Verify that the version of the PNOR image that is on the |
| 402 | ... BMC is the same as the one in the given image. |
| 403 | [Arguments] ${image_file_path} |
| 404 | |
| 405 | # Description of argument(s): |
| 406 | # image_file_path Path to the PNOR image tarball. |
| 407 | |
| 408 | ${tar_version}= Get Version Tar ${image_file_path} |
| 409 | ${pnor_version}= Get PNOR Version |
| 410 | Should Be Equal ${tar_version} ${pnor_version} |
Charles Paul Hofer | e0e1780 | 2017-09-21 09:19:33 -0500 | [diff] [blame] | 411 | |
George Keishing | 81ae45b | 2017-09-28 14:05:04 -0500 | [diff] [blame] | 412 | |
| 413 | Get Least Value Priority Image |
| 414 | [Documentation] Find the least value in "Priority" attribute and return. |
| 415 | [Arguments] ${version_type} |
| 416 | |
| 417 | # Description of argument(s): |
| 418 | # version_type Either BMC or host version purpose. |
| 419 | |
| 420 | ${priority_value_list}= Create List |
| 421 | ${sw_list}= Get Software Objects version_type=${version_type} |
| 422 | |
Marissa Garza | 20ccfc7 | 2020-06-19 12:51:10 -0500 | [diff] [blame] | 423 | FOR ${index} IN @{sw_list} |
| 424 | ${priority_value}= |
| 425 | ... Read Software Attribute ${index} Priority |
| 426 | Append To List ${priority_value_list} ${priority_value} |
| 427 | END |
George Keishing | 81ae45b | 2017-09-28 14:05:04 -0500 | [diff] [blame] | 428 | ${min_value}= Min List Value ${priority_value_list} |
| 429 | |
| 430 | [Return] ${min_value} |
George Keishing | fb76203 | 2017-11-14 11:18:21 -0600 | [diff] [blame] | 431 | |
| 432 | |
| 433 | Enable Field Mode And Verify Unmount |
| 434 | [Documentation] Enable field mode and check that /usr/local is unmounted. |
| 435 | |
| 436 | # After running, /xyz/openbmc_project/software should look like this: |
| 437 | # /xyz/openbmc_project/software |
| 438 | # { |
| 439 | # "FieldModeEnabled": 1, |
| 440 | # "associations": [ |
| 441 | # [ |
| 442 | # "active", |
| 443 | # "software_version", |
| 444 | # "/xyz/openbmc_project/software/fcf8e182" |
| 445 | # ], |
| 446 | # [ |
| 447 | # "functional", |
Gunnar Mills | af472ce | 2018-02-27 16:08:27 -0600 | [diff] [blame] | 448 | # "functional", |
George Keishing | fb76203 | 2017-11-14 11:18:21 -0600 | [diff] [blame] | 449 | # "/xyz/openbmc_project/software/fcf8e182" |
| 450 | # ] |
| 451 | # ] |
| 452 | # } |
| 453 | |
| 454 | ${args}= Create Dictionary data=${1} |
| 455 | Write Attribute ${SOFTWARE_VERSION_URI} FieldModeEnabled data=${args} |
| 456 | Sleep 5s |
| 457 | BMC Execute Command [ ! -d "/usr/local/share" ] |
| 458 | |
George Keishing | ef97f3f | 2017-11-15 10:32:59 -0600 | [diff] [blame] | 459 | |
| 460 | Disable Field Mode And Verify Unmount |
| 461 | [Documentation] Disable field mode, unmask usr local mount and reboot. |
| 462 | |
| 463 | BMC Execute Command /sbin/fw_setenv fieldmode |
| 464 | BMC Execute Command /bin/systemctl unmask usr-local.mount |
George Keishing | c903158 | 2017-12-18 11:58:11 -0600 | [diff] [blame] | 465 | OBMC Reboot (off) stack_mode=normal |
George Keishing | ef97f3f | 2017-11-15 10:32:59 -0600 | [diff] [blame] | 466 | BMC Execute Command [ -d "/usr/local/share" ] |
| 467 | |
George Keishing | 13b8a21 | 2017-11-17 00:35:13 -0600 | [diff] [blame] | 468 | |
| 469 | Field Mode Should Be Enabled |
| 470 | [Documentation] Check that field mode is enabled. |
| 471 | |
| 472 | ${value}= Read Attribute ${SOFTWARE_VERSION_URI} FieldModeEnabled |
| 473 | Should Be True ${value} ${1} |
Sweta Potthuri | 8c7ada4 | 2018-01-15 05:05:59 -0600 | [diff] [blame] | 474 | |
| 475 | List Installed Images |
| 476 | [Documentation] List all the installed images. |
| 477 | [Arguments] ${image_type} |
| 478 | |
Gunnar Mills | 948e2e2 | 2018-03-23 12:54:27 -0500 | [diff] [blame] | 479 | # Description of argument(s): |
Sweta Potthuri | 8c7ada4 | 2018-01-15 05:05:59 -0600 | [diff] [blame] | 480 | # image_type Either "BMC" or "PNOR". |
| 481 | |
| 482 | # List the installed images. |
| 483 | ${installed_images}= Get Software Objects |
| 484 | ... ${SOFTWARE_PURPOSE}.${image_type} |
| 485 | |
| 486 | Run Keyword If ${installed_images} != [] |
| 487 | ... Get List of Images ${installed_images} |
| 488 | ... ELSE Log No ${image_type} images are present. |
| 489 | |
| 490 | Get List of Images |
| 491 | [Documentation] Get List of Images |
| 492 | [Arguments] ${installed_images} |
| 493 | |
Sushil Singh | 8d8ce96 | 2020-06-05 09:43:33 -0500 | [diff] [blame] | 494 | FOR ${uri} IN @{installed_images} |
| 495 | ${resp}= OpenBMC Get Request ${uri} |
| 496 | ${json}= To JSON ${resp.content} |
| 497 | Log ${json["data"]} |
| 498 | END |
George Keishing | d594985 | 2018-01-31 12:56:55 -0600 | [diff] [blame] | 499 | |
| 500 | |
| 501 | Check Software Object Attribute |
| 502 | [Documentation] Get the software property of a given object and verify. |
| 503 | [Arguments] ${image_object} ${sw_attribute} ${value} |
| 504 | |
| 505 | # Description of argument(s): |
| 506 | # image_object Image software object name. |
| 507 | # sw_attribute Software attribute name. |
| 508 | # (e.g. "Activation", "Priority", "RequestedActivation" etc). |
| 509 | # value Software attribute value to compare. |
| 510 | |
| 511 | ${data}= Read Attribute |
| 512 | ... ${SOFTWARE_VERSION_URI}${image_object} ${sw_attribute} |
| 513 | |
| 514 | Should Be True ${data} == ${value} |
| 515 | ... msg=Given attribute value ${data} mismatch ${value}. |
George Keishing | 0b83743 | 2018-03-20 13:46:10 -0500 | [diff] [blame] | 516 | |
| 517 | |
| 518 | Image Should Be Signed |
| 519 | [Documentation] Fail if the image is not signed. |
| 520 | |
| 521 | Directory Should Exist ${ACTIVATION_DIR_PATH} |
| 522 | ... msg=${ACTIVATION_DIR_PATH} does not exist. Therefore, the image is not signed. |
George Keishing | cba6d42 | 2019-07-09 15:01:59 -0500 | [diff] [blame] | 523 | |
| 524 | |
| 525 | Get Latest Image ID |
| 526 | [Documentation] Return the ID of the most recently extracted image. |
| 527 | # Note: This keyword will fail if there is no such file. |
| 528 | |
| 529 | # Example: # ls /tmp/images/ |
| 530 | # 1b714fb7 |
| 531 | ${image_id}= Get Latest File /tmp/images/ |
Michael Walsh | e7edb22 | 2019-08-19 17:39:38 -0500 | [diff] [blame] | 532 | Valid Value image_id |
George Keishing | cba6d42 | 2019-07-09 15:01:59 -0500 | [diff] [blame] | 533 | |
| 534 | # Though an image sub-directory was found, it really isn't valid unless |
| 535 | # the MANIFEST file is present. |
| 536 | BMC Execute Command ls -l /tmp/images/${image_id}/MANIFEST |
| 537 | |
| 538 | [Return] ${image_id} |
| 539 | |
| 540 | |
| 541 | Check Image Update Progress State |
| 542 | [Documentation] Check that the image update progress state matches the specified state. |
| 543 | [Arguments] ${match_state} ${image_id} |
| 544 | |
| 545 | # Description of argument(s): |
| 546 | # match_state The expected state. This may be one or more comma-separated values |
| 547 | # (e.g. "Disabled", "Disabled, Updating"). If the actual state matches |
| 548 | # any of the states named in this argument, this keyword passes. |
| 549 | # image_id The image ID (e.g. "1b714fb7"). |
| 550 | |
| 551 | ${state}= Get Image Update Progress State image_id=${image_id} |
Michael Walsh | e7edb22 | 2019-08-19 17:39:38 -0500 | [diff] [blame] | 552 | Valid Value state valid_values=[${match_state}] |
George Keishing | cba6d42 | 2019-07-09 15:01:59 -0500 | [diff] [blame] | 553 | |
| 554 | |
| 555 | Get Image Update Progress State |
| 556 | [Documentation] Return the current state of the image update. |
| 557 | [Arguments] ${image_id} |
| 558 | |
| 559 | # Description of argument(s): |
| 560 | # image_id The image ID (e.g. "1b714fb7"). |
| 561 | |
| 562 | # In this example, this keyword would return the value "Enabled". |
| 563 | # "Status": { |
| 564 | # "Health": "OK", |
| 565 | # "HealthRollup": "OK", |
| 566 | # "State": "Enabled" |
| 567 | # }, |
| 568 | ${status}= Redfish.Get Attribute /redfish/v1/UpdateService/FirmwareInventory/${image_id} Status |
| 569 | Rprint Vars status |
| 570 | |
| 571 | [Return] ${status["State"]} |
| 572 | |
| 573 | |
| 574 | Get Firmware Image Version |
| 575 | [Documentation] Get the version of the currently installed firmware and return it. |
| 576 | [Arguments] ${image_id} |
| 577 | |
| 578 | # Description of argument(s): |
| 579 | # image_id The image ID (e.g. "1b714fb7"). |
| 580 | |
| 581 | # Example of a version returned by this keyword: |
| 582 | # 2.8.0-dev-19-g6d5764b33 |
| 583 | ${version}= Redfish.Get Attribute /redfish/v1/UpdateService/FirmwareInventory/${image_id} Version |
| 584 | Rprint Vars version |
| 585 | |
| 586 | [Return] ${version} |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 587 | |
| 588 | |
Sushil Singh | ca0bc3b | 2019-10-17 11:28:41 -0500 | [diff] [blame] | 589 | Get ApplyTime |
| 590 | [Documentation] Get the firmware "ApplyTime" policy. |
| 591 | [Arguments] ${policy} |
| 592 | |
| 593 | # Description of argument(s): |
| 594 | # policy ApplyTime allowed values (e.g. "OnReset", "Immediate"). |
| 595 | |
| 596 | ${system_applytime}= Redfish.Get Attribute ${REDFISH_BASE_URI}UpdateService HttpPushUriOptions |
Sushil Singh | f617c30 | 2020-07-23 01:01:07 -0500 | [diff] [blame] | 597 | |
Sushil Singh | ca0bc3b | 2019-10-17 11:28:41 -0500 | [diff] [blame] | 598 | [Return] ${system_applytime["HttpPushUriApplyTime"]["ApplyTime"]} |
| 599 | |
| 600 | |
| 601 | Verify Get ApplyTime |
| 602 | [Documentation] Get and verify the firmware "ApplyTime" policy. |
| 603 | [Arguments] ${policy} |
| 604 | |
| 605 | # Description of argument(s): |
| 606 | # policy ApplyTime allowed values (e.g. "OnReset", "Immediate"). |
| 607 | |
| 608 | ${system_applytime}= Get ApplyTime ${policy} |
Sushil Singh | f617c30 | 2020-07-23 01:01:07 -0500 | [diff] [blame] | 609 | Rprint Vars system_applytime |
Sushil Singh | ca0bc3b | 2019-10-17 11:28:41 -0500 | [diff] [blame] | 610 | Valid Value system_applytime ['${policy}'] |
| 611 | |
| 612 | |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 613 | Set ApplyTime |
| 614 | [Documentation] Set and verify the firmware "ApplyTime" policy. |
| 615 | [Arguments] ${policy} |
| 616 | |
| 617 | # Description of argument(s): |
| 618 | # policy ApplyTime allowed values (e.g. "OnReset", "Immediate"). |
| 619 | |
Sushil Singh | 56f590a | 2019-09-25 11:26:41 -0500 | [diff] [blame] | 620 | Redfish.Patch ${REDFISH_BASE_URI}UpdateService |
| 621 | ... body={'HttpPushUriOptions' : {'HttpPushUriApplyTime' : {'ApplyTime' : '${policy}'}}} |
Sushil Singh | ca0bc3b | 2019-10-17 11:28:41 -0500 | [diff] [blame] | 622 | Verify Get ApplyTime ${policy} |
Sushil Singh | c51eee7 | 2019-09-01 11:13:37 -0500 | [diff] [blame] | 623 | |
| 624 | |
| 625 | Get Image Version From TFTP Server |
| 626 | [Documentation] Get and return the image version |
| 627 | ... from the TFTP server. |
| 628 | [Arguments] ${server_host} ${image_file_name} |
| 629 | |
| 630 | # Description of argument(s): |
| 631 | # server_host The host name or IP address of the TFTP server. |
| 632 | # image_file_name The file name of the image. |
| 633 | |
| 634 | Shell Cmd |
| 635 | ... curl -s tftp://${server_host}/${image_file_name} > tftp_image.tar |
| 636 | ${version}= Get Version Tar tftp_image.tar |
| 637 | OperatingSystem.Remove File tftp_image.tar |
| 638 | |
| 639 | [Return] ${version} |
| 640 | |