George Keishing | 72abe82 | 2019-07-29 08:03:40 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Redfish BMC and PNOR software utilities keywords. |
| 3 | |
| 4 | Library code_update_utils.py |
| 5 | Library gen_robot_valid.py |
| 6 | Resource bmc_redfish_utils.robot |
| 7 | |
| 8 | *** Keywords *** |
| 9 | |
| 10 | Get Software Functional State |
| 11 | [Documentation] Return functional or active state of the software (i.e. True/False). |
| 12 | [Arguments] ${image_id} |
| 13 | |
| 14 | # Description of argument(s): |
| 15 | # image_id The image ID (e.g. "acc9e073"). |
| 16 | |
| 17 | ${image_info}= Redfish.Get Properties /redfish/v1/UpdateService/FirmwareInventory/${image_id} |
| 18 | |
| 19 | ${sw_functional}= Run Keyword If '${image_info["Description"]}' == 'BMC update' |
| 20 | ... Redfish.Get Attribute /redfish/v1/Managers/bmc FirmwareVersion |
| 21 | ... ELSE |
| 22 | ... Redfish.Get Attribute /redfish/v1/Systems/system BiosVersion |
| 23 | |
| 24 | ${functional}= Run Keyword And Return Status |
| 25 | ... Should Be Equal ${sw_functional} ${image_info["Version"]} |
| 26 | |
| 27 | [Return] ${functional} |
| 28 | |
| 29 | |
| 30 | Get Software Inventory State |
| 31 | [Documentation] Return dictionary of the image type, version and functional state |
| 32 | ... of the software objects active on the system. |
| 33 | |
| 34 | # User defined state for software objects. |
| 35 | # Note: "Functional" term refers to firmware which system is currently booted with. |
| 36 | # sw_inv_dict: |
| 37 | # [ace821ef]: |
| 38 | # [image_type]: Host update |
George Keishing | 3102949 | 2019-07-30 13:14:13 -0500 | [diff] [blame] | 39 | # [image_id]: ace821ef |
George Keishing | 72abe82 | 2019-07-29 08:03:40 -0500 | [diff] [blame] | 40 | # [functional]: True |
| 41 | # [version]: witherspoon-xx.xx.xx.xx |
| 42 | # [b9101858]: |
| 43 | # [image_type]: BMC update |
George Keishing | 3102949 | 2019-07-30 13:14:13 -0500 | [diff] [blame] | 44 | # [image_id]: b9101858 |
George Keishing | 72abe82 | 2019-07-29 08:03:40 -0500 | [diff] [blame] | 45 | # [functional]: True |
| 46 | # [version]: 2.8.0-dev-150-g04508dc9f |
| 47 | # [c45eafa5]: |
| 48 | # [image_type]: BMC update |
George Keishing | 3102949 | 2019-07-30 13:14:13 -0500 | [diff] [blame] | 49 | # [image_id]: c45eafa5 |
George Keishing | 72abe82 | 2019-07-29 08:03:40 -0500 | [diff] [blame] | 50 | # [functional]: False |
| 51 | # [version]: 2.8.0-dev-149-g1a8df5077 |
| 52 | |
| 53 | ${sw_member_list}= Redfish_Utils.Get Member List /redfish/v1/UpdateService/FirmwareInventory |
| 54 | &{sw_inv_dict}= Create Dictionary |
| 55 | |
| 56 | # sw_member_list: |
| 57 | # [0]: /redfish/v1/UpdateService/FirmwareInventory/98744d76 |
| 58 | # [1]: /redfish/v1/UpdateService/FirmwareInventory/9a8028ec |
| 59 | # [2]: /redfish/v1/UpdateService/FirmwareInventory/acc9e073 |
| 60 | |
| 61 | FOR ${uri_path} IN @{sw_member_list} |
| 62 | &{tmp_dict}= Create Dictionary |
| 63 | ${image_info}= Redfish.Get Properties ${uri_path} |
| 64 | Set To Dictionary ${tmp_dict} image_type ${image_info["Description"]} |
George Keishing | 3102949 | 2019-07-30 13:14:13 -0500 | [diff] [blame] | 65 | Set To Dictionary ${tmp_dict} image_id ${uri_path.split("/")[-1]} |
George Keishing | 72abe82 | 2019-07-29 08:03:40 -0500 | [diff] [blame] | 66 | ${functional}= Get Software Functional State ${uri_path.split("/")[-1]} |
| 67 | Set To Dictionary ${tmp_dict} functional ${functional} |
George Keishing | 72abe82 | 2019-07-29 08:03:40 -0500 | [diff] [blame] | 68 | Set To Dictionary ${tmp_dict} version ${image_info["Version"]} |
George Keishing | 3102949 | 2019-07-30 13:14:13 -0500 | [diff] [blame] | 69 | Set To Dictionary ${sw_inv_dict} ${uri_path.split("/")[-1]} ${tmp_dict} |
George Keishing | 72abe82 | 2019-07-29 08:03:40 -0500 | [diff] [blame] | 70 | END |
| 71 | |
| 72 | [Return] &{sw_inv_dict} |
George Keishing | 3102949 | 2019-07-30 13:14:13 -0500 | [diff] [blame] | 73 | |
| 74 | |
| 75 | Get Software Inventory State By Version |
| 76 | [Documentation] Return the software inventory record that matches the given software version. |
| 77 | [Arguments] ${software_version} |
| 78 | |
| 79 | # If no matchine record can be found, return ${EMPTY}. |
| 80 | |
| 81 | # Example of returned data: |
| 82 | # software_inventory_record: |
| 83 | # [image_type]: BMC update |
| 84 | # [image_id]: 1e662ba8 |
| 85 | # [functional]: True |
| 86 | # [version]: 2.8.0-dev-150-g04508dc9f |
| 87 | |
| 88 | # Description of argument(s): |
| 89 | # software_version A BMC or Host version (e.g "2.8.0-dev-150-g04508dc9f"). |
| 90 | |
| 91 | ${software_inventory}= Get Software Inventory State |
| 92 | # Filter out entries that don't match the criterion.. |
| 93 | ${software_inventory}= Filter Struct ${software_inventory} [('version', '${software_version}')] |
| 94 | # Convert from dictionary to list. |
| 95 | ${software_inventory}= Get Dictionary Values ${software_inventory} |
| 96 | ${num_records}= Get Length ${software_inventory} |
| 97 | |
| 98 | Return From Keyword If ${num_records} == ${0} ${EMPTY} |
| 99 | |
| 100 | # Return the first list entry. |
| 101 | [Return] ${software_inventory}[0] |