15e870cd2SGeorge Keishing*** Settings *** 25e870cd2SGeorge KeishingDocumentation Code update utility 35e870cd2SGeorge Keishing 45e870cd2SGeorge KeishingResource ../../lib/rest_client.robot 55e870cd2SGeorge KeishingResource ../../lib/connection_client.robot 65e870cd2SGeorge KeishingResource ../../lib/utils.robot 75e870cd2SGeorge KeishingLibrary OperatingSystem 85e870cd2SGeorge Keishing 95e870cd2SGeorge Keishing*** Variables *** 105e870cd2SGeorge Keishing 11f26367caSGeorge Keishing# Fix old org path locally for non-witherspoon system. 12f26367caSGeorge Keishing${ORG_OPENBMC_BASE_URI} /org/openbmc/ 137d0e25dbSSteven Sombar${ORG_CONTROL_FLASH} ${ORG_OPENBMC_BASE_URI}control/flash/ 147d0e25dbSSteven Sombar${BMC_UPD_METHOD} ${ORG_CONTROL_FLASH}bmc/action/update 157d0e25dbSSteven Sombar${BMC_PREP_METHOD} ${ORG_CONTROL_FLASH}bmc/action/PrepareForUpdate 167d0e25dbSSteven Sombar${BMC_UPD_ATTR} ${ORG_CONTROL_FLASH}bmc 17f26367caSGeorge Keishing${HOST_SETTING} ${ORG_OPENBMC_BASE_URI}settings/host0 185e870cd2SGeorge Keishing 195e870cd2SGeorge Keishing*** Keywords *** 205e870cd2SGeorge Keishing 215e870cd2SGeorge KeishingPreserve BMC Network Setting 225e870cd2SGeorge Keishing [Documentation] Preserve Network setting 237d0e25dbSSteven Sombar 245e870cd2SGeorge Keishing ${policy}= Set Variable ${1} 257d0e25dbSSteven Sombar ${value}= Create Dictionary data=${policy} 265e870cd2SGeorge Keishing Write Attribute ${BMC_UPD_ATTR} preserve_network_settings data=${value} 275e870cd2SGeorge Keishing ${data}= Read Properties ${BMC_UPD_ATTR} 287d0e25dbSSteven Sombar Should Be Equal As Strings 297d0e25dbSSteven Sombar ... ${data['preserve_network_settings']} ${True} 306662d18bSMichael Walsh ... msg=False indicates network is not preserved. 315e870cd2SGeorge Keishing 325e870cd2SGeorge Keishing 33317878a7SMichael WalshActivate BMC Flash Image 34317878a7SMichael Walsh [Documentation] Activate and verify the update status. 35317878a7SMichael Walsh ... The status could be either one of these: 365e870cd2SGeorge Keishing ... 'Deferred for mounted filesystem. reboot BMC to apply.' 375e870cd2SGeorge Keishing ... 'Image ready to apply.' 387d0e25dbSSteven Sombar 395e870cd2SGeorge Keishing @{img_path}= Create List /tmp/flashimg 40317878a7SMichael Walsh ${data}= Create Dictionary data=@{img_path} 41317878a7SMichael Walsh ${resp}= OpenBMC Post Request ${BMC_UPD_METHOD} data=${data} 42317878a7SMichael Walsh ... timeout=${30} 43317878a7SMichael Walsh Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} 445e870cd2SGeorge Keishing 455e870cd2SGeorge Keishing ${data}= Read Properties ${BMC_UPD_ATTR} 46317878a7SMichael Walsh Should Be Equal As Strings ${data["filename"]} /tmp/flashimg 47317878a7SMichael Walsh Should Contain ${data['status']} to apply 485e870cd2SGeorge Keishing 495e870cd2SGeorge Keishing 50dc5aa58eSGeorge KeishingPrepare For Update 51dc5aa58eSGeorge Keishing [Documentation] Switch to update mode in progress. This method calls 52dc5aa58eSGeorge Keishing ... the Abort method to remove the pending update if there 53dc5aa58eSGeorge Keishing ... is any before code activation. 547d0e25dbSSteven Sombar 55268099f9SGeorge Keishing ${data}= Create Dictionary data=@{EMPTY} 56268099f9SGeorge Keishing ${resp}= Openbmc Post Request ${BMC_PREP_METHOD} data=${data} 57dc5aa58eSGeorge Keishing 5811319f67SGeorge Keishing # Update method will reset the BMC, adding delay for reboot to 5911319f67SGeorge Keishing # come into force. 6011319f67SGeorge Keishing Sleep 10s 61dc5aa58eSGeorge Keishing 62dc5aa58eSGeorge Keishing 635e870cd2SGeorge KeishingSCP Tar Image File to BMC 647b64a31bSGeorge Keishing [Documentation] Copy BMC tar image to BMC. 657b64a31bSGeorge Keishing [Arguments] ${image_file_path} 667d0e25dbSSteven Sombar 677b64a31bSGeorge Keishing # Description of argument(s): 687b64a31bSGeorge Keishing # image_file_path Downloaded BMC tar file image path. 697b64a31bSGeorge Keishing 705e870cd2SGeorge Keishing Open Connection for SCP 717b64a31bSGeorge Keishing Open Connection And Log In 727b64a31bSGeorge Keishing Loop SCP Retry ${image_file_path} 737b64a31bSGeorge Keishing 747b64a31bSGeorge Keishing 757b64a31bSGeorge KeishingLoop SCP Retry 767b64a31bSGeorge Keishing [Documentation] Try transferring the file 4 times. 777b64a31bSGeorge Keishing [Arguments] ${image_file_path} 787d0e25dbSSteven Sombar 797b64a31bSGeorge Keishing # Description of argument(s): 807b64a31bSGeorge Keishing # image_file_path Downloaded BMC tar file image path. 817b64a31bSGeorge Keishing 82ab209cddSSushil Singh FOR ${index} IN RANGE 0 4 83ab209cddSSushil Singh ${status}= Retry SCP ${image_file_path} 84ab209cddSSushil Singh Exit For Loop If '${status}' == '${True}' 85ab209cddSSushil Singh END 867b64a31bSGeorge Keishing 877b64a31bSGeorge Keishing 887b64a31bSGeorge KeishingRetry SCP 897b64a31bSGeorge Keishing [Documentation] Delete the incomplete file and scp file. 907b64a31bSGeorge Keishing [Arguments] ${image_file_path} 917d0e25dbSSteven Sombar 927b64a31bSGeorge Keishing # Description of argument(s): 937b64a31bSGeorge Keishing # image_file_path Downloaded BMC tar file image path. 947b64a31bSGeorge Keishing 957b64a31bSGeorge Keishing ${targ_file_path}= Set Variable /tmp/flashimg 967b64a31bSGeorge Keishing 977b64a31bSGeorge Keishing # Example output: 987b64a31bSGeorge Keishing # root@witherspoon:~# ls -lh /tmp/flashimg 997b64a31bSGeorge Keishing # -rwxr-xr-x 1 root root 32.0M Jun 29 01:12 /tmp/flashimg 1002ef965acSJoy Onyerikwu BMC Execute Command rm -f /tmp/flashimg 1017b64a31bSGeorge Keishing scp.Put File ${image_file_path} ${targ_file_path} 1027b64a31bSGeorge Keishing 1032ef965acSJoy Onyerikwu ${file_size} ${stderr} ${rc}= BMC Execute Command 1042ef965acSJoy Onyerikwu ... ls -lh ${targ_file_path} 1057b64a31bSGeorge Keishing ${status}= Run Keyword And Return Status 1067b64a31bSGeorge Keishing ... Should Contain ${file_size} 32.0M msg=Incomplete file transfer. 107*409df05dSGeorge Keishing RETURN ${status} 1085e870cd2SGeorge Keishing 1095e870cd2SGeorge Keishing 1105e870cd2SGeorge KeishingCheck If File Exist 111f4a807bfSJoy Onyerikwu [Documentation] Verify that the file exists on this machine. 1125e870cd2SGeorge Keishing [Arguments] ${filepath} 1137d0e25dbSSteven Sombar 1147d0e25dbSSteven Sombar # Description of argument(s): 1157d0e25dbSSteven Sombar # filepath The path of the file whose existence is to be checked. 1167d0e25dbSSteven Sombar 1175e870cd2SGeorge Keishing Log \n PATH: ${filepath} 1185e870cd2SGeorge Keishing OperatingSystem.File Should Exist ${filepath} 1195e870cd2SGeorge Keishing ... msg=${filepath} doesn't exist [ ERROR ] 1205e870cd2SGeorge Keishing 1215e870cd2SGeorge Keishing Set Global Variable ${FILE_PATH} ${filepath} 1225e870cd2SGeorge Keishing 1235e870cd2SGeorge Keishing 1245e870cd2SGeorge KeishingSystem Readiness Test 1257d0e25dbSSteven Sombar [Documentation] Verify ping and REST authenticatec for the target 1267d0e25dbSSteven Sombar ... system. 1277d0e25dbSSteven Sombar 128c4d3dc0bSGeorge Keishing ${l_status}= Run Keyword and Return Status 129c4d3dc0bSGeorge Keishing ... Verify Ping and REST Authentication 1305e870cd2SGeorge Keishing Run Keyword If '${l_status}' == '${False}' 1315e870cd2SGeorge Keishing ... Fail msg=System not in ideal state to use [ERROR] 1325e870cd2SGeorge Keishing 1335e870cd2SGeorge Keishing 1345e870cd2SGeorge KeishingValidate BMC Version 135830211e4SGeorge Keishing [Documentation] Get BMC version from /etc/os-release and compare. 136830211e4SGeorge Keishing [Arguments] ${version} 137830211e4SGeorge Keishing 138830211e4SGeorge Keishing # Description of argument(s): 139830211e4SGeorge Keishing # version Software version (e.g. "v1.99.8-41-g86a4abc"). 140830211e4SGeorge Keishing 1415e870cd2SGeorge Keishing Open Connection And Log In 142830211e4SGeorge Keishing ${cmd}= Set Variable grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '=' 1432ef965acSJoy Onyerikwu ${output} ${stderr} ${rc}= BMC Execute Command ${cmd} 144830211e4SGeorge Keishing Should Be Equal As Strings ${version} ${output[1:-1]} 1455e870cd2SGeorge Keishing 1465e870cd2SGeorge Keishing 1475e870cd2SGeorge KeishingTrigger Warm Reset via Reboot 1486c0f715bSGeorge Keishing [Documentation] Execute reboot command on the remote BMC and 1496c0f715bSGeorge Keishing ... returns immediately. This keyword "Start Command" 1506c0f715bSGeorge Keishing ... returns nothing and does not wait for the command 1516c0f715bSGeorge Keishing ... execution to be finished. 1527d0e25dbSSteven Sombar 1535e870cd2SGeorge Keishing Open Connection And Log In 1545e870cd2SGeorge Keishing 1556c0f715bSGeorge Keishing Start Command /sbin/reboot 1568db0e1b5SGeorge Keishing 1577d0e25dbSSteven Sombar 1588db0e1b5SGeorge KeishingSet Policy Setting 1598db0e1b5SGeorge Keishing [Documentation] Set the given test policy 16038032805SGunnar Mills [Arguments] ${policy} 1618db0e1b5SGeorge Keishing 1627d0e25dbSSteven Sombar # Description of argument(s): 1637d0e25dbSSteven Sombar # policy Policy value to set (e.g. ${RESTORE_LAST_STATE}, 1647d0e25dbSSteven Sombar # ${ALWAYS_POWER_ON}, or ${ALWAYS_POWER_OFF}). 1657d0e25dbSSteven Sombar 1667d0e25dbSSteven Sombar ${valueDict}= Create Dictionary data=${policy} 1678db0e1b5SGeorge Keishing Write Attribute ${HOST_SETTING} power_policy data=${valueDict} 1688db0e1b5SGeorge Keishing ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy 1698db0e1b5SGeorge Keishing Should Be Equal ${currentPolicy} ${policy} 170