George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Code update utility |
| 3 | |
| 4 | Resource ../../lib/rest_client.robot |
| 5 | Resource ../../lib/connection_client.robot |
| 6 | Resource ../../lib/utils.robot |
| 7 | Library OperatingSystem |
| 8 | |
| 9 | *** Variables *** |
| 10 | |
George Keishing | 0fd3b24 | 2016-11-24 09:01:41 -0600 | [diff] [blame] | 11 | ${BMC_UPD_METHOD} ${OPENBMC_BASE_URI}control/flash/bmc/action/update |
| 12 | ${BMC_PREP_METHOD} ${OPENBMC_BASE_URI}control/flash/bmc/action/PrepareForUpdate |
| 13 | ${BMC_UPD_ATTR} ${OPENBMC_BASE_URI}control/flash/bmc |
| 14 | ${HOST_SETTING} ${OPENBMC_BASE_URI}settings/host0 |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 15 | |
| 16 | *** Keywords *** |
| 17 | |
Sivas SRR | 5a40e7f | 2017-04-02 23:16:48 -0500 | [diff] [blame] | 18 | Validate BMC Image File Name |
| 19 | [Documentation] Check that correct BMC image is in use. |
| 20 | [Arguments] ${file_path} |
| 21 | # Description of argument(s): |
| 22 | # file_path The name of the file path to be validated |
| 23 | # (e.g. /home/XXX/Downloads/witherspoon-XXX.all.tar). |
| 24 | Open Connection And Log In |
| 25 | ${bmc_model}= Get BMC System Model |
| 26 | ${file_name}= Fetch From Right ${filepath} / |
| 27 | ${status}= Run Keyword And Return Status Should Contain ${file_name} |
| 28 | ... ${bmc_model} ignore_case=True |
| 29 | Run Keyword If '${status}'=='False' Fatal Error Wrong Image |
| 30 | |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 31 | Preserve BMC Network Setting |
| 32 | [Documentation] Preserve Network setting |
Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 33 | ${policy}= Set Variable ${1} |
| 34 | ${value}= create dictionary data=${policy} |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 35 | Write Attribute ${BMC_UPD_ATTR} preserve_network_settings data=${value} |
| 36 | ${data}= Read Properties ${BMC_UPD_ATTR} |
| 37 | should be equal as strings ${data['preserve_network_settings']} ${1} |
| 38 | ... msg=0 indicates network is not preserved |
| 39 | |
| 40 | |
| 41 | Activate BMC flash image |
| 42 | [Documentation] Activate and verify the update status |
| 43 | ... The status could be either one of these |
| 44 | ... 'Deferred for mounted filesystem. reboot BMC to apply.' |
| 45 | ... 'Image ready to apply.' |
Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 46 | @{img_path}= Create List /tmp/flashimg |
| 47 | ${data}= create dictionary data=@{img_path} |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 48 | ${resp}= openbmc post request ${BMC_UPD_METHOD} data=${data} |
| 49 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 50 | |
| 51 | ${data}= Read Properties ${BMC_UPD_ATTR} |
George Keishing | 0229cd3 | 2016-08-30 08:32:32 -0500 | [diff] [blame] | 52 | should be equal as strings ${data["filename"]} /tmp/flashimg |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 53 | should contain ${data['status']} to apply |
| 54 | |
| 55 | |
George Keishing | dc5aa58e9 | 2016-09-27 01:35:11 -0500 | [diff] [blame] | 56 | Prepare For Update |
| 57 | [Documentation] Switch to update mode in progress. This method calls |
| 58 | ... the Abort method to remove the pending update if there |
| 59 | ... is any before code activation. |
Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 60 | ${data}= create dictionary data=@{EMPTY} |
George Keishing | dc5aa58e9 | 2016-09-27 01:35:11 -0500 | [diff] [blame] | 61 | ${resp}= openbmc post request ${BMC_PREP_METHOD} data=${data} |
| 62 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 63 | |
George Keishing | 11319f6 | 2017-03-14 13:28:56 -0500 | [diff] [blame] | 64 | # Update method will reset the BMC, adding delay for reboot to |
| 65 | # come into force. |
| 66 | Sleep 10s |
George Keishing | dc5aa58e9 | 2016-09-27 01:35:11 -0500 | [diff] [blame] | 67 | |
| 68 | |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 69 | SCP Tar Image File to BMC |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 70 | [Arguments] ${filepath} |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 71 | Open Connection for SCP |
| 72 | scp.Put File ${filepath} /tmp/flashimg |
| 73 | |
| 74 | |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 75 | Check If File Exist |
| 76 | [Arguments] ${filepath} |
| 77 | Log \n PATH: ${filepath} |
| 78 | OperatingSystem.File Should Exist ${filepath} |
| 79 | ... msg=${filepath} doesn't exist [ ERROR ] |
| 80 | |
| 81 | Set Global Variable ${FILE_PATH} ${filepath} |
| 82 | |
| 83 | |
| 84 | System Readiness Test |
Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 85 | ${l_status}= Run Keyword and Return Status |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 86 | ... Verify Ping and REST Authentication |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 87 | Run Keyword If '${l_status}' == '${False}' |
| 88 | ... Fail msg=System not in ideal state to use [ERROR] |
| 89 | |
| 90 | |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 91 | Validate BMC Version |
| 92 | [Arguments] ${args}=post |
| 93 | # Check BMC installed version |
| 94 | Open Connection And Log In |
| 95 | ${version} ${stderr}= Execute Command cat /etc/version |
| 96 | ... return_stderr=True |
| 97 | Should Be Empty ${stderr} |
| 98 | # The File name contains the version installed |
| 99 | Run Keyword If '${args}' == 'before' |
| 100 | ... Should not Contain ${FILE_PATH} ${version} |
| 101 | ... msg=Same version already installed |
| 102 | ... ELSE |
| 103 | ... Should Contain ${FILE_PATH} ${version} |
| 104 | ... msg=Code update Failed |
| 105 | |
| 106 | |
| 107 | Trigger Warm Reset via Reboot |
George Keishing | 6c0f715 | 2016-10-20 08:27:16 -0500 | [diff] [blame] | 108 | [Documentation] Execute reboot command on the remote BMC and |
| 109 | ... returns immediately. This keyword "Start Command" |
| 110 | ... returns nothing and does not wait for the command |
| 111 | ... execution to be finished. |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 112 | Open Connection And Log In |
| 113 | |
George Keishing | 6c0f715 | 2016-10-20 08:27:16 -0500 | [diff] [blame] | 114 | Start Command /sbin/reboot |
George Keishing | 8db0e1b | 2016-10-20 13:46:54 -0500 | [diff] [blame] | 115 | |
| 116 | Set Policy Setting |
| 117 | [Documentation] Set the given test policy |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 118 | [Arguments] ${policy} |
George Keishing | 8db0e1b | 2016-10-20 13:46:54 -0500 | [diff] [blame] | 119 | |
Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 120 | ${valueDict}= create dictionary data=${policy} |
George Keishing | 8db0e1b | 2016-10-20 13:46:54 -0500 | [diff] [blame] | 121 | Write Attribute ${HOST_SETTING} power_policy data=${valueDict} |
| 122 | ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy |
| 123 | Should Be Equal ${currentPolicy} ${policy} |