blob: ca714568620a7957edd994752ef93f2baa6a7efb [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
17*** Keywords ***
18
19Get 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 Singh8d8ce962020-06-05 09:43:33 -050039 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 Keishing27bf6932017-08-07 14:30:40 -050044
George Keishingd62db0f2017-09-13 08:50:33 -050045 [Return] ${host_list}
46
47
48Read 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 Keishing27bf6932017-08-07 14:30:40 -050062
63
George Keishingfe4ebd22017-09-12 06:05:22 -050064Get 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
77 :FOR ${index} IN @{sw_list}
78 \ Append To List ${sw_id_list} ${index.rsplit('/', 1)[1]}
79
80 [Return] ${sw_id_list}
81
82
George Keishing27bf6932017-08-07 14:30:40 -050083Get 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 Potthuricd966342017-09-06 03:41:32 -050094Get 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}
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
106 [Return] ${software}
George Keishing27bf6932017-08-07 14:30:40 -0500107
108Set 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 Keishing9ebc0522018-02-06 12:58:22 -0600120 # Sync time for software updater manager to update.
121 # TODO: openbmc/openbmc#2857
122 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 Keishing89e12bf2020-01-13 03:41:31 -0600176 Wait Until Keyword Succeeds 2 times 120 sec
177 ... Upload Image To BMC ${uri} timeout=${90} data=${image_data}
Sushil Singh5ea86d02019-07-11 02:05:16 -0500178
179
180Redfish Verify BMC Version
181 [Documentation] Verify that the version on the BMC is the same as the
182 ... version in the given image via Redfish.
183 [Arguments] ${image_file_path}
184
185 # Description of argument(s):
186 # image_file_path Path to the image tarball.
187
188 # Extract the version from the image tarball on our local system.
189 ${tar_version}= Get Version Tar ${image_file_path}
190 ${bmc_version}= Redfish Get BMC Version
191
Michael Walshe7edb222019-08-19 17:39:38 -0500192 Valid Value bmc_version valid_values=['${tar_version}']
Sushil Singh5ea86d02019-07-11 02:05:16 -0500193
194
195Redfish Verify Host Version
196 [Documentation] Verify that the version of the PNOR image that is on the
197 ... BMC is the same as the one in the given image via Redfish.
198 [Arguments] ${image_file_path}
199
200 # Description of argument(s):
201 # image_file_path Path to the image tarball.
202
203 # Extract the version from the image tarball on our local system.
204 ${tar_version}= Get Version Tar ${image_file_path}
205 ${host_version}= Redfish Get Host Version
206
Michael Walshe7edb222019-08-19 17:39:38 -0500207 Valid Value host_version valid_values=['${tar_version}']
Sushil Singh5ea86d02019-07-11 02:05:16 -0500208
209
Charles Paul Hofercef61992017-08-18 10:14:18 -0500210Upload And Activate Image
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500211 [Documentation] Upload an image to the BMC and activate it with REST.
Charles Paul Hoferb7842a52017-09-22 10:11:33 -0500212 [Arguments] ${image_file_path} ${wait}=${1} ${skip_if_active}=false
Charles Paul Hofercef61992017-08-18 10:14:18 -0500213
214 # Description of argument(s):
George Keishing71c24ed2017-09-25 13:11:10 -0500215 # image_file_path The path to the image tarball to upload and activate.
216 # wait Indicates that this keyword should wait for host or
217 # BMC activation is completed.
Charles Paul Hoferb7842a52017-09-22 10:11:33 -0500218 # skip_if_active If set to true, will skip the code update if this
219 # image is already on the BMC.
Charles Paul Hofercef61992017-08-18 10:14:18 -0500220
221 OperatingSystem.File Should Exist ${image_file_path}
222 ${image_version}= Get Version Tar ${image_file_path}
223
224 ${image_data}= OperatingSystem.Get Binary File ${image_file_path}
Leonel Gonzalez6ac206e2017-10-12 16:04:23 -0500225
George Keishing65a7f162019-10-30 01:33:28 -0500226 Wait Until Keyword Succeeds 3 times 120 sec
227 ... Upload Image To BMC /upload/image timeout=${90} data=${image_data}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500228 ${ret} ${version_id}= Verify Image Upload ${image_version}
229 Should Be True ${ret}
230
Charles Paul Hoferb7842a52017-09-22 10:11:33 -0500231 # Verify the image is 'READY' to be activated or if it's already active,
232 # set priority to 0 and reboot the BMC.
Charles Paul Hofercef61992017-08-18 10:14:18 -0500233 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Sushil Singhec4ab932020-06-08 01:32:11 -0500234 ${activation}= Set Variable ${software_state}[Activation]
George Keishingd5949852018-01-31 12:56:55 -0600235
Charles Paul Hoferb7842a52017-09-22 10:11:33 -0500236 Run Keyword If
237 ... '${skip_if_active}' == 'true' and '${activation}' == '${ACTIVE}'
Charles Paul Hoferb420c572017-10-31 09:24:12 -0500238 ... Run Keywords
239 ... Set Host Software Property ${SOFTWARE_VERSION_URI}${version_id}
240 ... Priority ${0}
241 ... AND
242 ... Return From Keyword
243
Sushil Singh8d8ce962020-06-05 09:43:33 -0500244 Should Be Equal As Strings ${software_state}[Activation] ${READY}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500245
246 # Request the image to be activated.
247 ${args}= Create Dictionary data=${REQUESTED_ACTIVE}
248 Write Attribute ${SOFTWARE_VERSION_URI}${version_id}
249 ... RequestedActivation data=${args}
250 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Sushil Singh8d8ce962020-06-05 09:43:33 -0500251 Should Be Equal As Strings ${software_state}[RequestedActivation]
Charles Paul Hofercef61992017-08-18 10:14:18 -0500252 ... ${REQUESTED_ACTIVE}
253
George Keishing71c24ed2017-09-25 13:11:10 -0500254 # Does caller want to wait for activation to complete?
Charles Paul Hofere0e17802017-09-21 09:19:33 -0500255 Return From Keyword If '${wait}' == '${0}' ${version_id}
George Keishing71c24ed2017-09-25 13:11:10 -0500256
Charles Paul Hofercef61992017-08-18 10:14:18 -0500257 # Verify code update was successful and Activation state is Active.
258 Wait For Activation State Change ${version_id} ${ACTIVATING}
259 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Sushil Singh8d8ce962020-06-05 09:43:33 -0500260 Should Be Equal As Strings ${software_state}[Activation] ${ACTIVE}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500261
George Keishingd5949852018-01-31 12:56:55 -0600262 # Uploaded and activated image should have priority set to 0. Due to timing
Gunnar Mills948e2e22018-03-23 12:54:27 -0500263 # contention, it may take up to 10 seconds to complete updating priority.
George Keishingd5949852018-01-31 12:56:55 -0600264 Wait Until Keyword Succeeds 10 sec 5 sec
265 ... Check Software Object Attribute ${version_id} Priority ${0}
266
Charles Paul Hofere0e17802017-09-21 09:19:33 -0500267 [Return] ${version_id}
268
Charles Paul Hofercef61992017-08-18 10:14:18 -0500269
Charles Paul Hofere09408d2017-10-02 14:42:38 -0500270Attempt To Reboot BMC During Image Activation
271 [Documentation] Attempt to reboot the BMC while an image is activating and
272 ... check that the BMC ignores the reboot command and finishes
273 ... activation.
274 [Arguments] ${image_file_path}
275
276 # Description of argument(s):
277 # image_file_path Path to the image to update to.
278
279 # Attempt to reboot during activation.
280 ${version_id}= Upload And Activate Image ${image_file_path}
281 ... wait=${0}
George Keishingfd346d12017-11-20 23:23:01 -0600282 ${resp}= OpenBMC Get Request ${SOFTWARE_VERSION_URI}${version_id}
283 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Charles Paul Hofere09408d2017-10-02 14:42:38 -0500284
George Keishingfd346d12017-11-20 23:23:01 -0600285 OBMC Reboot (off)
Charles Paul Hofere09408d2017-10-02 14:42:38 -0500286
George Keishingfd346d12017-11-20 23:23:01 -0600287 ${resp}= OpenBMC Get Request ${SOFTWARE_VERSION_URI}${version_id}
288 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
Charles Paul Hofere09408d2017-10-02 14:42:38 -0500289
290
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500291Activate Image And Verify No Duplicate Priorities
292 [Documentation] Upload an image, and then check that no images have the
293 ... same priority.
294 [Arguments] ${image_file_path} ${image_purpose}
295
296 # Description of argument(s):
297 # image_file_path The path to the image to upload.
298 # image_purpose The purpose in the image's MANIFEST file.
299
George Keishing72373f82017-11-20 09:18:41 -0600300 Upload And Activate Image ${image_file_path} skip_if_active=true
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500301 Verify No Duplicate Image Priorities ${image_purpose}
302
303
Charles Paul Hofera5673162017-08-30 09:49:16 -0500304Set Same Priority For Multiple Images
305 [Documentation] Find two images, set the priorities to be the same, and
306 ... verify that the priorities are not the same.
307 [Arguments] ${version_purpose}
308
309 # Description of argument(s):
310 # version_purpose Either BMC or host version purpose.
311 # (e.g. "xyz.openbmc_project.Software.Version.VersionPurpose.BMC"
312 # "xyz.openbmc_project.Software.Version.VersionPurpose.Host").
313
314 # Make sure we have more than two images.
315 ${software_objects}= Get Software Objects version_type=${version_purpose}
316 ${num_images}= Get Length ${software_objects}
317 Should Be True 1 < ${num_images}
318 ... msg=Only found one image on the BMC with purpose ${version_purpose}.
319
320 # Set the priority of the second image to the priority of the first.
321 ${properties}= Get Host Software Property @{software_objects}[0]
322 Set Host Software Property @{software_objects}[1] Priority
323 ... &{properties}[Priority]
324 Verify No Duplicate Image Priorities ${version_purpose}
325
326 # Set the priority of the first image back to what it was before
327 Set Host Software Property @{software_objects}[0] Priority
328 ... &{properties}[Priority]
329
330
Charles Paul Hoferda24d0a2017-08-09 15:03:40 -0500331Delete Software Object
332 [Documentation] Deletes an image from the BMC.
333 [Arguments] ${software_object}
334
335 # Description of argument(s):
336 # software_object The URI to the software image to delete.
337
338 ${arglist}= Create List
339 ${args}= Create Dictionary data=${arglist}
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
374 @{datalist}= Create List
375 ${data}= Create Dictionary data=@{datalist}
376 Call Method ${SOFTWARE_VERSION_URI} DeleteAll data=${data}
377
378
George Keishing00715492017-08-18 11:46:37 -0500379Check Error And Collect FFDC
380 [Documentation] Collect FFDC if error log exists.
381
382 ${status}= Run Keyword And Return Status Error Logs Should Not Exist
383 Run Keyword If '${status}' == 'False' FFDC
384 Delete Error Logs
Charles Paul Hofere43fb2f2017-09-26 15:36:18 -0500385
386
387Verify Running BMC Image
388 [Documentation] Verify that the version on the BMC is the same as the
389 ... version in the given image.
390 [Arguments] ${image_file_path}
391
392 # Description of argument(s):
393 # image_file_path Path to the BMC image tarball.
394
395 ${tar_version}= Get Version Tar ${image_file_path}
396 ${bmc_version}= Get BMC Version
397 ${bmc_version}= Remove String ${bmc_version} "
398 Should Be Equal ${tar_version} ${bmc_version}
399
400
401Verify Running Host Image
402 [Documentation] Verify that the version of the PNOR image that is on the
403 ... BMC is the same as the one in the given image.
404 [Arguments] ${image_file_path}
405
406 # Description of argument(s):
407 # image_file_path Path to the PNOR image tarball.
408
409 ${tar_version}= Get Version Tar ${image_file_path}
410 ${pnor_version}= Get PNOR Version
411 Should Be Equal ${tar_version} ${pnor_version}
Charles Paul Hofere0e17802017-09-21 09:19:33 -0500412
George Keishing81ae45b2017-09-28 14:05:04 -0500413
414Get Least Value Priority Image
415 [Documentation] Find the least value in "Priority" attribute and return.
416 [Arguments] ${version_type}
417
418 # Description of argument(s):
419 # version_type Either BMC or host version purpose.
420
421 ${priority_value_list}= Create List
422 ${sw_list}= Get Software Objects version_type=${version_type}
423
424 :FOR ${index} IN @{sw_list}
425 \ ${priority_value}=
426 ... Read Software Attribute ${index} Priority
427 \ Append To List ${priority_value_list} ${priority_value}
428
429 ${min_value}= Min List Value ${priority_value_list}
430
431 [Return] ${min_value}
George Keishingfb762032017-11-14 11:18:21 -0600432
433
434Enable Field Mode And Verify Unmount
435 [Documentation] Enable field mode and check that /usr/local is unmounted.
436
437 # After running, /xyz/openbmc_project/software should look like this:
438 # /xyz/openbmc_project/software
439 # {
440 # "FieldModeEnabled": 1,
441 # "associations": [
442 # [
443 # "active",
444 # "software_version",
445 # "/xyz/openbmc_project/software/fcf8e182"
446 # ],
447 # [
448 # "functional",
Gunnar Millsaf472ce2018-02-27 16:08:27 -0600449 # "functional",
George Keishingfb762032017-11-14 11:18:21 -0600450 # "/xyz/openbmc_project/software/fcf8e182"
451 # ]
452 # ]
453 # }
454
455 ${args}= Create Dictionary data=${1}
456 Write Attribute ${SOFTWARE_VERSION_URI} FieldModeEnabled data=${args}
457 Sleep 5s
458 BMC Execute Command [ ! -d "/usr/local/share" ]
459
George Keishingef97f3f2017-11-15 10:32:59 -0600460
461Disable Field Mode And Verify Unmount
462 [Documentation] Disable field mode, unmask usr local mount and reboot.
463
464 BMC Execute Command /sbin/fw_setenv fieldmode
465 BMC Execute Command /bin/systemctl unmask usr-local.mount
George Keishingc9031582017-12-18 11:58:11 -0600466 OBMC Reboot (off) stack_mode=normal
George Keishingef97f3f2017-11-15 10:32:59 -0600467 BMC Execute Command [ -d "/usr/local/share" ]
468
George Keishing13b8a212017-11-17 00:35:13 -0600469
470Field Mode Should Be Enabled
471 [Documentation] Check that field mode is enabled.
472
473 ${value}= Read Attribute ${SOFTWARE_VERSION_URI} FieldModeEnabled
474 Should Be True ${value} ${1}
Sweta Potthuri8c7ada42018-01-15 05:05:59 -0600475
476List Installed Images
477 [Documentation] List all the installed images.
478 [Arguments] ${image_type}
479
Gunnar Mills948e2e22018-03-23 12:54:27 -0500480 # Description of argument(s):
Sweta Potthuri8c7ada42018-01-15 05:05:59 -0600481 # image_type Either "BMC" or "PNOR".
482
483 # List the installed images.
484 ${installed_images}= Get Software Objects
485 ... ${SOFTWARE_PURPOSE}.${image_type}
486
487 Run Keyword If ${installed_images} != []
488 ... Get List of Images ${installed_images}
489 ... ELSE Log No ${image_type} images are present.
490
491Get List of Images
492 [Documentation] Get List of Images
493 [Arguments] ${installed_images}
494
Sushil Singh8d8ce962020-06-05 09:43:33 -0500495 FOR ${uri} IN @{installed_images}
496 ${resp}= OpenBMC Get Request ${uri}
497 ${json}= To JSON ${resp.content}
498 Log ${json["data"]}
499 END
George Keishingd5949852018-01-31 12:56:55 -0600500
501
502Check Software Object Attribute
503 [Documentation] Get the software property of a given object and verify.
504 [Arguments] ${image_object} ${sw_attribute} ${value}
505
506 # Description of argument(s):
507 # image_object Image software object name.
508 # sw_attribute Software attribute name.
509 # (e.g. "Activation", "Priority", "RequestedActivation" etc).
510 # value Software attribute value to compare.
511
512 ${data}= Read Attribute
513 ... ${SOFTWARE_VERSION_URI}${image_object} ${sw_attribute}
514
515 Should Be True ${data} == ${value}
516 ... msg=Given attribute value ${data} mismatch ${value}.
George Keishing0b837432018-03-20 13:46:10 -0500517
518
519Image Should Be Signed
520 [Documentation] Fail if the image is not signed.
521
522 Directory Should Exist ${ACTIVATION_DIR_PATH}
523 ... msg=${ACTIVATION_DIR_PATH} does not exist. Therefore, the image is not signed.
George Keishingcba6d422019-07-09 15:01:59 -0500524
525
526Get Latest Image ID
527 [Documentation] Return the ID of the most recently extracted image.
528 # Note: This keyword will fail if there is no such file.
529
530 # Example: # ls /tmp/images/
531 # 1b714fb7
532 ${image_id}= Get Latest File /tmp/images/
Michael Walshe7edb222019-08-19 17:39:38 -0500533 Valid Value image_id
George Keishingcba6d422019-07-09 15:01:59 -0500534
535 # Though an image sub-directory was found, it really isn't valid unless
536 # the MANIFEST file is present.
537 BMC Execute Command ls -l /tmp/images/${image_id}/MANIFEST
538
539 [Return] ${image_id}
540
541
542Check Image Update Progress State
543 [Documentation] Check that the image update progress state matches the specified state.
544 [Arguments] ${match_state} ${image_id}
545
546 # Description of argument(s):
547 # match_state The expected state. This may be one or more comma-separated values
548 # (e.g. "Disabled", "Disabled, Updating"). If the actual state matches
549 # any of the states named in this argument, this keyword passes.
550 # image_id The image ID (e.g. "1b714fb7").
551
552 ${state}= Get Image Update Progress State image_id=${image_id}
Michael Walshe7edb222019-08-19 17:39:38 -0500553 Valid Value state valid_values=[${match_state}]
George Keishingcba6d422019-07-09 15:01:59 -0500554
555
556Get Image Update Progress State
557 [Documentation] Return the current state of the image update.
558 [Arguments] ${image_id}
559
560 # Description of argument(s):
561 # image_id The image ID (e.g. "1b714fb7").
562
563 # In this example, this keyword would return the value "Enabled".
564 # "Status": {
565 # "Health": "OK",
566 # "HealthRollup": "OK",
567 # "State": "Enabled"
568 # },
569 ${status}= Redfish.Get Attribute /redfish/v1/UpdateService/FirmwareInventory/${image_id} Status
570 Rprint Vars status
571
572 [Return] ${status["State"]}
573
574
575Get Firmware Image Version
576 [Documentation] Get the version of the currently installed firmware and return it.
577 [Arguments] ${image_id}
578
579 # Description of argument(s):
580 # image_id The image ID (e.g. "1b714fb7").
581
582 # Example of a version returned by this keyword:
583 # 2.8.0-dev-19-g6d5764b33
584 ${version}= Redfish.Get Attribute /redfish/v1/UpdateService/FirmwareInventory/${image_id} Version
585 Rprint Vars version
586
587 [Return] ${version}
George Keishingcfa950c2019-07-18 12:46:46 -0500588
589
Sushil Singhca0bc3b2019-10-17 11:28:41 -0500590Get ApplyTime
591 [Documentation] Get the firmware "ApplyTime" policy.
592 [Arguments] ${policy}
593
594 # Description of argument(s):
595 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
596
597 ${system_applytime}= Redfish.Get Attribute ${REDFISH_BASE_URI}UpdateService HttpPushUriOptions
598 [Return] ${system_applytime["HttpPushUriApplyTime"]["ApplyTime"]}
599
600
601Verify 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}
609 Valid Value system_applytime ['${policy}']
610
611
George Keishingcfa950c2019-07-18 12:46:46 -0500612Set ApplyTime
613 [Documentation] Set and verify the firmware "ApplyTime" policy.
614 [Arguments] ${policy}
615
616 # Description of argument(s):
617 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate").
618
Sushil Singh56f590a2019-09-25 11:26:41 -0500619 Redfish.Patch ${REDFISH_BASE_URI}UpdateService
620 ... body={'HttpPushUriOptions' : {'HttpPushUriApplyTime' : {'ApplyTime' : '${policy}'}}}
Sushil Singhca0bc3b2019-10-17 11:28:41 -0500621 Verify Get ApplyTime ${policy}
George Keishingcfa950c2019-07-18 12:46:46 -0500622 Rprint Vars apply_time
Sushil Singhc51eee72019-09-01 11:13:37 -0500623
624
625Get 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