Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Update the BMC code on a target BMC via Redifsh. |
| 3 | |
| 4 | # Test Parameters: |
| 5 | # IMAGE_FILE_PATH The path to the BMC image file. |
| 6 | # |
| 7 | # Firmware update states: |
| 8 | # Enabled Image is installed and either functional or active. |
| 9 | # Disabled Image installation failed or ready for activation. |
| 10 | # Updating Image installation currently in progress. |
| 11 | |
| 12 | Resource ../../lib/resource.robot |
| 13 | Resource ../../lib/bmc_redfish_resource.robot |
| 14 | Resource ../../lib/openbmc_ffdc.robot |
| 15 | Resource ../../lib/common_utils.robot |
| 16 | Resource ../../lib/code_update_utils.robot |
| 17 | Resource ../../lib/redfish_code_update_utils.robot |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 18 | Library ../../lib/gen_robot_valid.py |
| 19 | Library ../../lib/var_funcs.py |
Sushil Singh | 8f48c8f | 2020-01-16 04:36:25 -0600 | [diff] [blame] | 20 | Library ../../lib/gen_robot_keyword.py |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 21 | |
Sushil Singh | b2162d8 | 2019-09-27 07:22:04 -0500 | [diff] [blame] | 22 | Suite Setup Suite Setup Execution |
| 23 | Suite Teardown Redfish.Logout |
| 24 | Test Setup Printn |
| 25 | Test Teardown FFDC On Test Case Fail |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 26 | |
Sushil Singh | b2162d8 | 2019-09-27 07:22:04 -0500 | [diff] [blame] | 27 | Force Tags BMC_Code_Update |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 28 | |
| 29 | *** Test Cases *** |
| 30 | |
| 31 | Redfish BMC Code Update |
| 32 | [Documentation] Update the firmware image. |
| 33 | [Tags] Redfish_BMC_Code_Update |
| 34 | |
| 35 | ${image_version}= Get Version Tar ${IMAGE_FILE_PATH} |
| 36 | Rprint Vars image_version |
| 37 | |
| 38 | Run Keyword If not ${FORCE_UPDATE} |
| 39 | ... Activate Existing Firmware ${image_version} |
| 40 | Redfish Update Firmware |
| 41 | |
| 42 | *** Keywords *** |
| 43 | |
| 44 | Suite Setup Execution |
| 45 | [Documentation] Do the suite setup. |
| 46 | |
| 47 | Redfish.Login |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 48 | # Delete BMC dump and Error logs. |
| 49 | Delete All BMC Dump |
| 50 | Redfish Purge Event Log |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 51 | # Checking for file existence. |
| 52 | Valid File Path IMAGE_FILE_PATH |
| 53 | |
| 54 | |
| 55 | Activate Existing Firmware |
| 56 | [Documentation] Set fimware image to lower priority. |
| 57 | [Arguments] ${image_version} |
| 58 | |
| 59 | # Description of argument(s): |
| 60 | # image_version Version of image. |
| 61 | |
| 62 | ${software_inventory_record}= Get Software Inventory State By Version |
| 63 | ... ${image_version} |
| 64 | ${num_keys}= Get Length ${software_inventory_record} |
| 65 | |
| 66 | Rprint Vars software_inventory_record |
| 67 | |
| 68 | # If no software inventory record was found, there is no existing |
| 69 | # firmware for the given version and therefore no action to be taken. |
| 70 | Return From Keyword If not ${num_keys} |
| 71 | |
| 72 | # Check if the existing firmware is functional. |
| 73 | Pass Execution If ${software_inventory_record['functional']} |
| 74 | ... The existing ${image_version} firmware is already functional. |
| 75 | |
| 76 | # If existing firmware is not functional, then set the priority to least. |
| 77 | Print Timen The existing ${image_version} firmware is not yet functional. |
| 78 | Set BMC Image Priority To Least ${image_version} ${software_inventory_record} |
| 79 | |
| 80 | Pass Execution The existing ${image_version} firmware is now functional. |
| 81 | |
| 82 | |
| 83 | Get Image Priority |
| 84 | [Documentation] Get Current Image Priority. |
| 85 | [Arguments] ${image_version} |
| 86 | |
| 87 | # Description of argument(s): |
George Keishing | 1970076 | 2020-01-22 12:32:53 -0600 | [diff] [blame] | 88 | # image_version The Fimware image version (e.g. 2.8.0-dev-1107-g512028d95). |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 89 | |
| 90 | ${software_info}= Read Properties |
| 91 | ... ${SOFTWARE_VERSION_URI}/enumerate quiet=1 |
| 92 | # Get only the record associated with our image_version. |
| 93 | |
| 94 | ${software_info}= Filter Struct |
| 95 | ... ${software_info} [('Version', '${image_version}')] |
| 96 | # Convert from dict to list. |
| 97 | ${software_info}= Get Dictionary Values ${software_info} |
| 98 | |
| 99 | [Return] ${software_info[0]['Priority']} |
| 100 | |
| 101 | |
| 102 | Set BMC Image Priority To Least |
| 103 | [Documentation] Set BMC image priority to least value. |
| 104 | [Arguments] ${image_version} ${software_inventory} |
| 105 | |
| 106 | # Description of argument(s): |
George Keishing | 1970076 | 2020-01-22 12:32:53 -0600 | [diff] [blame] | 107 | # image_version The Fimware image version (e.g. 2.8.0-dev-1107-g512028d95). |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 108 | # software_inventory Software inventory details. |
| 109 | |
| 110 | ${least_priority}= Get Least Value Priority Image ${VERSION_PURPOSE_BMC} |
| 111 | ${cur_priority}= Get Image Priority ${image_version} |
| 112 | Rprint Vars least_priority cur_priority |
| 113 | |
| 114 | Return From Keyword If '${least_priority}' == ${cur_priority} |
| 115 | Set Host Software Property |
| 116 | ... ${SOFTWARE_VERSION_URI}${software_inventory['image_id']} |
| 117 | ... Priority ${least_priority} |
| 118 | |
| 119 | # Reboot BMC And Login |
| 120 | Redfish OBMC Reboot (off) |
| 121 | Redfish.Login |
| 122 | |
| 123 | |
| 124 | Redfish Update Firmware |
| 125 | [Documentation] Update the BMC firmware via redfish interface. |
| 126 | |
| 127 | ${state}= Get Pre Reboot State |
| 128 | Rprint Vars state |
| 129 | |
Sushil Singh | 090eedc | 2019-11-05 02:04:59 -0600 | [diff] [blame] | 130 | Run Keyword And Ignore Error Set ApplyTime policy=OnReset |
Sushil Singh | 6f86f17 | 2019-10-30 11:36:25 -0500 | [diff] [blame] | 131 | Redfish Upload Image And Check Progress State |
Sushil Singh | 8f48c8f | 2020-01-16 04:36:25 -0600 | [diff] [blame] | 132 | ${tar_version}= Get Version Tar ${IMAGE_FILE_PATH} |
| 133 | ${image_info}= Get Software Inventory State By Version ${tar_version} |
Sushil Singh | 4704bff | 2020-01-17 07:58:57 -0600 | [diff] [blame] | 134 | ${get_json_file}= OperatingSystem.Get File ${EXECDIR}/lib/applytime_table.json |
Sushil Singh | 8f48c8f | 2020-01-16 04:36:25 -0600 | [diff] [blame] | 135 | ${post_code_update_actions}= Evaluate json.loads('''${get_json_file}''') json |
| 136 | Run Key ${post_code_update_actions['${image_info["image_type"]}']['OnReset']} |
| 137 | Redfish.Login |
| 138 | Redfish Verify BMC Version ${IMAGE_FILE_PATH} |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 139 | |