Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Resource ../lib/resource.txt |
| 3 | Resource ../lib/rest_client.robot |
| 4 | |
| 5 | Library OperatingSystem |
| 6 | |
| 7 | *** Variables *** |
| 8 | ${SYSTEM_SHUTDOWN_TIME} ${5} |
| 9 | |
| 10 | *** Keywords *** |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 11 | Wait For Host To Ping |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 12 | [Arguments] ${host} ${timeout}=${OPENBMC_REBOOT_TIMEOUT}min |
| 13 | ... ${interval}=5 sec |
| 14 | |
| 15 | # host The DNS name or IP of the host to ping. |
| 16 | # timeout The amount of time after which attempts to ping cease. |
| 17 | # interval The amount of time in between attempts to ping. |
| 18 | |
| 19 | Wait Until Keyword Succeeds ${timeout} ${interval} Ping Host ${host} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 20 | |
| 21 | Ping Host |
| 22 | [Arguments] ${host} |
George Keishing | 8a84f95 | 2016-08-25 04:54:53 -0500 | [diff] [blame] | 23 | Should Not Be Empty ${host} msg=No host provided |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 24 | ${RC} ${output} = Run and return RC and Output ping -c 4 ${host} |
| 25 | Log RC: ${RC}\nOutput:\n${output} |
| 26 | Should be equal ${RC} ${0} |
| 27 | |
| 28 | Get Boot Progress |
| 29 | ${state} = Read Attribute /org/openbmc/sensors/host/BootProgress value |
| 30 | [return] ${state} |
| 31 | |
| 32 | Is Power On |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 33 | ${state}= Get Power State |
| 34 | Should be equal ${state} ${1} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 35 | |
| 36 | Is Power Off |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 37 | ${state}= Get Power State |
| 38 | Should be equal ${state} ${0} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 39 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 40 | Initiate Power On |
| 41 | [Documentation] Initiates the power on and waits until the Is Power On |
| 42 | ... keyword returns that the power state has switched to on. |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 43 | @{arglist}= Create List |
| 44 | ${args}= Create Dictionary data=@{arglist} |
| 45 | ${resp}= Call Method /org/openbmc/control/chassis0/ powerOn data=${args} |
| 46 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 47 | Wait Until Keyword Succeeds 3 min 10 sec Is Power On |
| 48 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 49 | Initiate Power Off |
| 50 | [Documentation] Initiates the power off and waits until the Is Power Off |
| 51 | ... keyword returns that the power state has switched to off. |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 52 | @{arglist}= Create List |
| 53 | ${args}= Create Dictionary data=@{arglist} |
| 54 | ${resp}= Call Method /org/openbmc/control/chassis0/ powerOff data=${args} |
| 55 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 56 | Wait Until Keyword Succeeds 1 min 10 sec Is Power Off |
| 57 | |
| 58 | Trigger Warm Reset |
| 59 | log to console "Triggering warm reset" |
| 60 | ${data} = create dictionary data=@{EMPTY} |
| 61 | ${resp} = openbmc post request /org/openbmc/control/bmc0/action/warmReset data=${data} |
| 62 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 63 | Sleep ${SYSTEM_SHUTDOWN_TIME}min |
| 64 | Wait For Host To Ping ${OPENBMC_HOST} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 65 | |
| 66 | Check OS |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 67 | [Documentation] Attempts to ping the host OS and then checks that the host |
| 68 | ... OS is up by running an SSH command. |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 69 | |
| 70 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 71 | ... ${os_password}=${OS_PASSWORD} |
| 72 | [Teardown] Close Connection |
| 73 | |
| 74 | # os_host The DNS name/IP of the OS host associated with our BMC. |
| 75 | # os_username The username to be used to sign on to the OS host. |
| 76 | # os_password The password to be used to sign on to the OS host. |
| 77 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 78 | # Attempt to ping the OS. Store the return code to check later. |
| 79 | ${ping_rc}= Run Keyword and Return Status Ping Host ${os_host} |
| 80 | |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 81 | Open connection ${os_host} |
| 82 | Login ${os_username} ${os_password} |
| 83 | |
| 84 | ${output} ${stderr} ${rc}= Execute Command uptime return_stderr=True |
| 85 | ... return_rc=True |
| 86 | |
| 87 | # If the return code returned by "Execute Command" is non-zero, this keyword |
| 88 | # will fail. |
| 89 | Should Be Equal ${rc} ${0} |
| 90 | # We will likewise fail if there is any stderr data. |
| 91 | Should Be Empty ${stderr} |
| 92 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 93 | # We will likewise fail if the OS did not ping, as we could SSH but not ping |
| 94 | Should Be Equal As Strings ${ping_rc} ${TRUE} |
| 95 | |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 96 | Wait for OS |
| 97 | [Documentation] Waits for the host OS to come up via calls to "Check OS". |
| 98 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 99 | ... ${os_password}=${OS_PASSWORD} ${timeout}=${OS_WAIT_TIMEOUT} |
| 100 | |
| 101 | # os_host The DNS name or IP of the OS host associated with our |
| 102 | # BMC. |
| 103 | # os_username The username to be used to sign on to the OS host. |
| 104 | # os_password The password to be used to sign on to the OS host. |
| 105 | # timeout The timeout in seconds indicating how long you're |
| 106 | # willing to wait for the OS to respond. |
| 107 | |
| 108 | # The interval to be used between calls to "Check OS". |
| 109 | ${interval}= Set Variable 5 |
| 110 | |
| 111 | Wait Until Keyword Succeeds ${timeout} sec ${interval} Check OS |
| 112 | ... ${os_host} ${os_username} ${os_password} |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 113 | |
| 114 | Get BMC State |
| 115 | [Documentation] Returns the state of the BMC as a string. (i.e: BMC_READY) |
| 116 | @{arglist}= Create List |
| 117 | ${args}= Create Dictionary data=@{arglist} |
| 118 | ${resp}= Call Method /org/openbmc/managers/System/ getSystemState |
| 119 | ... data=${args} |
| 120 | Should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 121 | ${content}= to json ${resp.content} |
| 122 | [return] ${content["data"]} |
| 123 | |
| 124 | Get Power State |
| 125 | [Documentation] Returns the power state as an integer. Either 0 or 1. |
| 126 | @{arglist}= Create List |
| 127 | ${args}= Create Dictionary data=@{arglist} |
| 128 | ${resp}= Call Method /org/openbmc/control/chassis0/ getPowerState |
| 129 | ... data=${args} |
| 130 | Should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 131 | ${content}= to json ${resp.content} |
| 132 | [return] ${content["data"]} |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame^] | 133 | |
| 134 | Clear BMC Record Log |
| 135 | [Documentation] Clears all the event logs on the BMC. This would be |
| 136 | ... equivalent to ipmitool sel clear. |
| 137 | @{arglist}= Create List |
| 138 | ${args}= Create Dictionary data=@{arglist} |
| 139 | ${resp}= Call Method /org/openbmc/records/events/ clear data=${args} |
| 140 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 141 | |
| 142 | Copy PNOR to BMC |
| 143 | Import Library SCPLibrary WITH NAME scp |
| 144 | Open Connection for SCP |
| 145 | Log Copying ${PNOR_IMAGE_PATH} to /tmp |
| 146 | scp.Put File ${PNOR_IMAGE_PATH} /tmp |
| 147 | |
| 148 | Flash PNOR |
| 149 | [Documentation] Calls flash bios update method to flash PNOR image |
| 150 | [arguments] ${pnor_image} |
| 151 | @{arglist}= Create List ${pnor_image} |
| 152 | ${args}= Create Dictionary data=@{arglist} |
| 153 | ${resp}= Call Method /org/openbmc/control/flash/bios/ update data=${args} |
| 154 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 155 | Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing |
| 156 | |
| 157 | Get Flash BIOS Status |
| 158 | [Documentation] Returns the status of the flash BIOS API as a string. For |
| 159 | ... example 'Flashing', 'Flash Done', etc |
| 160 | ${data}= Read Properties /org/openbmc/control/flash/bios |
| 161 | [return] ${data['status']} |
| 162 | |
| 163 | Is PNOR Flashing |
| 164 | [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR |
| 165 | ... flashing has started. |
| 166 | ${status}= Get Flash BIOS Status |
| 167 | should be equal as strings ${status} Flashing |
| 168 | |
| 169 | Is PNOR Flash Done |
| 170 | [Documentation] Get BIOS 'Flash Done' status. This indicates that the |
| 171 | ... PNOR flashing has completed. |
| 172 | ${status}= Get Flash BIOS Status |
| 173 | should be equal as strings ${status} Flash Done |
| 174 | |
| 175 | Is System State Host Booted |
| 176 | [Documentation] Checks whether system state is HOST_BOOTED. |
| 177 | ${state}= Get BMC State |
| 178 | should be equal as strings ${state} HOST_BOOTED |