blob: 233e782cb7c2ac9a590d87997d61f66bd80ac332 [file] [log] [blame]
Rahul Maheshwariad676bf2017-06-22 15:06:05 -05001*** Settings ***
2Documentation This module provides general keywords for dump.
3
Rahul Maheshwari1612ac92017-08-30 14:42:32 -05004Library bmc_ssh_utils.py
Rahul Maheshwariad676bf2017-06-22 15:06:05 -05005
6*** Variables ***
7
8*** Keywords ***
9
10Create User Initiated Dump
11 [Documentation] Generate user initiated dump and return
Steven Sombara011c022019-01-16 18:13:52 -060012 ... the dump id number (e.g., "5"). Optionally return EMPTY
13 ... if out of dump space.
14 [Arguments] ${check_out_of_space}=${False}
15
16 # Description of Argument(s):
17 # check_out_of_space If ${False}, a dump will be created and
18 # its dump_id will be returned.
19 # If ${True}, either the dump_id will be
20 # returned, or the value ${EMPTY} will be
21 # returned if out of dump space was
22 # detected when creating the dump.
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050023
24 ${data}= Create Dictionary data=@{EMPTY}
25 ${resp}= OpenBMC Post Request
Steven Sombara011c022019-01-16 18:13:52 -060026 ... ${DUMP_URI}action/CreateDump data=${data} quiet=${1}
27
28 Run Keyword If '${check_out_of_space}' == '${False}'
George Keishing656eb4a2019-09-03 03:48:01 -050029 ... Run Keyword And Return Get The Dump Id ${resp}
30 ... ELSE
31 ... Run Keyword And Return Check For Too Many Dumps ${resp}
Steven Sombara011c022019-01-16 18:13:52 -060032
33
34Get The Dump Id
35 [Documentation] Wait for the dump to be created. Return the
36 ... dump id number (e.g., "5").
37 [Arguments] ${resp}
38
39 # Description of Argument(s):
40 # resp Response object from action/Create Dump attempt.
41 # Example object:
42 # {
43 # "data": 5,
44 # "message": "200 OK",
45 # "status": "ok"
46 # },
47 # The "data" field conveys the id number of the created dump.
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050048
49 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
50 ${json}= To JSON ${resp.content}
George Keishing73c4ebf2017-11-13 07:10:28 -060051
George Keishing73c4ebf2017-11-13 07:10:28 -060052 Run Keyword If ${json["data"]} == ${None}
53 ... Fail Dump id returned null.
54
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050055 ${dump_id}= Set Variable ${json["data"]}
56
Rahul Maheshwarie2cd17f2017-09-26 21:26:50 -050057 Wait Until Keyword Succeeds 3 min 15 sec Check Dump Existence
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050058 ... ${dump_id}
59
60 [Return] ${dump_id}
61
62
Steven Sombara011c022019-01-16 18:13:52 -060063Check For Too Many Dumps
64 [Documentation] Return the dump_id number, or return ${EMPTY} if dump
65 ... creation failed due to too many dumps.
66 [Arguments] ${resp}
67
68 # Description of Argument(s):
69 # resp Response object from action/Create Dump attempt.
70 # Example object if there are too many dumps:
George Keishing506756e2019-08-06 01:07:55 -050071 # {
Steven Sombara011c022019-01-16 18:13:52 -060072 # "data": {
George Keishing506756e2019-08-06 01:07:55 -050073 # "description": "xyz.openbmc_project.Dump.Create.Error.QuotaExceeded"
74 # },
75 # "message": "Dump not captured due to a cap.",
Steven Sombara011c022019-01-16 18:13:52 -060076 # "status": "error"
George Keishing506756e2019-08-06 01:07:55 -050077 # }
Steven Sombara011c022019-01-16 18:13:52 -060078
79 # If dump was created normally, return the dump_id number.
80 Run Keyword If '${resp.status_code}' == '${HTTP_OK}'
81 ... Run Keyword And Return Get The Dump Id ${resp}
82
George Keishing506756e2019-08-06 01:07:55 -050083 ${json}= To JSON ${resp.content}
84 ${exception}= Set Variable ${json["message"]}
Steven Sombara011c022019-01-16 18:13:52 -060085 ${at_capacity}= Set Variable Dump not captured due to a cap
86 ${too_many_dumps}= Evaluate $at_capacity in $exception
Michael Walshc108e422019-03-28 12:27:18 -050087 Printn
Steven Sombara011c022019-01-16 18:13:52 -060088 Rprint Vars exception too_many_dumps
89 # If there are too many dumps, return ${EMPTY}, otherwise Fail.
90 ${status}= Run Keyword If ${too_many_dumps} Set Variable ${EMPTY}
91 ... ELSE Fail msg=${exception}.
92
93 [Return] ${status}
94
95
Rahul Maheshwari953038b2017-10-17 05:08:59 -050096Verify No Dump In Progress
97 [Documentation] Verify no dump in progress.
98
Rahul Maheshwari4cfdc392017-10-25 09:44:47 -050099 ${dump_progress} ${stderr} ${rc}= BMC Execute Command ls /tmp
100 Should Not Contain ${dump_progress} obmcdump
Rahul Maheshwari953038b2017-10-17 05:08:59 -0500101
102
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500103Check Dump Existence
104 [Documentation] Verify if given dump exist.
105 [Arguments] ${dump_id}
106
107 # Description of Argument(s):
108 # dump_id An integer value that identifies a particular dump
109 # object(e.g. 1, 3, 5).
110
George Keishing8d693382018-12-18 12:15:04 -0600111 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}${dump_id}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500112 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
113
114
115Delete BMC Dump
116 [Documentation] Deletes a given bmc dump.
117 [Arguments] ${dump_id}
118
119 # Description of Argument(s):
Gunnar Mills28e403b2017-10-25 16:16:38 -0500120 # dump_id An integer value that identifies a particular dump (e.g. 1, 3).
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500121
122 ${data}= Create Dictionary data=@{EMPTY}
123 ${resp}= OpenBMC Post Request
George Keishing8d693382018-12-18 12:15:04 -0600124 ... ${DUMP_ENTRY_URI}${dump_id}/action/Delete data=${data}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500125
126 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
127
128Delete All Dumps
129 [Documentation] Delete all dumps.
130
131 # Check if dump entries exist, if not return.
George Keishing6a6e76d2017-09-14 08:19:17 -0500132 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}list quiet=${1}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500133 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
134
135 # Get the list of dump entries and delete them all.
136 ${dump_entries}= Get URL List ${DUMP_ENTRY_URI}
Marissa Garza20ccfc72020-06-19 12:51:10 -0500137 FOR ${entry} IN @{dump_entries}
138 ${dump_id}= Fetch From Right ${entry} /
139 Delete BMC Dump ${dump_id}
140 END
George Keishingc9fcd092017-09-20 09:24:37 -0500141
Rahul Maheshwaride5d6f12020-10-14 02:08:00 -0500142
143Redfish Delete All BMC Dumps
144 [Documentation] Delete all BMC dumps via Redfish.
145
146 # Check if dump entries exist, if not return.
147 ${resp}= Redfish.Get /redfish/v1/Managers/bmc/LogServices/Dump/Entries
148 Return From Keyword If ${resp.dict["Members@odata.count"]} == ${0}
149
150 Redfish.Post /redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.ClearLog
151
152
George Keishingc9fcd092017-09-20 09:24:37 -0500153Delete All BMC Dump
154 [Documentation] Delete all BMC dump entries using "DeleteAll" interface.
155
156 ${data}= Create Dictionary data=@{EMPTY}
157 ${resp}= Openbmc Post Request ${DUMP_URI}action/DeleteAll data=${data}
158 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
George Keishingdc428762017-11-11 12:37:12 -0600159
George Keishingdc428762017-11-11 12:37:12 -0600160Dump Should Not Exist
161 [Documentation] Verify that BMC dumps do not exist.
162
George Keishing8d693382018-12-18 12:15:04 -0600163 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}list quiet=${1}
George Keishingdc428762017-11-11 12:37:12 -0600164 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
165
Steven Sombar336fa972019-11-07 13:12:58 -0600166Check Existence Of BMC Dump File
Sivas SRR7aabd792017-10-18 21:28:23 -0500167 [Documentation] Verify existence of BMC dump file.
168 [Arguments] ${dump_id}
169
170 # Description of argument(s):
171 # dump_id BMC dump identifier
172
173 ${dump_check_cmd}= Set Variable
174 ... ls /var/lib/phosphor-debug-collector/dumps
175
176 # Output of sample BMC Execute command with '2' as dump id is as follows
177 # ls /var/lib/phosphor-debug-collector/dumps/2
178 # obmcdump_2_XXXXXXXXXX.tar.xz
179 ${file_there} ${stderr} ${rc}= BMC Execute Command
180 ... ${dump_check_cmd}/${dump_id}
181 Should End With ${file_there} tar.xz msg=BMC dump file not found.
Rahul Maheshwari1612ac92017-08-30 14:42:32 -0500182
183Get Dump Entries
184 [Documentation] Return dump entries list.
185
186 ${dump_entries}= Get URL List ${DUMP_ENTRY_URI}
187 [Return] ${dump_entries}
188
189
190Trigger Core Dump
191 [Documentation] Trigger core dump.
192
193 # Find the pid of the active ipmid and kill it.
George Keishingbfd5c8f2018-07-11 10:27:28 -0500194 ${cmd_buf}= Catenate kill -s SEGV $(ps | egrep ' ipmid$' |
Rahul Maheshwari1612ac92017-08-30 14:42:32 -0500195 ... egrep -v grep | \ cut -c1-6)
196
197 ${cmd_output} ${stderr} ${rc}= BMC Execute Command ${cmd_buf}
198 Should Be Empty ${stderr} msg=BMC execute command error.
199 Should Be Equal As Integers ${rc} ${0}
200 ... msg=BMC execute command return code is not zero.