blob: d1998ae6e1dc311d1f0f5319cdb434e40f08df3d [file] [log] [blame]
George Keishingb88df3d2017-01-10 07:28:08 -06001*** Settings ***
George Keishingbec365b2017-01-19 01:28:41 -06002Resource ../lib/utils.robot
3Variables ../data/variables.py
George Keishingb88df3d2017-01-10 07:28:08 -06004
5*** Variables ***
6
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -06007${BMC_READY_STATE} Ready
8${BMC_NOT_READY_STATE} NotReady
George Keishingb88df3d2017-01-10 07:28:08 -06009${QUIET} ${0}
10
Michael Walshb2869542017-04-12 15:41:02 -050011# "1" indicates that the new "xyz" interface should be used.
12${OBMC_STATES_VERSION} ${1}
George Keishing43a021f2017-01-30 11:10:13 -060013
George Keishingb88df3d2017-01-10 07:28:08 -060014*** Keywords ***
15
16Initiate Host Boot
17 [Documentation] Initiate host power on.
Michael Walsh67ef6222017-03-21 14:48:26 -050018 [Arguments] ${wait}=${1}
19
20 # Description of arguments:
21 # wait Indicates that this keyword should wait for host running state.
22
George Keishingb88df3d2017-01-10 07:28:08 -060023 ${args}= Create Dictionary data=${HOST_POWERON_TRANS}
24 Write Attribute
25 ... ${HOST_STATE_URI} RequestedHostTransition data=${args}
26
Michael Walsh67ef6222017-03-21 14:48:26 -050027 # Does caller want to wait for status?
28 Run Keyword If '${wait}' == '${0}' Return From Keyword
29
George Keishingb88df3d2017-01-10 07:28:08 -060030 Wait Until Keyword Succeeds
31 ... 10 min 10 sec Is Host Running
32
33
34Initiate Host PowerOff
35 [Documentation] Initiate host power off.
Michael Walsh67ef6222017-03-21 14:48:26 -050036 [Arguments] ${wait}=${1}
37
38 # Description of arguments:
39 # wait Indicates that this keyword should wait for host off state.
40
George Keishingb88df3d2017-01-10 07:28:08 -060041 ${args}= Create Dictionary data=${HOST_POWEROFF_TRANS}
42 Write Attribute
43 ... ${HOST_STATE_URI} RequestedHostTransition data=${args}
44
Michael Walsh67ef6222017-03-21 14:48:26 -050045 # Does caller want to wait for status?
46 Run Keyword If '${wait}' == '${0}' Return From Keyword
47
George Keishing2c54e692017-07-10 13:07:02 -050048 # TODO: Reference to open-power/skiboot#81.
49 # Revert to 3 minutes once fixed.
George Keishingb88df3d2017-01-10 07:28:08 -060050 Wait Until Keyword Succeeds
George Keishing2c54e692017-07-10 13:07:02 -050051 ... 6 min 10 sec Is Host Off
George Keishingb88df3d2017-01-10 07:28:08 -060052
53
Rahul Maheshwarif7ead242017-02-14 01:59:42 -060054Initiate Host Reboot
55 [Documentation] Initiate host reboot via REST.
56
57 ${args}= Create Dictionary data=${HOST_REBOOT_TRANS}
58 Write Attribute
59 ... ${HOST_STATE_URI} RequestedHostTransition data=${args}
60 Is Host Rebooted
61
62
George Keishingb88df3d2017-01-10 07:28:08 -060063Is Host Running
Rahul Maheshwarif7ead242017-02-14 01:59:42 -060064 [Documentation] Check if host state is "Running".
George Keishing13cc2102017-07-25 07:48:58 -050065 # Chassis state should be "On" before we check the host state.
66 Is Chassis On
George Keishingb88df3d2017-01-10 07:28:08 -060067 ${host_state}= Get Host State
George Keishing59d6cb42017-01-19 08:26:03 -060068 Should Be Equal Running ${host_state}
George Keishing13cc2102017-07-25 07:48:58 -050069 # Check to verify that the host is really booted.
70 Is OS Starting
George Keishingb88df3d2017-01-10 07:28:08 -060071
72
73Is Host Off
Rahul Maheshwarif7ead242017-02-14 01:59:42 -060074 [Documentation] Check if host state is "Off".
George Keishing13cc2102017-07-25 07:48:58 -050075 # Chassis state should be "Off" before we check the host state.
76 Is Chassis Off
George Keishingb88df3d2017-01-10 07:28:08 -060077 ${host_state}= Get Host State
George Keishing59d6cb42017-01-19 08:26:03 -060078 Should Be Equal Off ${host_state}
George Keishing13cc2102017-07-25 07:48:58 -050079 # Check to verify that the host shutdown completely.
80 Is OS Off
George Keishingb88df3d2017-01-10 07:28:08 -060081
Rahul Maheshwarif7ead242017-02-14 01:59:42 -060082
83Is Host Rebooted
84 [Documentation] Checks if host rebooted.
85
86 ${host_trans_state}= Get Host Trans State
87 Should Be Equal ${host_trans_state} Reboot
88 Is Host Running
89
90
91Is Chassis On
92 [Documentation] Check if chassis state is "On".
93 ${power_state}= Get Chassis Power State
94 Should Be Equal On ${power_state}
95
96
97Is Chassis Off
98 [Documentation] Check if chassis state is "Off".
99 ${power_state}= Get Chassis Power State
100 Should Be Equal Off ${power_state}
101
Rahul Maheshwarid01596e2017-02-20 00:04:42 -0600102Is Host Quiesced
103 [Documentation] Check if host state is quiesced.
104 ${host_state}= Get Host State
Rahul Maheshwarid01596e2017-02-20 00:04:42 -0600105 ${status}= Run Keyword And Return Status Should Be Equal
106 ... ${host_state} Quiesced
107 [Return] ${status}
108
George Keishingb88df3d2017-01-10 07:28:08 -0600109
Rahul Maheshwari09439a22017-02-23 01:10:05 -0600110Recover Quiesced Host
111 [Documentation] Recover host from quisced state.
112
113 ${resp}= Run Keyword And Return Status Is Host Quiesced
114 Run Keyword If '${resp}' == 'True'
115 ... Run Keywords Initiate Host PowerOff AND
116 ... Log HOST is recovered from quiesced state
117
118
George Keishingb88df3d2017-01-10 07:28:08 -0600119Get Host State
120 [Documentation] Return the state of the host as a string.
121 [Arguments] ${quiet}=${QUIET}
122 # quiet - Suppress REST output logging to console.
123 ${state}=
124 ... Read Attribute ${HOST_STATE_URI} CurrentHostState
125 ... quiet=${quiet}
George Keishing59d6cb42017-01-19 08:26:03 -0600126 [Return] ${state.rsplit('.', 1)[1]}
George Keishingb88df3d2017-01-10 07:28:08 -0600127
Rahul Maheshwarif7ead242017-02-14 01:59:42 -0600128Get Host Trans State
129 [Documentation] Return the transition state of host as a string.
130 ... e.g. On, Off, Reboot
131 [Arguments] ${quiet}=${QUIET}
132 # Description of arguments:
133 # quiet Suppress REST output logging to console.
134
135 ${state}=
136 ... Read Attribute ${HOST_STATE_URI} RequestedHostTransition
137 ... quiet=${quiet}
138 [Return] ${state.rsplit('.', 1)[1]}
George Keishingb88df3d2017-01-10 07:28:08 -0600139
140Get Chassis Power State
141 [Documentation] Return the power state of the Chassis
142 ... as a string.
143 [Arguments] ${quiet}=${QUIET}
144 # quiet - Suppress REST output logging to console.
145 ${state}=
146 ... Read Attribute ${CHASSIS_STATE_URI} CurrentPowerState
147 ... quiet=${quiet}
George Keishing59d6cb42017-01-19 08:26:03 -0600148 [Return] ${state.rsplit('.', 1)[1]}
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -0600149
150
151Get BMC State
152 [Documentation] Return the state of the BMC.
153 [Arguments] ${quiet}=${QUIET}
154 # quiet - Suppress REST output logging to console.
155 ${state}=
156 ... Read Attribute ${BMC_STATE_URI} CurrentBMCState quiet=${quiet}
157 [Return] ${state.rsplit('.', 1)[1]}
158
159
160Put BMC State
161 [Documentation] Put BMC in given state.
162 [Arguments] ${expected_state}
163 # expected_state - expected BMC state
164
165 ${bmc_state}= Get BMC State
166 Run Keyword If '${bmc_state}' == '${expected_state}'
167 ... Log BMC is already in ${expected_state} state
168 ... ELSE Run Keywords Initiate BMC Reboot AND
169 ... Wait for BMC state ${expected_state}
170
171
172Initiate BMC Reboot
173 [Documentation] Initiate BMC reboot.
174 ${args}= Create Dictionary data=${BMC_REBOOT_TRANS}
Rahul Maheshwari55a68e22017-04-20 04:36:21 -0500175
176 Run Keyword And Ignore Error Write Attribute
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -0600177 ... ${BMC_STATE_URI} RequestedBMCTransition data=${args}
178
179 ${session_active}= Check If BMC Reboot Is Initiated
180 Run Keyword If '${session_active}' == '${True}'
181 ... Fail msg=BMC Reboot didn't occur
182
183 Check If BMC is Up
184
185Check If BMC Reboot Is Initiated
186 [Documentation] Checks whether BMC Reboot is initiated by checking
187 ... BMC connection loss.
188 # Reboot adds 3 seconds delay before forcing reboot
189 # To minimize race conditions, we wait for 7 seconds
190 Sleep 7s
191 ${alive}= Run Keyword and Return Status
192 ... Open Connection And Log In
193 Return From Keyword If '${alive}' == '${False}' ${False}
194 [Return] ${True}
195
196Is BMC Ready
197 [Documentation] Check if BMC state is Ready.
198 ${bmc_state}= Get BMC State
199 Should Be Equal ${BMC_READY_STATE} ${bmc_state}
200
201Is BMC Not Ready
202 [Documentation] Check if BMC state is Not Ready.
203 ${bmc_state}= Get BMC State
204 Should Be Equal ${BMC_NOT_READY_STATE} ${bmc_state}
205
206Wait for BMC state
207 [Documentation] Wait until given BMC state is reached.
208 [Arguments] ${state}
209 # state - BMC state to wait for
210 Run Keyword If '${state}' == '${BMC_READY_STATE}'
211 ... Wait Until Keyword Succeeds
212 ... 10 min 10 sec Is BMC Ready
213 ... ELSE IF '${state}' == '${BMC_NOT_READY_STATE}'
214 ... Wait Until Keyword Succeeds
215 ... 10 min 10 sec Is BMC Not Ready
216 ... ELSE Fail msg=Invalid BMC state
George Keishing43a021f2017-01-30 11:10:13 -0600217
218
219Set State Interface Version
220 [Documentation] Set version to indicate which interface to use.
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600221 ${resp}= Openbmc Get Request ${CHASSIS_STATE_URI}
George Keishing43a021f2017-01-30 11:10:13 -0600222 ${status}= Run Keyword And Return Status
223 ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
224 Run Keyword If '${status}' == '${True}'
225 ... Set Global Variable ${OBMC_STATES_VERSION} ${1}
226 ... ELSE
227 ... Set Global Variable ${OBMC_STATES_VERSION} ${0}
228
229
230Power Off Request
231 [Documentation] Select appropriate poweroff keyword.
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600232 Run Keyword If '${OBMC_STATES_VERSION}' == '${0}'
George Keishing43a021f2017-01-30 11:10:13 -0600233 ... Initiate Power Off
234 ... ELSE
235 ... Initiate Host PowerOff
236
237
238Wait For BMC Ready
239 [Documentation] Check BMC state and wait for BMC Ready.
240 @{states}= Create List BMC_READY HOST_POWERED_OFF
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600241 Run Keyword If '${OBMC_STATES_VERSION}' == '${0}'
George Keishing43a021f2017-01-30 11:10:13 -0600242 ... Wait Until Keyword Succeeds 10 min 10 sec
243 ... Verify BMC State ${states}
244 ... ELSE
245 ... Wait Until Keyword Succeeds 10 min 10 sec
246 ... Is BMC Ready
247
248