blob: 60d55bad1be252afe72c73eebb6fd2ca085b0ab6 [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.
George Keishing2bd6fc02017-08-10 01:15:16 -050070 Is OS Booted
71
72
73Get Host State Attribute
74 [Documentation] Return the state of the host as a string.
75 [Arguments] ${host_attribute} ${quiet}=${QUIET}
76
77 # Description of argument(s):
78 # host_attribute Host attribute name.
79 # quiet Suppress REST output logging to console.
80
81 ${state}=
82 ... Read Attribute ${HOST_STATE_URI} ${host_attribute} quiet=${quiet}
83 [Return] ${state}
84
85
86Is OS Booted
87 [Documentation] Check OS status.
88
89 # Example:
90 # "/xyz/openbmc_project/state/host0": {
91 # "AttemptsLeft": 0,
92 # "BootProgress": "xyz.openbmc_project.State.Boot.Progress.ProgressStages.OSStart",
93 # "CurrentHostState": "xyz.openbmc_project.State.Host.HostState.Running",
94 # "OperatingSystemState": "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.BootComplete",
95 # "RequestedHostTransition": "xyz.openbmc_project.State.Host.Transition.On"
96 # }
97
98 # TODO: Remove this logic once migration is complete.
99 ${status}= Run Keyword And Return Status Is OS Starting
100 Return From Keyword If '${status}' == '${True}' ${True}
101
102 ${boot_stage}= Get Host State Attribute BootProgress
103 Should Be Equal ${OS_BOOT_START} ${boot_stage}
104
105 ${os_state}= Get Host State Attribute OperatingSystemState
106 Should Be Equal ${OS_BOOT_COMPLETE} ${os_state}
George Keishingb88df3d2017-01-10 07:28:08 -0600107
108
109Is Host Off
Rahul Maheshwarif7ead242017-02-14 01:59:42 -0600110 [Documentation] Check if host state is "Off".
George Keishing13cc2102017-07-25 07:48:58 -0500111 # Chassis state should be "Off" before we check the host state.
112 Is Chassis Off
George Keishingb88df3d2017-01-10 07:28:08 -0600113 ${host_state}= Get Host State
George Keishing59d6cb42017-01-19 08:26:03 -0600114 Should Be Equal Off ${host_state}
George Keishing13cc2102017-07-25 07:48:58 -0500115 # Check to verify that the host shutdown completely.
Andrew Geissler854e9fe2017-07-29 09:51:13 -0500116 # TODO openbmc/openbmc#2049 - boot sensor not cleared on power off
117 #Is OS Off
George Keishingb88df3d2017-01-10 07:28:08 -0600118
Rahul Maheshwarif7ead242017-02-14 01:59:42 -0600119
120Is Host Rebooted
121 [Documentation] Checks if host rebooted.
122
123 ${host_trans_state}= Get Host Trans State
124 Should Be Equal ${host_trans_state} Reboot
125 Is Host Running
126
127
128Is Chassis On
129 [Documentation] Check if chassis state is "On".
130 ${power_state}= Get Chassis Power State
131 Should Be Equal On ${power_state}
132
133
134Is Chassis Off
135 [Documentation] Check if chassis state is "Off".
136 ${power_state}= Get Chassis Power State
137 Should Be Equal Off ${power_state}
138
Rahul Maheshwarid01596e2017-02-20 00:04:42 -0600139Is Host Quiesced
140 [Documentation] Check if host state is quiesced.
141 ${host_state}= Get Host State
Rahul Maheshwarid01596e2017-02-20 00:04:42 -0600142 ${status}= Run Keyword And Return Status Should Be Equal
143 ... ${host_state} Quiesced
144 [Return] ${status}
145
George Keishingb88df3d2017-01-10 07:28:08 -0600146
Rahul Maheshwari09439a22017-02-23 01:10:05 -0600147Recover Quiesced Host
148 [Documentation] Recover host from quisced state.
149
150 ${resp}= Run Keyword And Return Status Is Host Quiesced
151 Run Keyword If '${resp}' == 'True'
152 ... Run Keywords Initiate Host PowerOff AND
153 ... Log HOST is recovered from quiesced state
154
155
George Keishingb88df3d2017-01-10 07:28:08 -0600156Get Host State
157 [Documentation] Return the state of the host as a string.
158 [Arguments] ${quiet}=${QUIET}
159 # quiet - Suppress REST output logging to console.
160 ${state}=
161 ... Read Attribute ${HOST_STATE_URI} CurrentHostState
162 ... quiet=${quiet}
George Keishing59d6cb42017-01-19 08:26:03 -0600163 [Return] ${state.rsplit('.', 1)[1]}
George Keishingb88df3d2017-01-10 07:28:08 -0600164
Rahul Maheshwarif7ead242017-02-14 01:59:42 -0600165Get Host Trans State
166 [Documentation] Return the transition state of host as a string.
167 ... e.g. On, Off, Reboot
168 [Arguments] ${quiet}=${QUIET}
169 # Description of arguments:
170 # quiet Suppress REST output logging to console.
171
172 ${state}=
173 ... Read Attribute ${HOST_STATE_URI} RequestedHostTransition
174 ... quiet=${quiet}
175 [Return] ${state.rsplit('.', 1)[1]}
George Keishingb88df3d2017-01-10 07:28:08 -0600176
177Get Chassis Power State
178 [Documentation] Return the power state of the Chassis
179 ... as a string.
180 [Arguments] ${quiet}=${QUIET}
181 # quiet - Suppress REST output logging to console.
182 ${state}=
183 ... Read Attribute ${CHASSIS_STATE_URI} CurrentPowerState
184 ... quiet=${quiet}
George Keishing59d6cb42017-01-19 08:26:03 -0600185 [Return] ${state.rsplit('.', 1)[1]}
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -0600186
187
188Get BMC State
189 [Documentation] Return the state of the BMC.
190 [Arguments] ${quiet}=${QUIET}
191 # quiet - Suppress REST output logging to console.
192 ${state}=
193 ... Read Attribute ${BMC_STATE_URI} CurrentBMCState quiet=${quiet}
194 [Return] ${state.rsplit('.', 1)[1]}
195
196
197Put BMC State
198 [Documentation] Put BMC in given state.
199 [Arguments] ${expected_state}
200 # expected_state - expected BMC state
201
202 ${bmc_state}= Get BMC State
203 Run Keyword If '${bmc_state}' == '${expected_state}'
204 ... Log BMC is already in ${expected_state} state
205 ... ELSE Run Keywords Initiate BMC Reboot AND
206 ... Wait for BMC state ${expected_state}
207
208
209Initiate BMC Reboot
210 [Documentation] Initiate BMC reboot.
211 ${args}= Create Dictionary data=${BMC_REBOOT_TRANS}
Rahul Maheshwari55a68e22017-04-20 04:36:21 -0500212
213 Run Keyword And Ignore Error Write Attribute
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -0600214 ... ${BMC_STATE_URI} RequestedBMCTransition data=${args}
215
216 ${session_active}= Check If BMC Reboot Is Initiated
217 Run Keyword If '${session_active}' == '${True}'
218 ... Fail msg=BMC Reboot didn't occur
219
220 Check If BMC is Up
221
222Check If BMC Reboot Is Initiated
223 [Documentation] Checks whether BMC Reboot is initiated by checking
224 ... BMC connection loss.
225 # Reboot adds 3 seconds delay before forcing reboot
226 # To minimize race conditions, we wait for 7 seconds
227 Sleep 7s
228 ${alive}= Run Keyword and Return Status
229 ... Open Connection And Log In
230 Return From Keyword If '${alive}' == '${False}' ${False}
231 [Return] ${True}
232
233Is BMC Ready
234 [Documentation] Check if BMC state is Ready.
235 ${bmc_state}= Get BMC State
236 Should Be Equal ${BMC_READY_STATE} ${bmc_state}
237
238Is BMC Not Ready
239 [Documentation] Check if BMC state is Not Ready.
240 ${bmc_state}= Get BMC State
241 Should Be Equal ${BMC_NOT_READY_STATE} ${bmc_state}
242
243Wait for BMC state
244 [Documentation] Wait until given BMC state is reached.
245 [Arguments] ${state}
246 # state - BMC state to wait for
247 Run Keyword If '${state}' == '${BMC_READY_STATE}'
248 ... Wait Until Keyword Succeeds
249 ... 10 min 10 sec Is BMC Ready
250 ... ELSE IF '${state}' == '${BMC_NOT_READY_STATE}'
251 ... Wait Until Keyword Succeeds
252 ... 10 min 10 sec Is BMC Not Ready
253 ... ELSE Fail msg=Invalid BMC state
George Keishing43a021f2017-01-30 11:10:13 -0600254
255
256Set State Interface Version
257 [Documentation] Set version to indicate which interface to use.
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600258 ${resp}= Openbmc Get Request ${CHASSIS_STATE_URI}
George Keishing43a021f2017-01-30 11:10:13 -0600259 ${status}= Run Keyword And Return Status
260 ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
261 Run Keyword If '${status}' == '${True}'
262 ... Set Global Variable ${OBMC_STATES_VERSION} ${1}
263 ... ELSE
264 ... Set Global Variable ${OBMC_STATES_VERSION} ${0}
265
266
267Power Off Request
268 [Documentation] Select appropriate poweroff keyword.
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600269 Run Keyword If '${OBMC_STATES_VERSION}' == '${0}'
George Keishing43a021f2017-01-30 11:10:13 -0600270 ... Initiate Power Off
271 ... ELSE
272 ... Initiate Host PowerOff
273
274
275Wait For BMC Ready
276 [Documentation] Check BMC state and wait for BMC Ready.
277 @{states}= Create List BMC_READY HOST_POWERED_OFF
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600278 Run Keyword If '${OBMC_STATES_VERSION}' == '${0}'
George Keishing43a021f2017-01-30 11:10:13 -0600279 ... Wait Until Keyword Succeeds 10 min 10 sec
280 ... Verify BMC State ${states}
281 ... ELSE
282 ... Wait Until Keyword Succeeds 10 min 10 sec
283 ... Is BMC Ready
284
285