blob: a9082f8ac5d2ceca26525589381138fcf5718f2b [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.
George Keishingfbea6042017-08-01 06:31:51 -050036 # 1. Request soft power off
37 # 2. Hard power off, if failed.
Michael Walsh67ef6222017-03-21 14:48:26 -050038 [Arguments] ${wait}=${1}
39
40 # Description of arguments:
41 # wait Indicates that this keyword should wait for host off state.
42
George Keishingb88df3d2017-01-10 07:28:08 -060043 ${args}= Create Dictionary data=${HOST_POWEROFF_TRANS}
44 Write Attribute
45 ... ${HOST_STATE_URI} RequestedHostTransition data=${args}
46
Michael Walsh67ef6222017-03-21 14:48:26 -050047 # Does caller want to wait for status?
48 Run Keyword If '${wait}' == '${0}' Return From Keyword
49
George Keishingfbea6042017-08-01 06:31:51 -050050 ${status}= Run Keyword And Return Status Wait For PowerOff
51
52 Run Keyword if '${status}' == '${False}' Hard Power Off
53
54
55Wait For PowerOff
56 [Documentation] Wait for power off state.
57
George Keishing2c54e692017-07-10 13:07:02 -050058 # TODO: Reference to open-power/skiboot#81.
59 # Revert to 3 minutes once fixed.
George Keishingfbea6042017-08-01 06:31:51 -050060 Wait Until Keyword Succeeds 6 min 10 sec Is Host Off
61
62
63Hard Power Off
64 [Documentation] Do a hard power off.
65
66 ${args}= Create Dictionary data=${CHASSIS_POWEROFF_TRANS}
67 Write Attribute
68 ... ${CHASSIS_STATE_URI} RequestedPowerTransition data=${args}
69
George Keishingb88df3d2017-01-10 07:28:08 -060070 Wait Until Keyword Succeeds
George Keishingfbea6042017-08-01 06:31:51 -050071 ... 1 min 10 sec Run Keywords Is Chassis Off AND Is Host Off
George Keishingb88df3d2017-01-10 07:28:08 -060072
73
Rahul Maheshwarif7ead242017-02-14 01:59:42 -060074Initiate Host Reboot
75 [Documentation] Initiate host reboot via REST.
76
77 ${args}= Create Dictionary data=${HOST_REBOOT_TRANS}
78 Write Attribute
79 ... ${HOST_STATE_URI} RequestedHostTransition data=${args}
80 Is Host Rebooted
81
82
George Keishingb88df3d2017-01-10 07:28:08 -060083Is Host Running
Rahul Maheshwarif7ead242017-02-14 01:59:42 -060084 [Documentation] Check if host state is "Running".
George Keishing13cc2102017-07-25 07:48:58 -050085 # Chassis state should be "On" before we check the host state.
86 Is Chassis On
George Keishingb88df3d2017-01-10 07:28:08 -060087 ${host_state}= Get Host State
George Keishing59d6cb42017-01-19 08:26:03 -060088 Should Be Equal Running ${host_state}
George Keishing13cc2102017-07-25 07:48:58 -050089 # Check to verify that the host is really booted.
George Keishing2bd6fc02017-08-10 01:15:16 -050090 Is OS Booted
91
92
93Get Host State Attribute
94 [Documentation] Return the state of the host as a string.
95 [Arguments] ${host_attribute} ${quiet}=${QUIET}
96
97 # Description of argument(s):
98 # host_attribute Host attribute name.
99 # quiet Suppress REST output logging to console.
100
101 ${state}=
102 ... Read Attribute ${HOST_STATE_URI} ${host_attribute} quiet=${quiet}
103 [Return] ${state}
104
105
106Is OS Booted
107 [Documentation] Check OS status.
108
109 # Example:
110 # "/xyz/openbmc_project/state/host0": {
111 # "AttemptsLeft": 0,
112 # "BootProgress": "xyz.openbmc_project.State.Boot.Progress.ProgressStages.OSStart",
113 # "CurrentHostState": "xyz.openbmc_project.State.Host.HostState.Running",
114 # "OperatingSystemState": "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.BootComplete",
115 # "RequestedHostTransition": "xyz.openbmc_project.State.Host.Transition.On"
116 # }
117
George Keishing2bd6fc02017-08-10 01:15:16 -0500118 ${boot_stage}= Get Host State Attribute BootProgress
119 Should Be Equal ${OS_BOOT_START} ${boot_stage}
120
121 ${os_state}= Get Host State Attribute OperatingSystemState
122 Should Be Equal ${OS_BOOT_COMPLETE} ${os_state}
George Keishingb88df3d2017-01-10 07:28:08 -0600123
124
125Is Host Off
Rahul Maheshwarif7ead242017-02-14 01:59:42 -0600126 [Documentation] Check if host state is "Off".
George Keishing13cc2102017-07-25 07:48:58 -0500127 # Chassis state should be "Off" before we check the host state.
128 Is Chassis Off
George Keishingb88df3d2017-01-10 07:28:08 -0600129 ${host_state}= Get Host State
George Keishing59d6cb42017-01-19 08:26:03 -0600130 Should Be Equal Off ${host_state}
George Keishing13cc2102017-07-25 07:48:58 -0500131 # Check to verify that the host shutdown completely.
Andrew Geissler854e9fe2017-07-29 09:51:13 -0500132 # TODO openbmc/openbmc#2049 - boot sensor not cleared on power off
133 #Is OS Off
George Keishingb88df3d2017-01-10 07:28:08 -0600134
Rahul Maheshwarif7ead242017-02-14 01:59:42 -0600135
136Is Host Rebooted
137 [Documentation] Checks if host rebooted.
138
139 ${host_trans_state}= Get Host Trans State
140 Should Be Equal ${host_trans_state} Reboot
141 Is Host Running
142
143
144Is Chassis On
145 [Documentation] Check if chassis state is "On".
146 ${power_state}= Get Chassis Power State
147 Should Be Equal On ${power_state}
148
149
150Is Chassis Off
151 [Documentation] Check if chassis state is "Off".
152 ${power_state}= Get Chassis Power State
153 Should Be Equal Off ${power_state}
154
Rahul Maheshwarid01596e2017-02-20 00:04:42 -0600155Is Host Quiesced
156 [Documentation] Check if host state is quiesced.
157 ${host_state}= Get Host State
Rahul Maheshwarid01596e2017-02-20 00:04:42 -0600158 ${status}= Run Keyword And Return Status Should Be Equal
159 ... ${host_state} Quiesced
160 [Return] ${status}
161
George Keishingb88df3d2017-01-10 07:28:08 -0600162
Rahul Maheshwari09439a22017-02-23 01:10:05 -0600163Recover Quiesced Host
164 [Documentation] Recover host from quisced state.
165
166 ${resp}= Run Keyword And Return Status Is Host Quiesced
167 Run Keyword If '${resp}' == 'True'
168 ... Run Keywords Initiate Host PowerOff AND
169 ... Log HOST is recovered from quiesced state
170
171
George Keishingb88df3d2017-01-10 07:28:08 -0600172Get Host State
173 [Documentation] Return the state of the host as a string.
174 [Arguments] ${quiet}=${QUIET}
175 # quiet - Suppress REST output logging to console.
176 ${state}=
177 ... Read Attribute ${HOST_STATE_URI} CurrentHostState
178 ... quiet=${quiet}
George Keishing59d6cb42017-01-19 08:26:03 -0600179 [Return] ${state.rsplit('.', 1)[1]}
George Keishingb88df3d2017-01-10 07:28:08 -0600180
Rahul Maheshwarif7ead242017-02-14 01:59:42 -0600181Get Host Trans State
182 [Documentation] Return the transition state of host as a string.
183 ... e.g. On, Off, Reboot
184 [Arguments] ${quiet}=${QUIET}
185 # Description of arguments:
186 # quiet Suppress REST output logging to console.
187
188 ${state}=
189 ... Read Attribute ${HOST_STATE_URI} RequestedHostTransition
190 ... quiet=${quiet}
191 [Return] ${state.rsplit('.', 1)[1]}
George Keishingb88df3d2017-01-10 07:28:08 -0600192
193Get Chassis Power State
194 [Documentation] Return the power state of the Chassis
195 ... as a string.
196 [Arguments] ${quiet}=${QUIET}
197 # quiet - Suppress REST output logging to console.
198 ${state}=
199 ... Read Attribute ${CHASSIS_STATE_URI} CurrentPowerState
200 ... quiet=${quiet}
George Keishing59d6cb42017-01-19 08:26:03 -0600201 [Return] ${state.rsplit('.', 1)[1]}
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -0600202
203
204Get BMC State
205 [Documentation] Return the state of the BMC.
206 [Arguments] ${quiet}=${QUIET}
207 # quiet - Suppress REST output logging to console.
208 ${state}=
209 ... Read Attribute ${BMC_STATE_URI} CurrentBMCState quiet=${quiet}
210 [Return] ${state.rsplit('.', 1)[1]}
211
212
213Put BMC State
214 [Documentation] Put BMC in given state.
215 [Arguments] ${expected_state}
216 # expected_state - expected BMC state
217
218 ${bmc_state}= Get BMC State
219 Run Keyword If '${bmc_state}' == '${expected_state}'
220 ... Log BMC is already in ${expected_state} state
221 ... ELSE Run Keywords Initiate BMC Reboot AND
222 ... Wait for BMC state ${expected_state}
223
224
225Initiate BMC Reboot
226 [Documentation] Initiate BMC reboot.
227 ${args}= Create Dictionary data=${BMC_REBOOT_TRANS}
Rahul Maheshwari55a68e22017-04-20 04:36:21 -0500228
229 Run Keyword And Ignore Error Write Attribute
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -0600230 ... ${BMC_STATE_URI} RequestedBMCTransition data=${args}
231
232 ${session_active}= Check If BMC Reboot Is Initiated
233 Run Keyword If '${session_active}' == '${True}'
234 ... Fail msg=BMC Reboot didn't occur
235
236 Check If BMC is Up
237
238Check If BMC Reboot Is Initiated
239 [Documentation] Checks whether BMC Reboot is initiated by checking
240 ... BMC connection loss.
241 # Reboot adds 3 seconds delay before forcing reboot
242 # To minimize race conditions, we wait for 7 seconds
243 Sleep 7s
244 ${alive}= Run Keyword and Return Status
245 ... Open Connection And Log In
246 Return From Keyword If '${alive}' == '${False}' ${False}
247 [Return] ${True}
248
249Is BMC Ready
250 [Documentation] Check if BMC state is Ready.
251 ${bmc_state}= Get BMC State
252 Should Be Equal ${BMC_READY_STATE} ${bmc_state}
253
254Is BMC Not Ready
255 [Documentation] Check if BMC state is Not Ready.
256 ${bmc_state}= Get BMC State
257 Should Be Equal ${BMC_NOT_READY_STATE} ${bmc_state}
258
259Wait for BMC state
260 [Documentation] Wait until given BMC state is reached.
261 [Arguments] ${state}
262 # state - BMC state to wait for
263 Run Keyword If '${state}' == '${BMC_READY_STATE}'
264 ... Wait Until Keyword Succeeds
265 ... 10 min 10 sec Is BMC Ready
266 ... ELSE IF '${state}' == '${BMC_NOT_READY_STATE}'
267 ... Wait Until Keyword Succeeds
268 ... 10 min 10 sec Is BMC Not Ready
269 ... ELSE Fail msg=Invalid BMC state
George Keishing43a021f2017-01-30 11:10:13 -0600270
271
272Set State Interface Version
273 [Documentation] Set version to indicate which interface to use.
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600274 ${resp}= Openbmc Get Request ${CHASSIS_STATE_URI}
George Keishing43a021f2017-01-30 11:10:13 -0600275 ${status}= Run Keyword And Return Status
276 ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
277 Run Keyword If '${status}' == '${True}'
278 ... Set Global Variable ${OBMC_STATES_VERSION} ${1}
279 ... ELSE
280 ... Set Global Variable ${OBMC_STATES_VERSION} ${0}
281
282
283Power Off Request
284 [Documentation] Select appropriate poweroff keyword.
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600285 Run Keyword If '${OBMC_STATES_VERSION}' == '${0}'
George Keishing43a021f2017-01-30 11:10:13 -0600286 ... Initiate Power Off
287 ... ELSE
288 ... Initiate Host PowerOff
289
290
291Wait For BMC Ready
292 [Documentation] Check BMC state and wait for BMC Ready.
293 @{states}= Create List BMC_READY HOST_POWERED_OFF
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600294 Run Keyword If '${OBMC_STATES_VERSION}' == '${0}'
George Keishing43a021f2017-01-30 11:10:13 -0600295 ... Wait Until Keyword Succeeds 10 min 10 sec
296 ... Verify BMC State ${states}
297 ... ELSE
298 ... Wait Until Keyword Succeeds 10 min 10 sec
299 ... Is BMC Ready
300
301