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 22Library ../../lib/gen_robot_valid.py 23Library ../../lib/tftp_update_utils.py 24Library ../../lib/gen_robot_keyword.py 25 26Suite Setup Suite Setup Execution 27Suite Teardown Redfish.Logout 28Test Setup Printn 29Test Teardown FFDC On Test Case Fail 30 31Force Tags BMC_Code_Update 32 33*** Variables *** 34 35@{ADMIN} admin_user TestPwd123 36&{USERS} Administrator=${ADMIN} 37 38*** Test Cases *** 39 40Redfish Code Update With ApplyTime OnReset 41 [Documentation] Update the firmware image with ApplyTime of OnReset. 42 [Tags] Redfish_Code_Update_With_ApplyTime_OnReset 43 [Template] Redfish Update Firmware 44 45 # policy 46 OnReset 47 48 49Redfish Code Update With ApplyTime Immediate 50 [Documentation] Update the firmware image with ApplyTime of Immediate. 51 [Tags] Redfish_Code_Update_With_ApplyTime_Immediate 52 [Template] Redfish Update Firmware 53 54 # policy 55 Immediate 56 57 58Redfish Code Update With Multiple Firmware 59 [Documentation] Update the firmware image with ApplyTime of Immediate. 60 [Tags] Redfish_Code_Update_With_Multiple_Firmware 61 [Template] Redfish Multiple Upload Image And Check Progress State 62 63 # policy image_file_path alternate_image_file_path 64 Immediate ${IMAGE_FILE_PATH} ${ALTERNATE_IMAGE_FILE_PATH} 65 66 67Verify If The Modified Admin Credential Is Valid Post Image Switched To Backup 68 [Documentation] Verify updated admin credential remain same post switch to back up image. 69 [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Image_Switched_To_Backup 70 [Setup] Create Users With Different Roles users=${USERS} force=${True} 71 [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS} 72 73 ${post_code_update_actions}= Get Post Boot Action 74 ${state}= Get Pre Reboot State 75 Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123 76 77 Redfish.Login 78 # change to backup image and reset the BMC. 79 Switch Backup Firmware Image To Functional 80 Wait For Reboot start_boot_seconds=${state['epoch_seconds']} 81 82 # verify modified admin password on backup image. 83 Redfish.Login admin_user 0penBmc123 84 Redfish.Logout 85 86 87Verify If The Modified Admin Credential Is Valid Post Update 88 [Documentation] Verify updated admin credential remain same post code update image. 89 [Tags] Verify_If_The_Modified_Admin_Credential_Is_Valid_Post_Update 90 [Setup] Create Users With Different Roles users=${USERS} force=${True} 91 [Teardown] Run Keywords Redfish.Login AND Delete BMC Users Via Redfish users=${USERS} 92 93 Expire And Update New Password Via Redfish ${ADMIN[0]} ${ADMIN[1]} 0penBmc123 94 95 Redfish.Login 96 # Flash latest firmware using redfish. 97 Redfish Update Firmware OnReset 98 99 # verify modified admin credentails on latest image. 100 Redfish.Login admin_user 0penBmc123 101 Redfish.Logout 102 103*** Keywords *** 104 105Suite Setup Execution 106 [Documentation] Do the suite setup. 107 108 Valid File Path IMAGE_FILE_PATH 109 Redfish.Login 110 Redfish Delete All BMC Dumps 111 Redfish Purge Event Log 112 113 114Redfish Update Firmware 115 [Documentation] Update the BMC firmware via redfish interface. 116 [Arguments] ${apply_time} 117 118 # Description of argument(s): 119 # policy ApplyTime allowed values (e.g. "OnReset", "Immediate"). 120 121 ${post_code_update_actions}= Get Post Boot Action 122 ${state}= Get Pre Reboot State 123 Rprint Vars state 124 Set ApplyTime policy=${apply_Time} 125 126 ${task_inv_dict}= Get Task State from File 127 128 ${file_bin_data}= OperatingSystem.Get Binary File ${image_file_path} 129 130 Log To Console Start uploading image to BMC. 131 Upload Image To BMC ${REDFISH_BASE_URI}UpdateService timeout=${600} data=${file_bin_data} 132 Log To Console Completed image upload to BMC. 133 134 ${task_inv}= Check Task With Match TargetUri /redfish/v1/UpdateService 135 136 Rprint Vars task_inv 137 138 Wait Until Keyword Succeeds 5 min 10 sec 139 ... Verify Task Progress State ${task_inv} ${task_inv_dict['TaskCompleted']} 140 141 Run Key ${post_code_update_actions['BMC image']['${apply_time}']} 142 Redfish.Login 143 Redfish Verify BMC Version ${IMAGE_FILE_PATH} 144 Verify Get ApplyTime ${apply_time} 145 146 147Redfish Multiple Upload Image And Check Progress State 148 [Documentation] Update multiple BMC firmware via redfish interface and check status. 149 [Arguments] ${apply_time} ${IMAGE_FILE_PATH} ${ALTERNATE_IMAGE_FILE_PATH} 150 151 # Description of argument(s): 152 # apply_time ApplyTime allowed values (e.g. "OnReset", "Immediate"). 153 # IMAGE_FILE_PATH The path to BMC image file. 154 # ALTERNATE_IMAGE_FILE_PATH The path to alternate BMC image file. 155 156 ${post_code_update_actions}= Get Post Boot Action 157 Valid File Path ALTERNATE_IMAGE_FILE_PATH 158 ${state}= Get Pre Reboot State 159 Rprint Vars state 160 161 Set ApplyTime policy=${apply_time} 162 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${IMAGE_FILE_PATH} 163 164 ${first_image_id}= Get Latest Image ID 165 Rprint Vars first_image_id 166 Sleep 5s 167 Redfish Upload Image ${REDFISH_BASE_URI}UpdateService ${ALTERNATE_IMAGE_FILE_PATH} 168 169 ${second_image_id}= Get Latest Image ID 170 Rprint Vars second_image_id 171 172 Check Image Update Progress State 173 ... match_state='Updating', 'Disabled' image_id=${second_image_id} 174 175 Check Image Update Progress State 176 ... match_state='Updating' image_id=${first_image_id} 177 178 Wait Until Keyword Succeeds 8 min 20 sec 179 ... Check Image Update Progress State 180 ... match_state='Enabled' image_id=${first_image_id} 181 Run Key ${post_code_update_actions['BMC image']['${apply_time}']} 182 Redfish.Login 183 Redfish Verify BMC Version ${IMAGE_FILE_PATH} 184