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 |
| 20 | |
Sushil Singh | b2162d8 | 2019-09-27 07:22:04 -0500 | [diff] [blame] | 21 | Suite Setup Suite Setup Execution |
| 22 | Suite Teardown Redfish.Logout |
| 23 | Test Setup Printn |
| 24 | Test Teardown FFDC On Test Case Fail |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 25 | |
Sushil Singh | b2162d8 | 2019-09-27 07:22:04 -0500 | [diff] [blame] | 26 | Force Tags BMC_Code_Update |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 27 | |
| 28 | *** Test Cases *** |
| 29 | |
| 30 | Redfish BMC Code Update |
| 31 | [Documentation] Update the firmware image. |
| 32 | [Tags] Redfish_BMC_Code_Update |
| 33 | |
| 34 | ${image_version}= Get Version Tar ${IMAGE_FILE_PATH} |
| 35 | Rprint Vars image_version |
| 36 | |
| 37 | Run Keyword If not ${FORCE_UPDATE} |
| 38 | ... Activate Existing Firmware ${image_version} |
| 39 | Redfish Update Firmware |
| 40 | |
| 41 | *** Keywords *** |
| 42 | |
| 43 | Suite Setup Execution |
| 44 | [Documentation] Do the suite setup. |
| 45 | |
| 46 | Redfish.Login |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 47 | # Delete BMC dump and Error logs. |
| 48 | Delete All BMC Dump |
| 49 | Redfish Purge Event Log |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 50 | # Checking for file existence. |
| 51 | Valid File Path IMAGE_FILE_PATH |
| 52 | |
| 53 | |
| 54 | Activate Existing Firmware |
| 55 | [Documentation] Set fimware image to lower priority. |
| 56 | [Arguments] ${image_version} |
| 57 | |
| 58 | # Description of argument(s): |
| 59 | # image_version Version of image. |
| 60 | |
| 61 | ${software_inventory_record}= Get Software Inventory State By Version |
| 62 | ... ${image_version} |
| 63 | ${num_keys}= Get Length ${software_inventory_record} |
| 64 | |
| 65 | Rprint Vars software_inventory_record |
| 66 | |
| 67 | # If no software inventory record was found, there is no existing |
| 68 | # firmware for the given version and therefore no action to be taken. |
| 69 | Return From Keyword If not ${num_keys} |
| 70 | |
| 71 | # Check if the existing firmware is functional. |
| 72 | Pass Execution If ${software_inventory_record['functional']} |
| 73 | ... The existing ${image_version} firmware is already functional. |
| 74 | |
| 75 | # If existing firmware is not functional, then set the priority to least. |
| 76 | Print Timen The existing ${image_version} firmware is not yet functional. |
| 77 | Set BMC Image Priority To Least ${image_version} ${software_inventory_record} |
| 78 | |
| 79 | Pass Execution The existing ${image_version} firmware is now functional. |
| 80 | |
| 81 | |
| 82 | Get Image Priority |
| 83 | [Documentation] Get Current Image Priority. |
| 84 | [Arguments] ${image_version} |
| 85 | |
| 86 | # Description of argument(s): |
| 87 | # image_version The Fimware image version (e.g. ibm-v.x-xx). |
| 88 | |
| 89 | ${software_info}= Read Properties |
| 90 | ... ${SOFTWARE_VERSION_URI}/enumerate quiet=1 |
| 91 | # Get only the record associated with our image_version. |
| 92 | |
| 93 | ${software_info}= Filter Struct |
| 94 | ... ${software_info} [('Version', '${image_version}')] |
| 95 | # Convert from dict to list. |
| 96 | ${software_info}= Get Dictionary Values ${software_info} |
| 97 | |
| 98 | [Return] ${software_info[0]['Priority']} |
| 99 | |
| 100 | |
| 101 | Set BMC Image Priority To Least |
| 102 | [Documentation] Set BMC image priority to least value. |
| 103 | [Arguments] ${image_version} ${software_inventory} |
| 104 | |
| 105 | # Description of argument(s): |
| 106 | # image_version The Fimware image version (e.g. ibm-v.x-xx). |
| 107 | # software_inventory Software inventory details. |
| 108 | |
| 109 | ${least_priority}= Get Least Value Priority Image ${VERSION_PURPOSE_BMC} |
| 110 | ${cur_priority}= Get Image Priority ${image_version} |
| 111 | Rprint Vars least_priority cur_priority |
| 112 | |
| 113 | Return From Keyword If '${least_priority}' == ${cur_priority} |
| 114 | Set Host Software Property |
| 115 | ... ${SOFTWARE_VERSION_URI}${software_inventory['image_id']} |
| 116 | ... Priority ${least_priority} |
| 117 | |
| 118 | # Reboot BMC And Login |
| 119 | Redfish OBMC Reboot (off) |
| 120 | Redfish.Login |
| 121 | |
| 122 | |
| 123 | Redfish Update Firmware |
| 124 | [Documentation] Update the BMC firmware via redfish interface. |
| 125 | |
| 126 | ${state}= Get Pre Reboot State |
| 127 | Rprint Vars state |
| 128 | |
Sushil Singh | 090eedc | 2019-11-05 02:04:59 -0600 | [diff] [blame] | 129 | Run Keyword And Ignore Error Set ApplyTime policy=OnReset |
Sushil Singh | 6f86f17 | 2019-10-30 11:36:25 -0500 | [diff] [blame] | 130 | Redfish Upload Image And Check Progress State |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 131 | Reboot BMC And Verify BMC Image |
Sushil Singh | 090eedc | 2019-11-05 02:04:59 -0600 | [diff] [blame] | 132 | ... OnReset start_boot_seconds=${state['epoch_seconds']} |
Sushil Singh | 87dcee1 | 2019-08-07 13:13:13 -0500 | [diff] [blame] | 133 | |