blob: cff9937a893737d8301a11d29e0aca0163f74e4d [file] [log] [blame]
George Keishing27bf6932017-08-07 14:30:40 -05001*** Settings ***
Sushil Singhc51eee72019-09-01 11:13:37 -05002Documentation BMC and PNOR update utilities keywords.
George Keishing27bf6932017-08-07 14:30:40 -05003
Sushil Singhc51eee72019-09-01 11:13:37 -05004Library code_update_utils.py
5Library OperatingSystem
6Library String
7Library utilities.py
8Library gen_robot_valid.py
9Variables ../data/variables.py
10Resource boot_utils.robot
11Resource rest_client.robot
12Resource openbmc_ffdc.robot
13
14*** Variables ***
15${ignore_err} ${0}
George Keishing27bf6932017-08-07 14:30:40 -050016
George Keishingf0d5ae72022-02-24 10:36:15 -060017# Time in minutes.
18${IMAGE_UPLOAD_WAIT_TIMEOUT} 4
19
George Keishing27bf6932017-08-07 14:30:40 -050020*** Keywords ***
21
22Get Software Objects
23 [Documentation] Get the host software objects and return as a list.
24 [Arguments] ${version_type}=${VERSION_PURPOSE_HOST}
25
26 # Description of argument(s):
27 # version_type Either BMC or host version purpose.
28 # By default host version purpose string.
29 # (e.g. "xyz.openbmc_project.Software.Version.VersionPurpose.BMC"
30 # "xyz.openbmc_project.Software.Version.VersionPurpose.Host").
31
32 # Example:
33 # "data": [
34 # "/xyz/openbmc_project/software/f3b29aa8",
35 # "/xyz/openbmc_project/software/e49bc78e",
36 # ],
37 # Iterate the list and return the host object name path list.
38
39 ${host_list}= Create List
40 ${sw_list}= Read Properties ${SOFTWARE_VERSION_URI}
41
Sushil Singh8d8ce962020-06-05 09:43:33 -050042 FOR ${index} IN @{sw_list}
43 ${attr_purpose}= Read Software Attribute ${index} Purpose
44 Continue For Loop If '${attr_purpose}' != '${version_type}'
45 Append To List ${host_list} ${index}
46 END
George Keishing27bf6932017-08-07 14:30:40 -050047
George Keishingd62db0f2017-09-13 08:50:33 -050048 [Return] ${host_list}
49
50
51Read Software Attribute
52 [Documentation] Return software attribute data.
53 [Arguments] ${software_object} ${attribute_name}
54
55 # Description of argument(s):
56 # software_object Software object path.
57 # (e.g. "/xyz/openbmc_project/software/f3b29aa8").
58 # attribute_name Software object attribute name.
59
60 ${resp}= OpenBMC Get Request ${software_object}/attr/${attribute_name}
61 ... quiet=${1}
62 Return From Keyword If ${resp.status_code} != ${HTTP_OK}
George Keishingfbd67002022-08-01 11:24:03 -050063 [Return] ${resp.json()["data"]}
George Keishing27bf6932017-08-07 14:30:40 -050064
65
George Keishingfe4ebd22017-09-12 06:05:22 -050066Get Software Objects Id
67 [Documentation] Get the software objects id and return as a list.
68 [Arguments] ${version_type}=${VERSION_PURPOSE_HOST}
69
70 # Description of argument(s):
71 # version_type Either BMC or host version purpose.
72 # By default host version purpose string.
73 # (e.g. "xyz.openbmc_project.Software.Version.VersionPurpose.BMC"
74 # "xyz.openbmc_project.Software.Version.VersionPurpose.Host").
75
76 ${sw_id_list}= Create List
77 ${sw_list}= Get Software Objects ${version_type}
78
Marissa Garza20ccfc72020-06-19 12:51:10 -050079 FOR ${index} IN @{sw_list}
80 Append To List ${sw_id_list} ${index.rsplit('/', 1)[1]}
81 END
George Keishingfe4ebd22017-09-12 06:05:22 -050082 [Return] ${sw_id_list}
83
84
George Keishing27bf6932017-08-07 14:30:40 -050085Get Host Software Property
86 [Documentation] Return a dictionary of host software properties.
87 [Arguments] ${host_object}
88
89 # Description of argument(s):
90 # host_object Host software object path.
91 # (e.g. "/xyz/openbmc_project/software/f3b29aa8").
92
93 ${sw_attributes}= Read Properties ${host_object}
94 [return] ${sw_attributes}
95
Sweta Potthuricd966342017-09-06 03:41:32 -050096Get Host Software Objects Details
97 [Documentation] Return software object details as a list of dictionaries.
98 [Arguments] ${quiet}=${QUIET}
99
100 ${software}= Create List
101
102 ${pnor_details}= Get Software Objects ${VERSION_PURPOSE_HOST}
Marissa Garza20ccfc72020-06-19 12:51:10 -0500103 FOR ${pnor} IN @{pnor_details}
104 ${resp}= OpenBMC Get Request ${pnor} quiet=${1}
George Keishingfbd67002022-08-01 11:24:03 -0500105 Append To List ${software} ${resp.json()["data"]}
Marissa Garza20ccfc72020-06-19 12:51:10 -0500106 END
Sweta Potthuricd966342017-09-06 03:41:32 -0500107 [Return] ${software}
George Keishing27bf6932017-08-07 14:30:40 -0500108
109Set Host Software Property
110 [Documentation] Set the host software properties of a given object.
111 [Arguments] ${host_object} ${sw_attribute} ${data}
112
113 # Description of argument(s):
114 # host_object Host software object name.
115 # sw_attribute Host software attribute name.
116 # (e.g. "Activation", "Priority", "RequestedActivation" etc).
117 # data Value to be written.
118
119 ${args}= Create Dictionary data=${data}
120 Write Attribute ${host_object} ${sw_attribute} data=${args}
George Keishing9ebc0522018-02-06 12:58:22 -0600121 # Sync time for software updater manager to update.
George Keishing9ebc0522018-02-06 12:58:22 -0600122 Sleep 10s
George Keishing27bf6932017-08-07 14:30:40 -0500123
Charles Paul Hofercef61992017-08-18 10:14:18 -0500124
125Set Property To Invalid Value And Verify No Change
126 [Documentation] Attempt to set a property and check that the value didn't
127 ... change.
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500128 [Arguments] ${property} ${version_type}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500129
130 # Description of argument(s):
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500131 # property The property to attempt to set.
132 # version_type Either BMC or host version purpose.
133 # By default host version purpose string.
134 # (e.g. "xyz.openbmc_project.Software.Version.VersionPurpose.BMC"
135 # "xyz.openbmc_project.Software.Version.VersionPurpose.Host").
Charles Paul Hofercef61992017-08-18 10:14:18 -0500136
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500137 ${software_objects}= Get Software Objects version_type=${version_type}
138 ${prev_properties}= Get Host Software Property @{software_objects}[0]
Charles Paul Hofercef61992017-08-18 10:14:18 -0500139 Run Keyword And Expect Error 500 != 200
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500140 ... Set Host Software Property @{software_objects}[0] ${property} foo
141 ${cur_properties}= Get Host Software Property @{software_objects}[0]
142 Should Be Equal As Strings &{prev_properties}[${property}]
143 ... &{cur_properties}[${property}]
Charles Paul Hofercef61992017-08-18 10:14:18 -0500144
145
Charles Paul Hofer42f17462017-09-12 14:09:32 -0500146Set Priority To Invalid Value And Expect Error
147 [Documentation] Set the priority of an image to an invalid value and
148 ... check that an error was returned.
149 [Arguments] ${version_type} ${priority}
150
151 # Description of argument(s):
152 # version_type Either BMC or host version purpose.
153 # (e.g. "xyz.openbmc_project.Software.Version.VersionPurpose.BMC"
154 # "xyz.openbmc_project.Software.Version.VersionPurpose.Host").
155 # priority The priority value to set. Should be an integer outside of
156 # the range of 0 through 255.
157
158 ${images}= Get Software Objects version_type=${version_type}
159 ${num_images}= Get Length ${images}
160 Should Be True 0 < ${num_images}
161
162 Run Keyword And Expect Error 403 != 200
163 ... Set Host Software Property @{images}[0] Priority ${priority}
164
165
Sushil Singh5ea86d02019-07-11 02:05:16 -0500166Redfish Upload Image
167 [Documentation] Upload an image to the BMC via redfish.
168 [Arguments] ${uri} ${image_file_path}
169
170 # Description of argument(s):
171 # uri URI for uploading image via redfish.
172 # image_file_path The path to the image tarball.
173
174 ${image_data}= OperatingSystem.Get Binary File ${image_file_path}
175
George Keishingf0d5ae72022-02-24 10:36:15 -0600176 # Force time out for image file upload if failed to complete on time.
177 Wait Until Keyword Succeeds 1 times ${IMAGE_UPLOAD_WAIT_TIMEOUT} min
George Keishing36db9962021-05-13 02:10:45 -0500178 ... Upload Image To BMC ${uri} timeout=${240} data=${image_data}
Sushil Singh5ea86d02019-07-11 02:05:16 -0500179
180
181Redfish Verify BMC Version
182 [Documentation] Verify that the version on the BMC is the same as the
183 ... version in the given image via Redfish.
184 [Arguments] ${image_file_path}
185
186 # Description of argument(s):
187 # image_file_path Path to the image tarball.
188
189 # Extract the version from the image tarball on our local system.
190 ${tar_version}= Get Version Tar ${image_file_path}
191 ${bmc_version}= Redfish Get BMC Version
192
Michael Walshe7edb222019-08-19 17:39:38 -0500193 Valid Value bmc_version valid_values=['${tar_version}']
Sushil Singh5ea86d02019-07-11 02:05:16 -0500194
195
196Redfish Verify Host Version
197 [Documentation] Verify that the version of the PNOR image that is on the
198 ... BMC is the same as the one in the given image via Redfish.
199 [Arguments] ${image_file_path}
200
201 # Description of argument(s):
202 # image_file_path Path to the image tarball.
203
204 # Extract the version from the image tarball on our local system.
205 ${tar_version}= Get Version Tar ${image_file_path}
206 ${host_version}= Redfish Get Host Version
207
Michael Walshe7edb222019-08-19 17:39:38 -0500208 Valid Value host_version valid_values=['${tar_version}']
Sushil Singh5ea86d02019-07-11 02:05:16 -0500209
210
Charles Paul Hofercef61992017-08-18 10:14:18 -0500211Upload And Activate Image
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500212 [Documentation] Upload an image to the BMC and activate it with REST.
Charles Paul Hoferb7842a52017-09-22 10:11:33 -0500213 [Arguments] ${image_file_path} ${wait}=${1} ${skip_if_active}=false
Charles Paul Hofercef61992017-08-18 10:14:18 -0500214
215 # Description of argument(s):
George Keishing71c24ed2017-09-25 13:11:10 -0500216 # image_file_path The path to the image tarball to upload and activate.
217 # wait Indicates that this keyword should wait for host or
218 # BMC activation is completed.
Charles Paul Hoferb7842a52017-09-22 10:11:33 -0500219 # skip_if_active If set to true, will skip the code update if this
220 # image is already on the BMC.
Charles Paul Hofercef61992017-08-18 10:14:18 -0500221
222 OperatingSystem.File Should Exist ${image_file_path}
223 ${image_version}= Get Version Tar ${image_file_path}
224
225 ${image_data}= OperatingSystem.Get Binary File ${image_file_path}
Leonel Gonzalez6ac206e2017-10-12 16:04:23 -0500226
George Keishing65a7f162019-10-30 01:33:28 -0500227 Wait Until Keyword Succeeds 3 times 120 sec
228 ... Upload Image To BMC /upload/image timeout=${90} data=${image_data}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500229 ${ret} ${version_id}= Verify Image Upload ${image_version}
230 Should Be True ${ret}
231
Charles Paul Hoferb7842a52017-09-22 10:11:33 -0500232 # Verify the image is 'READY' to be activated or if it's already active,
233 # set priority to 0 and reboot the BMC.
Charles Paul Hofercef61992017-08-18 10:14:18 -0500234 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Sushil Singhec4ab932020-06-08 01:32:11 -0500235 ${activation}= Set Variable ${software_state}[Activation]
George Keishingd5949852018-01-31 12:56:55 -0600236
Charles Paul Hoferb7842a52017-09-22 10:11:33 -0500237 Run Keyword If
238 ... '${skip_if_active}' == 'true' and '${activation}' == '${ACTIVE}'
Charles Paul Hoferb420c572017-10-31 09:24:12 -0500239 ... Run Keywords
240 ... Set Host Software Property ${SOFTWARE_VERSION_URI}${version_id}
241 ... Priority ${0}
242 ... AND
243 ... Return From Keyword
244
Sushil Singh8d8ce962020-06-05 09:43:33 -0500245 Should Be Equal As Strings ${software_state}[Activation] ${READY}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500246
247 # Request the image to be activated.
248 ${args}= Create Dictionary data=${REQUESTED_ACTIVE}
249 Write Attribute ${SOFTWARE_VERSION_URI}${version_id}
250 ... RequestedActivation data=${args}
251 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Sushil Singh8d8ce962020-06-05 09:43:33 -0500252 Should Be Equal As Strings ${software_state}[RequestedActivation]
Charles Paul Hofercef61992017-08-18 10:14:18 -0500253 ... ${REQUESTED_ACTIVE}
254
George Keishing71c24ed2017-09-25 13:11:10 -0500255 # Does caller want to wait for activation to complete?
Charles Paul Hofere0e17802017-09-21 09:19:33 -0500256 Return From Keyword If '${wait}' == '${0}' ${version_id}
George Keishing71c24ed2017-09-25 13:11:10 -0500257
Charles Paul Hofercef61992017-08-18 10:14:18 -0500258 # Verify code update was successful and Activation state is Active.
259 Wait For Activation State Change ${version_id} ${ACTIVATING}
260 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Sushil Singh8d8ce962020-06-05 09:43:33 -0500261 Should Be Equal As Strings ${software_state}[Activation] ${ACTIVE}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500262
George Keishingd5949852018-01-31 12:56:55 -0600263 # Uploaded and activated image should have priority set to 0. Due to timing
Gunnar Mills948e2e22018-03-23 12:54:27 -0500264 # contention, it may take up to 10 seconds to complete updating priority.
George Keishingd5949852018-01-31 12:56:55 -0600265 Wait Until Keyword Succeeds 10 sec 5 sec
266 ... Check Software Object Attribute ${version_id} Priority ${0}
267
Charles Paul Hofere0e17802017-09-21 09:19:33 -0500268 [Return] ${version_id}
269
Charles Paul Hofercef61992017-08-18 10:14:18 -0500270
Charles Paul Hofere09408d2017-10-02 14:42:38 -0500271Attempt To Reboot BMC During Image Activation
272 [Documentation] Attempt to reboot the BMC while an image is activating and
273 ... check that the BMC ignores the reboot command and finishes
274 ... activation.
275 [Arguments] ${image_file_path}
276
277 # Description of argument(s):
278 # image_file_path Path to the image to update to.
279
280 # Attempt to reboot during activation.
281 ${version_id}= Upload And Activate Image ${image_file_path}
282 ... wait=${0}
George Keishingfd346d12017-11-20 23:23:01 -0600283 ${resp}= OpenBMC Get Request ${SOFTWARE_VERSION_URI}${version_id}
284 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Charles Paul Hofere09408d2017-10-02 14:42:38 -0500285
George Keishingfd346d12017-11-20 23:23:01 -0600286 OBMC Reboot (off)
Charles Paul Hofere09408d2017-10-02 14:42:38 -0500287
George Keishingfd346d12017-11-20 23:23:01 -0600288 ${resp}= OpenBMC Get Request ${SOFTWARE_VERSION_URI}${version_id}
289 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
Charles Paul Hofere09408d2017-10-02 14:42:38 -0500290
291
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500292Activate Image And Verify No Duplicate Priorities
293 [Documentation] Upload an image, and then check that no images have the
294 ... same priority.
295 [Arguments] ${image_file_path} ${image_purpose}
296
297 # Description of argument(s):
298 # image_file_path The path to the image to upload.
299 # image_purpose The purpose in the image's MANIFEST file.
300
George Keishing72373f82017-11-20 09:18:41 -0600301 Upload And Activate Image ${image_file_path} skip_if_active=true
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500302 Verify No Duplicate Image Priorities ${image_purpose}
303
304
Charles Paul Hofera5673162017-08-30 09:49:16 -0500305Set Same Priority For Multiple Images
306 [Documentation] Find two images, set the priorities to be the same, and
307 ... verify that the priorities are not the same.
308 [Arguments] ${version_purpose}
309
310 # Description of argument(s):
311 # version_purpose Either BMC or host version purpose.
312 # (e.g. "xyz.openbmc_project.Software.Version.VersionPurpose.BMC"
313 # "xyz.openbmc_project.Software.Version.VersionPurpose.Host").
314
315 # Make sure we have more than two images.
316 ${software_objects}= Get Software Objects version_type=${version_purpose}
317 ${num_images}= Get Length ${software_objects}
318 Should Be True 1 < ${num_images}
319 ... msg=Only found one image on the BMC with purpose ${version_purpose}.
320
321 # Set the priority of the second image to the priority of the first.
322 ${properties}= Get Host Software Property @{software_objects}[0]
323 Set Host Software Property @{software_objects}[1] Priority
324 ... &{properties}[Priority]
325 Verify No Duplicate Image Priorities ${version_purpose}
326
327 # Set the priority of the first image back to what it was before
328 Set Host Software Property @{software_objects}[0] Priority
329 ... &{properties}[Priority]
330
331
Charles Paul Hoferda24d0a2017-08-09 15:03:40 -0500332Delete Software Object
333 [Documentation] Deletes an image from the BMC.
334 [Arguments] ${software_object}
335
336 # Description of argument(s):
337 # software_object The URI to the software image to delete.
338
George Keishingfbd67002022-08-01 11:24:03 -0500339 ${args}= Set Variable {"data": []}
Adriana Kobylak2e9d9cf2019-08-12 13:48:47 -0500340 ${resp}= OpenBMC Post Request ${software_object}/action/Delete
Charles Paul Hoferda24d0a2017-08-09 15:03:40 -0500341 ... data=${args}
342 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500343
344
345Delete Image And Verify
346 [Documentation] Delete an image from the BMC and verify that it was
347 ... removed from software and the /tmp/images directory.
348 [Arguments] ${software_object} ${version_type}
349
350 # Description of argument(s):
351 # software_object The URI of the software object to delete.
352 # version_type The type of the software object, e.g.
353 # xyz.openbmc_project.Software.Version.VersionPurpose.Host
354 # or xyz.openbmc_project.Software.Version.VersionPurpose.BMC.
355
Gunnar Mills917ba1a2018-04-08 16:42:12 -0500356 Log To Console Deleting ${software_object}
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500357
Charles Paul Hofercef61992017-08-18 10:14:18 -0500358 # Delete the image.
359 Delete Software Object ${software_object}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500360
361 # Verify that it's gone from software.
362 ${software_objects}= Get Software Objects version_type=${version_type}
363 Should Not Contain ${software_objects} ${software_object}
364
365 # Check that there is no file in the /tmp/images directory.
366 ${image_id}= Fetch From Right ${software_object} /
367 BMC Execute Command
368 ... [ ! -d "/tmp/images/${image_id}" ]
George Keishing00715492017-08-18 11:46:37 -0500369
370
Charles Paul Hofere8dc5252017-10-10 13:50:18 -0500371Delete All Non Running BMC Images
372 [Documentation] Delete all BMC images that are not running on the BMC.
373
George Keishingfbd67002022-08-01 11:24:03 -0500374 ${args}= Set Variable {"data": []}
375 Call Method ${SOFTWARE_VERSION_URI} DeleteAll data=${args}
Charles Paul Hofere8dc5252017-10-10 13:50:18 -0500376
377
George Keishing00715492017-08-18 11:46:37 -0500378Check 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 Hofere43fb2f2017-09-26 15:36:18 -0500384
385
386Verify 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
400Verify 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 Hofere0e17802017-09-21 09:19:33 -0500411
George Keishing81ae45b2017-09-28 14:05:04 -0500412
413Get 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 Garza20ccfc72020-06-19 12:51:10 -0500423 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 Keishing81ae45b2017-09-28 14:05:04 -0500428 ${min_value}= Min List Value ${priority_value_list}
429
430 [Return] ${min_value}
George Keishingfb762032017-11-14 11:18:21 -0600431
432
433Enable 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 Millsaf472ce2018-02-27 16:08:27 -0600448 # "functional",
George Keishingfb762032017-11-14 11:18:21 -0600449 # "/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 Keishingef97f3f2017-11-15 10:32:59 -0600459
460Disable 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 Keishingc9031582017-12-18 11:58:11 -0600465 OBMC Reboot (off) stack_mode=normal
George Keishingef97f3f2017-11-15 10:32:59 -0600466 BMC Execute Command [ -d "/usr/local/share" ]
467
George Keishing13b8a212017-11-17 00:35:13 -0600468
469Field 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 Potthuri8c7ada42018-01-15 05:05:59 -0600474
475List Installed Images
476 [Documentation] List all the installed images.
477 [Arguments] ${image_type}
478
Gunnar Mills948e2e22018-03-23 12:54:27 -0500479 # Description of argument(s):
Sweta Potthuri8c7ada42018-01-15 05:05:59 -0600480 # 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
490Get List of Images
491 [Documentation] Get List of Images
492 [Arguments] ${installed_images}
493
Sushil Singh8d8ce962020-06-05 09:43:33 -0500494 FOR ${uri} IN @{installed_images}
495 ${resp}= OpenBMC Get Request ${uri}
George Keishingfbd67002022-08-01 11:24:03 -0500496 Log ${resp.json()["data"]}
Sushil Singh8d8ce962020-06-05 09:43:33 -0500497 END
George Keishingd5949852018-01-31 12:56:55 -0600498
499
500Check Software Object Attribute
501 [Documentation] Get the software property of a given object and verify.
502 [Arguments] ${image_object} ${sw_attribute} ${value}
503
504 # Description of argument(s):
505 # image_object Image software object name.
506 # sw_attribute Software attribute name.
507 # (e.g. "Activation", "Priority", "RequestedActivation" etc).
508 # value Software attribute value to compare.
509
510 ${data}= Read Attribute
511 ... ${SOFTWARE_VERSION_URI}${image_object} ${sw_attribute}
512
513 Should Be True ${data} == ${value}
514 ... msg=Given attribute value ${data} mismatch ${value}.
George Keishing0b837432018-03-20 13:46:10 -0500515
516
517Image Should Be Signed
518 [Documentation] Fail if the image is not signed.
519
520 Directory Should Exist ${ACTIVATION_DIR_PATH}
521 ... msg=${ACTIVATION_DIR_PATH} does not exist. Therefore, the image is not signed.
George Keishingcba6d422019-07-09 15:01:59 -0500522
523
524Get Latest Image ID
525 [Documentation] Return the ID of the most recently extracted image.
526 # Note: This keyword will fail if there is no such file.
527
528 # Example: # ls /tmp/images/
529 # 1b714fb7
530 ${image_id}= Get Latest File /tmp/images/
George Keishingcba6d422019-07-09 15:01:59 -0500531
George Keishinge25113a2021-06-18 13:50:43 -0500532 Return From Keyword If '${image_id}' != '${EMPTY}' ${image_id}
George Keishingcba6d422019-07-09 15:01:59 -0500533
George Keishinge25113a2021-06-18 13:50:43 -0500534 ${image_id}= Get Image Id Updating
George Keishingcba6d422019-07-09 15:01:59 -0500535 [Return] ${image_id}
536
537
538Check Image Update Progress State
539 [Documentation] Check that the image update progress state matches the specified state.
540 [Arguments] ${match_state} ${image_id}
541
542 # Description of argument(s):
543 # match_state The expected state. This may be one or more comma-separated values
544 # (e.g. "Disabled", "Disabled, Updating"). If the actual state matches
545 # any of the states named in this argument, this keyword passes.
546 # image_id The image ID (e.g. "1b714fb7").
547
548 ${state}= Get Image Update Progress State image_id=${image_id}
Michael Walshe7edb222019-08-19 17:39:38 -0500549 Valid Value state valid_values=[${match_state}]
George Keishingcba6d422019-07-09 15:01:59 -0500550
551
Sushil Singhffa2d4b2021-10-25 03:57:31 -0500552Get All Task
553 [Documentation] Get all the active tasks.
554 [Arguments] ${target_uri} ${match_status} ${match_state}
555
556 # Description of argument(s):
557 # target_uri Target URI.
558 # match_status The expected status. The value is (e.g. OK). If the actual state matches
559 # any of the states named in this argument, this keyword passes.
560 # match_state The expected state. This may be one or more comma-separated values
561 # (e.g. Running, Completed). If the actual state matches
562 # any of the states named in this argument, this keyword passes.
563
564 ${task_list}= Redfish.Get Members List /redfish/v1/TaskService/Tasks
565 ${num_records}= Get Length ${task_list}
566 Return From Keyword If ${num_records} == ${0} ${EMPTY
567
568 ${task_dict}= Get Task Objects ${task_list}
569
570 ${task_inventory}= Check Task Attribute ${target_uri} ${match_status} ${match_state} ${task_dict}
571
572 ${num_records}= Get Length ${task_inventory}
573 Return From Keyword If ${num_records} == ${0} ${EMPTY}
574
575 [Return] ${task_inventory}
576
577
578Get Task Objects
579 [Documentation] Check all the task to filter update service target URI and
580 ... return the task attributes as dictionary.
581 [Arguments] ${task_list}
582
583 # Description of argument(s):
584 # task_list List of all active task.
585
586 &{task_inv_dict}= Create Dictionary
587
588 FOR ${task_id} IN @{task_list}
589 &{tmp_dict}= Create Dictionary
590 ${task_payload}= Redfish.Get Attribute ${task_id} Payload
591 Set To Dictionary ${tmp_dict} TargetUri ${task_payload['TargetUri']}
592
593 ${task_state}= Redfish.Get Attribute ${task_id} TaskState
594 Set To Dictionary ${tmp_dict} TaskState ${task_state}
595
596 ${task_status}= Redfish.Get Attribute ${task_id} TaskStatus
597 Set To Dictionary ${tmp_dict} TaskStatus ${task_status}
598 Set To Dictionary ${task_inv_dict} ${task_id.split("/")[-1]} ${tmp_dict}
599 END
600
601 [Return] ${task_inv_dict}
602
603
604Check Task Attribute
605 [Documentation] Get the active task progress state.
606 [Arguments] ${target_uri} ${match_status} ${match_state} ${task_dict}
607
608 # Description of argument(s):
609 # target_uri Active task which has update service target URI.
610 # match_status The expected status. The value is (e.g. OK). If the actual state matches
611 # any of the states named in this argument, this keyword passes.
612 # match_state The expected state. This may be one or more comma-separated values
613 # (e.g. Running, Completed). If the actual state matches
614 # any of the states named in this argument, this keyword passes.
615 # task_dict Task inventory.
616
617 Return From Keyword If ${target_uri} == '' or ${target_uri} == None ${task_dict}
618 Return From Keyword If ${match_state} == '' or ${match_state} == None ${task_dict}
619
620 FOR ${task_ins} IN @{task_dict.items()}
621 &{tmp_dict}= Create Dictionary
622 Set To Dictionary ${tmp_dict} ${task_ins[0]} ${task_ins[1]}
623 Return From Keyword If
624 ... ${target_uri} == '${task_ins[1]['TargetUri']}' and ${match_state} == '${task_ins[1]['TaskState']}'
625 ... ${tmp_dict}
626 END
627
628 [Return] ${EMPTY}
629
630
631Check Task Progress State
632 [Documentation] Check that the task update progress state matches the specified state.
633 [Arguments] ${task_inv_dict} ${match_status} ${match_state}
634
635 # Description of argument(s):
636 # task_inv_dict Task inventory dictionary.
637 # match_status The expected state. The value is (e.g. OK). If the actual state matches
638 # any of the states named in this argument, this keyword passes.
639 # match_state The expected state. This may be one or more comma-separated values
640 # (e.g. Running, Completed). If the actual state matches
641 # any of the states named in this argument, this keyword passes.
642
643 FOR ${task_ins} IN @{task_inv_dict.items()}
644 ${task_state}= Redfish.Get Attribute /redfish/v1/TaskService/Tasks/${task_ins}[0] TaskState
645 ${task_status}= Redfish.Get Attribute /redfish/v1/TaskService/Tasks/${task_ins}[0] TaskStatus
646 ${task_payload}= Redfish.Get Attribute /redfish/v1/TaskService/Tasks/${task_ins}[0] Payload
647
648 Rprint Vars task_state
649 Rprint Vars task_status
650 Rprint Vars task_payload['TargetUri']
651
652 Valid Value task_state valid_values=[${match_state}]
653 Valid Value task_status valid_values=[${match_status}]
654 END
655
656
Sushil Singh5fe1e022021-06-13 23:50:59 -0500657Get Image Id
658 [Documentation] Get image id.
659 [Arguments] ${match_state}
660
661 # Description of argument(s):
662 # match_state The expected state. This may be one or more comma-separated values
663 # (e.g. "Disabled", "Disabled, Updating"). If the actual state matches
664 # any of the states named in this argument, this keyword passes.
665
666 ${sw_member_list}= Redfish.Get Members List /redfish/v1/UpdateService/FirmwareInventory
667
668 FOR ${sw_member} IN @{sw_member_list}
669 ${status}= Redfish.Get Attribute ${sw_member} Status
Sushil Singh1ee3c932023-02-24 01:58:09 -0600670 Return From Keyword If '${status['State']}' == '${match_state}'
671 ... ${sw_member.split('/')[-1]}
Sushil Singh5fe1e022021-06-13 23:50:59 -0500672 END
673
674 [Return] None
675
676
George Keishingcba6d422019-07-09 15:01:59 -0500677Get Image Update Progress State
678 [Documentation] Return the current state of the image update.
679 [Arguments] ${image_id}
680
681 # Description of argument(s):
682 # image_id The image ID (e.g. "1b714fb7").
683
684 # In this example, this keyword would return the value "Enabled".
685 # "Status": {
686 # "Health": "OK",
687 # "HealthRollup": "OK",
688 # "State": "Enabled"
689 # },
690 ${status}= Redfish.Get Attribute /redfish/v1/UpdateService/FirmwareInventory/${image_id} Status
691 Rprint Vars status
692
693 [Return] ${status["State"]}
694
695
696Get Firmware Image Version
697 [Documentation] Get the version of the currently installed firmware and return it.
698 [Arguments] ${image_id}
699
700 # Description of argument(s):
701 # image_id The image ID (e.g. "1b714fb7").
702
703 # Example of a version returned by this keyword:
704 # 2.8.0-dev-19-g6d5764b33
705 ${version}= Redfish.Get Attribute /redfish/v1/UpdateService/FirmwareInventory/${image_id} Version
706 Rprint Vars version
707
708 [Return] ${version}
George Keishingcfa950c2019-07-18 12:46:46 -0500709
710
Sushil Singhca0bc3b2019-10-17 11:28:41 -0500711Get ApplyTime
712 [Documentation] Get the firmware "ApplyTime" policy.
713 [Arguments] ${policy}
714
715 # Description of argument(s):
716 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
717
718 ${system_applytime}= Redfish.Get Attribute ${REDFISH_BASE_URI}UpdateService HttpPushUriOptions
Sushil Singhf617c302020-07-23 01:01:07 -0500719
Sushil Singhca0bc3b2019-10-17 11:28:41 -0500720 [Return] ${system_applytime["HttpPushUriApplyTime"]["ApplyTime"]}
721
722
723Verify Get ApplyTime
724 [Documentation] Get and verify the firmware "ApplyTime" policy.
725 [Arguments] ${policy}
726
727 # Description of argument(s):
728 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
729
730 ${system_applytime}= Get ApplyTime ${policy}
Sushil Singhf617c302020-07-23 01:01:07 -0500731 Rprint Vars system_applytime
Sushil Singhca0bc3b2019-10-17 11:28:41 -0500732 Valid Value system_applytime ['${policy}']
733
734
George Keishingcfa950c2019-07-18 12:46:46 -0500735Set ApplyTime
736 [Documentation] Set and verify the firmware "ApplyTime" policy.
737 [Arguments] ${policy}
738
739 # Description of argument(s):
740 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
741
Sushil Singh56f590a2019-09-25 11:26:41 -0500742 Redfish.Patch ${REDFISH_BASE_URI}UpdateService
743 ... body={'HttpPushUriOptions' : {'HttpPushUriApplyTime' : {'ApplyTime' : '${policy}'}}}
Sushil Singhca0bc3b2019-10-17 11:28:41 -0500744 Verify Get ApplyTime ${policy}
Sushil Singhc51eee72019-09-01 11:13:37 -0500745
746
747Get Image Version From TFTP Server
748 [Documentation] Get and return the image version
749 ... from the TFTP server.
750 [Arguments] ${server_host} ${image_file_name}
751
752 # Description of argument(s):
753 # server_host The host name or IP address of the TFTP server.
754 # image_file_name The file name of the image.
755
756 Shell Cmd
757 ... curl -s tftp://${server_host}/${image_file_name} > tftp_image.tar
758 ${version}= Get Version Tar tftp_image.tar
759 OperatingSystem.Remove File tftp_image.tar
760
761 [Return] ${version}
762