blob: 034e5c83cd717299b62a8ecf35732067a11e90da [file] [log] [blame]
George Keishing27bf6932017-08-07 14:30:40 -05001*** Settings ***
2Documentation BMC and PNOR update utilities keywords.
3
Charles Paul Hofercef61992017-08-18 10:14:18 -05004Library code_update_utils.py
5Library OperatingSystem
6Library String
George Keishing81ae45b2017-09-28 14:05:04 -05007Library utilities.py
Sushil Singh5ea86d02019-07-11 02:05:16 -05008Library gen_robot_valid.py
Charles Paul Hofercef61992017-08-18 10:14:18 -05009Variables ../data/variables.py
Charles Paul Hofere0e17802017-09-21 09:19:33 -050010Resource boot_utils.robot
Charles Paul Hofercef61992017-08-18 10:14:18 -050011Resource rest_client.robot
George Keishing00715492017-08-18 11:46:37 -050012Resource openbmc_ffdc.robot
George Keishing27bf6932017-08-07 14:30:40 -050013
14*** Keywords ***
15
16Get 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 Keishingd62db0f2017-09-13 08:50:33 -050037 \ ${attr_purpose}= Read Software Attribute ${index} Purpose
George Keishing27bf6932017-08-07 14:30:40 -050038 \ Continue For Loop If '${attr_purpose}' != '${version_type}'
39 \ Append To List ${host_list} ${index}
40
George Keishingd62db0f2017-09-13 08:50:33 -050041 [Return] ${host_list}
42
43
44Read 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 Keishing27bf6932017-08-07 14:30:40 -050058
59
George Keishingfe4ebd22017-09-12 06:05:22 -050060Get 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 Keishing27bf6932017-08-07 14:30:40 -050079Get 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 Potthuricd966342017-09-06 03:41:32 -050090Get 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 Keishing27bf6932017-08-07 14:30:40 -0500103
104Set 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 Keishing9ebc0522018-02-06 12:58:22 -0600116 # Sync time for software updater manager to update.
117 # TODO: openbmc/openbmc#2857
118 Sleep 10s
George Keishing27bf6932017-08-07 14:30:40 -0500119
Charles Paul Hofercef61992017-08-18 10:14:18 -0500120
121Set 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 Hofer9f74d3a2017-08-18 09:54:28 -0500124 [Arguments] ${property} ${version_type}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500125
126 # Description of argument(s):
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500127 # 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 Hofercef61992017-08-18 10:14:18 -0500132
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500133 ${software_objects}= Get Software Objects version_type=${version_type}
134 ${prev_properties}= Get Host Software Property @{software_objects}[0]
Charles Paul Hofercef61992017-08-18 10:14:18 -0500135 Run Keyword And Expect Error 500 != 200
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500136 ... 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 Hofercef61992017-08-18 10:14:18 -0500140
141
Charles Paul Hofer42f17462017-09-12 14:09:32 -0500142Set 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 Singh5ea86d02019-07-11 02:05:16 -0500162Redfish 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
176Redfish 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
188 Rvalid Value bmc_version valid_values=['${tar_version}']
189
190
191Redfish 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
203 Rvalid Value host_version valid_values=['${tar_version}']
204
205
Charles Paul Hofercef61992017-08-18 10:14:18 -0500206Upload And Activate Image
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500207 [Documentation] Upload an image to the BMC and activate it with REST.
Charles Paul Hoferb7842a52017-09-22 10:11:33 -0500208 [Arguments] ${image_file_path} ${wait}=${1} ${skip_if_active}=false
Charles Paul Hofercef61992017-08-18 10:14:18 -0500209
210 # Description of argument(s):
George Keishing71c24ed2017-09-25 13:11:10 -0500211 # 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 Hoferb7842a52017-09-22 10:11:33 -0500214 # skip_if_active If set to true, will skip the code update if this
215 # image is already on the BMC.
Charles Paul Hofercef61992017-08-18 10:14:18 -0500216
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 Gonzalez6ac206e2017-10-12 16:04:23 -0500221
222 Wait Until Keyword Succeeds 3 times 60 sec
George Keishing36efbc02018-12-12 10:18:23 -0600223 ... Upload Image To BMC /upload/image timeout=${30} data=${image_data}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500224 ${ret} ${version_id}= Verify Image Upload ${image_version}
225 Should Be True ${ret}
226
Charles Paul Hoferb7842a52017-09-22 10:11:33 -0500227 # 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 Hofercef61992017-08-18 10:14:18 -0500229 ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Charles Paul Hoferb7842a52017-09-22 10:11:33 -0500230 ${activation}= Set Variable &{software_state}[Activation]
George Keishingd5949852018-01-31 12:56:55 -0600231
Charles Paul Hoferb7842a52017-09-22 10:11:33 -0500232 Run Keyword If
233 ... '${skip_if_active}' == 'true' and '${activation}' == '${ACTIVE}'
Charles Paul Hoferb420c572017-10-31 09:24:12 -0500234 ... Run Keywords
235 ... Set Host Software Property ${SOFTWARE_VERSION_URI}${version_id}
236 ... Priority ${0}
237 ... AND
238 ... Return From Keyword
239
Charles Paul Hofercef61992017-08-18 10:14:18 -0500240 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 Keishing71c24ed2017-09-25 13:11:10 -0500250 # Does caller want to wait for activation to complete?
Charles Paul Hofere0e17802017-09-21 09:19:33 -0500251 Return From Keyword If '${wait}' == '${0}' ${version_id}
George Keishing71c24ed2017-09-25 13:11:10 -0500252
Charles Paul Hofercef61992017-08-18 10:14:18 -0500253 # 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 Keishingd5949852018-01-31 12:56:55 -0600258 # Uploaded and activated image should have priority set to 0. Due to timing
Gunnar Mills948e2e22018-03-23 12:54:27 -0500259 # contention, it may take up to 10 seconds to complete updating priority.
George Keishingd5949852018-01-31 12:56:55 -0600260 Wait Until Keyword Succeeds 10 sec 5 sec
261 ... Check Software Object Attribute ${version_id} Priority ${0}
262
Charles Paul Hofere0e17802017-09-21 09:19:33 -0500263 [Return] ${version_id}
264
Charles Paul Hofercef61992017-08-18 10:14:18 -0500265
Charles Paul Hofere09408d2017-10-02 14:42:38 -0500266Attempt 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 Keishingfd346d12017-11-20 23:23:01 -0600278 ${resp}= OpenBMC Get Request ${SOFTWARE_VERSION_URI}${version_id}
279 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Charles Paul Hofere09408d2017-10-02 14:42:38 -0500280
George Keishingfd346d12017-11-20 23:23:01 -0600281 OBMC Reboot (off)
Charles Paul Hofere09408d2017-10-02 14:42:38 -0500282
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_NOT_FOUND}
Charles Paul Hofere09408d2017-10-02 14:42:38 -0500285
286
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500287Activate 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 Keishing72373f82017-11-20 09:18:41 -0600296 Upload And Activate Image ${image_file_path} skip_if_active=true
Charles Paul Hoferc1fa2bc2017-08-18 16:44:03 -0500297 Verify No Duplicate Image Priorities ${image_purpose}
298
299
Charles Paul Hofera5673162017-08-30 09:49:16 -0500300Set 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 Hoferda24d0a2017-08-09 15:03:40 -0500327Delete 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 Kobylak2e9d9cf2019-08-12 13:48:47 -0500336 ${resp}= OpenBMC Post Request ${software_object}/action/Delete
Charles Paul Hoferda24d0a2017-08-09 15:03:40 -0500337 ... data=${args}
338 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500339
340
341Delete 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 Mills917ba1a2018-04-08 16:42:12 -0500352 Log To Console Deleting ${software_object}
Charles Paul Hofer9f74d3a2017-08-18 09:54:28 -0500353
Charles Paul Hofercef61992017-08-18 10:14:18 -0500354 # Delete the image.
355 Delete Software Object ${software_object}
Charles Paul Hofercef61992017-08-18 10:14:18 -0500356
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 Keishing00715492017-08-18 11:46:37 -0500365
366
Charles Paul Hofere8dc5252017-10-10 13:50:18 -0500367Delete 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 Keishing00715492017-08-18 11:46:37 -0500375Check 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 Hofere43fb2f2017-09-26 15:36:18 -0500381
382
383Verify 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
397Verify 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 Hofere0e17802017-09-21 09:19:33 -0500408
George Keishing81ae45b2017-09-28 14:05:04 -0500409
410Get 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 Keishingfb762032017-11-14 11:18:21 -0600428
429
430Enable 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 Millsaf472ce2018-02-27 16:08:27 -0600445 # "functional",
George Keishingfb762032017-11-14 11:18:21 -0600446 # "/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 Keishingef97f3f2017-11-15 10:32:59 -0600456
457Disable 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 Keishingc9031582017-12-18 11:58:11 -0600462 OBMC Reboot (off) stack_mode=normal
George Keishingef97f3f2017-11-15 10:32:59 -0600463 BMC Execute Command [ -d "/usr/local/share" ]
464
George Keishing13b8a212017-11-17 00:35:13 -0600465
466Field 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 Potthuri8c7ada42018-01-15 05:05:59 -0600471
472List Installed Images
473 [Documentation] List all the installed images.
474 [Arguments] ${image_type}
475
Gunnar Mills948e2e22018-03-23 12:54:27 -0500476 # Description of argument(s):
Sweta Potthuri8c7ada42018-01-15 05:05:59 -0600477 # 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
487Get 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 Keishing40e6d212019-06-28 09:48:58 -0500494 \ Log ${json["data"]}
George Keishingd5949852018-01-31 12:56:55 -0600495
496
497Check 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 Keishing0b837432018-03-20 13:46:10 -0500512
513
514Image 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 Keishingcba6d422019-07-09 15:01:59 -0500519
520
521Get 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/
528 Rvalid Value image_id
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
537Check 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}
548 Rvalid Value state valid_values=[${match_state}]
549
550
551Get 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
570Get 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 Keishingcfa950c2019-07-18 12:46:46 -0500583
584
585Set 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
594 Rvalid Value apply_time valid_values=["xyz.openbmc_project.Software.ApplyTime.RequestedApplyTimes.${policy}"]
595 Rprint Vars apply_time