1*** Settings *** 2Documentation Redfish test to switch image sides and boot. 3 4Resource ../../lib/resource.robot 5Resource ../../lib/bmc_redfish_resource.robot 6Resource ../../lib/openbmc_ffdc.robot 7Resource ../../lib/redfish_code_update_utils.robot 8Library ../../lib/tftp_update_utils.py 9 10Suite Setup Suite Setup Execution 11Suite Teardown Redfish.Logout 12Test Teardown FFDC On Test Case Fail 13 14*** Variables *** 15 16# Switch iteration count. By default it does only 2 switch. 17# User can input -v LOOP_COUNT:n to drive the switch back and forth for 18# nth iteration. 19${LOOP_COUNT} ${2} 20 21*** Test Cases *** 22 23Test Firmware Image Switch Without Powering Host 24 [Documentation] Switch image at host powered off. 25 [Tags] Test_Firmware_Image_Switch_Without_Powering_Host 26 [Template] Firmware Switch Loop 27 28 # iteration power_on 29 ${LOOP_COUNT} NO 30 31 32Test Firmware Image Switch And Power On Host 33 [Documentation] Switch image and power on host and verify that it boots. 34 [Tags] Test_Firmware_Image_Switch_And_Power_On_Host 35 [Template] Firmware Switch Loop 36 37 # iteration power_on 38 ${LOOP_COUNT} YES 39 40 41*** Keywords *** 42 43Firmware Switch Loop 44 [Documentation] Wrapper keyword for iteration for firmware side switch. 45 [Arguments] ${iteration} ${power_on} 46 47 # Description of argument(s): 48 # iteration Number of switch it needs to perform. 49 # power_on If YES, boot the system post firmware image switch, 50 # if NO, do not perform any poweron operation. 51 52 FOR ${count} IN RANGE 0 ${iteration} 53 Log To Console LOOP_COUNT:${count} execution. 54 Redfish BMC Switch Firmware Side 55 56 Continue For Loop If '${power_on}' == 'NO' 57 58 Log To Console Power on requested, issuing power on. 59 Redfish Power On 60 61 # Power Off for next iteration. Firmware image switch ideally needs to be 62 # to be executed when Host is powered off. 63 Log To Console Power off requested, issuing power off. 64 Redfish Power Off 65 END 66 67 68Suite Setup Execution 69 [Documentation] Do the suite setup. 70 71 Redfish.Login 72 Run Keyword And Ignore Error Redfish Purge Event Log 73 Redfish Power Off stack_mode=skip 74 75 76Redfish BMC Switch Firmware Side 77 [Documentation] Switch back up image to running and verify. 78 [Tags] Redfish_BMC_Switch_Firmware_Side 79 80 # fw_inv_dict: 81 # [19a3ef3e]: 82 # [image_type]: BMC image 83 # [image_id]: 19a3ef3e 84 # [functional]: True 85 # [version]: 2.12.0-dev-1440-g8dada0a1a 86 # [62d16947]: 87 # [image_type]: BMC image 88 # [image_id]: 62d16947 89 # [functional]: False 90 # [version]: 2.12.0-dev-1441-g8deadbeef 91 ${fw_inv_dict}= Get Software Inventory State 92 Rprint Vars fw_inv_dict 93 94 # Get the backup firmware version for reference. 95 FOR ${id} IN @{fw_inv_dict.keys()} 96 Continue For Loop If '${fw_inv_dict['${id}']['functional']}' == 'True' 97 # Find the non functional id and fetch the version. 98 ${image_version}= Set Variable ${fw_inv_dict['${id}']['version']} 99 END 100 101 Log To Console Backup firmware version: ${image_version} 102 103 Switch Firmware Side ${image_version} 104 105 Match BMC Release And Redifsh Firmware Version 106 Log To Console The backup firmware image ${image_version} is now functional. 107 108 109Match BMC Release And Redifsh Firmware Version 110 [Documentation] The /etc/os-release vs Redfish FirmwareVersion attribute value from 111 ... /redfish/v1/Managers/bmc should match. 112 113 # Python module: get_bmc_release_info() 114 ${bmc_release_info}= utils.Get BMC Release Info 115 ${bmc_release}= Set Variable ${bmc_release_info['version_id']} 116 Rprint Vars bmc_release 117 118 ${firmware_version}= Redfish.Get Attribute /redfish/v1/Managers/bmc FirmwareVersion 119 Rprint Vars firmware_version 120 121 Should Be Equal As Strings ${bmc_release} ${firmware_version} 122 ... msg=${bmc_release} does not match redfish version ${firmware_version} 123 124 125Switch Firmware Side 126 [Documentation] Set the backup firmware to functional and verify after BMC rebooted. 127 [Arguments] ${image_version} 128 129 # Description of argument(s): 130 # image_version Version of image. 131 132 ${state}= Get Pre Reboot State 133 134 Print Timen Switch to back up and rebooting. 135 Switch Backup Firmware Image To Functional 136 Wait For Reboot start_boot_seconds=${state['epoch_seconds']} 137 Print Timen Switch to back up completed. 138 139 # Check if the BMC version after rebooted is the same version asked to switch. 140 ${firmware_version}= Redfish.Get Attribute /redfish/v1/Managers/bmc FirmwareVersion 141 Should Be Equal As Strings ${image_version} ${firmware_version} 142 ... msg=${image_version} does not match redfish version ${firmware_version} 143