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