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 | dc5aa58e9 | 2016-09-27 01:35:11 -0500 | [diff] [blame] | 11 | ${BMC_UPD_METHOD} /org/openbmc/control/flash/bmc/action/update |
| 12 | ${BMC_PREP_METHOD} /org/openbmc/control/flash/bmc/action/PrepareForUpdate |
| 13 | ${BMC_UPD_ATTR} /org/openbmc/control/flash/bmc |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 14 | |
| 15 | *** Keywords *** |
| 16 | |
| 17 | Preserve BMC Network Setting |
| 18 | [Documentation] Preserve Network setting |
| 19 | ${policy} = Set Variable ${1} |
| 20 | ${value} = create dictionary data=${policy} |
| 21 | Write Attribute ${BMC_UPD_ATTR} preserve_network_settings data=${value} |
| 22 | ${data}= Read Properties ${BMC_UPD_ATTR} |
| 23 | should be equal as strings ${data['preserve_network_settings']} ${1} |
| 24 | ... msg=0 indicates network is not preserved |
| 25 | |
| 26 | |
| 27 | Activate BMC flash image |
| 28 | [Documentation] Activate and verify the update status |
| 29 | ... The status could be either one of these |
| 30 | ... 'Deferred for mounted filesystem. reboot BMC to apply.' |
| 31 | ... 'Image ready to apply.' |
| 32 | @{img_path} = Create List /tmp/flashimg |
| 33 | ${data} = create dictionary data=@{img_path} |
| 34 | ${resp}= openbmc post request ${BMC_UPD_METHOD} data=${data} |
| 35 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 36 | |
| 37 | ${data}= Read Properties ${BMC_UPD_ATTR} |
George Keishing | 0229cd3 | 2016-08-30 08:32:32 -0500 | [diff] [blame] | 38 | should be equal as strings ${data["filename"]} /tmp/flashimg |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 39 | should contain ${data['status']} to apply |
| 40 | |
| 41 | |
George Keishing | dc5aa58e9 | 2016-09-27 01:35:11 -0500 | [diff] [blame] | 42 | Prepare For Update |
| 43 | [Documentation] Switch to update mode in progress. This method calls |
| 44 | ... the Abort method to remove the pending update if there |
| 45 | ... is any before code activation. |
| 46 | ${data} = create dictionary data=@{EMPTY} |
| 47 | ${resp}= openbmc post request ${BMC_PREP_METHOD} data=${data} |
| 48 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 49 | |
| 50 | ${data}= Read Properties ${BMC_UPD_ATTR} |
| 51 | should contain ${data['status']} Switch to update mode in progress |
| 52 | |
| 53 | |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 54 | SCP Tar Image File to BMC |
| 55 | [arguments] ${filepath} |
| 56 | Open Connection for SCP |
| 57 | scp.Put File ${filepath} /tmp/flashimg |
| 58 | |
| 59 | |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 60 | Check If File Exist |
| 61 | [Arguments] ${filepath} |
| 62 | Log \n PATH: ${filepath} |
| 63 | OperatingSystem.File Should Exist ${filepath} |
| 64 | ... msg=${filepath} doesn't exist [ ERROR ] |
| 65 | |
| 66 | Set Global Variable ${FILE_PATH} ${filepath} |
| 67 | |
| 68 | |
| 69 | System Readiness Test |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 70 | ${l_status} = Run Keyword and Return Status |
| 71 | ... Verify Ping and REST Authentication |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 72 | Run Keyword If '${l_status}' == '${False}' |
| 73 | ... Fail msg=System not in ideal state to use [ERROR] |
| 74 | |
| 75 | |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 76 | Validate BMC Version |
| 77 | [Arguments] ${args}=post |
| 78 | # Check BMC installed version |
| 79 | Open Connection And Log In |
| 80 | ${version} ${stderr}= Execute Command cat /etc/version |
| 81 | ... return_stderr=True |
| 82 | Should Be Empty ${stderr} |
| 83 | # The File name contains the version installed |
| 84 | Run Keyword If '${args}' == 'before' |
| 85 | ... Should not Contain ${FILE_PATH} ${version} |
| 86 | ... msg=Same version already installed |
| 87 | ... ELSE |
| 88 | ... Should Contain ${FILE_PATH} ${version} |
| 89 | ... msg=Code update Failed |
| 90 | |
| 91 | |
| 92 | Trigger Warm Reset via Reboot |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 93 | [Documentation] The reboot commands execute successfully but |
| 94 | ... returns negative value 1 |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 95 | Open Connection And Log In |
| 96 | |
| 97 | ${rc}= SSHLibrary.Execute Command |
| 98 | ... /sbin/reboot return_stdout=False return_rc=True |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 99 | Should Be Equal As Integers ${rc} ${-1} |