blob: f08aadd285e4207a6f3b6dba78fe08602f8e11a5 [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
Gunnar Mills7e2cda22016-10-11 15:37:34 -05008
George Keishing69e6f712016-09-12 06:30:09 -05009*** Keywords ***
10
11################################################################
12# Method : Call FFDC Methods #
13# Execute the user define keywords from the FFDC List #
14# Unlike any other keywords this will call into the #
15# list of keywords defined in the FFDC list at one go #
16################################################################
17
18Call FFDC Methods
19 [Documentation] Calls into FFDC Keyword index list
20
21 @{entries}= Get ffdc method index
22 :FOR ${index} IN @{entries}
23 \ Method Call Keyword List ${index}
24
25
26Method Call Keyword List
27 [Documentation] Iterate the list through keyword index
28 [Arguments] ${index}
29
30 @{method_list}= Get ffdc method call ${index}
31 :FOR ${method} IN @{method_list}
32 \ Execute Keyword Method ${method[1]}
33
34
35Execute Keyword Method
36 [Documentation] Calls into BMC method keywords. Don't let one
37 ... failure skips the remaining. Get whatever data
38 ... it could gather at worse case scenario.
39 [Arguments] ${keyword_name}
40
41 Run Keyword And Continue On Failure ${keyword_name}
42
43
44################################################################
45# Method : BMC FFDC Manifest #
46# Execute command on BMC and write to ffdc_report.txt #
47################################################################
48
49BMC FFDC Manifest
50 [Documentation] Get the commands index for the FFDC_BMC_CMD,
51 ... login to BMC and execute commands.
52 Open Connection And Log In
53
54 @{entries}= Get ffdc cmd index
55 :FOR ${index} IN @{entries}
56 \ Iterate BMC Command List Pairs ${index}
57
58
59Iterate BMC Command List Pairs
60 [Documentation] Feed in key pair list from dictionary to execute
61 [Arguments] ${key_index}
62
63 @{cmd_list}= Get ffdc bmc cmd ${key_index}
64 Set Suite Variable ${ENTRY_INDEX} ${key_index}
65 :FOR ${cmd} IN @{cmd_list}
66 \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]}
67
68
69Execute Command and Write FFDC
Gunnar Millscce185d2016-10-17 17:04:15 -050070 [Documentation] Execute command on BMC or OS and write to ffdc
George Keishing69e6f712016-09-12 06:30:09 -050071 ... By default to ffdc_report.txt file else to
72 ... specified file path.
73 [Arguments] ${key_index}
74 ... ${cmd}
75 ... ${logpath}=${FFDC_FILE_PATH}
76
77 Run Keyword If '${logpath}' == '${FFDC_FILE_PATH}'
78 ... Write Cmd Output to FFDC File ${key_index} ${cmd}
79
80 ${stdout} ${stderr}=
81 ... Execute Command ${cmd} return_stderr=True
82
83 # Write stdout data on success and error msg to the file on failure
84 Run Keyword If '${stderr}' == '${EMPTY}'
85 ... Write Data to File ${stdout}${\n} ${logpath}
86 ... ELSE Run Keyword Write Data to File ${stderr}${\n} ${logpath}
87
88
89################################################################
90# Method : BMC FFDC Files #
91# Execute command on BMC and write to individual file #
92# based on the file name pre-defined in the list #
93################################################################
94
95BMC FFDC Files
96 [Documentation] Get the command list and iterate
97 Open Connection And Log In
98 @{entries}= Get ffdc file index
99 :FOR ${index} IN @{entries}
100 \ Create File and Write Data ${index}
101
102
103Create File and Write Data
104 [Documentation] Create files to current FFDC log directory,
105 ... executes command and write to corresponding
106 ... file name in the current FFDC directory.
107 [Arguments] ${key_index}
108
109 @{cmd_list}= Get ffdc bmc file ${key_index}
110 :FOR ${cmd} IN @{cmd_list}
Gunnar Mills50070fa2016-11-14 11:17:30 -0600111 \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt
George Keishing69e6f712016-09-12 06:30:09 -0500112 \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} ${logpath}
113
114
115################################################################
116# Method : Log Test Case Status #
117# Creates test result history footprint for reference #
118################################################################
119
120Log Test Case Status
121 [Documentation] Test case execution result history.
122 ... Create once and append to this file
123 ... logs/test_history.txt
124 ... Format Date:Test suite:Test case:Status
125 ... 20160909214053719992:Test Warmreset:Test WarmReset via REST:FAIL
126 Create Directory ${FFDC_LOG_PATH}
127
128 ${exist}= Run Keyword and Return Status
129 ... OperatingSystem.File Should Exist ${TEST_HISTORY}
130
131 Run Keyword If '${exist}' == '${False}'
132 ... Create File ${TEST_HISTORY}
133
134 ${cur_time}= Get Current Time Stamp
135
136 Append To File ${TEST_HISTORY}
137 ... ${cur_time}:${SUITE_NAME}:${TEST_NAME}:${TEST_STATUS}${\n}
138
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500139
140Log FFDC Get Requests
141 [Documentation] Create file in current FFDC log directory.
142 ... Do openbmc get request and write to
143 ... corresponding file name.
George Keishing8e47f532016-10-05 08:41:45 -0500144 ... JSON pretty print for logging to file.
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500145 [Arguments] ${key_index}
146
147 @{cmd_list}= Get ffdc get request ${key_index}
148 :FOR ${cmd} IN @{cmd_list}
Gunnar Mills50070fa2016-11-14 11:17:30 -0600149 \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500150 \ ${resp}= OpenBMC Get Request ${cmd[1]}
George Keishing8e47f532016-10-05 08:41:45 -0500151 \ ${status}= Run Keyword and Return Status
152 ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
153 \ Run Keyword If '${status}' == '${False}' Continue For Loop
154 \ ${jsondata}= to json ${resp.content} pretty_print=True
155 \ Write Data to File ${\n}${jsondata}${\n} ${logpath}
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500156
157
158BMC FFDC Get Requests
159 [Documentation] Get the command list and iterate
160 Open Connection And Log In
161 @{entries}= Get ffdc get request index
162 :FOR ${index} IN @{entries}
163 \ Log FFDC Get Requests ${index}
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500164
165
Gunnar Millscce185d2016-10-17 17:04:15 -0500166Log OS ALL DISTROS FFDC
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500167 [Documentation] Create file in current FFDC log directory.
168 ... Executes OS command and write to
169 ... corresponding file name.
170 [Arguments] ${key_index}
171
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500172 @{cmd_list}= get ffdc os all distros call ${key_index}
173 :FOR ${cmd} IN @{cmd_list}
Gunnar Mills50070fa2016-11-14 11:17:30 -0600174 \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500175 \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} ${logpath}
176
177
Gunnar Millscce185d2016-10-17 17:04:15 -0500178Log OS SPECIFIC DISTRO FFDC
179 [Documentation] Create file in current FFDC log directory.
180 ... Executes OS command and write to
181 ... corresponding file name.
182 [Arguments] ${key_index} ${linux_distro}
183
184 @{cmd_list}= get ffdc os distro call ${key_index} ${linux_distro}
185 :FOR ${cmd} IN @{cmd_list}
Gunnar Mills50070fa2016-11-14 11:17:30 -0600186 \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}.txt
Gunnar Millscce185d2016-10-17 17:04:15 -0500187 \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} ${logpath}
188
189
190
George Keishingca8c4c62016-10-14 10:08:40 -0500191OS FFDC Files
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500192 [Documentation] Get the command list and iterate
Gunnar Millsaca140d2016-10-26 13:05:10 -0500193 [Arguments] ${OS_HOST}=${OS_HOST} ${OS_USERNAME}=${OS_USERNAME}
194 ... ${OS_PASSWORD}=${OS_PASSWORD}
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500195
196 Return From Keyword If '${OS_HOST}' == '${EMPTY}'
197 ... No OS Host Provided
Gunnar Millsaca140d2016-10-26 13:05:10 -0500198
199 # If can't ping, return
200 ${rc}= Run Keyword and Return Status Ping Host ${OS_HOST}
201 Return From Keyword If '${rc}' == '${False}'
202 ... Could not ping OS
203
Gunnar Millscce185d2016-10-17 17:04:15 -0500204 Open Connection And Log In host=${OS_HOST} username=${OS_USERNAME}
205 ... password=${OS_PASSWORD}
206
Gunnar Millsaca140d2016-10-26 13:05:10 -0500207 ${output} ${stderr} ${rc}= Execute Command uptime return_stderr=True
208 ... return_rc=True
209
210 # If the return code returned by "Execute Command" is non-zero, return
211 Return From Keyword If '${rc}' != '${0}'
212 ... Could not connect to OS
213
Gunnar Mills7e2cda22016-10-11 15:37:34 -0500214 @{entries}= Get ffdc os all distros index
215 :FOR ${index} IN @{entries}
Gunnar Millscce185d2016-10-17 17:04:15 -0500216 \ Log OS ALL DISTROS FFDC ${index}
217
218 ${linux_distro}= Execute Command
219 ... . /etc/os-release; echo $ID
220 ... return_stdout=True return_stderr=False return_rc=False
221
222 Return From Keyword If '${linux_distro}' == '${EMPTY}' or '${linux_distro}' == 'None'
223 ... Could not determine Linux Distribution
224
225 @{entries}= Get ffdc os distro index ${linux_distro}
226 :FOR ${index} IN @{entries}
227 \ Log OS SPECIFIC DISTRO FFDC ${index} ${linux_distro}