| George Keishing | 78ea2dc | 2016-11-18 04:33:45 -0600 | [diff] [blame] | 1 | *** Settings *** | 
|  | 2 | Documentation     This module will take whatever action is necessary | 
|  | 3 | ...               to bring the BMC to a stable, standby state.  For our | 
|  | 4 | ...               purposes, a stable state is defined as: | 
|  | 5 | ...                  - BMC is communicating | 
|  | 6 | ...                   (pinging, sshing and REST commands working) | 
|  | 7 | ...                  - Power state is 0 (off) | 
|  | 8 | ...                  - BMC state is "BMC_READY" or "HOST_POWERED_OFF" | 
|  | 9 | ...                  - Boot policy is "RESTORE_LAST_STATE" | 
| George Keishing | 34d4b8d | 2016-12-07 08:35:29 -0600 | [diff] [blame] | 10 | ...               Power cycle system via PDU if specified | 
| George Keishing | 78ea2dc | 2016-11-18 04:33:45 -0600 | [diff] [blame] | 11 |  | 
|  | 12 | Resource          ../lib/boot/boot_resource_master.robot | 
|  | 13 | Resource          ../lib/utils.robot | 
| George Keishing | 34d4b8d | 2016-12-07 08:35:29 -0600 | [diff] [blame] | 14 | Resource          ../lib/pdu/pdu.robot | 
| George Keishing | 78ea2dc | 2016-11-18 04:33:45 -0600 | [diff] [blame] | 15 |  | 
|  | 16 | *** Variables *** | 
|  | 17 | ${HOST_SETTING}      /org/openbmc/settings/host0 | 
|  | 18 |  | 
| Gunnar Mills | 7c8923f | 2016-12-12 21:19:52 -0600 | [diff] [blame] | 19 | *** Test Cases *** | 
| George Keishing | 78ea2dc | 2016-11-18 04:33:45 -0600 | [diff] [blame] | 20 |  | 
|  | 21 | Get to Stable State | 
|  | 22 | [Documentation]    BMC cleanup drive to stable state | 
| George Keishing | 34d4b8d | 2016-12-07 08:35:29 -0600 | [diff] [blame] | 23 | ...                1. PDU powercycle if specified | 
| George Keishing | 78ea2dc | 2016-11-18 04:33:45 -0600 | [diff] [blame] | 24 | ...                1. Ping Test | 
|  | 25 | ...                2. SSH Connection session Test | 
|  | 26 | ...                3. REST Connection session Test | 
|  | 27 | ...                4. Reboot BMC if REST Test failed | 
|  | 28 | ...                5. Check BMC state for standby | 
|  | 29 | ...                6. Issue poweroff if not already in | 
|  | 30 | ...                   standby state | 
|  | 31 | ...                7. Update restore policy | 
|  | 32 | [Tags]  Get to Stable State | 
|  | 33 |  | 
| George Keishing | 34d4b8d | 2016-12-07 08:35:29 -0600 | [diff] [blame] | 34 | Run Keyword And Ignore Error   Powercycle System Via PDU | 
|  | 35 |  | 
| George Keishing | 78ea2dc | 2016-11-18 04:33:45 -0600 | [diff] [blame] | 36 | Wait For Host To Ping  ${OPENBMC_HOST}  1 mins | 
|  | 37 | Open Connection And Log In   host=${OPENBMC_HOST} | 
|  | 38 |  | 
| Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 39 | ${l_rest}=   Run Keyword And Return Status | 
| George Keishing | 78ea2dc | 2016-11-18 04:33:45 -0600 | [diff] [blame] | 40 | ...    Initialize OpenBMC | 
|  | 41 | Run Keyword If  '${l_rest}' == '${False}' | 
|  | 42 | ...    Reboot and Wait for BMC Online | 
|  | 43 |  | 
| Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 44 | ${l_ready}=   Run Keyword And Return Status | 
| George Keishing | 78ea2dc | 2016-11-18 04:33:45 -0600 | [diff] [blame] | 45 | ...    Get BMC State and Expect Standby | 
|  | 46 |  | 
|  | 47 | Run Keyword If  '${l_ready}' == '${False}' | 
|  | 48 | ...    Initiate Power Off | 
|  | 49 |  | 
| George Keishing | 7540056 | 2016-12-13 06:11:19 -0600 | [diff] [blame^] | 50 | Run Keyword And Ignore Error | 
|  | 51 | ...   Update Policy Setting   RESTORE_LAST_STATE | 
| George Keishing | 78ea2dc | 2016-11-18 04:33:45 -0600 | [diff] [blame] | 52 |  | 
|  | 53 |  | 
|  | 54 | *** Keywords *** | 
|  | 55 |  | 
|  | 56 | Reboot and Wait for BMC Online | 
|  | 57 | [Documentation]    Reboot BMC and wait for it to come online | 
|  | 58 | ...                and boot to standby | 
|  | 59 |  | 
|  | 60 | Trigger Warm Reset via Reboot | 
|  | 61 | Wait Until Keyword Succeeds | 
|  | 62 | ...    5 min   10 sec    BMC Online Test | 
|  | 63 |  | 
|  | 64 | Wait For BMC Standby | 
|  | 65 |  | 
|  | 66 |  | 
|  | 67 | BMC Online Test | 
|  | 68 | [Documentation]   BMC ping, SSH, REST connection Test | 
|  | 69 |  | 
| Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 70 | ${l_status}=   Run Keyword and Return Status | 
| George Keishing | 78ea2dc | 2016-11-18 04:33:45 -0600 | [diff] [blame] | 71 | ...   Verify Ping and REST Authentication | 
|  | 72 | Run Keyword If  '${l_status}' == '${False}' | 
|  | 73 | ...   Fail  msg=System not in ideal state to continue [ERROR] | 
|  | 74 |  | 
|  | 75 |  | 
|  | 76 | Wait For BMC Standby | 
|  | 77 | [Documentation]   Wait Until BMC standby post BMC reboot | 
|  | 78 |  | 
|  | 79 | @{states}=   Create List   BMC_READY   HOST_POWERED_OFF | 
|  | 80 | Wait Until Keyword Succeeds | 
|  | 81 | ...    10 min   10 sec   Verify BMC State   ${states} | 
|  | 82 |  | 
|  | 83 |  | 
|  | 84 | Get BMC State and Expect Standby | 
|  | 85 | [Documentation]   Get BMC state and should be at standby | 
|  | 86 |  | 
|  | 87 | @{states}=     Create List   BMC_READY   HOST_POWERED_OFF | 
|  | 88 | ${bmc_state}=  Get BMC State | 
|  | 89 | Should Contain  ${states}   ${bmc_state} | 
|  | 90 |  | 
|  | 91 |  | 
|  | 92 | Update Policy Setting | 
|  | 93 | [Documentation]   Update the given restore policy | 
| Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 94 | [Arguments]   ${policy} | 
| George Keishing | 78ea2dc | 2016-11-18 04:33:45 -0600 | [diff] [blame] | 95 |  | 
| Gunnar Mills | 597ffa0 | 2016-12-06 11:26:53 -0600 | [diff] [blame] | 96 | ${valueDict}=     create dictionary  data=${policy} | 
| George Keishing | 78ea2dc | 2016-11-18 04:33:45 -0600 | [diff] [blame] | 97 | Write Attribute    ${HOST_SETTING}    power_policy   data=${valueDict} | 
|  | 98 | ${currentPolicy}=  Read Attribute     ${HOST_SETTING}   power_policy | 
|  | 99 | Should Be Equal    ${currentPolicy}   ${policy} | 
|  | 100 |  | 
| George Keishing | d5123f7 | 2016-12-07 09:54:51 -0600 | [diff] [blame] | 101 |  | 
|  | 102 | Trigger Warm Reset via Reboot | 
|  | 103 | [Documentation]    Execute reboot command on the remote BMC and | 
|  | 104 | ...                returns immediately. This keyword "Start Command" | 
|  | 105 | ...                returns nothing and does not wait for the command | 
|  | 106 | ...                execution to be finished. | 
|  | 107 | Open Connection And Log In | 
|  | 108 |  | 
|  | 109 | Start Command   /sbin/reboot | 
| George Keishing | 34d4b8d | 2016-12-07 08:35:29 -0600 | [diff] [blame] | 110 |  | 
|  | 111 |  | 
|  | 112 | Powercycle System Via PDU | 
|  | 113 | [Documentation]   AC cycle the system via PDU | 
|  | 114 |  | 
|  | 115 | Validate Parameters | 
|  | 116 | PDU Power Cycle | 
|  | 117 | Check If BMC is Up   5 min    10 sec | 
|  | 118 |  | 
|  | 119 |  | 
|  | 120 | Validate Parameters | 
|  | 121 | Should Not Be Empty   ${PDU_IP} | 
|  | 122 | Should Not Be Empty   ${PDU_TYPE} | 
|  | 123 | Should Not Be Empty   ${PDU_SLOT_NO} | 
|  | 124 | Should Not Be Empty   ${PDU_USERNAME} | 
|  | 125 | Should Not Be Empty   ${PDU_PASSWORD} |