blob: 33ce1704d3b7ff29435ab8818e4b4e4028cad81f [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.
Andrew Geissler854e9fe2017-07-29 09:51:13 -050080 # TODO openbmc/openbmc#2049 - boot sensor not cleared on power off
81 #Is OS Off
George Keishingb88df3d2017-01-10 07:28:08 -060082
Rahul Maheshwarif7ead242017-02-14 01:59:42 -060083
84Is Host Rebooted
85 [Documentation] Checks if host rebooted.
86
87 ${host_trans_state}= Get Host Trans State
88 Should Be Equal ${host_trans_state} Reboot
89 Is Host Running
90
91
92Is Chassis On
93 [Documentation] Check if chassis state is "On".
94 ${power_state}= Get Chassis Power State
95 Should Be Equal On ${power_state}
96
97
98Is Chassis Off
99 [Documentation] Check if chassis state is "Off".
100 ${power_state}= Get Chassis Power State
101 Should Be Equal Off ${power_state}
102
Rahul Maheshwarid01596e2017-02-20 00:04:42 -0600103Is Host Quiesced
104 [Documentation] Check if host state is quiesced.
105 ${host_state}= Get Host State
Rahul Maheshwarid01596e2017-02-20 00:04:42 -0600106 ${status}= Run Keyword And Return Status Should Be Equal
107 ... ${host_state} Quiesced
108 [Return] ${status}
109
George Keishingb88df3d2017-01-10 07:28:08 -0600110
Rahul Maheshwari09439a22017-02-23 01:10:05 -0600111Recover Quiesced Host
112 [Documentation] Recover host from quisced state.
113
114 ${resp}= Run Keyword And Return Status Is Host Quiesced
115 Run Keyword If '${resp}' == 'True'
116 ... Run Keywords Initiate Host PowerOff AND
117 ... Log HOST is recovered from quiesced state
118
119
George Keishingb88df3d2017-01-10 07:28:08 -0600120Get Host State
121 [Documentation] Return the state of the host as a string.
122 [Arguments] ${quiet}=${QUIET}
123 # quiet - Suppress REST output logging to console.
124 ${state}=
125 ... Read Attribute ${HOST_STATE_URI} CurrentHostState
126 ... quiet=${quiet}
George Keishing59d6cb42017-01-19 08:26:03 -0600127 [Return] ${state.rsplit('.', 1)[1]}
George Keishingb88df3d2017-01-10 07:28:08 -0600128
Rahul Maheshwarif7ead242017-02-14 01:59:42 -0600129Get Host Trans State
130 [Documentation] Return the transition state of host as a string.
131 ... e.g. On, Off, Reboot
132 [Arguments] ${quiet}=${QUIET}
133 # Description of arguments:
134 # quiet Suppress REST output logging to console.
135
136 ${state}=
137 ... Read Attribute ${HOST_STATE_URI} RequestedHostTransition
138 ... quiet=${quiet}
139 [Return] ${state.rsplit('.', 1)[1]}
George Keishingb88df3d2017-01-10 07:28:08 -0600140
141Get Chassis Power State
142 [Documentation] Return the power state of the Chassis
143 ... as a string.
144 [Arguments] ${quiet}=${QUIET}
145 # quiet - Suppress REST output logging to console.
146 ${state}=
147 ... Read Attribute ${CHASSIS_STATE_URI} CurrentPowerState
148 ... quiet=${quiet}
George Keishing59d6cb42017-01-19 08:26:03 -0600149 [Return] ${state.rsplit('.', 1)[1]}
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -0600150
151
152Get BMC State
153 [Documentation] Return the state of the BMC.
154 [Arguments] ${quiet}=${QUIET}
155 # quiet - Suppress REST output logging to console.
156 ${state}=
157 ... Read Attribute ${BMC_STATE_URI} CurrentBMCState quiet=${quiet}
158 [Return] ${state.rsplit('.', 1)[1]}
159
160
161Put BMC State
162 [Documentation] Put BMC in given state.
163 [Arguments] ${expected_state}
164 # expected_state - expected BMC state
165
166 ${bmc_state}= Get BMC State
167 Run Keyword If '${bmc_state}' == '${expected_state}'
168 ... Log BMC is already in ${expected_state} state
169 ... ELSE Run Keywords Initiate BMC Reboot AND
170 ... Wait for BMC state ${expected_state}
171
172
173Initiate BMC Reboot
174 [Documentation] Initiate BMC reboot.
175 ${args}= Create Dictionary data=${BMC_REBOOT_TRANS}
Rahul Maheshwari55a68e22017-04-20 04:36:21 -0500176
177 Run Keyword And Ignore Error Write Attribute
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -0600178 ... ${BMC_STATE_URI} RequestedBMCTransition data=${args}
179
180 ${session_active}= Check If BMC Reboot Is Initiated
181 Run Keyword If '${session_active}' == '${True}'
182 ... Fail msg=BMC Reboot didn't occur
183
184 Check If BMC is Up
185
186Check If BMC Reboot Is Initiated
187 [Documentation] Checks whether BMC Reboot is initiated by checking
188 ... BMC connection loss.
189 # Reboot adds 3 seconds delay before forcing reboot
190 # To minimize race conditions, we wait for 7 seconds
191 Sleep 7s
192 ${alive}= Run Keyword and Return Status
193 ... Open Connection And Log In
194 Return From Keyword If '${alive}' == '${False}' ${False}
195 [Return] ${True}
196
197Is BMC Ready
198 [Documentation] Check if BMC state is Ready.
199 ${bmc_state}= Get BMC State
200 Should Be Equal ${BMC_READY_STATE} ${bmc_state}
201
202Is BMC Not Ready
203 [Documentation] Check if BMC state is Not Ready.
204 ${bmc_state}= Get BMC State
205 Should Be Equal ${BMC_NOT_READY_STATE} ${bmc_state}
206
207Wait for BMC state
208 [Documentation] Wait until given BMC state is reached.
209 [Arguments] ${state}
210 # state - BMC state to wait for
211 Run Keyword If '${state}' == '${BMC_READY_STATE}'
212 ... Wait Until Keyword Succeeds
213 ... 10 min 10 sec Is BMC Ready
214 ... ELSE IF '${state}' == '${BMC_NOT_READY_STATE}'
215 ... Wait Until Keyword Succeeds
216 ... 10 min 10 sec Is BMC Not Ready
217 ... ELSE Fail msg=Invalid BMC state
George Keishing43a021f2017-01-30 11:10:13 -0600218
219
220Set State Interface Version
221 [Documentation] Set version to indicate which interface to use.
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600222 ${resp}= Openbmc Get Request ${CHASSIS_STATE_URI}
George Keishing43a021f2017-01-30 11:10:13 -0600223 ${status}= Run Keyword And Return Status
224 ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
225 Run Keyword If '${status}' == '${True}'
226 ... Set Global Variable ${OBMC_STATES_VERSION} ${1}
227 ... ELSE
228 ... Set Global Variable ${OBMC_STATES_VERSION} ${0}
229
230
231Power Off Request
232 [Documentation] Select appropriate poweroff keyword.
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600233 Run Keyword If '${OBMC_STATES_VERSION}' == '${0}'
George Keishing43a021f2017-01-30 11:10:13 -0600234 ... Initiate Power Off
235 ... ELSE
236 ... Initiate Host PowerOff
237
238
239Wait For BMC Ready
240 [Documentation] Check BMC state and wait for BMC Ready.
241 @{states}= Create List BMC_READY HOST_POWERED_OFF
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600242 Run Keyword If '${OBMC_STATES_VERSION}' == '${0}'
George Keishing43a021f2017-01-30 11:10:13 -0600243 ... Wait Until Keyword Succeeds 10 min 10 sec
244 ... Verify BMC State ${states}
245 ... ELSE
246 ... Wait Until Keyword Succeeds 10 min 10 sec
247 ... Is BMC Ready
248
249