blob: efc40d0b2995405117a005cc96dd84a8d3bd5222 [file] [log] [blame]
George Keishing78ea2dc2016-11-18 04:33:45 -06001*** Settings ***
2Documentation 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 Keishing34d4b8d2016-12-07 08:35:29 -060010... Power cycle system via PDU if specified
George Keishing0bd59f12016-12-14 10:39:21 -060011... Prune archived journal logs
George Keishing78ea2dc2016-11-18 04:33:45 -060012
13Resource ../lib/boot/boot_resource_master.robot
14Resource ../lib/utils.robot
George Keishing34d4b8d2016-12-07 08:35:29 -060015Resource ../lib/pdu/pdu.robot
George Keishing78ea2dc2016-11-18 04:33:45 -060016
17*** Variables ***
18${HOST_SETTING} /org/openbmc/settings/host0
19
Gunnar Mills7c8923f2016-12-12 21:19:52 -060020*** Test Cases ***
George Keishing78ea2dc2016-11-18 04:33:45 -060021
22Get to Stable State
23 [Documentation] BMC cleanup drive to stable state
George Keishing34d4b8d2016-12-07 08:35:29 -060024 ... 1. PDU powercycle if specified
George Keishing78ea2dc2016-11-18 04:33:45 -060025 ... 1. Ping Test
26 ... 2. SSH Connection session Test
27 ... 3. REST Connection session Test
28 ... 4. Reboot BMC if REST Test failed
29 ... 5. Check BMC state for standby
30 ... 6. Issue poweroff if not already in
31 ... standby state
32 ... 7. Update restore policy
33 [Tags] Get to Stable State
34
George Keishing34d4b8d2016-12-07 08:35:29 -060035 Run Keyword And Ignore Error Powercycle System Via PDU
36
George Keishing78ea2dc2016-11-18 04:33:45 -060037 Wait For Host To Ping ${OPENBMC_HOST} 1 mins
38 Open Connection And Log In host=${OPENBMC_HOST}
39
Gunnar Mills597ffa02016-12-06 11:26:53 -060040 ${l_rest}= Run Keyword And Return Status
George Keishing78ea2dc2016-11-18 04:33:45 -060041 ... Initialize OpenBMC
42 Run Keyword If '${l_rest}' == '${False}'
43 ... Reboot and Wait for BMC Online
44
Gunnar Mills597ffa02016-12-06 11:26:53 -060045 ${l_ready}= Run Keyword And Return Status
George Keishing78ea2dc2016-11-18 04:33:45 -060046 ... Get BMC State and Expect Standby
47
48 Run Keyword If '${l_ready}' == '${False}'
49 ... Initiate Power Off
50
George Keishing0bd59f12016-12-14 10:39:21 -060051 Prune Journal Log
52
George Keishing75400562016-12-13 06:11:19 -060053 Run Keyword And Ignore Error
54 ... Update Policy Setting RESTORE_LAST_STATE
George Keishing78ea2dc2016-11-18 04:33:45 -060055
56
57*** Keywords ***
58
59Reboot and Wait for BMC Online
60 [Documentation] Reboot BMC and wait for it to come online
61 ... and boot to standby
62
63 Trigger Warm Reset via Reboot
64 Wait Until Keyword Succeeds
65 ... 5 min 10 sec BMC Online Test
66
67 Wait For BMC Standby
68
69
70BMC Online Test
71 [Documentation] BMC ping, SSH, REST connection Test
72
Gunnar Mills597ffa02016-12-06 11:26:53 -060073 ${l_status}= Run Keyword and Return Status
George Keishing78ea2dc2016-11-18 04:33:45 -060074 ... Verify Ping and REST Authentication
75 Run Keyword If '${l_status}' == '${False}'
76 ... Fail msg=System not in ideal state to continue [ERROR]
77
78
79Wait For BMC Standby
80 [Documentation] Wait Until BMC standby post BMC reboot
81
82 @{states}= Create List BMC_READY HOST_POWERED_OFF
83 Wait Until Keyword Succeeds
84 ... 10 min 10 sec Verify BMC State ${states}
85
86
87Get BMC State and Expect Standby
88 [Documentation] Get BMC state and should be at standby
89
90 @{states}= Create List BMC_READY HOST_POWERED_OFF
91 ${bmc_state}= Get BMC State
92 Should Contain ${states} ${bmc_state}
93
94
95Update Policy Setting
96 [Documentation] Update the given restore policy
Gunnar Mills38032802016-12-12 13:43:40 -060097 [Arguments] ${policy}
George Keishing78ea2dc2016-11-18 04:33:45 -060098
Gunnar Mills597ffa02016-12-06 11:26:53 -060099 ${valueDict}= create dictionary data=${policy}
George Keishing78ea2dc2016-11-18 04:33:45 -0600100 Write Attribute ${HOST_SETTING} power_policy data=${valueDict}
101 ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy
102 Should Be Equal ${currentPolicy} ${policy}
103
George Keishingd5123f72016-12-07 09:54:51 -0600104
105Trigger Warm Reset via Reboot
106 [Documentation] Execute reboot command on the remote BMC and
107 ... returns immediately. This keyword "Start Command"
108 ... returns nothing and does not wait for the command
109 ... execution to be finished.
110 Open Connection And Log In
111
112 Start Command /sbin/reboot
George Keishing34d4b8d2016-12-07 08:35:29 -0600113
114
115Powercycle System Via PDU
116 [Documentation] AC cycle the system via PDU
117
118 Validate Parameters
119 PDU Power Cycle
120 Check If BMC is Up 5 min 10 sec
121
122
123Validate Parameters
124 Should Not Be Empty ${PDU_IP}
125 Should Not Be Empty ${PDU_TYPE}
126 Should Not Be Empty ${PDU_SLOT_NO}
127 Should Not Be Empty ${PDU_USERNAME}
128 Should Not Be Empty ${PDU_PASSWORD}