blob: f0fa402d1d4777639f0f5a7bf0c55420a389e53e [file] [log] [blame]
George Keishing69e6f712016-09-12 06:30:09 -05001*** Settings ***
2Documentation Methods to execute commands on BMC and collect
3... data to a list of FFDC files
4
5Resource openbmc_ffdc_utils.robot
George Keishing8e47f532016-10-05 08:41:45 -05006Resource rest_client.robot
Gunnar Millsaca140d2016-10-26 13:05:10 -05007Resource utils.robot
George Keishingab7a9072017-02-24 13:03:24 -06008Library SSHLibrary
Gunnar Mills7e2cda22016-10-11 15:37:34 -05009
George Keishing69e6f712016-09-12 06:30:09 -050010*** Keywords ***
11
12################################################################
13# Method : Call FFDC Methods #
14# Execute the user define keywords from the FFDC List #
15# Unlike any other keywords this will call into the #
16# list of keywords defined in the FFDC list at one go #
17################################################################
18
19Call FFDC Methods
20 [Documentation] Calls into FFDC Keyword index list
21
22 @{entries}= Get ffdc method index
23 :FOR ${index} IN @{entries}
24 \ Method Call Keyword List ${index}
George Keishingab7a9072017-02-24 13:03:24 -060025 SSHLibrary.Close All Connections
George Keishing69e6f712016-09-12 06:30:09 -050026
27
28Method Call Keyword List
29 [Documentation] Iterate the list through keyword index
30 [Arguments] ${index}
31
32 @{method_list}= Get ffdc method call ${index}
33 :FOR ${method} IN @{method_list}
34 \ Execute Keyword Method ${method[1]}
35
36
37Execute Keyword Method
38 [Documentation] Calls into BMC method keywords. Don't let one
39 ... failure skips the remaining. Get whatever data
40 ... it could gather at worse case scenario.
41 [Arguments] ${keyword_name}
42
43 Run Keyword And Continue On Failure ${keyword_name}
44
45
46################################################################
47# Method : BMC FFDC Manifest #
48# Execute command on BMC and write to ffdc_report.txt #
49################################################################
50
51BMC FFDC Manifest
52 [Documentation] Get the commands index for the FFDC_BMC_CMD,
53 ... login to BMC and execute commands.
54 Open Connection And Log In
55
56 @{entries}= Get ffdc cmd index
57 :FOR ${index} IN @{entries}
58 \ Iterate BMC Command List Pairs ${index}
59
60
61Iterate BMC Command List Pairs
62 [Documentation] Feed in key pair list from dictionary to execute
63 [Arguments] ${key_index}
64
65 @{cmd_list}= Get ffdc bmc cmd ${key_index}
66 Set Suite Variable ${ENTRY_INDEX} ${key_index}
67 :FOR ${cmd} IN @{cmd_list}
68 \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]}
69
70
71Execute Command and Write FFDC
Gunnar Millscce185d2016-10-17 17:04:15 -050072 [Documentation] Execute command on BMC or OS and write to ffdc
George Keishing69e6f712016-09-12 06:30:09 -050073 ... By default to ffdc_report.txt file else to
74 ... specified file path.
75 [Arguments] ${key_index}
76 ... ${cmd}
77 ... ${logpath}=${FFDC_FILE_PATH}
78
79 Run Keyword If '${logpath}' == '${FFDC_FILE_PATH}'
80 ... Write Cmd Output to FFDC File ${key_index} ${cmd}
81
82 ${stdout} ${stderr}=
83 ... Execute Command ${cmd} return_stderr=True
84
Jeff Whitlock7d805b22017-01-20 14:04:33 -060085 # Write stdout on success and stderr/stdout to the file on failure.
86 Run Keyword If $stderr == '${EMPTY}'
Sweta Potthuri15e6d2f2017-02-28 03:10:02 -060087 ... Write Data To File ${stdout}${\n} ${logpath}
88 ... ELSE Write Data To File
Jeff Whitlock7d805b22017-01-20 14:04:33 -060089 ... ERROR output:${\n}${stderr}${\n}Output:${\n}${stdout}${\n}
90 ... ${logpath}
George Keishing69e6f712016-09-12 06:30:09 -050091
92
93################################################################
94# Method : BMC FFDC Files #
95# Execute command on BMC and write to individual file #
96# based on the file name pre-defined in the list #
97################################################################
98
99BMC FFDC Files
100 [Documentation] Get the command list and iterate
101 Open Connection And Log In
102 @{entries}= Get ffdc file index
103 :FOR ${index} IN @{entries}
104 \ Create File and Write Data ${index}
105
106
107Create File and Write Data
108 [Documentation] Create files to current FFDC log directory,
109 ... executes command and write to corresponding
110 ... file name in the current FFDC directory.
111 [Arguments] ${key_index}
112
113 @{cmd_list}= Get ffdc bmc file ${key_index}
114 :FOR ${cmd} IN @{cmd_list}
Gunnar Mills50070fa2016-11-14 11:17:30 -0600115 \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt
George Keishing69e6f712016-09-12 06:30:09 -0500116 \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} ${logpath}
117
118
119################################################################
120# Method : Log Test Case Status #
121# Creates test result history footprint for reference #
122################################################################
123
124Log Test Case Status
Jeff Whitlock7d805b22017-01-20 14:04:33 -0600125 [Documentation] Test case execution result history.
126 ... Create once and append to this file
127 ... logs/test_history.txt
128 ... Format Date:Test suite:Test case:Status
129 ... 20160909214053719992:Test Warmreset:Test WarmReset via REST:FAIL
George Keishing69e6f712016-09-12 06:30:09 -0500130 Create Directory ${FFDC_LOG_PATH}
131
132 ${exist}= Run Keyword and Return Status
133 ... OperatingSystem.File Should Exist ${TEST_HISTORY}
134
135 Run Keyword If '${exist}' == '${False}'
136 ... Create File ${TEST_HISTORY}
137
138 ${cur_time}= Get Current Time Stamp
139
140 Append To File ${TEST_HISTORY}
141 ... ${cur_time}:${SUITE_NAME}:${TEST_NAME}:${TEST_STATUS}${\n}
142
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500143
144Log FFDC Get Requests
145 [Documentation] Create file in current FFDC log directory.
146 ... Do openbmc get request and write to
147 ... corresponding file name.
George Keishing8e47f532016-10-05 08:41:45 -0500148 ... JSON pretty print for logging to file.
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500149 [Arguments] ${key_index}
150
151 @{cmd_list}= Get ffdc get request ${key_index}
152 :FOR ${cmd} IN @{cmd_list}
Gunnar Mills50070fa2016-11-14 11:17:30 -0600153 \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt
George Keishingd71e9122016-11-30 11:15:21 -0600154 \ ${resp}= OpenBMC Get Request ${cmd[1]} quiet=${1}
George Keishing8e47f532016-10-05 08:41:45 -0500155 \ ${status}= Run Keyword and Return Status
156 ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
157 \ Run Keyword If '${status}' == '${False}' Continue For Loop
158 \ ${jsondata}= to json ${resp.content} pretty_print=True
Sweta Potthuri15e6d2f2017-02-28 03:10:02 -0600159 \ Write Data To File ${\n}${jsondata}${\n} ${logpath}
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500160
161
162BMC FFDC Get Requests
163 [Documentation] Get the command list and iterate
164 Open Connection And Log In
165 @{entries}= Get ffdc get request index
166 :FOR ${index} IN @{entries}
167 \ Log FFDC Get Requests ${index}
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500168
169
Gunnar Millscce185d2016-10-17 17:04:15 -0500170Log OS ALL DISTROS FFDC
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500171 [Documentation] Create file in current FFDC log directory.
172 ... Executes OS command and write to
173 ... corresponding file name.
174 [Arguments] ${key_index}
175
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500176 @{cmd_list}= get ffdc os all distros call ${key_index}
177 :FOR ${cmd} IN @{cmd_list}
Gunnar Mills50070fa2016-11-14 11:17:30 -0600178 \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500179 \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} ${logpath}
180
181
Gunnar Millscce185d2016-10-17 17:04:15 -0500182Log OS SPECIFIC DISTRO FFDC
183 [Documentation] Create file in current FFDC log directory.
184 ... Executes OS command and write to
185 ... corresponding file name.
186 [Arguments] ${key_index} ${linux_distro}
187
188 @{cmd_list}= get ffdc os distro call ${key_index} ${linux_distro}
189 :FOR ${cmd} IN @{cmd_list}
Gunnar Mills50070fa2016-11-14 11:17:30 -0600190 \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt
Gunnar Millscce185d2016-10-17 17:04:15 -0500191 \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} ${logpath}
192
193
194
George Keishingca8c4c62016-10-14 10:08:40 -0500195OS FFDC Files
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500196 [Documentation] Get the command list and iterate
Gunnar Millsaca140d2016-10-26 13:05:10 -0500197 [Arguments] ${OS_HOST}=${OS_HOST} ${OS_USERNAME}=${OS_USERNAME}
198 ... ${OS_PASSWORD}=${OS_PASSWORD}
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500199
200 Return From Keyword If '${OS_HOST}' == '${EMPTY}'
201 ... No OS Host Provided
Gunnar Millsaca140d2016-10-26 13:05:10 -0500202
203 # If can't ping, return
204 ${rc}= Run Keyword and Return Status Ping Host ${OS_HOST}
205 Return From Keyword If '${rc}' == '${False}'
206 ... Could not ping OS
207
Gunnar Millscce185d2016-10-17 17:04:15 -0500208 Open Connection And Log In host=${OS_HOST} username=${OS_USERNAME}
209 ... password=${OS_PASSWORD}
210
Gunnar Millsaca140d2016-10-26 13:05:10 -0500211 ${output} ${stderr} ${rc}= Execute Command uptime return_stderr=True
212 ... return_rc=True
213
214 # If the return code returned by "Execute Command" is non-zero, return
215 Return From Keyword If '${rc}' != '${0}'
216 ... Could not connect to OS
217
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500218 @{entries}= Get ffdc os all distros index
219 :FOR ${index} IN @{entries}
Gunnar Millscce185d2016-10-17 17:04:15 -0500220 \ Log OS ALL DISTROS FFDC ${index}
221
222 ${linux_distro}= Execute Command
223 ... . /etc/os-release; echo $ID
224 ... return_stdout=True return_stderr=False return_rc=False
225
Jeff Whitlock7d805b22017-01-20 14:04:33 -0600226 Return From Keyword If
227 ... '${linux_distro}' == '${EMPTY}' or '${linux_distro}' == 'None'
228 ... Could not determine Linux Distribution
Gunnar Millscce185d2016-10-17 17:04:15 -0500229
230 @{entries}= Get ffdc os distro index ${linux_distro}
231 :FOR ${index} IN @{entries}
232 \ Log OS SPECIFIC DISTRO FFDC ${index} ${linux_distro}
George Keishing7a520222017-02-27 09:44:30 -0600233
234
235##############################################################################
236SCP Coredump Files
237 [Documentation] Copy core dump file from BMC to local system.
238 # Check if core dump exist in the /tmp
239 Open Connection And Log In
Michael Walsh87b1ce32017-03-03 15:21:42 -0600240 ${core_files}= Execute Command ls /tmp/core_*
George Keishing7a520222017-02-27 09:44:30 -0600241 @{core_list} = Split String ${core_files}
242 # Copy the core files
243 Open Connection for SCP
244 :FOR ${index} IN @{core_list}
245 \ scp.Get File ${index} ${LOG_PREFIX}${index.lstrip("/tmp/")}
246 # Remove the file from remote to avoid re-copying on next FFDC call
247 \ Execute Command On BMC rm ${index}
248