1*** Settings *** 2Documentation Code update utility 3 4Resource ../../lib/rest_client.robot 5Resource ../../lib/connection_client.robot 6Resource ../../lib/utils.robot 7Library OperatingSystem 8 9*** Variables *** 10 11${BMC_UPD_METHOD} /org/openbmc/control/flash/bmc/action/update 12${BMC_UPD_ATTR} /org/openbmc/control/flash/bmc 13 14*** Keywords *** 15 16Preserve BMC Network Setting 17 [Documentation] Preserve Network setting 18 ${policy} = Set Variable ${1} 19 ${value} = create dictionary data=${policy} 20 Write Attribute ${BMC_UPD_ATTR} preserve_network_settings data=${value} 21 ${data}= Read Properties ${BMC_UPD_ATTR} 22 should be equal as strings ${data['preserve_network_settings']} ${1} 23 ... msg=0 indicates network is not preserved 24 25 26Activate BMC flash image 27 [Documentation] Activate and verify the update status 28 ... The status could be either one of these 29 ... 'Deferred for mounted filesystem. reboot BMC to apply.' 30 ... 'Image ready to apply.' 31 @{img_path} = Create List /tmp/flashimg 32 ${data} = create dictionary data=@{img_path} 33 ${resp}= openbmc post request ${BMC_UPD_METHOD} data=${data} 34 should be equal as strings ${resp.status_code} ${HTTP_OK} 35 ${content}= To Json ${resp.content} 36 should be equal as strings ${content["data"]["filename"]} /tmp/flashimg 37 38 ${data}= Read Properties ${BMC_UPD_ATTR} 39 should contain ${data['status']} to apply 40 41 42SCP Tar Image File to BMC 43 [arguments] ${filepath} 44 Open Connection for SCP 45 scp.Put File ${filepath} /tmp/flashimg 46 47 48Check If warmReset is Initiated 49 # Ping would be still alive, so try SSH to connect if fails 50 # the ports are down indicating reboot in progress 51 ${alive}= Run Keyword and Return Status 52 ... Open Connection And Log In 53 Return From Keyword If '${alive}' == '${False}' ${False} 54 [return] ${True} 55 56 57Check If File Exist 58 [Arguments] ${filepath} 59 Log \n PATH: ${filepath} 60 OperatingSystem.File Should Exist ${filepath} 61 ... msg=${filepath} doesn't exist [ ERROR ] 62 63 Set Global Variable ${FILE_PATH} ${filepath} 64 65 66System Readiness Test 67 ${l_status} = Run Keyword Verify Ping and REST Authentication 68 Run Keyword If '${l_status}' == '${False}' 69 ... Fail msg=System not in ideal state to use [ERROR] 70 71 72Wait for BMC to respond 73 # Average code update takes from 15 -20 minutes 74 # For worse case 30 minutes, check every 1 min 75 Wait For Host To Ping ${OPENBMC_HOST} 30 min 1 min 76 77 78Validate BMC Version 79 [Arguments] ${args}=post 80 # Check BMC installed version 81 Open Connection And Log In 82 ${version} ${stderr}= Execute Command cat /etc/version 83 ... return_stderr=True 84 Should Be Empty ${stderr} 85 # The File name contains the version installed 86 Run Keyword If '${args}' == 'before' 87 ... Should not Contain ${FILE_PATH} ${version} 88 ... msg=Same version already installed 89 ... ELSE 90 ... Should Contain ${FILE_PATH} ${version} 91 ... msg=Code update Failed 92 93 94Trigger Warm Reset via Reboot 95 Open Connection And Log In 96 97 ${rc}= SSHLibrary.Execute Command 98 ... /sbin/reboot return_stdout=False return_rc=True 99 Should Be Equal As Integers ${rc} 0 100