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 |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 6 | Library tftp_update_utils.py |
George Keishing | 72abe82 | 2019-07-29 08:03:40 -0500 | [diff] [blame] | 7 | Resource bmc_redfish_utils.robot |
Sushil Singh | 32e2b58 | 2019-08-16 04:58:24 -0500 | [diff] [blame] | 8 | Resource boot_utils.robot |
George Keishing | 72abe82 | 2019-07-29 08:03:40 -0500 | [diff] [blame] | 9 | |
| 10 | *** Keywords *** |
| 11 | |
| 12 | Get Software Functional State |
| 13 | [Documentation] Return functional or active state of the software (i.e. True/False). |
| 14 | [Arguments] ${image_id} |
| 15 | |
| 16 | # Description of argument(s): |
| 17 | # image_id The image ID (e.g. "acc9e073"). |
| 18 | |
| 19 | ${image_info}= Redfish.Get Properties /redfish/v1/UpdateService/FirmwareInventory/${image_id} |
| 20 | |
| 21 | ${sw_functional}= Run Keyword If '${image_info["Description"]}' == 'BMC update' |
| 22 | ... Redfish.Get Attribute /redfish/v1/Managers/bmc FirmwareVersion |
| 23 | ... ELSE |
| 24 | ... Redfish.Get Attribute /redfish/v1/Systems/system BiosVersion |
| 25 | |
| 26 | ${functional}= Run Keyword And Return Status |
| 27 | ... Should Be Equal ${sw_functional} ${image_info["Version"]} |
| 28 | |
| 29 | [Return] ${functional} |
| 30 | |
| 31 | |
| 32 | Get Software Inventory State |
| 33 | [Documentation] Return dictionary of the image type, version and functional state |
| 34 | ... of the software objects active on the system. |
| 35 | |
| 36 | # User defined state for software objects. |
| 37 | # Note: "Functional" term refers to firmware which system is currently booted with. |
| 38 | # sw_inv_dict: |
| 39 | # [ace821ef]: |
| 40 | # [image_type]: Host update |
George Keishing | 3102949 | 2019-07-30 13:14:13 -0500 | [diff] [blame] | 41 | # [image_id]: ace821ef |
George Keishing | 72abe82 | 2019-07-29 08:03:40 -0500 | [diff] [blame] | 42 | # [functional]: True |
| 43 | # [version]: witherspoon-xx.xx.xx.xx |
| 44 | # [b9101858]: |
| 45 | # [image_type]: BMC update |
George Keishing | 3102949 | 2019-07-30 13:14:13 -0500 | [diff] [blame] | 46 | # [image_id]: b9101858 |
George Keishing | 72abe82 | 2019-07-29 08:03:40 -0500 | [diff] [blame] | 47 | # [functional]: True |
| 48 | # [version]: 2.8.0-dev-150-g04508dc9f |
| 49 | # [c45eafa5]: |
| 50 | # [image_type]: BMC update |
George Keishing | 3102949 | 2019-07-30 13:14:13 -0500 | [diff] [blame] | 51 | # [image_id]: c45eafa5 |
George Keishing | 72abe82 | 2019-07-29 08:03:40 -0500 | [diff] [blame] | 52 | # [functional]: False |
| 53 | # [version]: 2.8.0-dev-149-g1a8df5077 |
| 54 | |
| 55 | ${sw_member_list}= Redfish_Utils.Get Member List /redfish/v1/UpdateService/FirmwareInventory |
| 56 | &{sw_inv_dict}= Create Dictionary |
| 57 | |
| 58 | # sw_member_list: |
| 59 | # [0]: /redfish/v1/UpdateService/FirmwareInventory/98744d76 |
| 60 | # [1]: /redfish/v1/UpdateService/FirmwareInventory/9a8028ec |
| 61 | # [2]: /redfish/v1/UpdateService/FirmwareInventory/acc9e073 |
| 62 | |
| 63 | FOR ${uri_path} IN @{sw_member_list} |
| 64 | &{tmp_dict}= Create Dictionary |
| 65 | ${image_info}= Redfish.Get Properties ${uri_path} |
| 66 | Set To Dictionary ${tmp_dict} image_type ${image_info["Description"]} |
George Keishing | 3102949 | 2019-07-30 13:14:13 -0500 | [diff] [blame] | 67 | Set To Dictionary ${tmp_dict} image_id ${uri_path.split("/")[-1]} |
George Keishing | 72abe82 | 2019-07-29 08:03:40 -0500 | [diff] [blame] | 68 | ${functional}= Get Software Functional State ${uri_path.split("/")[-1]} |
| 69 | Set To Dictionary ${tmp_dict} functional ${functional} |
George Keishing | 72abe82 | 2019-07-29 08:03:40 -0500 | [diff] [blame] | 70 | Set To Dictionary ${tmp_dict} version ${image_info["Version"]} |
George Keishing | 3102949 | 2019-07-30 13:14:13 -0500 | [diff] [blame] | 71 | Set To Dictionary ${sw_inv_dict} ${uri_path.split("/")[-1]} ${tmp_dict} |
George Keishing | 72abe82 | 2019-07-29 08:03:40 -0500 | [diff] [blame] | 72 | END |
| 73 | |
| 74 | [Return] &{sw_inv_dict} |
George Keishing | 3102949 | 2019-07-30 13:14:13 -0500 | [diff] [blame] | 75 | |
| 76 | |
| 77 | Get Software Inventory State By Version |
| 78 | [Documentation] Return the software inventory record that matches the given software version. |
| 79 | [Arguments] ${software_version} |
| 80 | |
| 81 | # If no matchine record can be found, return ${EMPTY}. |
| 82 | |
| 83 | # Example of returned data: |
| 84 | # software_inventory_record: |
| 85 | # [image_type]: BMC update |
| 86 | # [image_id]: 1e662ba8 |
| 87 | # [functional]: True |
| 88 | # [version]: 2.8.0-dev-150-g04508dc9f |
| 89 | |
| 90 | # Description of argument(s): |
| 91 | # software_version A BMC or Host version (e.g "2.8.0-dev-150-g04508dc9f"). |
| 92 | |
| 93 | ${software_inventory}= Get Software Inventory State |
| 94 | # Filter out entries that don't match the criterion.. |
| 95 | ${software_inventory}= Filter Struct ${software_inventory} [('version', '${software_version}')] |
| 96 | # Convert from dictionary to list. |
| 97 | ${software_inventory}= Get Dictionary Values ${software_inventory} |
| 98 | ${num_records}= Get Length ${software_inventory} |
| 99 | |
| 100 | Return From Keyword If ${num_records} == ${0} ${EMPTY} |
| 101 | |
| 102 | # Return the first list entry. |
| 103 | [Return] ${software_inventory}[0] |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 104 | |
| 105 | |
| 106 | Redfish Upload Image And Check Progress State |
| 107 | [Documentation] Code update with ApplyTime. |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 108 | |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 109 | Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${IMAGE_FILE_PATH} |
| 110 | |
| 111 | ${image_id}= Get Latest Image ID |
| 112 | Rprint Vars image_id |
| 113 | |
| 114 | Check Image Update Progress State |
| 115 | ... match_state='Disabled', 'Updating' image_id=${image_id} |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 116 | # Wait a few seconds to check if the update progress started. |
| 117 | Sleep 5s |
| 118 | Check Image Update Progress State |
| 119 | ... match_state='Updating' image_id=${image_id} |
| 120 | |
| 121 | Wait Until Keyword Succeeds 8 min 20 sec |
| 122 | ... Check Image Update Progress State |
| 123 | ... match_state='Enabled' image_id=${image_id} |
| 124 | |
| 125 | |
| 126 | Reboot BMC And Verify BMC Image |
| 127 | [Documentation] Reboot or wait for BMC standby post reboot and |
| 128 | ... verify installed image is functional. |
| 129 | [Arguments] ${apply_time} ${start_boot_seconds} |
| 130 | |
| 131 | # Description of argument(s): |
Sushil Singh | 1620cfb | 2019-10-10 06:07:53 -0500 | [diff] [blame] | 132 | # apply_time ApplyTime allowed values |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 133 | # (e.g. "OnReset", "Immediate"). |
| 134 | # start_boot_seconds See 'Wait For Reboot' for details. |
| 135 | |
| 136 | Run Keyword if 'OnReset' == '${apply_time}' |
| 137 | ... Run Keyword |
| 138 | ... Redfish OBMC Reboot (off) |
| 139 | ... ELSE |
| 140 | ... Run Keyword |
| 141 | ... Wait For Reboot start_boot_seconds=${start_boot_seconds} |
| 142 | Redfish.Login |
| 143 | Redfish Verify BMC Version ${IMAGE_FILE_PATH} |
| 144 | |
Sushil Singh | 32e2b58 | 2019-08-16 04:58:24 -0500 | [diff] [blame] | 145 | |
| 146 | Poweron Host And Verify Host Image |
| 147 | [Documentation] Power on Host and verify installed image is functional. |
Sushil Singh | 1620cfb | 2019-10-10 06:07:53 -0500 | [diff] [blame] | 148 | [Arguments] ${apply_time} |
Sushil Singh | 32e2b58 | 2019-08-16 04:58:24 -0500 | [diff] [blame] | 149 | |
Sushil Singh | 1620cfb | 2019-10-10 06:07:53 -0500 | [diff] [blame] | 150 | # Description of argument(s): |
| 151 | # apply_time ApplyTime allowed values |
| 152 | # (e.g. "OnReset", "Immediate"). |
| 153 | |
| 154 | Run Keyword if 'OnReset' == '${apply_time}' |
| 155 | ... Redfish Host Reboot |
| 156 | ... ELSE |
| 157 | ... Wait State os_running_match_state 10 mins |
Sushil Singh | 32e2b58 | 2019-08-16 04:58:24 -0500 | [diff] [blame] | 158 | Redfish.Login |
| 159 | Redfish Verify Host Version ${IMAGE_FILE_PATH} |
| 160 | |
| 161 | |
| 162 | Get Host Power State |
| 163 | [Documentation] Get host power state. |
| 164 | [Arguments] ${quiet}=0 |
| 165 | |
| 166 | # Description of arguments: |
| 167 | # quiet Indicates whether results should be printed. |
| 168 | |
| 169 | ${state}= Redfish.Get Attribute |
| 170 | ... ${REDFISH_BASE_URI}Systems/system PowerState |
| 171 | Rqprint Vars state |
| 172 | |
| 173 | [Return] ${state} |
| 174 | |
| 175 | |
| 176 | Check Host Power State |
| 177 | [Documentation] Check that the machine's host state matches |
| 178 | ... the caller's required host state. |
| 179 | [Arguments] ${match_state} |
| 180 | |
| 181 | # Description of argument(s): |
| 182 | # match_state The expected state. This may be one or more |
| 183 | # comma-separated values (e.g. "On", "Off"). |
| 184 | # If the actual state matches any of the |
| 185 | # states named in this argument, |
| 186 | # this keyword passes. |
| 187 | |
| 188 | ${state}= Get Host Power State |
| 189 | Rvalid Value state valid_values=[${match_state}] |
| 190 | |