1*** Settings *** 2Documentation Update firmware 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 12Resource ../../lib/resource.robot 13Resource ../../lib/bmc_redfish_resource.robot 14Resource ../../lib/openbmc_ffdc.robot 15Resource ../../lib/common_utils.robot 16Resource ../../lib/code_update_utils.robot 17Resource ../../lib/dump_utils.robot 18Resource ../../lib/logging_utils.robot 19Resource ../../lib/redfish_code_update_utils.robot 20Resource ../../lib/utils.robot 21Resource ../../lib/bmc_redfish_utils.robot 22Resource ../../lib/external_intf/management_console_utils.robot 23Library ../../lib/gen_robot_valid.py 24Library ../../lib/tftp_update_utils.py 25Library ../../lib/gen_robot_keyword.py 26 27Suite Setup Suite Setup Execution 28Suite Teardown Redfish.Logout 29Test Setup Printn 30Test Teardown FFDC On Test Case Fail 31 32Force Tags BMC_Code_Update 33 34*** Variables *** 35 36@{ADMIN} admin_user TestPwd123 37&{USERS} Administrator=${ADMIN} 38${LOOP_COUNT} ${2} 39 40*** Test Cases *** 41 42Redfish Code Update With ApplyTime OnReset 43 [Documentation] Update the firmware image with ApplyTime of OnReset. 44 [Tags] Redfish_Code_Update_With_ApplyTime_OnReset 45 [Template] Redfish Update Firmware 46 47 # policy 48 OnReset 49 50 51Redfish Code Update With ApplyTime Immediate 52 [Documentation] Update the firmware image with ApplyTime of Immediate. 53 [Tags] Redfish_Code_Update_With_ApplyTime_Immediate 54 [Template] Redfish Update Firmware 55 56 # policy 57 Immediate 58 59 60Redfish Code Update Same Firmware Multiple Times 61 [Documentation] Multiple times update the firmware image for update service. 62 [Tags] Redfish_Code_Update_Same_Firmware_Multiple_Times 63 64 ${temp_update_loop_count}= Evaluate ${LOOP_COUNT} + 1 65 66 FOR ${count} IN RANGE 1 ${temp_update_loop_count} 67 Print Timen *************************************** 68 Print Timen * The Current Loop Count is ${count} of ${LOOP_COUNT} * 69 Print Timen *************************************** 70 71 Redfish Update Firmware apply_time=OnReset 72 END 73 74 75 76Redfish Code Update With Multiple Firmware 77 [Documentation] Update the firmware image with ApplyTime of Immediate. 78 [Tags] Redfish_Code_Update_With_Multiple_Firmware 79 [Template] Redfish Multiple Upload Image And Check Progress State 80 81 # policy image_file_path alternate_image_file_path 82 Immediate ${IMAGE_FILE_PATH} ${ALTERNATE_IMAGE_FILE_PATH} 83 84 85Post BMC Reset Perform Redfish Code Update 86 [Documentation] Test to reset BMC at standby and then perform BMC firmware update and 87 ... ensure there is not error or dump logs post update. 88 [Tags] Post_BMC_Reset_Perform_Redfish_Code_Update 89 90 Redfish Delete All BMC Dumps 91 Redfish Purge Event Log 92 93 Redfish OBMC Reboot (off) 94 95 Redfish Update Firmware apply_time=OnReset 96 97 Event Log Should Not Exist 98 Redfish BMC Dump Should Not Exist 99 100 Redfish Power Off 101 102 103Post BMC Reset Perform Image Switched To Backup Multiple Times 104 [Documentation] Test to reset BMC at standby and then perform switch 105 ... to backup image multiple times. 106 ... Then ensure no event and dump logs exist. 107 [Tags] Post_BMC_Reset_Perform_Image_Switched_To_Backup_Multiple_Times 108 109 Redfish Delete All BMC Dumps 110 Redfish Purge Event Log 111 112 Redfish OBMC Reboot (off) 113 114 ${temp_update_loop_count}= Evaluate ${LOOP_COUNT} + 1 115 116 FOR ${count} IN RANGE 1 ${temp_update_loop_count} 117 ${state}= Get Pre Reboot State 118 119 # change to backup image and reset the BMC. 120 Switch Backup Firmware Image To Functional 121 122 Wait For Reboot start_boot_seconds=${state['epoch_seconds']} 123 END 124 125 Event Log Should Not Exist 126 Redfish BMC Dump Should Not Exist 127 128 129Verify Code Update Fails When Kernel Panic Occur 130 [Documentation] Ensure firmware update is un-successful when kernel panic 131 ... occur during ongoing firmware update. 132 [Tags] Verify_Code_Update_Fails_When_Kernel_Panic_Occur 133 134 ${before_update_activeswimage}= Redfish.Get Attribute /redfish/v1/Managers/bmc Links 135 Rprint Vars before_update_activeswimage 136 137 Set ApplyTime policy=OnReset 138 139 ${task_inv_dict}= Get Task State from File 140 141 ${file_bin_data}= OperatingSystem.Get Binary File ${image_file_path} 142 143 Log To Console Start uploading image to BMC. 144 Upload Image To BMC ${REDFISH_BASE_URI}UpdateService timeout=${600} data=${file_bin_data} 145 Log To Console Completed image upload to BMC. 146 147 Sleep 5 148 149 ${task_inv}= Check Task With Match TargetUri /redfish/v1/UpdateService 150 Rprint Vars task_inv 151 152 Run Keyword Kernel Panic BMC Reset Operation 153 154 Is BMC Unpingable 155 156 Wait Until Keyword Succeeds 10 min 10 sec Is BMC Standby 157 158 Redfish.Login 159 160 ${after_update_activeswimage}= Redfish.Get Attribute /redfish/v1/Managers/bmc Links 161 Rprint Vars after_update_activeswimage 162 163 Should Be Equal As Strings 164 ... ${before_update_activeswimage['ActiveSoftwareImage']['@odata.id']} 165 ... ${after_update_activeswimage['ActiveSoftwareImage']['@odata.id']} 166 167 Verify Get ApplyTime OnReset 168 169 170Verify If The Modified Admin Credential Is Valid Post Image Switched To Backup 171 [Documentation] Verify updated admin credential remain same post switch to back up image. 172 [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Image_Switched_To_Backup 173 [Setup] Create Users With Different Roles users=${USERS} force=${True} 174 [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS} 175 176 ${post_code_update_actions}= Get Post Boot Action 177 ${state}= Get Pre Reboot State 178 Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123 179 180 Redfish.Login 181 # change to backup image and reset the BMC. 182 Switch Backup Firmware Image To Functional 183 Wait For Reboot start_boot_seconds=${state['epoch_seconds']} 184 185 # verify modified admin password on backup image. 186 Redfish.Login admin_user 0penBmc123 187 Redfish.Logout 188 189 190Verify If The Modified Admin Credential Is Valid Post Update 191 [Documentation] Verify updated admin credential remain same post code update image. 192 [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Update 193 [Setup] Create Users With Different Roles users=${USERS} force=${True} 194 [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS} 195 196 Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123 197 198 Redfish.Login 199 # Flash latest firmware using redfish. 200 Redfish Update Firmware OnReset 201 202 # verify modified admin credentails on latest image. 203 Redfish.Login admin_user 0penBmc123 204 Redfish.Logout 205 206*** Keywords *** 207 208Suite Setup Execution 209 [Documentation] Do the suite setup. 210 211 Valid File Path IMAGE_FILE_PATH 212 Redfish.Login 213 214 Redfish Delete All BMC Dumps 215 Redfish Purge Event Log 216 217 Redfish Power Off stack_mode=skip 218 219 220Redfish Update Firmware 221 [Documentation] Update the BMC firmware via redfish interface. 222 [Arguments] ${apply_time} 223 224 # Description of argument(s): 225 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate"). 226 227 ${post_code_update_actions}= Get Post Boot Action 228 ${state}= Get Pre Reboot State 229 Rprint Vars state 230 Set ApplyTime policy=${apply_Time} 231 232 ${task_inv_dict}= Get Task State from File 233 234 ${file_bin_data}= OperatingSystem.Get Binary File ${image_file_path} 235 236 Log To Console Start uploading image to BMC. 237 Upload Image To BMC ${REDFISH_BASE_URI}UpdateService timeout=${600} data=${file_bin_data} 238 Log To Console Completed image upload to BMC. 239 240 ${task_inv}= Check Task With Match TargetUri /redfish/v1/UpdateService 241 242 Rprint Vars task_inv 243 244 Wait Until Keyword Succeeds 5 min 10 sec 245 ... Verify Task Progress State ${task_inv} ${task_inv_dict['TaskCompleted']} 246 247 Run Key ${post_code_update_actions['BMC image']['${apply_time}']} 248 Redfish.Login 249 Redfish Verify BMC Version ${IMAGE_FILE_PATH} 250 Verify Get ApplyTime ${apply_time} 251 252 253Redfish Multiple Upload Image And Check Progress State 254 [Documentation] Update multiple BMC firmware via redfish interface and check status. 255 [Arguments] ${apply_time} ${IMAGE_FILE_PATH} ${ALTERNATE_IMAGE_FILE_PATH} 256 257 # Description of argument(s): 258 # apply_time ApplyTime allowed values (e.g. "OnReset", "Immediate"). 259 # IMAGE_FILE_PATH The path to BMC image file. 260 # ALTERNATE_IMAGE_FILE_PATH The path to alternate BMC image file. 261 262 ${post_code_update_actions}= Get Post Boot Action 263 Valid File Path ALTERNATE_IMAGE_FILE_PATH 264 ${state}= Get Pre Reboot State 265 Rprint Vars state 266 267 Set ApplyTime policy=${apply_time} 268 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${IMAGE_FILE_PATH} 269 270 ${first_image_id}= Get Latest Image ID 271 Rprint Vars first_image_id 272 Sleep 5s 273 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${ALTERNATE_IMAGE_FILE_PATH} 274 275 ${second_image_id}= Get Latest Image ID 276 Rprint Vars second_image_id 277 278 Check Image Update Progress State 279 ... match_state='Updating', 'Disabled' image_id=${second_image_id} 280 281 Check Image Update Progress State 282 ... match_state='Updating' image_id=${first_image_id} 283 284 Wait Until Keyword Succeeds 8 min 20 sec 285 ... Check Image Update Progress State 286 ... match_state='Enabled' image_id=${first_image_id} 287 Run Key ${post_code_update_actions['BMC image']['${apply_time}']} 288 Redfish.Login 289 Redfish Verify BMC Version ${IMAGE_FILE_PATH} 290 291 292