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