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 | |
| 11 | ${BMC_UPD_METHOD} /org/openbmc/control/flash/bmc/action/update |
| 12 | ${BMC_UPD_ATTR} /org/openbmc/control/flash/bmc |
| 13 | |
| 14 | *** Keywords *** |
| 15 | |
| 16 | Preserve 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 | |
| 26 | Activate 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} |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 35 | |
| 36 | ${data}= Read Properties ${BMC_UPD_ATTR} |
George Keishing | 0229cd3 | 2016-08-30 08:32:32 -0500 | [diff] [blame] | 37 | should be equal as strings ${data["filename"]} /tmp/flashimg |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 38 | should contain ${data['status']} to apply |
| 39 | |
| 40 | |
| 41 | SCP Tar Image File to BMC |
| 42 | [arguments] ${filepath} |
| 43 | Open Connection for SCP |
| 44 | scp.Put File ${filepath} /tmp/flashimg |
| 45 | |
| 46 | |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 47 | Check If File Exist |
| 48 | [Arguments] ${filepath} |
| 49 | Log \n PATH: ${filepath} |
| 50 | OperatingSystem.File Should Exist ${filepath} |
| 51 | ... msg=${filepath} doesn't exist [ ERROR ] |
| 52 | |
| 53 | Set Global Variable ${FILE_PATH} ${filepath} |
| 54 | |
| 55 | |
| 56 | System Readiness Test |
| 57 | ${l_status} = Run Keyword Verify Ping and REST Authentication |
| 58 | Run Keyword If '${l_status}' == '${False}' |
| 59 | ... Fail msg=System not in ideal state to use [ERROR] |
| 60 | |
| 61 | |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 62 | Check If BMC is Up |
| 63 | ${status}= Verify Ping and REST Authentication |
| 64 | Run Keyword If '${status}' == '${False}' |
| 65 | ... Fail msg=Ping and REST auth failed |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 66 | |
| 67 | |
| 68 | Validate BMC Version |
| 69 | [Arguments] ${args}=post |
| 70 | # Check BMC installed version |
| 71 | Open Connection And Log In |
| 72 | ${version} ${stderr}= Execute Command cat /etc/version |
| 73 | ... return_stderr=True |
| 74 | Should Be Empty ${stderr} |
| 75 | # The File name contains the version installed |
| 76 | Run Keyword If '${args}' == 'before' |
| 77 | ... Should not Contain ${FILE_PATH} ${version} |
| 78 | ... msg=Same version already installed |
| 79 | ... ELSE |
| 80 | ... Should Contain ${FILE_PATH} ${version} |
| 81 | ... msg=Code update Failed |
| 82 | |
| 83 | |
| 84 | Trigger Warm Reset via Reboot |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 85 | [Documentation] The reboot commands execute successfully but |
| 86 | ... returns negative value 1 |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 87 | Open Connection And Log In |
| 88 | |
| 89 | ${rc}= SSHLibrary.Execute Command |
| 90 | ... /sbin/reboot return_stdout=False return_rc=True |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 91 | Should Be Equal As Integers ${rc} ${-1} |