blob: bcd190eade586be110d7c46689341a0e62694c88 [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}
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -050026 Run Keyword If '${resp.status_code}' == '${HTTP_NOT_FOUND}'
George Keishing1dc8a1e2021-08-03 04:49:38 -050027 ... Set Global Variable ${REST_DUMP_URI} /xyz/openbmc_project/dump/
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -050028
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050029 ${data}= Create Dictionary data=@{EMPTY}
30 ${resp}= OpenBMC Post Request
George Keishing1dc8a1e2021-08-03 04:49:38 -050031 ... ${REST_DUMP_URI}action/CreateDump data=${data} quiet=${1}
Steven Sombara011c022019-01-16 18:13:52 -060032
33 Run Keyword If '${check_out_of_space}' == '${False}'
George Keishing656eb4a2019-09-03 03:48:01 -050034 ... Run Keyword And Return Get The Dump Id ${resp}
35 ... ELSE
36 ... Run Keyword And Return Check For Too Many Dumps ${resp}
Steven Sombara011c022019-01-16 18:13:52 -060037
38
39Get The Dump Id
40 [Documentation] Wait for the dump to be created. Return the
41 ... dump id number (e.g., "5").
42 [Arguments] ${resp}
43
44 # Description of Argument(s):
45 # resp Response object from action/Create Dump attempt.
46 # Example object:
47 # {
48 # "data": 5,
49 # "message": "200 OK",
50 # "status": "ok"
51 # },
52 # The "data" field conveys the id number of the created dump.
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050053
54 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
George Keishing73c4ebf2017-11-13 07:10:28 -060055
George Keishingfbd67002022-08-01 11:24:03 -050056 Run Keyword If ${resp.json()["data"]} == ${None}
George Keishing73c4ebf2017-11-13 07:10:28 -060057 ... Fail Dump id returned null.
58
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050059 ${dump_id}= Set Variable ${json["data"]}
60
Rahul Maheshwarie2cd17f2017-09-26 21:26:50 -050061 Wait Until Keyword Succeeds 3 min 15 sec Check Dump Existence
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050062 ... ${dump_id}
63
64 [Return] ${dump_id}
65
66
Steven Sombara011c022019-01-16 18:13:52 -060067Check For Too Many Dumps
68 [Documentation] Return the dump_id number, or return ${EMPTY} if dump
69 ... creation failed due to too many dumps.
70 [Arguments] ${resp}
71
72 # Description of Argument(s):
73 # resp Response object from action/Create Dump attempt.
74 # Example object if there are too many dumps:
George Keishing506756e2019-08-06 01:07:55 -050075 # {
Steven Sombara011c022019-01-16 18:13:52 -060076 # "data": {
George Keishing506756e2019-08-06 01:07:55 -050077 # "description": "xyz.openbmc_project.Dump.Create.Error.QuotaExceeded"
78 # },
79 # "message": "Dump not captured due to a cap.",
Steven Sombara011c022019-01-16 18:13:52 -060080 # "status": "error"
George Keishing506756e2019-08-06 01:07:55 -050081 # }
Steven Sombara011c022019-01-16 18:13:52 -060082
83 # If dump was created normally, return the dump_id number.
84 Run Keyword If '${resp.status_code}' == '${HTTP_OK}'
85 ... Run Keyword And Return Get The Dump Id ${resp}
86
George Keishingfbd67002022-08-01 11:24:03 -050087 ${exception}= Set Variable ${resp.json()["message"]}
Steven Sombara011c022019-01-16 18:13:52 -060088 ${at_capacity}= Set Variable Dump not captured due to a cap
89 ${too_many_dumps}= Evaluate $at_capacity in $exception
Michael Walshc108e422019-03-28 12:27:18 -050090 Printn
Steven Sombara011c022019-01-16 18:13:52 -060091 Rprint Vars exception too_many_dumps
92 # If there are too many dumps, return ${EMPTY}, otherwise Fail.
93 ${status}= Run Keyword If ${too_many_dumps} Set Variable ${EMPTY}
94 ... ELSE Fail msg=${exception}.
95
96 [Return] ${status}
97
98
Rahul Maheshwari953038b2017-10-17 05:08:59 -050099Verify No Dump In Progress
100 [Documentation] Verify no dump in progress.
101
Rahul Maheshwari4cfdc392017-10-25 09:44:47 -0500102 ${dump_progress} ${stderr} ${rc}= BMC Execute Command ls /tmp
103 Should Not Contain ${dump_progress} obmcdump
Rahul Maheshwari953038b2017-10-17 05:08:59 -0500104
105
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500106Check Dump Existence
107 [Documentation] Verify if given dump exist.
108 [Arguments] ${dump_id}
109
110 # Description of Argument(s):
111 # dump_id An integer value that identifies a particular dump
112 # object(e.g. 1, 3, 5).
113
George Keishing1dc8a1e2021-08-03 04:49:38 -0500114 ${resp}= OpenBMC Get Request ${REST_DUMP_URI}
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500115 Run Keyword If '${resp.status_code}' == '${HTTP_NOT_FOUND}'
George Keishing73d8f242021-03-19 08:51:56 -0500116 ... Set Global Variable ${DUMP_ENTRY_URI} /xyz/openbmc_project/dump/entry/
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500117
George Keishing8d693382018-12-18 12:15:04 -0600118 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}${dump_id}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500119 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
120
121
122Delete BMC Dump
123 [Documentation] Deletes a given bmc dump.
124 [Arguments] ${dump_id}
125
126 # Description of Argument(s):
Gunnar Mills28e403b2017-10-25 16:16:38 -0500127 # dump_id An integer value that identifies a particular dump (e.g. 1, 3).
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500128
George Keishing1dc8a1e2021-08-03 04:49:38 -0500129 ${resp}= OpenBMC Get Request ${REST_DUMP_URI}
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500130 Run Keyword If '${resp.status_code}' == '${HTTP_NOT_FOUND}'
George Keishing73d8f242021-03-19 08:51:56 -0500131 ... Set Global Variable ${DUMP_ENTRY_URI} /xyz/openbmc_project/dump/entry/
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500132
George Keishingfbd67002022-08-01 11:24:03 -0500133 ${args}= Set Variable {"data": []}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500134 ${resp}= OpenBMC Post Request
George Keishingfbd67002022-08-01 11:24:03 -0500135 ... ${DUMP_ENTRY_URI}${dump_id}/action/Delete data=${args}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500136
137 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
138
139Delete All Dumps
140 [Documentation] Delete all dumps.
141
George Keishing1dc8a1e2021-08-03 04:49:38 -0500142 ${resp}= OpenBMC Get Request ${REST_DUMP_URI}
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500143 Run Keyword If '${resp.status_code}' == '${HTTP_NOT_FOUND}'
George Keishing73d8f242021-03-19 08:51:56 -0500144 ... Set Global Variable ${DUMP_ENTRY_URI} /xyz/openbmc_project/dump/entry/
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500145
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500146 # Check if dump entries exist, if not return.
George Keishing6a6e76d2017-09-14 08:19:17 -0500147 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}list quiet=${1}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -0500148 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
149
150 # Get the list of dump entries and delete them all.
151 ${dump_entries}= Get URL List ${DUMP_ENTRY_URI}
Marissa Garza20ccfc72020-06-19 12:51:10 -0500152 FOR ${entry} IN @{dump_entries}
153 ${dump_id}= Fetch From Right ${entry} /
154 Delete BMC Dump ${dump_id}
155 END
George Keishingc9fcd092017-09-20 09:24:37 -0500156
Rahul Maheshwaride5d6f12020-10-14 02:08:00 -0500157
Rahul Maheshwari95cbceb2020-10-21 23:25:08 -0500158Redfish Delete BMC Dump
159 [Documentation] Deletes a given BMC dump via Redfish..
160 [Arguments] ${dump_id}
161
162 # Description of Argument(s):
163 # dump_id An integer value that identifies a particular dump (e.g. 1, 3).
164
165 Redfish.Delete /redfish/v1/Managers/bmc/LogServices/Dump/Entries/${dump_id}
166
167
Rahul Maheshwaride5d6f12020-10-14 02:08:00 -0500168Redfish Delete All BMC Dumps
169 [Documentation] Delete all BMC dumps via Redfish.
170
171 # Check if dump entries exist, if not return.
172 ${resp}= Redfish.Get /redfish/v1/Managers/bmc/LogServices/Dump/Entries
173 Return From Keyword If ${resp.dict["Members@odata.count"]} == ${0}
174
175 Redfish.Post /redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.ClearLog
176
177
Sushil Singh468d85f2022-11-30 07:33:36 -0600178Get Redfish BMC Dump Log Entries
179 [Documentation] Get the BMC dump log entries.
180
181 ${resp}= Redfish.Get ${REDFISH_DUMP_URI}
182
183 [Return] ${resp.dict}
184
185
George Keishing2ef6a7d2021-05-19 09:05:32 -0500186Redfish Delete All System Dumps
187 [Documentation] Delete all system dumps via Redfish.
188
189 Redfish.Post /redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.ClearLog
190
191
Sushil Singh468d85f2022-11-30 07:33:36 -0600192Redfish BMC Dump Should Not Exist
193 [Documentation] Verify that there is no BMC dump at dump URI.
194
195 # Verify no dump exists.
196 ${dump_entries}= Get Redfish BMC Dump Log Entries
197 Should Be Equal As Integers 0 ${dump_entries['Members@odata.count']}
198
199
George Keishingc9fcd092017-09-20 09:24:37 -0500200Delete All BMC Dump
201 [Documentation] Delete all BMC dump entries using "DeleteAll" interface.
202
George Keishing1dc8a1e2021-08-03 04:49:38 -0500203 ${resp}= OpenBMC Get Request ${REST_DUMP_URI}
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500204 Run Keyword If '${resp.status_code}' == '${HTTP_NOT_FOUND}'
George Keishing1dc8a1e2021-08-03 04:49:38 -0500205 ... Set Global Variable ${REST_DUMP_URI} /xyz/openbmc_project/dump/
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500206
George Keishingfbd67002022-08-01 11:24:03 -0500207 ${args}= Set Variable {"data": []}
208 ${resp}= Openbmc Post Request ${REST_DUMP_URI}action/DeleteAll data=${args}
George Keishingc9fcd092017-09-20 09:24:37 -0500209 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
George Keishingdc428762017-11-11 12:37:12 -0600210
George Keishingdc428762017-11-11 12:37:12 -0600211Dump Should Not Exist
212 [Documentation] Verify that BMC dumps do not exist.
213
George Keishing1dc8a1e2021-08-03 04:49:38 -0500214 ${resp}= OpenBMC Get Request ${REST_DUMP_URI}
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500215 Run Keyword If '${resp.status_code}' == '${HTTP_NOT_FOUND}'
George Keishing73d8f242021-03-19 08:51:56 -0500216 ... Set Global Variable ${DUMP_ENTRY_URI} /xyz/openbmc_project/dump/entry/
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500217
George Keishing8d693382018-12-18 12:15:04 -0600218 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}list quiet=${1}
George Keishingdc428762017-11-11 12:37:12 -0600219 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
220
Steven Sombar336fa972019-11-07 13:12:58 -0600221Check Existence Of BMC Dump File
Sivas SRR7aabd792017-10-18 21:28:23 -0500222 [Documentation] Verify existence of BMC dump file.
223 [Arguments] ${dump_id}
224
225 # Description of argument(s):
226 # dump_id BMC dump identifier
227
228 ${dump_check_cmd}= Set Variable
229 ... ls /var/lib/phosphor-debug-collector/dumps
230
231 # Output of sample BMC Execute command with '2' as dump id is as follows
232 # ls /var/lib/phosphor-debug-collector/dumps/2
233 # obmcdump_2_XXXXXXXXXX.tar.xz
234 ${file_there} ${stderr} ${rc}= BMC Execute Command
235 ... ${dump_check_cmd}/${dump_id}
236 Should End With ${file_there} tar.xz msg=BMC dump file not found.
Rahul Maheshwari1612ac92017-08-30 14:42:32 -0500237
238Get Dump Entries
239 [Documentation] Return dump entries list.
240
George Keishing1dc8a1e2021-08-03 04:49:38 -0500241 ${resp}= OpenBMC Get Request ${REST_DUMP_URI}
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500242 Run Keyword If '${resp.status_code}' == '${HTTP_NOT_FOUND}'
George Keishing73d8f242021-03-19 08:51:56 -0500243 ... Set Global Variable ${DUMP_ENTRY_URI} /xyz/openbmc_project/dump/entry/
Rahul Maheshwaria89ff9e2020-09-25 05:04:33 -0500244
Rahul Maheshwari1612ac92017-08-30 14:42:32 -0500245 ${dump_entries}= Get URL List ${DUMP_ENTRY_URI}
246 [Return] ${dump_entries}
247
Rahul Maheshwari1612ac92017-08-30 14:42:32 -0500248Trigger Core Dump
249 [Documentation] Trigger core dump.
250
251 # Find the pid of the active ipmid and kill it.
George Keishingbfd5c8f2018-07-11 10:27:28 -0500252 ${cmd_buf}= Catenate kill -s SEGV $(ps | egrep ' ipmid$' |
Rahul Maheshwari1612ac92017-08-30 14:42:32 -0500253 ... egrep -v grep | \ cut -c1-6)
254
255 ${cmd_output} ${stderr} ${rc}= BMC Execute Command ${cmd_buf}
256 Should Be Empty ${stderr} msg=BMC execute command error.
257 Should Be Equal As Integers ${rc} ${0}
258 ... msg=BMC execute command return code is not zero.
Anusha Dathatrifd350222021-04-08 06:07:49 -0500259
Anusha Dathatri83ddaf92022-08-12 03:31:54 -0500260Initiate BMC Dump Using Redfish And Return Task Id
261 [Documentation] Initiate BMC dump via Redfish and return its task ID.
262
263 ${payload}= Create Dictionary DiagnosticDataType=Manager
264 ${resp}= Redfish.Post
265 ... /redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData
266 ... body=${payload} valid_status_codes=[${HTTP_ACCEPTED}]
267
268 # Example of response from above Redfish POST request.
269 # "@odata.id": "/redfish/v1/TaskService/Tasks/0",
270 # "@odata.type": "#Task.v1_4_3.Task",
271 # "Id": "0",
272 # "TaskState": "Running",
273 # "TaskStatus": "OK"
274
275 [Return] ${resp.dict['Id']}
276
Tim Lee792e31e2021-12-10 14:10:46 +0800277Create User Initiated BMC Dump Via Redfish
278 [Documentation] Generate user initiated BMC dump via Redfish and return the dump id number (e.g., "5").
manashsarmafcbfdf62022-12-07 06:36:28 -0600279 [Arguments] ${skip_dump_completion}=0
280
281 # Description of Argument(s):
282 # skip_dump_completion If skip_dump_completion is set to 0, this
283 # keyword will waiting for BMC dump to
284 # complete and returns the dump id.
285 # Otherwise, the keyword is skipped after
286 # initiating BMC dump and returns dump task id.
Anusha Dathatrifd350222021-04-08 06:07:49 -0500287
288 ${payload}= Create Dictionary DiagnosticDataType=Manager
Tim Lee792e31e2021-12-10 14:10:46 +0800289 ${resp}= Redfish.Post /redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData
290 ... body=${payload} valid_status_codes=[${HTTP_ACCEPTED}]
Anusha Dathatrifd350222021-04-08 06:07:49 -0500291
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
manashsarmafcbfdf62022-12-07 06:36:28 -0600299 Run Keyword If ${skip_dump_completion} != 0 Return From Keyword ${resp.dict['Id']}
Tim Lee792e31e2021-12-10 14:10:46 +0800300 Wait Until Keyword Succeeds 5 min 15 sec Check Task Completion ${resp.dict['Id']}
Anusha Dathatrifd350222021-04-08 06:07:49 -0500301 ${task_id}= Set Variable ${resp.dict['Id']}
Tim Lee792e31e2021-12-10 14:10:46 +0800302
303 ${task_dict}= Redfish.Get Properties /redfish/v1/TaskService/Tasks/${task_id}
304
305 # Example of HttpHeaders field of task details.
306 # "Payload": {
307 # "HttpHeaders": [
308 # "Host: <BMC_IP>",
309 # "Accept-Encoding: identity",
310 # "Connection: Keep-Alive",
311 # "Accept: */*",
312 # "Content-Length: 33",
313 # "Location: /redfish/v1/Managers/bmc/LogServices/Dump/Entries/2"]
314 # ],
315 # "HttpOperation": "POST",
316 # "JsonBody": "{\"DiagnosticDataType\":\"Manager\"}",
317 # "TargetUri": "/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData"
318 # }
319
320 [Return] ${task_dict["Payload"]["HttpHeaders"][-1].split("/")[-1]}
Anusha Dathatrifd350222021-04-08 06:07:49 -0500321
322Auto Generate BMC Dump
323 [Documentation] Auto generate BMC dump.
324
Anusha Dathatri21961472021-06-10 03:16:35 -0500325 ${cmd}= Catenate busctl --verbose call xyz.openbmc_project.Dump.Manager
Anusha Dathatrif09efb82021-08-18 10:09:33 -0500326 ... /xyz/openbmc_project/dump/bmc xyz.openbmc_project.Dump.Create CreateDump a{sv} 0
Anusha Dathatri21961472021-06-10 03:16:35 -0500327 ${stdout} ${stderr} ${rc}=
328 ... BMC Execute Command ${cmd}
Anusha Dathatrifd350222021-04-08 06:07:49 -0500329 [Return] ${stdout} ${stderr} ${rc}
330
331Get Dump Size
332 [Documentation] Get dump size.
Anusha Dathatrieed0e592021-04-21 03:17:12 -0500333 [Arguments] ${dump_uri}
Anusha Dathatrifd350222021-04-08 06:07:49 -0500334
335 # Description of argument(s):
Anusha Dathatrieed0e592021-04-21 03:17:12 -0500336 # dump_uri Dump URI
337 # (Eg. /xyz/openbmc_project/dump/bmc/entry/1).
Anusha Dathatrifd350222021-04-08 06:07:49 -0500338
Anusha Dathatrieed0e592021-04-21 03:17:12 -0500339 # Example of Dump entry.
340 # "data": {
341 # "CompletedTime": 1616760931,
342 # "Elapsed": 1616760931,
343 # "OffloadUri": "",
344 # "Offloaded": false,
345 # "Password": "",
346 # "Size": 3056,
347 # "SourceDumpId": 117440513,
348 # "StartTime": 1616760931,
349 # "Status": "xyz.openbmc_project.Common.Progress.OperationStatus.Completed",
350 # "VSPString": ""
351 # },
Anusha Dathatrifd350222021-04-08 06:07:49 -0500352
Anusha Dathatrieed0e592021-04-21 03:17:12 -0500353 Log ${dump_uri}
354 ${dump_data}= Redfish.Get Properties ${dump_uri}
355 [Return] ${dump_data["data"]["Size"]}
Anusha Dathatrifd350222021-04-08 06:07:49 -0500356
357Get Dump ID
Anusha Dathatrieed0e592021-04-21 03:17:12 -0500358 [Documentation] Return dump ID.
Anusha Dathatrifd350222021-04-08 06:07:49 -0500359 [Arguments] ${task_id}
360
361 # Description of argument(s):
362 # task_id Task ID.
363
364 # Example of HttpHeaders field of task details.
365 # "Payload": {
366 # "HttpHeaders": [
367 # "Host: <BMC_IP>",
368 # "Accept-Encoding: identity",
369 # "Connection: Keep-Alive",
370 # "Accept: */*",
371 # "Content-Length: 33",
372 # "Location: /redfish/v1/Managers/bmc/LogServices/Dump/Entries/2"]
373 # ],
374 # "HttpOperation": "POST",
375 # "JsonBody": "{\"DiagnosticDataType\":\"Manager\"}",
376 # "TargetUri":
377 # "/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData"
378 # }
379
380 ${task_dict}= Redfish.Get Properties /redfish/v1/TaskService/Tasks/${task_id}
381 ${key} ${value}= Set Variable ${task_dict["Payload"]["HttpHeaders"][-1].split(":")}
382 Run Keyword If '${key}' != 'Location' Fail
Anusha Dathatrifa4209e2021-06-30 00:48:39 -0500383 [Return] ${value.strip('/').split('/')[-1]}
Anusha Dathatrifd350222021-04-08 06:07:49 -0500384
385Get Task Status
386 [Documentation] Return task status.
387 [Arguments] ${task_id}
388
389 # Description of argument(s):
390 # task_id Task ID.
391
392 ${resp}= Redfish.Get Properties /redfish/v1/TaskService/Tasks/${task_id}
393 [Return] ${resp['TaskState']}
394
Anusha Dathatrieed0e592021-04-21 03:17:12 -0500395Check Task Completion
396 [Documentation] Check if the task is complete.
397 [Arguments] ${task_id}
398
399 # Description of argument(s):
400 # task_id Task ID.
401
Tim Lee792e31e2021-12-10 14:10:46 +0800402 ${task_dict}= Redfish.Get Properties /redfish/v1/TaskService/Tasks/${task_id}
403 Should Be Equal As Strings ${task_dict['TaskState']} Completed
Anusha Dathatrieed0e592021-04-21 03:17:12 -0500404
Anusha Dathatrifd350222021-04-08 06:07:49 -0500405Get Dump ID And Status
406 [Documentation] Return dump ID and status.
407 [Arguments] ${task_id}
408
409 # Description of argument(s):
410 # task_id Task ID.
411
Anusha Dathatri66af3c42022-08-08 10:18:48 -0500412 Wait Until Keyword Succeeds 10 min 15 sec Check Task Completion ${task_id}
413 ${dump_id}= Get Dump ID ${task_id}
414 [Return] ${dump_id} Completed
aravinth0510350edc82022-09-30 06:33:48 +0000415
416
417Create BMC User Dump
418 [Documentation] Generate user initiated BMC dump via Redfish and return
419 ... the task instance Id and response object (e.g., "5").
420
421 ${payload}= Create Dictionary DiagnosticDataType=Manager
422 ${resp}= Redfish.Post /redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData
423 ... body=${payload} valid_status_codes=[${HTTP_ACCEPTED}]
424
425 ${ip_resp}= Evaluate json.loads(r'''${resp.text}''') json
426
427 Return From Keyword ${ip_resp["Id"]} ${resp}
428
429
430Wait For Task Completion
431 [Documentation] Check whether the state of task instance matches any of the
432 ... expected completion states before maximum number of retries exceeds and
433 ... exit loop in case completion state is met.
434 [Arguments] ${task_id} ${expected_status} ${retry_max_count}=300
435 ... ${check_state}=${FALSE}
436
437 # Description of argument(s):
438 # task_id the task id for which completion is
439 # to be monitored.
440 # expected_status the task state which is to be considered as the
441 # end of task life cycle.
442 # retry_max_count the maximum number of retry count to wait for
443 # task to reach its completion state. Default
444 # value of retry_max_count is 300.
445 # check_state if set as TRUE, the task state will be
446 # monitored whether the task state value is
447 # valid throughout task life cycle until
448 # expected completion state is reached.
449 # Default value of check_state is FALSE.
450
451 FOR ${retry} IN RANGE ${retry_max_count}
452 ${resp}= Redfish.Get Properties /redfish/v1/TaskService/Tasks/${task_id}
453 ${current_task_state}= Set Variable ${resp["TaskState"]}
454 Rprint Vars current_task_state
455
456 Run Keyword If ${check_state} == ${TRUE} Should Be True
457 ... '${resp["TaskState"]}' in ${allowed_task_state}
458 ... msg=Verify task state is valid
459
460 Exit For Loop If
461 ... '${resp["TaskState"]}' in ${expected_status}
462
463 Sleep 5s
harikaVi715ddf62022-11-29 01:01:59 -0600464 END
465
466Get Dump Status In BMC
Sushil Singh468d85f2022-11-30 07:33:36 -0600467 [Documentation] Get dump status from BMC using busctl method.
harikaVi715ddf62022-11-29 01:01:59 -0600468 [Arguments] ${dump_uri}
469
470 # Description of argument(s):
471 # dump_uri Dump URI E.g: /xyz/openbmc_project/dump/bmc/entry/7.
472
473 ${cmd}= Catenate busctl get-property xyz.openbmc_project.Dump.Manager
474 ... ${dump_uri} xyz.openbmc_project.Common.Progress Status
475
476 ${stdout} ${stderr} ${rc}= BMC Execute Command ${cmd}
477 Log ${stdout}
478 # Example output:
479 # s "xyz.openbmc_project.Common.Progress.OperationStatus.Completed".
480
481 ${status}= Set Variable ${stdout.split('.')[-1].strip('"')}
482 [Return] ${status}
483
484Verify Dump Status In BMC
485 [Documentation] Verify Dump Status in BMC.
486 [Arguments] ${dump_uri} ${expected_dump_status}
487
488 # Description of argument(s):
489 # dump_uri Dump URI E.g: /xyz/openbmc_project/dump/bmc/entry/7.
490 # expected_dump_status Expected Dump Status (Completed or Failed etc).
491
492 ${dump_status}= Get Dump Status In BMC ${dump_uri}
493 Should Be Equal ${dump_status} ${expected_dump_status}