blob: 5c4b9cfc27a240cd68f34e4117ff78bab0f8726e [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
George Keishing69e6f712016-09-12 06:30:09 -05007
8*** Keywords ***
9
10################################################################
11# Method : Call FFDC Methods #
12# Execute the user define keywords from the FFDC List #
13# Unlike any other keywords this will call into the #
14# list of keywords defined in the FFDC list at one go #
15################################################################
16
17Call FFDC Methods
18 [Documentation] Calls into FFDC Keyword index list
19
20 @{entries}= Get ffdc method index
21 :FOR ${index} IN @{entries}
22 \ Method Call Keyword List ${index}
23
24
25Method Call Keyword List
26 [Documentation] Iterate the list through keyword index
27 [Arguments] ${index}
28
29 @{method_list}= Get ffdc method call ${index}
30 :FOR ${method} IN @{method_list}
31 \ Execute Keyword Method ${method[1]}
32
33
34Execute Keyword Method
35 [Documentation] Calls into BMC method keywords. Don't let one
36 ... failure skips the remaining. Get whatever data
37 ... it could gather at worse case scenario.
38 [Arguments] ${keyword_name}
39
40 Run Keyword And Continue On Failure ${keyword_name}
41
42
43################################################################
44# Method : BMC FFDC Manifest #
45# Execute command on BMC and write to ffdc_report.txt #
46################################################################
47
48BMC FFDC Manifest
49 [Documentation] Get the commands index for the FFDC_BMC_CMD,
50 ... login to BMC and execute commands.
51 Open Connection And Log In
52
53 @{entries}= Get ffdc cmd index
54 :FOR ${index} IN @{entries}
55 \ Iterate BMC Command List Pairs ${index}
56
57
58Iterate BMC Command List Pairs
59 [Documentation] Feed in key pair list from dictionary to execute
60 [Arguments] ${key_index}
61
62 @{cmd_list}= Get ffdc bmc cmd ${key_index}
63 Set Suite Variable ${ENTRY_INDEX} ${key_index}
64 :FOR ${cmd} IN @{cmd_list}
65 \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]}
66
67
68Execute Command and Write FFDC
69 [Documentation] Execute command on BMC and write to ffdc
70 ... By default to ffdc_report.txt file else to
71 ... specified file path.
72 [Arguments] ${key_index}
73 ... ${cmd}
74 ... ${logpath}=${FFDC_FILE_PATH}
75
76 Run Keyword If '${logpath}' == '${FFDC_FILE_PATH}'
77 ... Write Cmd Output to FFDC File ${key_index} ${cmd}
78
79 ${stdout} ${stderr}=
80 ... Execute Command ${cmd} return_stderr=True
81
82 # Write stdout data on success and error msg to the file on failure
83 Run Keyword If '${stderr}' == '${EMPTY}'
84 ... Write Data to File ${stdout}${\n} ${logpath}
85 ... ELSE Run Keyword Write Data to File ${stderr}${\n} ${logpath}
86
87
88################################################################
89# Method : BMC FFDC Files #
90# Execute command on BMC and write to individual file #
91# based on the file name pre-defined in the list #
92################################################################
93
94BMC FFDC Files
95 [Documentation] Get the command list and iterate
96 Open Connection And Log In
97 @{entries}= Get ffdc file index
98 :FOR ${index} IN @{entries}
99 \ Create File and Write Data ${index}
100
101
102Create File and Write Data
103 [Documentation] Create files to current FFDC log directory,
104 ... executes command and write to corresponding
105 ... file name in the current FFDC directory.
106 [Arguments] ${key_index}
107
108 @{cmd_list}= Get ffdc bmc file ${key_index}
109 :FOR ${cmd} IN @{cmd_list}
110 \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}
111 \ Execute Command and Write FFDC ${cmd[0]} ${cmd[1]} ${logpath}
112
113
114################################################################
115# Method : Log Test Case Status #
116# Creates test result history footprint for reference #
117################################################################
118
119Log Test Case Status
120 [Documentation] Test case execution result history.
121 ... Create once and append to this file
122 ... logs/test_history.txt
123 ... Format Date:Test suite:Test case:Status
124 ... 20160909214053719992:Test Warmreset:Test WarmReset via REST:FAIL
125 Create Directory ${FFDC_LOG_PATH}
126
127 ${exist}= Run Keyword and Return Status
128 ... OperatingSystem.File Should Exist ${TEST_HISTORY}
129
130 Run Keyword If '${exist}' == '${False}'
131 ... Create File ${TEST_HISTORY}
132
133 ${cur_time}= Get Current Time Stamp
134
135 Append To File ${TEST_HISTORY}
136 ... ${cur_time}:${SUITE_NAME}:${TEST_NAME}:${TEST_STATUS}${\n}
137
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500138
139Log FFDC Get Requests
140 [Documentation] Create file in current FFDC log directory.
141 ... Do openbmc get request and write to
142 ... corresponding file name.
George Keishing8e47f532016-10-05 08:41:45 -0500143 ... JSON pretty print for logging to file.
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500144 [Arguments] ${key_index}
145
146 @{cmd_list}= Get ffdc get request ${key_index}
147 :FOR ${cmd} IN @{cmd_list}
148 \ ${logpath}= Catenate SEPARATOR= ${LOG_PREFIX} ${cmd[0]}
149 \ ${resp}= OpenBMC Get Request ${cmd[1]}
George Keishing8e47f532016-10-05 08:41:45 -0500150 \ ${status}= Run Keyword and Return Status
151 ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
152 \ Run Keyword If '${status}' == '${False}' Continue For Loop
153 \ ${jsondata}= to json ${resp.content} pretty_print=True
154 \ Write Data to File ${\n}${jsondata}${\n} ${logpath}
Gunnar Millsa812e0f2016-09-29 20:30:03 -0500155
156
157BMC FFDC Get Requests
158 [Documentation] Get the command list and iterate
159 Open Connection And Log In
160 @{entries}= Get ffdc get request index
161 :FOR ${index} IN @{entries}
162 \ Log FFDC Get Requests ${index}