blob: 979c82e51518d7a053e16fbc685f772e3f2d3d33 [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
George Keishing43a021f2017-01-30 11:10:13 -060011# "0" indicates that the new "xyz" interface should be used.
12${OBMC_STATES_VERSION} ${0}
13
George Keishingb88df3d2017-01-10 07:28:08 -060014*** Keywords ***
15
16Initiate Host Boot
17 [Documentation] Initiate host power on.
18 ${args}= Create Dictionary data=${HOST_POWERON_TRANS}
19 Write Attribute
20 ... ${HOST_STATE_URI} RequestedHostTransition data=${args}
21
22 Wait Until Keyword Succeeds
23 ... 10 min 10 sec Is Host Running
24
25
26Initiate Host PowerOff
27 [Documentation] Initiate host power off.
28 ${args}= Create Dictionary data=${HOST_POWEROFF_TRANS}
29 Write Attribute
30 ... ${HOST_STATE_URI} RequestedHostTransition data=${args}
31
32 Wait Until Keyword Succeeds
33 ... 3 min 10 sec Is Host Off
34
35
Rahul Maheshwarif7ead242017-02-14 01:59:42 -060036Initiate Host Reboot
37 [Documentation] Initiate host reboot via REST.
38
39 ${args}= Create Dictionary data=${HOST_REBOOT_TRANS}
40 Write Attribute
41 ... ${HOST_STATE_URI} RequestedHostTransition data=${args}
42 Is Host Rebooted
43
44
George Keishingb88df3d2017-01-10 07:28:08 -060045Is Host Running
Rahul Maheshwarif7ead242017-02-14 01:59:42 -060046 [Documentation] Check if host state is "Running".
George Keishingb88df3d2017-01-10 07:28:08 -060047 ${host_state}= Get Host State
George Keishing59d6cb42017-01-19 08:26:03 -060048 Should Be Equal Running ${host_state}
George Keishingb88df3d2017-01-10 07:28:08 -060049
50
51Is Host Off
Rahul Maheshwarif7ead242017-02-14 01:59:42 -060052 [Documentation] Check if host state is "Off".
George Keishingb88df3d2017-01-10 07:28:08 -060053 ${host_state}= Get Host State
George Keishing59d6cb42017-01-19 08:26:03 -060054 Should Be Equal Off ${host_state}
George Keishingb88df3d2017-01-10 07:28:08 -060055
Rahul Maheshwarif7ead242017-02-14 01:59:42 -060056
57Is Host Rebooted
58 [Documentation] Checks if host rebooted.
59
60 ${host_trans_state}= Get Host Trans State
61 Should Be Equal ${host_trans_state} Reboot
62 Is Host Running
63
64
65Is Chassis On
66 [Documentation] Check if chassis state is "On".
67 ${power_state}= Get Chassis Power State
68 Should Be Equal On ${power_state}
69
70
71Is Chassis Off
72 [Documentation] Check if chassis state is "Off".
73 ${power_state}= Get Chassis Power State
74 Should Be Equal Off ${power_state}
75
Rahul Maheshwarid01596e2017-02-20 00:04:42 -060076Is Host Quiesced
77 [Documentation] Check if host state is quiesced.
78 ${host_state}= Get Host State
Rahul Maheshwarid01596e2017-02-20 00:04:42 -060079 ${status}= Run Keyword And Return Status Should Be Equal
80 ... ${host_state} Quiesced
81 [Return] ${status}
82
George Keishingb88df3d2017-01-10 07:28:08 -060083
Rahul Maheshwari09439a22017-02-23 01:10:05 -060084Recover Quiesced Host
85 [Documentation] Recover host from quisced state.
86
87 ${resp}= Run Keyword And Return Status Is Host Quiesced
88 Run Keyword If '${resp}' == 'True'
89 ... Run Keywords Initiate Host PowerOff AND
90 ... Log HOST is recovered from quiesced state
91
92
George Keishingb88df3d2017-01-10 07:28:08 -060093Get Host State
94 [Documentation] Return the state of the host as a string.
95 [Arguments] ${quiet}=${QUIET}
96 # quiet - Suppress REST output logging to console.
97 ${state}=
98 ... Read Attribute ${HOST_STATE_URI} CurrentHostState
99 ... quiet=${quiet}
George Keishing59d6cb42017-01-19 08:26:03 -0600100 [Return] ${state.rsplit('.', 1)[1]}
George Keishingb88df3d2017-01-10 07:28:08 -0600101
Rahul Maheshwarif7ead242017-02-14 01:59:42 -0600102Get Host Trans State
103 [Documentation] Return the transition state of host as a string.
104 ... e.g. On, Off, Reboot
105 [Arguments] ${quiet}=${QUIET}
106 # Description of arguments:
107 # quiet Suppress REST output logging to console.
108
109 ${state}=
110 ... Read Attribute ${HOST_STATE_URI} RequestedHostTransition
111 ... quiet=${quiet}
112 [Return] ${state.rsplit('.', 1)[1]}
George Keishingb88df3d2017-01-10 07:28:08 -0600113
114Get Chassis Power State
115 [Documentation] Return the power state of the Chassis
116 ... as a string.
117 [Arguments] ${quiet}=${QUIET}
118 # quiet - Suppress REST output logging to console.
119 ${state}=
120 ... Read Attribute ${CHASSIS_STATE_URI} CurrentPowerState
121 ... quiet=${quiet}
George Keishing59d6cb42017-01-19 08:26:03 -0600122 [Return] ${state.rsplit('.', 1)[1]}
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -0600123
124
125Get BMC State
126 [Documentation] Return the state of the BMC.
127 [Arguments] ${quiet}=${QUIET}
128 # quiet - Suppress REST output logging to console.
129 ${state}=
130 ... Read Attribute ${BMC_STATE_URI} CurrentBMCState quiet=${quiet}
131 [Return] ${state.rsplit('.', 1)[1]}
132
133
134Put BMC State
135 [Documentation] Put BMC in given state.
136 [Arguments] ${expected_state}
137 # expected_state - expected BMC state
138
139 ${bmc_state}= Get BMC State
140 Run Keyword If '${bmc_state}' == '${expected_state}'
141 ... Log BMC is already in ${expected_state} state
142 ... ELSE Run Keywords Initiate BMC Reboot AND
143 ... Wait for BMC state ${expected_state}
144
145
146Initiate BMC Reboot
147 [Documentation] Initiate BMC reboot.
148 ${args}= Create Dictionary data=${BMC_REBOOT_TRANS}
149 Write Attribute
150 ... ${BMC_STATE_URI} RequestedBMCTransition data=${args}
151
152 ${session_active}= Check If BMC Reboot Is Initiated
153 Run Keyword If '${session_active}' == '${True}'
154 ... Fail msg=BMC Reboot didn't occur
155
156 Check If BMC is Up
157
158Check If BMC Reboot Is Initiated
159 [Documentation] Checks whether BMC Reboot is initiated by checking
160 ... BMC connection loss.
161 # Reboot adds 3 seconds delay before forcing reboot
162 # To minimize race conditions, we wait for 7 seconds
163 Sleep 7s
164 ${alive}= Run Keyword and Return Status
165 ... Open Connection And Log In
166 Return From Keyword If '${alive}' == '${False}' ${False}
167 [Return] ${True}
168
169Is BMC Ready
170 [Documentation] Check if BMC state is Ready.
171 ${bmc_state}= Get BMC State
172 Should Be Equal ${BMC_READY_STATE} ${bmc_state}
173
174Is BMC Not Ready
175 [Documentation] Check if BMC state is Not Ready.
176 ${bmc_state}= Get BMC State
177 Should Be Equal ${BMC_NOT_READY_STATE} ${bmc_state}
178
179Wait for BMC state
180 [Documentation] Wait until given BMC state is reached.
181 [Arguments] ${state}
182 # state - BMC state to wait for
183 Run Keyword If '${state}' == '${BMC_READY_STATE}'
184 ... Wait Until Keyword Succeeds
185 ... 10 min 10 sec Is BMC Ready
186 ... ELSE IF '${state}' == '${BMC_NOT_READY_STATE}'
187 ... Wait Until Keyword Succeeds
188 ... 10 min 10 sec Is BMC Not Ready
189 ... ELSE Fail msg=Invalid BMC state
George Keishing43a021f2017-01-30 11:10:13 -0600190
191
192Set State Interface Version
193 [Documentation] Set version to indicate which interface to use.
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600194 ${resp}= Openbmc Get Request ${CHASSIS_STATE_URI}
George Keishing43a021f2017-01-30 11:10:13 -0600195 ${status}= Run Keyword And Return Status
196 ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
197 Run Keyword If '${status}' == '${True}'
198 ... Set Global Variable ${OBMC_STATES_VERSION} ${1}
199 ... ELSE
200 ... Set Global Variable ${OBMC_STATES_VERSION} ${0}
201
202
203Power Off Request
204 [Documentation] Select appropriate poweroff keyword.
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600205 Run Keyword If '${OBMC_STATES_VERSION}' == '${0}'
George Keishing43a021f2017-01-30 11:10:13 -0600206 ... Initiate Power Off
207 ... ELSE
208 ... Initiate Host PowerOff
209
210
211Wait For BMC Ready
212 [Documentation] Check BMC state and wait for BMC Ready.
213 @{states}= Create List BMC_READY HOST_POWERED_OFF
Rahul Maheshwari073f8ad2017-03-02 00:55:22 -0600214 Run Keyword If '${OBMC_STATES_VERSION}' == '${0}'
George Keishing43a021f2017-01-30 11:10:13 -0600215 ... Wait Until Keyword Succeeds 10 min 10 sec
216 ... Verify BMC State ${states}
217 ... ELSE
218 ... Wait Until Keyword Succeeds 10 min 10 sec
219 ... Is BMC Ready
220
221