blob: a1003148b635fe37c440631d1e5784e7e5048ab4 [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
Sushil Singh468d85f2022-11-30 07:33:36 -06005Variables ../data/variables.py
Rahul Maheshwariad676bf2017-06-22 15:06:05 -05006
7*** Variables ***
8
9*** Keywords ***
10
11Create User Initiated Dump
12 [Documentation] Generate user initiated dump and return
Steven Sombara011c022019-01-16 18:13:52 -060013 ... the dump id number (e.g., "5"). Optionally return EMPTY
14 ... if out of dump space.
15 [Arguments] ${check_out_of_space}=${False}
16
17 # Description of Argument(s):
18 # check_out_of_space If ${False}, a dump will be created and
19 # its dump_id will be returned.
20 # If ${True}, either the dump_id will be
21 # returned, or the value ${EMPTY} will be
22 # returned if out of dump space was
23 # detected when creating the dump.
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050024
George Keishing1dc8a1e2021-08-03 04:49:38 -050025 ${resp}= OpenBMC Get Request ${REST_DUMP_URI}
Ashwini Chandrappa314a7782025-07-24 23:46:33 -050026 IF '${resp.status_code}' == '${HTTP_NOT_FOUND}'
27 Set Global Variable ${REST_DUMP_URI} /xyz/openbmc_project/dump/
28 END
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -050029
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050030 ${data}= Create Dictionary data=@{EMPTY}
31 ${resp}= OpenBMC Post Request
George Keishing1dc8a1e2021-08-03 04:49:38 -050032 ... ${REST_DUMP_URI}action/CreateDump data=${data} quiet=${1}
Steven Sombara011c022019-01-16 18:13:52 -060033
Ashwini Chandrappa314a7782025-07-24 23:46:33 -050034 IF '${check_out_of_space}' == '${False}'
35 Run Keyword And Return Get The Dump Id ${resp}
36 ELSE
37 Run Keyword And Return Check For Too Many Dumps ${resp}
38 END
Steven Sombara011c022019-01-16 18:13:52 -060039
40Get The Dump Id
41 [Documentation] Wait for the dump to be created. Return the
42 ... dump id number (e.g., "5").
43 [Arguments] ${resp}
44
45 # Description of Argument(s):
46 # resp Response object from action/Create Dump attempt.
47 # Example object:
48 # {
49 # "data": 5,
50 # "message": "200 OK",
51 # "status": "ok"
52 # },
53 # The "data" field conveys the id number of the created dump.
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050054
55 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
George Keishing73c4ebf2017-11-13 07:10:28 -060056
Ashwini Chandrappa314a7782025-07-24 23:46:33 -050057 IF ${resp.json()["data"]} == ${None}
58 Fail Dump id returned null.
59 END
George Keishing73c4ebf2017-11-13 07:10:28 -060060
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050061 ${dump_id}= Set Variable ${json["data"]}
62
Rahul Maheshwarie2cd17f2017-09-26 21:26:50 -050063 Wait Until Keyword Succeeds 3 min 15 sec Check Dump Existence
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050064 ... ${dump_id}
65
George Keishing409df052024-01-17 22:36:14 +053066 RETURN ${dump_id}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050067
68
Steven Sombara011c022019-01-16 18:13:52 -060069Check For Too Many Dumps
70 [Documentation] Return the dump_id number, or return ${EMPTY} if dump
71 ... creation failed due to too many dumps.
72 [Arguments] ${resp}
73
74 # Description of Argument(s):
75 # resp Response object from action/Create Dump attempt.
76 # Example object if there are too many dumps:
George Keishing506756e2019-08-06 01:07:55 -050077 # {
Steven Sombara011c022019-01-16 18:13:52 -060078 # "data": {
George Keishing506756e2019-08-06 01:07:55 -050079 # "description": "xyz.openbmc_project.Dump.Create.Error.QuotaExceeded"
80 # },
81 # "message": "Dump not captured due to a cap.",
Steven Sombara011c022019-01-16 18:13:52 -060082 # "status": "error"
George Keishing506756e2019-08-06 01:07:55 -050083 # }
Steven Sombara011c022019-01-16 18:13:52 -060084
85 # If dump was created normally, return the dump_id number.
Ashwini Chandrappa314a7782025-07-24 23:46:33 -050086 IF '${resp.status_code}' == '${HTTP_OK}'
87 Run Keyword And Return Get The Dump Id ${resp}
88 END
Steven Sombara011c022019-01-16 18:13:52 -060089
George Keishingfbd67002022-08-01 11:24:03 -050090 ${exception}= Set Variable ${resp.json()["message"]}
Steven Sombara011c022019-01-16 18:13:52 -060091 ${at_capacity}= Set Variable Dump not captured due to a cap
92 ${too_many_dumps}= Evaluate $at_capacity in $exception
Michael Walshc108e422019-03-28 12:27:18 -050093 Printn
Steven Sombara011c022019-01-16 18:13:52 -060094 Rprint Vars exception too_many_dumps
95 # If there are too many dumps, return ${EMPTY}, otherwise Fail.
Ashwini Chandrappa314a7782025-07-24 23:46:33 -050096 ${status}= IF ${too_many_dumps} Set Variable ${EMPTY}
Steven Sombara011c022019-01-16 18:13:52 -060097 ... ELSE Fail msg=${exception}.
98
George Keishing409df052024-01-17 22:36:14 +053099 RETURN ${status}
Steven Sombara011c022019-01-16 18:13:52 -0600100
101
Rahul Maheshwari953038b2017-10-17 05:08:59 -0500102Verify No Dump In Progress
103 [Documentation] Verify no dump in progress.
104
Rahul Maheshwari4cfdc392017-10-25 09:44:47 -0500105 ${dump_progress} ${stderr} ${rc}= BMC Execute Command ls /tmp
106 Should Not Contain ${dump_progress} obmcdump
Rahul Maheshwari953038b2017-10-17 05:08:59 -0500107
108
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500109Check Dump Existence
110 [Documentation] Verify if given dump exist.
111 [Arguments] ${dump_id}
112
113 # Description of Argument(s):
114 # dump_id An integer value that identifies a particular dump
115 # object(e.g. 1, 3, 5).
116
George Keishing1dc8a1e2021-08-03 04:49:38 -0500117 ${resp}= OpenBMC Get Request ${REST_DUMP_URI}
Ashwini Chandrappa314a7782025-07-24 23:46:33 -0500118 IF '${resp.status_code}' == '${HTTP_NOT_FOUND}'
119 Set Global Variable ${DUMP_ENTRY_URI} /xyz/openbmc_project/dump/entry/
120 END
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500121
George Keishing8d693382018-12-18 12:15:04 -0600122 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}${dump_id}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500123 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
124
125
126Delete BMC Dump
127 [Documentation] Deletes a given bmc dump.
128 [Arguments] ${dump_id}
129
130 # Description of Argument(s):
Gunnar Mills28e403b2017-10-25 16:16:38 -0500131 # dump_id An integer value that identifies a particular dump (e.g. 1, 3).
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500132
George Keishing1dc8a1e2021-08-03 04:49:38 -0500133 ${resp}= OpenBMC Get Request ${REST_DUMP_URI}
Ashwini Chandrappa314a7782025-07-24 23:46:33 -0500134 IF '${resp.status_code}' == '${HTTP_NOT_FOUND}'
135 Set Global Variable ${DUMP_ENTRY_URI} /xyz/openbmc_project/dump/entry/
136 END
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500137
George Keishingfbd67002022-08-01 11:24:03 -0500138 ${args}= Set Variable {"data": []}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500139 ${resp}= OpenBMC Post Request
George Keishingfbd67002022-08-01 11:24:03 -0500140 ... ${DUMP_ENTRY_URI}${dump_id}/action/Delete data=${args}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500141
142 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
143
144Delete All Dumps
145 [Documentation] Delete all dumps.
146
George Keishing1dc8a1e2021-08-03 04:49:38 -0500147 ${resp}= OpenBMC Get Request ${REST_DUMP_URI}
Ashwini Chandrappa314a7782025-07-24 23:46:33 -0500148 IF '${resp.status_code}' == '${HTTP_NOT_FOUND}'
149 Set Global Variable ${DUMP_ENTRY_URI} /xyz/openbmc_project/dump/entry/
150 END
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500151
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500152 # Check if dump entries exist, if not return.
George Keishing6a6e76d2017-09-14 08:19:17 -0500153 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}list quiet=${1}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500154 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
155
156 # Get the list of dump entries and delete them all.
157 ${dump_entries}= Get URL List ${DUMP_ENTRY_URI}
Marissa Garza20ccfc72020-06-19 12:51:10 -0500158 FOR ${entry} IN @{dump_entries}
159 ${dump_id}= Fetch From Right ${entry} /
160 Delete BMC Dump ${dump_id}
161 END
George Keishingc9fcd092017-09-20 09:24:37 -0500162
Rahul Maheshwaride5d6f12020-10-14 02:08:00 -0500163
Rahul Maheshwari95cbceb2020-10-21 23:25:08 -0500164Redfish Delete BMC Dump
Sushil Singh472177b2023-08-28 05:28:30 -0500165 [Documentation] Deletes a given BMC dump via Redfish.
Rahul Maheshwari95cbceb2020-10-21 23:25:08 -0500166 [Arguments] ${dump_id}
167
168 # Description of Argument(s):
169 # dump_id An integer value that identifies a particular dump (e.g. 1, 3).
170
ganesanb4d430282023-04-27 14:33:23 +0000171 Redfish.Delete /redfish/v1/Managers/${MANAGER_ID}/LogServices/Dump/Entries/${dump_id}
Rahul Maheshwari95cbceb2020-10-21 23:25:08 -0500172
173
Rahul Maheshwaride5d6f12020-10-14 02:08:00 -0500174Redfish Delete All BMC Dumps
175 [Documentation] Delete all BMC dumps via Redfish.
176
177 # Check if dump entries exist, if not return.
ganesanb4d430282023-04-27 14:33:23 +0000178 ${resp}= Redfish.Get /redfish/v1/Managers/${MANAGER_ID}/LogServices/Dump/Entries
Rahul Maheshwaride5d6f12020-10-14 02:08:00 -0500179 Return From Keyword If ${resp.dict["Members@odata.count"]} == ${0}
180
ganesanb4d430282023-04-27 14:33:23 +0000181 Redfish.Post /redfish/v1/Managers/${MANAGER_ID}/LogServices/Dump/Actions/LogService.ClearLog
Rahul Maheshwaride5d6f12020-10-14 02:08:00 -0500182
183
Sushil Singh472177b2023-08-28 05:28:30 -0500184Redfish Get All System Dumps
185 [Documentation] Get the system dump log entries.
186
187 ${resp}= Redfish.Get ${REDFISH_SYSTEM_DUMP}
188
George Keishing409df052024-01-17 22:36:14 +0530189 RETURN ${resp.dict}
Sushil Singh472177b2023-08-28 05:28:30 -0500190
191
Sushil Singh468d85f2022-11-30 07:33:36 -0600192Get Redfish BMC Dump Log Entries
193 [Documentation] Get the BMC dump log entries.
194
195 ${resp}= Redfish.Get ${REDFISH_DUMP_URI}
196
George Keishing409df052024-01-17 22:36:14 +0530197 RETURN ${resp.dict}
Sushil Singh468d85f2022-11-30 07:33:36 -0600198
199
George Keishing2ef6a7d2021-05-19 09:05:32 -0500200Redfish Delete All System Dumps
201 [Documentation] Delete all system dumps via Redfish.
202
Yi Huc32434a2024-01-11 17:33:10 -0800203 Redfish.Post /redfish/v1/Systems/${SYSTEM_ID}/LogServices/Dump/Actions/LogService.ClearLog
George Keishing2ef6a7d2021-05-19 09:05:32 -0500204
205
Sushil Singh468d85f2022-11-30 07:33:36 -0600206Redfish BMC Dump Should Not Exist
207 [Documentation] Verify that there is no BMC dump at dump URI.
208
209 # Verify no dump exists.
210 ${dump_entries}= Get Redfish BMC Dump Log Entries
211 Should Be Equal As Integers 0 ${dump_entries['Members@odata.count']}
212
213
shilpa-parameshbc1e3942023-09-25 12:56:17 -0500214Redfish BMC Dump Should Exist
215 [Documentation] Check if BMC dump is generated.
216
217 ${dump_entries}= Get Redfish BMC Dump Log Entries
218 Should Be True ${dump_entries['Members@odata.count']} >= 1 msg=No BMC dump generated.
219
220
George Keishingc9fcd092017-09-20 09:24:37 -0500221Delete All BMC Dump
222 [Documentation] Delete all BMC dump entries using "DeleteAll" interface.
223
George Keishing1dc8a1e2021-08-03 04:49:38 -0500224 ${resp}= OpenBMC Get Request ${REST_DUMP_URI}
Ashwini Chandrappa314a7782025-07-24 23:46:33 -0500225 IF '${resp.status_code}' == '${HTTP_NOT_FOUND}'
226 Set Global Variable ${REST_DUMP_URI} /xyz/openbmc_project/dump/
227 END
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500228
George Keishingfbd67002022-08-01 11:24:03 -0500229 ${args}= Set Variable {"data": []}
230 ${resp}= Openbmc Post Request ${REST_DUMP_URI}action/DeleteAll data=${args}
George Keishingc9fcd092017-09-20 09:24:37 -0500231 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
George Keishingdc428762017-11-11 12:37:12 -0600232
George Keishingdc428762017-11-11 12:37:12 -0600233Dump Should Not Exist
234 [Documentation] Verify that BMC dumps do not exist.
235
George Keishing1dc8a1e2021-08-03 04:49:38 -0500236 ${resp}= OpenBMC Get Request ${REST_DUMP_URI}
Ashwini Chandrappa314a7782025-07-24 23:46:33 -0500237 IF '${resp.status_code}' == '${HTTP_NOT_FOUND}'
238 Set Global Variable ${DUMP_ENTRY_URI} /xyz/openbmc_project/dump/entry/
239 END
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500240
George Keishing8d693382018-12-18 12:15:04 -0600241 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}list quiet=${1}
George Keishingdc428762017-11-11 12:37:12 -0600242 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
243
Steven Sombar336fa972019-11-07 13:12:58 -0600244Check Existence Of BMC Dump File
Sivas SRR7aabd792017-10-18 21:28:23 -0500245 [Documentation] Verify existence of BMC dump file.
246 [Arguments] ${dump_id}
247
248 # Description of argument(s):
249 # dump_id BMC dump identifier
250
251 ${dump_check_cmd}= Set Variable
252 ... ls /var/lib/phosphor-debug-collector/dumps
253
254 # Output of sample BMC Execute command with '2' as dump id is as follows
255 # ls /var/lib/phosphor-debug-collector/dumps/2
256 # obmcdump_2_XXXXXXXXXX.tar.xz
257 ${file_there} ${stderr} ${rc}= BMC Execute Command
258 ... ${dump_check_cmd}/${dump_id}
259 Should End With ${file_there} tar.xz msg=BMC dump file not found.
Rahul Maheshwari1612ac92017-08-30 14:42:32 -0500260
261Get Dump Entries
262 [Documentation] Return dump entries list.
263
George Keishing1dc8a1e2021-08-03 04:49:38 -0500264 ${resp}= OpenBMC Get Request ${REST_DUMP_URI}
Ashwini Chandrappa314a7782025-07-24 23:46:33 -0500265 IF '${resp.status_code}' == '${HTTP_NOT_FOUND}'
266 Set Global Variable ${DUMP_ENTRY_URI} /xyz/openbmc_project/dump/entry/
267 END
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500268
Rahul Maheshwari1612ac92017-08-30 14:42:32 -0500269 ${dump_entries}= Get URL List ${DUMP_ENTRY_URI}
George Keishing409df052024-01-17 22:36:14 +0530270 RETURN ${dump_entries}
Rahul Maheshwari1612ac92017-08-30 14:42:32 -0500271
Rahul Maheshwari1612ac92017-08-30 14:42:32 -0500272Trigger Core Dump
273 [Documentation] Trigger core dump.
274
275 # Find the pid of the active ipmid and kill it.
George Keishingbfd5c8f2018-07-11 10:27:28 -0500276 ${cmd_buf}= Catenate kill -s SEGV $(ps | egrep ' ipmid$' |
Rahul Maheshwari1612ac92017-08-30 14:42:32 -0500277 ... egrep -v grep | \ cut -c1-6)
278
279 ${cmd_output} ${stderr} ${rc}= BMC Execute Command ${cmd_buf}
280 Should Be Empty ${stderr} msg=BMC execute command error.
281 Should Be Equal As Integers ${rc} ${0}
282 ... msg=BMC execute command return code is not zero.
Anusha Dathatrifd350222021-04-08 06:07:49 -0500283
Anusha Dathatri83ddaf92022-08-12 03:31:54 -0500284Initiate BMC Dump Using Redfish And Return Task Id
285 [Documentation] Initiate BMC dump via Redfish and return its task ID.
286
287 ${payload}= Create Dictionary DiagnosticDataType=Manager
288 ${resp}= Redfish.Post
ganesanb4d430282023-04-27 14:33:23 +0000289 ... /redfish/v1/Managers/${MANAGER_ID}/LogServices/Dump/Actions/LogService.CollectDiagnosticData
Anusha Dathatri83ddaf92022-08-12 03:31:54 -0500290 ... body=${payload} valid_status_codes=[${HTTP_ACCEPTED}]
291
292 # Example of response from above Redfish POST request.
293 # "@odata.id": "/redfish/v1/TaskService/Tasks/0",
294 # "@odata.type": "#Task.v1_4_3.Task",
295 # "Id": "0",
296 # "TaskState": "Running",
297 # "TaskStatus": "OK"
298
George Keishing409df052024-01-17 22:36:14 +0530299 RETURN ${resp.dict['Id']}
Anusha Dathatri83ddaf92022-08-12 03:31:54 -0500300
Tim Lee792e31e2021-12-10 14:10:46 +0800301Create User Initiated BMC Dump Via Redfish
302 [Documentation] Generate user initiated BMC dump via Redfish and return the dump id number (e.g., "5").
manashsarmafcbfdf62022-12-07 06:36:28 -0600303 [Arguments] ${skip_dump_completion}=0
304
305 # Description of Argument(s):
306 # skip_dump_completion If skip_dump_completion is set to 0, this
307 # keyword will waiting for BMC dump to
308 # complete and returns the dump id.
309 # Otherwise, the keyword is skipped after
310 # initiating BMC dump and returns dump task id.
Anusha Dathatrifd350222021-04-08 06:07:49 -0500311
312 ${payload}= Create Dictionary DiagnosticDataType=Manager
ganesanb4d430282023-04-27 14:33:23 +0000313 ${resp}= Redfish.Post /redfish/v1/Managers/${MANAGER_ID}/LogServices/Dump/Actions/LogService.CollectDiagnosticData
Tim Lee792e31e2021-12-10 14:10:46 +0800314 ... body=${payload} valid_status_codes=[${HTTP_ACCEPTED}]
Anusha Dathatrifd350222021-04-08 06:07:49 -0500315
316 # Example of response from above Redfish POST request.
317 # "@odata.id": "/redfish/v1/TaskService/Tasks/0",
318 # "@odata.type": "#Task.v1_4_3.Task",
319 # "Id": "0",
320 # "TaskState": "Running",
321 # "TaskStatus": "OK"
322
Ashwini Chandrappa314a7782025-07-24 23:46:33 -0500323 IF ${skip_dump_completion} != 0 Return From Keyword ${resp.dict['Id']}
Tim Lee792e31e2021-12-10 14:10:46 +0800324 Wait Until Keyword Succeeds 5 min 15 sec Check Task Completion ${resp.dict['Id']}
Anusha Dathatrifd350222021-04-08 06:07:49 -0500325 ${task_id}= Set Variable ${resp.dict['Id']}
Tim Lee792e31e2021-12-10 14:10:46 +0800326
327 ${task_dict}= Redfish.Get Properties /redfish/v1/TaskService/Tasks/${task_id}
328
329 # Example of HttpHeaders field of task details.
330 # "Payload": {
331 # "HttpHeaders": [
332 # "Host: <BMC_IP>",
333 # "Accept-Encoding: identity",
334 # "Connection: Keep-Alive",
335 # "Accept: */*",
336 # "Content-Length: 33",
ganesanb4d430282023-04-27 14:33:23 +0000337 # "Location: /redfish/v1/Managers/${MANAGER_ID}/LogServices/Dump/Entries/2"]
Tim Lee792e31e2021-12-10 14:10:46 +0800338 # ],
339 # "HttpOperation": "POST",
340 # "JsonBody": "{\"DiagnosticDataType\":\"Manager\"}",
ganesanb4d430282023-04-27 14:33:23 +0000341 # "TargetUri": "/redfish/v1/Managers/${MANAGER_ID}/LogServices/Dump/Actions/LogService.CollectDiagnosticData"
Tim Lee792e31e2021-12-10 14:10:46 +0800342 # }
343
George Keishing409df052024-01-17 22:36:14 +0530344 RETURN ${task_dict["Payload"]["HttpHeaders"][-1].split("/")[-1]}
Anusha Dathatrifd350222021-04-08 06:07:49 -0500345
346Auto Generate BMC Dump
347 [Documentation] Auto generate BMC dump.
348
Anusha Dathatri21961472021-06-10 03:16:35 -0500349 ${cmd}= Catenate busctl --verbose call xyz.openbmc_project.Dump.Manager
Anusha Dathatrif09efb82021-08-18 10:09:33 -0500350 ... /xyz/openbmc_project/dump/bmc xyz.openbmc_project.Dump.Create CreateDump a{sv} 0
Anusha Dathatri21961472021-06-10 03:16:35 -0500351 ${stdout} ${stderr} ${rc}=
352 ... BMC Execute Command ${cmd}
George Keishing409df052024-01-17 22:36:14 +0530353 RETURN ${stdout} ${stderr} ${rc}
Anusha Dathatrifd350222021-04-08 06:07:49 -0500354
355Get Dump Size
356 [Documentation] Get dump size.
Anusha Dathatrieed0e592021-04-21 03:17:12 -0500357 [Arguments] ${dump_uri}
Anusha Dathatrifd350222021-04-08 06:07:49 -0500358
359 # Description of argument(s):
Anusha Dathatrieed0e592021-04-21 03:17:12 -0500360 # dump_uri Dump URI
361 # (Eg. /xyz/openbmc_project/dump/bmc/entry/1).
Anusha Dathatrifd350222021-04-08 06:07:49 -0500362
Anusha Dathatrieed0e592021-04-21 03:17:12 -0500363 # Example of Dump entry.
364 # "data": {
365 # "CompletedTime": 1616760931,
366 # "Elapsed": 1616760931,
367 # "OffloadUri": "",
368 # "Offloaded": false,
369 # "Password": "",
370 # "Size": 3056,
371 # "SourceDumpId": 117440513,
372 # "StartTime": 1616760931,
373 # "Status": "xyz.openbmc_project.Common.Progress.OperationStatus.Completed",
374 # "VSPString": ""
375 # },
Anusha Dathatrifd350222021-04-08 06:07:49 -0500376
Anusha Dathatrieed0e592021-04-21 03:17:12 -0500377 Log ${dump_uri}
378 ${dump_data}= Redfish.Get Properties ${dump_uri}
George Keishing409df052024-01-17 22:36:14 +0530379 RETURN ${dump_data["data"]["Size"]}
Anusha Dathatrifd350222021-04-08 06:07:49 -0500380
381Get Dump ID
Anusha Dathatrieed0e592021-04-21 03:17:12 -0500382 [Documentation] Return dump ID.
Anusha Dathatrifd350222021-04-08 06:07:49 -0500383 [Arguments] ${task_id}
384
385 # Description of argument(s):
386 # task_id Task ID.
387
388 # Example of HttpHeaders field of task details.
389 # "Payload": {
390 # "HttpHeaders": [
391 # "Host: <BMC_IP>",
392 # "Accept-Encoding: identity",
393 # "Connection: Keep-Alive",
394 # "Accept: */*",
395 # "Content-Length: 33",
ganesanb4d430282023-04-27 14:33:23 +0000396 # "Location: /redfish/v1/Managers/${MANAGER_ID}/LogServices/Dump/Entries/2"]
Anusha Dathatrifd350222021-04-08 06:07:49 -0500397 # ],
398 # "HttpOperation": "POST",
399 # "JsonBody": "{\"DiagnosticDataType\":\"Manager\"}",
400 # "TargetUri":
ganesanb4d430282023-04-27 14:33:23 +0000401 # "/redfish/v1/Managers/${MANAGER_ID}/LogServices/Dump/Actions/LogService.CollectDiagnosticData"
Anusha Dathatrifd350222021-04-08 06:07:49 -0500402 # }
403
404 ${task_dict}= Redfish.Get Properties /redfish/v1/TaskService/Tasks/${task_id}
405 ${key} ${value}= Set Variable ${task_dict["Payload"]["HttpHeaders"][-1].split(":")}
Ashwini Chandrappa314a7782025-07-24 23:46:33 -0500406 IF '${key}' != 'Location' Fail
George Keishing409df052024-01-17 22:36:14 +0530407 RETURN ${value.strip('/').split('/')[-1]}
Anusha Dathatrifd350222021-04-08 06:07:49 -0500408
409Get Task Status
410 [Documentation] Return task status.
411 [Arguments] ${task_id}
412
413 # Description of argument(s):
414 # task_id Task ID.
415
416 ${resp}= Redfish.Get Properties /redfish/v1/TaskService/Tasks/${task_id}
George Keishing409df052024-01-17 22:36:14 +0530417 RETURN ${resp['TaskState']}
Anusha Dathatrifd350222021-04-08 06:07:49 -0500418
Anusha Dathatrieed0e592021-04-21 03:17:12 -0500419Check Task Completion
420 [Documentation] Check if the task is complete.
421 [Arguments] ${task_id}
422
423 # Description of argument(s):
424 # task_id Task ID.
425
Tim Lee792e31e2021-12-10 14:10:46 +0800426 ${task_dict}= Redfish.Get Properties /redfish/v1/TaskService/Tasks/${task_id}
427 Should Be Equal As Strings ${task_dict['TaskState']} Completed
Anusha Dathatrieed0e592021-04-21 03:17:12 -0500428
Anusha Dathatrifd350222021-04-08 06:07:49 -0500429Get Dump ID And Status
430 [Documentation] Return dump ID and status.
431 [Arguments] ${task_id}
432
433 # Description of argument(s):
434 # task_id Task ID.
435
Anusha Dathatri66af3c42022-08-08 10:18:48 -0500436 Wait Until Keyword Succeeds 10 min 15 sec Check Task Completion ${task_id}
437 ${dump_id}= Get Dump ID ${task_id}
George Keishing409df052024-01-17 22:36:14 +0530438 RETURN ${dump_id} Completed
aravinth0510350edc82022-09-30 06:33:48 +0000439
440
441Create BMC User Dump
442 [Documentation] Generate user initiated BMC dump via Redfish and return
443 ... the task instance Id and response object (e.g., "5").
444
445 ${payload}= Create Dictionary DiagnosticDataType=Manager
ganesanb4d430282023-04-27 14:33:23 +0000446 ${resp}= Redfish.Post /redfish/v1/Managers/${MANAGER_ID}/LogServices/Dump/Actions/LogService.CollectDiagnosticData
aravinth0510350edc82022-09-30 06:33:48 +0000447 ... body=${payload} valid_status_codes=[${HTTP_ACCEPTED}]
448
449 ${ip_resp}= Evaluate json.loads(r'''${resp.text}''') json
450
451 Return From Keyword ${ip_resp["Id"]} ${resp}
452
453
454Wait For Task Completion
455 [Documentation] Check whether the state of task instance matches any of the
456 ... expected completion states before maximum number of retries exceeds and
457 ... exit loop in case completion state is met.
458 [Arguments] ${task_id} ${expected_status} ${retry_max_count}=300
459 ... ${check_state}=${FALSE}
460
461 # Description of argument(s):
462 # task_id the task id for which completion is
463 # to be monitored.
464 # expected_status the task state which is to be considered as the
465 # end of task life cycle.
466 # retry_max_count the maximum number of retry count to wait for
467 # task to reach its completion state. Default
468 # value of retry_max_count is 300.
469 # check_state if set as TRUE, the task state will be
470 # monitored whether the task state value is
471 # valid throughout task life cycle until
472 # expected completion state is reached.
473 # Default value of check_state is FALSE.
474
475 FOR ${retry} IN RANGE ${retry_max_count}
476 ${resp}= Redfish.Get Properties /redfish/v1/TaskService/Tasks/${task_id}
477 ${current_task_state}= Set Variable ${resp["TaskState"]}
478 Rprint Vars current_task_state
479
Ashwini Chandrappa314a7782025-07-24 23:46:33 -0500480 IF ${check_state} == ${TRUE}
481 Should Be True '${resp["TaskState"]}' in ${allowed_task_state}
aravinth0510350edc82022-09-30 06:33:48 +0000482 ... msg=Verify task state is valid
Ashwini Chandrappa314a7782025-07-24 23:46:33 -0500483 END
aravinth0510350edc82022-09-30 06:33:48 +0000484 Exit For Loop If
485 ... '${resp["TaskState"]}' in ${expected_status}
486
487 Sleep 5s
harikaVi715ddf62022-11-29 01:01:59 -0600488 END
489
490Get Dump Status In BMC
Sushil Singh468d85f2022-11-30 07:33:36 -0600491 [Documentation] Get dump status from BMC using busctl method.
harikaVi715ddf62022-11-29 01:01:59 -0600492 [Arguments] ${dump_uri}
493
494 # Description of argument(s):
495 # dump_uri Dump URI E.g: /xyz/openbmc_project/dump/bmc/entry/7.
496
497 ${cmd}= Catenate busctl get-property xyz.openbmc_project.Dump.Manager
498 ... ${dump_uri} xyz.openbmc_project.Common.Progress Status
499
500 ${stdout} ${stderr} ${rc}= BMC Execute Command ${cmd}
501 Log ${stdout}
502 # Example output:
503 # s "xyz.openbmc_project.Common.Progress.OperationStatus.Completed".
504
505 ${status}= Set Variable ${stdout.split('.')[-1].strip('"')}
George Keishing409df052024-01-17 22:36:14 +0530506 RETURN ${status}
harikaVi715ddf62022-11-29 01:01:59 -0600507
508Verify Dump Status In BMC
509 [Documentation] Verify Dump Status in BMC.
510 [Arguments] ${dump_uri} ${expected_dump_status}
511
512 # Description of argument(s):
513 # dump_uri Dump URI E.g: /xyz/openbmc_project/dump/bmc/entry/7.
514 # expected_dump_status Expected Dump Status (Completed or Failed etc).
515
516 ${dump_status}= Get Dump Status In BMC ${dump_uri}
517 Should Be Equal ${dump_status} ${expected_dump_status}