1*** Settings *** 2Documentation Update the PNOR code on a target BMC. 3... Execution Method: 4... python -m robot -v OPENBMC_HOST:<hostname> 5... -v DELETE_OLD_PNOR_IMAGES:<"true" or "false"> 6... -v IMAGE_FILE_PATH:<path/*.tar> 7... -v ALTERNATE_IMAGE_FILE_PATH:<path/*.tar> 8... host_code_update.robot 9... 10... Code update method BMC 11... Update work flow sequence: 12... - Upload image via REST 13... - Verify that the file exists on the BMC 14... - Check that software "Activation" is set to "Ready" 15... - Set "Requested Activation" to "Active" 16... - Wait for code update to complete 17... - Verify the new version 18 19Library ../../lib/bmc_ssh_utils.py 20Library ../../lib/code_update_utils.py 21Variables ../../data/variables.py 22Resource ../../lib/boot_utils.robot 23Resource code_update_utils.robot 24Resource ../../lib/code_update_utils.robot 25Resource ../../lib/openbmc_ffdc.robot 26Resource ../../lib/state_manager.robot 27Resource ../../lib/dump_utils.robot 28 29Test Teardown Code Update Test Teardown 30 31Force Tags Host_Code_Update 32 33*** Variables *** 34 35${QUIET} ${1} 36${IMAGE_FILE_PATH} ${EMPTY} 37${DELETE_OLD_PNOR_IMAGES} false 38${DELETE_OLD_GUARD_FILE} false 39${ALTERNATE_IMAGE_FILE_PATH} ${EMPTY} 40 41*** Test Cases *** 42 43REST Host Code Update 44 [Documentation] Do a PNOR code update by uploading image on BMC via REST. 45 # 1. Delete error logs if there is any. 46 # 1. Do code update. 47 # 2. Do post update the following: 48 # - Collect FFDC if error log exist and delete error logs. 49 [Tags] REST_Host_Code_Update 50 [Setup] Code Update Setup 51 52 Run Keyword And Ignore Error List Installed Images Host 53 54 Upload And Activate Image ${IMAGE_FILE_PATH} 55 OBMC Reboot (off) 56 57 58Post Update Boot To OS 59 [Documentation] Boot the host OS 60 [Tags] Post_Update_Boot_To_OS 61 [Setup] Start SOL Console Logging 62 [Teardown] Run Keywords Stop SOL Console Logging 63 ... AND Code Update Test Teardown 64 65 Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL' 66 ... Fail Code update failed. No need to boot to OS. 67 Delete Error Logs 68 REST Power On 69 Verify Running Host Image ${IMAGE_FILE_PATH} 70 71 72REST Host Code Update While OS Is Running 73 [Documentation] Do a PNOR code update while the host is running. 74 [Tags] REST_Host_Code_Update_While_OS_Is_Running 75 [Teardown] Run Keywords REST Power Off stack_mode=skip 76 ... AND Code Update Test Teardown 77 78 Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL' 79 ... Fail Cannot boot the OS. 80 81 REST Power On stack_mode=skip 82 Upload And Activate Image 83 ... ${ALTERNATE_IMAGE_FILE_PATH} skip_if_active=true 84 REST Power On stack_mode=normal 85 Verify Running Host Image ${ALTERNATE_IMAGE_FILE_PATH} 86 87Host Image Priority Attribute Test 88 [Documentation] Set "Priority" attribute. 89 [Tags] Host_Image_Priority_Attribute_Test 90 [Template] Temporarily Set PNOR Attribute 91 92 # Property Value 93 Priority ${0} 94 Priority ${1} 95 Priority ${127} 96 Priority ${255} 97 98 99Host Set Priority To Invalid Values 100 [Documentation] Attempt to set the priority of an image to an invalid 101 ... value and expect an error. 102 [Tags] Host_Set_Priority_To_Invalid_Values 103 [Template] Set Priority To Invalid Value And Expect Error 104 105 # Version Type Priority 106 ${VERSION_PURPOSE_HOST} ${-1} 107 ${VERSION_PURPOSE_HOST} ${256} 108 109 110Set RequestedActivation To None 111 [Documentation] Set the RequestedActivation of the image to None and 112 ... verify that it is in fact set to None. 113 [Tags] Set_RequestedActivation_To_None 114 115 ${software_objects}= Get Software Objects 116 Set Host Software Property @{software_objects}[0] RequestedActivation 117 ... ${REQUESTED_NONE} 118 ${software_properties}= Get Host Software Property @{software_objects}[0] 119 Should Be Equal As Strings &{software_properties}[RequestedActivation] 120 ... ${REQUESTED_NONE} 121 122 123Set RequestedActivation And Activation To Invalid Value 124 [Documentation] Set the RequestedActivation and Activation propreties of 125 ... the image to an invalid value and verify that it was not 126 ... changed. 127 [Template] Set Property To Invalid Value And Verify No Change 128 [Tags] Set_RequestedActivation_And_Activation_To_Invalid_Value 129 130 # Property Version Type 131 RequestedActivation ${VERSION_PURPOSE_HOST} 132 Activation ${VERSION_PURPOSE_HOST} 133 134 135Upload And Activate Multiple Host Images 136 [Documentation] Upload another PNOR image and verify that its state is 137 ... different from all others. 138 [Tags] Upload_And_Activate_Multiple_Host_Images 139 [Template] Activate Image And Verify No Duplicate Priorities 140 [Setup] Upload And Activate Multiple BMC Images Setup 141 142 # Image File Path Image Purpose 143 ${ALTERNATE_IMAGE_FILE_PATH} ${VERSION_PURPOSE_HOST} 144 145 146Set Same Priority For Multiple Host Images 147 [Documentation] Attempt to set the priority to be the same for two PNOR 148 ... images and verify that the priorities are not the same. 149 [Tags] Set_Same_Priority_For_Multiple_Host_Images 150 151 Run Keyword If '${PREV_TEST_STATUS}' == 'FAIL' 152 ... Fail Activation of alternate image failed. Cannot set priority. 153 Set Same Priority For Multiple Images ${VERSION_PURPOSE_HOST} 154 155 156Delete Host Image 157 [Documentation] Delete a PNOR image from the BMC and PNOR flash chip. 158 [Tags] Delete_Host_Image 159 [Setup] Initiate Host PowerOff 160 161 ${software_objects}= Get Software Objects 162 ... version_type=${VERSION_PURPOSE_HOST} 163 ${num_images}= Get Length ${software_objects} 164 Should Be True 0 < ${num_images} 165 ... msg=There are no PNOR images on the BMC to delete. 166 Delete Image And Verify @{software_objects}[0] ${VERSION_PURPOSE_HOST} 167 168 169Verify Host Update When Host Reboot During Activation In Progress 170 [Documentation] Attempt to reboot the host while an image is activating. 171 [Tags] Verify_Host_Update_When_Host_Reboot_During_Activation_In_Progress 172 173 Upload And Activate Image ${IMAGE_FILE_PATH} 174 REST Power On 175 Delete Error Logs 176 177 ${version_id}= Upload And Activate Image ${ALTERNATE_IMAGE_FILE_PATH} 178 ... wait=${0} 179 180 ${resp}= OpenBMC Get Request ${SOFTWARE_VERSION_URI}${version_id} 181 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} 182 183 # Reboot Host during activation. 184 Host Reboot 185 186 Wait For Activation State Change ${version_id} ${ACTIVATING} 187 188 # New image priority should be 0. 189 ${new_host_properties}= 190 ... Get Host Software Property ${SOFTWARE_VERSION_URI}${version_id} 191 Should Be Equal As Integers ${new_host_properties["Priority"]} ${0} 192 193 # Reboot host to boot up with the new host image version. 194 Host Reboot 195 Verify Running Host Image ${ALTERNATE_IMAGE_FILE_PATH} 196 197 198*** Keywords *** 199 200Temporarily Set PNOR Attribute 201 [Documentation] Update the PNOR attribute value. 202 [Arguments] ${attribute_name} ${attribute_value} 203 204 # Description of argument(s): 205 # attribute_name Host software attribute name (e.g. "Priority"). 206 # attribute_value Value to be written. 207 208 ${image_ids}= Get Software Objects 209 ${init_host_properties}= Get Host Software Property ${image_ids[0]} 210 ${initial_priority}= Set Variable ${init_host_properties["Priority"]} 211 212 Set Host Software Property ${image_ids[0]} ${attribute_name} 213 ... ${attribute_value} 214 215 ${cur_host_properties}= Get Host Software Property ${image_ids[0]} 216 Should Be Equal As Integers ${cur_host_properties["Priority"]} 217 ... ${attribute_value} 218 219 # Revert to to initial value. 220 Set Host Software Property 221 ... ${image_ids[0]} ${attribute_name} ${initial_priority} 222 223 224Code Update Setup 225 [Documentation] Do code update test case setup. 226 # - Clean up all existing BMC dumps. 227 # - Clean up all currently install PNOR images. 228 229 Run Keyword And Ignore Error Smart Power Off 230 Delete All Dumps 231 Delete Error Logs 232 Run Keyword If 'true' == '${DELETE_OLD_PNOR_IMAGES}' 233 ... Delete All PNOR Images 234 Run Keyword If 'true' == '${DELETE_OLD_GUARD_FILE}' BMC Execute Command 235 ... rm -f /var/lib/phosphor-software-manager/pnor/prsv/GUARD 236 237 238Upload And Activate Multiple BMC Images Setup 239 [Documentation] Check that the ALTERNATE_FILE_PATH variable is set. 240 241 Should Not Be Empty ${ALTERNATE_IMAGE_FILE_PATH} 242 Delete All PNOR Images 243 Upload And Activate Image ${IMAGE_FILE_PATH} skip_if_active=true 244 245Get PNOR Extended Version 246 [Documentation] Return the PNOR extended version. 247 [Arguments] ${manifest_path} 248 249 # Description of argument(s): 250 # manifest_path Path of the MANIFEST file 251 # (e.g. "/tmp/images/abc123/MANIFEST"). 252 253 ${version}= BMC Execute Command 254 ... grep extended_version= ${manifest_path} 255 [return] ${version.split(",")} 256 257 258Code Update Test Teardown 259 [Documentation] Do code update test case teardown. 260 # 1. Collect FFDC if test case failed. 261 # 2. Collect FFDC if test PASS but error log exists. 262 263 FFDC On Test Case Fail 264 Run Keyword If '${TEST_STATUS}' == 'PASS' Check Error And Collect FFDC 265