blob: 97533dc1968fdb26ea0243cb6885057e38df1dc7 [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
11*** Keywords ***
12
13Initiate Host Boot
14 [Documentation] Initiate host power on.
15 ${args}= Create Dictionary data=${HOST_POWERON_TRANS}
16 Write Attribute
17 ... ${HOST_STATE_URI} RequestedHostTransition data=${args}
18
19 Wait Until Keyword Succeeds
20 ... 10 min 10 sec Is Host Running
21
22
23Initiate Host PowerOff
24 [Documentation] Initiate host power off.
25 ${args}= Create Dictionary data=${HOST_POWEROFF_TRANS}
26 Write Attribute
27 ... ${HOST_STATE_URI} RequestedHostTransition data=${args}
28
29 Wait Until Keyword Succeeds
30 ... 3 min 10 sec Is Host Off
31
32
33Is Host Running
34 [Documentation] Check if Chassis and Host state is ON.
35 ${power_state}= Get Chassis Power State
George Keishing59d6cb42017-01-19 08:26:03 -060036 Should Be Equal On ${power_state}
George Keishingb88df3d2017-01-10 07:28:08 -060037 ${host_state}= Get Host State
George Keishing59d6cb42017-01-19 08:26:03 -060038 Should Be Equal Running ${host_state}
George Keishingb88df3d2017-01-10 07:28:08 -060039
40
41Is Host Off
42 [Documentation] Check if Chassis and Host state is OFF.
43 ${power_state}= Get Chassis Power State
George Keishing59d6cb42017-01-19 08:26:03 -060044 Should Be Equal Off ${power_state}
George Keishingb88df3d2017-01-10 07:28:08 -060045 ${host_state}= Get Host State
George Keishing59d6cb42017-01-19 08:26:03 -060046 Should Be Equal Off ${host_state}
George Keishingb88df3d2017-01-10 07:28:08 -060047
48
49Get Host State
50 [Documentation] Return the state of the host as a string.
51 [Arguments] ${quiet}=${QUIET}
52 # quiet - Suppress REST output logging to console.
53 ${state}=
54 ... Read Attribute ${HOST_STATE_URI} CurrentHostState
55 ... quiet=${quiet}
George Keishing59d6cb42017-01-19 08:26:03 -060056 [Return] ${state.rsplit('.', 1)[1]}
George Keishingb88df3d2017-01-10 07:28:08 -060057
58
59Get Chassis Power State
60 [Documentation] Return the power state of the Chassis
61 ... as a string.
62 [Arguments] ${quiet}=${QUIET}
63 # quiet - Suppress REST output logging to console.
64 ${state}=
65 ... Read Attribute ${CHASSIS_STATE_URI} CurrentPowerState
66 ... quiet=${quiet}
George Keishing59d6cb42017-01-19 08:26:03 -060067 [Return] ${state.rsplit('.', 1)[1]}
Rahul Maheshwari2f8de6c2017-01-17 07:00:22 -060068
69
70Get BMC State
71 [Documentation] Return the state of the BMC.
72 [Arguments] ${quiet}=${QUIET}
73 # quiet - Suppress REST output logging to console.
74 ${state}=
75 ... Read Attribute ${BMC_STATE_URI} CurrentBMCState quiet=${quiet}
76 [Return] ${state.rsplit('.', 1)[1]}
77
78
79Put BMC State
80 [Documentation] Put BMC in given state.
81 [Arguments] ${expected_state}
82 # expected_state - expected BMC state
83
84 ${bmc_state}= Get BMC State
85 Run Keyword If '${bmc_state}' == '${expected_state}'
86 ... Log BMC is already in ${expected_state} state
87 ... ELSE Run Keywords Initiate BMC Reboot AND
88 ... Wait for BMC state ${expected_state}
89
90
91Initiate BMC Reboot
92 [Documentation] Initiate BMC reboot.
93 ${args}= Create Dictionary data=${BMC_REBOOT_TRANS}
94 Write Attribute
95 ... ${BMC_STATE_URI} RequestedBMCTransition data=${args}
96
97 ${session_active}= Check If BMC Reboot Is Initiated
98 Run Keyword If '${session_active}' == '${True}'
99 ... Fail msg=BMC Reboot didn't occur
100
101 Check If BMC is Up
102
103Check If BMC Reboot Is Initiated
104 [Documentation] Checks whether BMC Reboot is initiated by checking
105 ... BMC connection loss.
106 # Reboot adds 3 seconds delay before forcing reboot
107 # To minimize race conditions, we wait for 7 seconds
108 Sleep 7s
109 ${alive}= Run Keyword and Return Status
110 ... Open Connection And Log In
111 Return From Keyword If '${alive}' == '${False}' ${False}
112 [Return] ${True}
113
114Is BMC Ready
115 [Documentation] Check if BMC state is Ready.
116 ${bmc_state}= Get BMC State
117 Should Be Equal ${BMC_READY_STATE} ${bmc_state}
118
119Is BMC Not Ready
120 [Documentation] Check if BMC state is Not Ready.
121 ${bmc_state}= Get BMC State
122 Should Be Equal ${BMC_NOT_READY_STATE} ${bmc_state}
123
124Wait for BMC state
125 [Documentation] Wait until given BMC state is reached.
126 [Arguments] ${state}
127 # state - BMC state to wait for
128 Run Keyword If '${state}' == '${BMC_READY_STATE}'
129 ... Wait Until Keyword Succeeds
130 ... 10 min 10 sec Is BMC Ready
131 ... ELSE IF '${state}' == '${BMC_NOT_READY_STATE}'
132 ... Wait Until Keyword Succeeds
133 ... 10 min 10 sec Is BMC Not Ready
134 ... ELSE Fail msg=Invalid BMC state