George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 1 | *** Settings *** |
George Keishing | bec365b | 2017-01-19 01:28:41 -0600 | [diff] [blame] | 2 | Resource ../lib/utils.robot |
| 3 | Variables ../data/variables.py |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 4 | |
| 5 | *** Variables *** |
| 6 | |
Rahul Maheshwari | 2f8de6c | 2017-01-17 07:00:22 -0600 | [diff] [blame] | 7 | ${BMC_READY_STATE} Ready |
| 8 | ${BMC_NOT_READY_STATE} NotReady |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 9 | ${QUIET} ${0} |
| 10 | |
| 11 | *** Keywords *** |
| 12 | |
| 13 | Initiate 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 | |
| 23 | Initiate 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 | |
| 33 | Is Host Running |
| 34 | [Documentation] Check if Chassis and Host state is ON. |
| 35 | ${power_state}= Get Chassis Power State |
George Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 36 | Should Be Equal On ${power_state} |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 37 | ${host_state}= Get Host State |
George Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 38 | Should Be Equal Running ${host_state} |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 39 | |
| 40 | |
| 41 | Is Host Off |
| 42 | [Documentation] Check if Chassis and Host state is OFF. |
| 43 | ${power_state}= Get Chassis Power State |
George Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 44 | Should Be Equal Off ${power_state} |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 45 | ${host_state}= Get Host State |
George Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 46 | Should Be Equal Off ${host_state} |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 47 | |
| 48 | |
| 49 | Get 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 Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 56 | [Return] ${state.rsplit('.', 1)[1]} |
George Keishing | b88df3d | 2017-01-10 07:28:08 -0600 | [diff] [blame] | 57 | |
| 58 | |
| 59 | Get 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 Keishing | 59d6cb4 | 2017-01-19 08:26:03 -0600 | [diff] [blame] | 67 | [Return] ${state.rsplit('.', 1)[1]} |
Rahul Maheshwari | 2f8de6c | 2017-01-17 07:00:22 -0600 | [diff] [blame] | 68 | |
| 69 | |
| 70 | Get 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 | |
| 79 | Put 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 | |
| 91 | Initiate 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 | |
| 103 | Check 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 | |
| 114 | Is 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 | |
| 119 | Is 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 | |
| 124 | Wait 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 |