Utilities to generate BMC dump
- Redfish user initiated dump
- Auto generated dump
Change-Id: Ief3d533c35e4bb78751856bf6904819b3ad18959
Signed-off-by: Anusha Dathatri <adathatr@in.ibm.com>
diff --git a/lib/dump_utils.robot b/lib/dump_utils.robot
index 6fbadef..c8ead9a 100644
--- a/lib/dump_utils.robot
+++ b/lib/dump_utils.robot
@@ -224,7 +224,6 @@
${dump_entries}= Get URL List ${DUMP_ENTRY_URI}
[Return] ${dump_entries}
-
Trigger Core Dump
[Documentation] Trigger core dump.
@@ -236,3 +235,100 @@
Should Be Empty ${stderr} msg=BMC execute command error.
Should Be Equal As Integers ${rc} ${0}
... msg=BMC execute command return code is not zero.
+
+Create User Initiated BMC Dump Using Redfish
+ [Documentation] Trigger user initiated BMC dump via Redfish and return task id.
+
+ ${payload}= Create Dictionary DiagnosticDataType=Manager
+ ${resp}= Redfish.Post
+ ... /redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData
+ ... body=${payload} valid_status_codes=[${HTTP_ACCEPTED}, ${HTTP_OK}]
+
+ # Example of response from above Redfish POST request.
+ # "@odata.id": "/redfish/v1/TaskService/Tasks/0",
+ # "@odata.type": "#Task.v1_4_3.Task",
+ # "Id": "0",
+ # "TaskState": "Running",
+ # "TaskStatus": "OK"
+
+ ${task_id}= Set Variable ${resp.dict['Id']}
+ [Return] ${task_id}
+
+Auto Generate BMC Dump
+ [Documentation] Auto generate BMC dump.
+
+ ${stdout} ${stderr} ${rc}=
+ ... BMC Execute Command
+ ... busctl --verbose call xyz.openbmc_project.Dump.Manager /xyz/openbmc_project/dump/bmc xyz.openbmc_project.Dump.Create CreateDump a{ss} 0
+ [Return] ${stdout} ${stderr} ${rc}
+
+Get Dump Size
+ [Documentation] Get dump size.
+ [Arguments] ${dump_id}
+
+ # Description of argument(s):
+ # dump_id Dump ID.
+
+ # Example of BMC Dump entry.
+ # "@odata.id": "/redfish/v1/Managers/bmc/LogServices/Dump/Entries/382",
+ # "@odata.type": "#LogEntry.v1_7_0.LogEntry",
+ # "AdditionalDataSizeBytes": 211072,
+ # "AdditionalDataURI": "/redfish/v1/Managers/bmc/LogServices/Dump/attachment/382",
+ # "Created": "2021-03-30T17:09:34+00:00",
+ # "DiagnosticDataType": "Manager",
+ # "EntryType": "Event",
+ # "Id": "382",
+ # "Name": "BMC Dump Entry"
+
+ ${dump_data}= Redfish.Get Properties
+ ... /redfish/v1/Managers/bmc/LogServices/Dump/Entries/${dump_id}
+ [Return] ${dump_data["AdditionalDataSizeBytes"]}
+
+Get Dump ID
+ [Documentation] Return task status.
+ [Arguments] ${task_id}
+
+ # Description of argument(s):
+ # task_id Task ID.
+
+ # Example of HttpHeaders field of task details.
+ # "Payload": {
+ # "HttpHeaders": [
+ # "Host: <BMC_IP>",
+ # "Accept-Encoding: identity",
+ # "Connection: Keep-Alive",
+ # "Accept: */*",
+ # "Content-Length: 33",
+ # "Location: /redfish/v1/Managers/bmc/LogServices/Dump/Entries/2"]
+ # ],
+ # "HttpOperation": "POST",
+ # "JsonBody": "{\"DiagnosticDataType\":\"Manager\"}",
+ # "TargetUri":
+ # "/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData"
+ # }
+
+ ${task_dict}= Redfish.Get Properties /redfish/v1/TaskService/Tasks/${task_id}
+ ${key} ${value}= Set Variable ${task_dict["Payload"]["HttpHeaders"][-1].split(":")}
+ Run Keyword If '${key}' != 'Location' Fail
+ [Return] ${value.split('/')[-1]}
+
+Get Task Status
+ [Documentation] Return task status.
+ [Arguments] ${task_id}
+
+ # Description of argument(s):
+ # task_id Task ID.
+
+ ${resp}= Redfish.Get Properties /redfish/v1/TaskService/Tasks/${task_id}
+ [Return] ${resp['TaskState']}
+
+Get Dump ID And Status
+ [Documentation] Return dump ID and status.
+ [Arguments] ${task_id}
+
+ # Description of argument(s):
+ # task_id Task ID.
+
+ ${dump_id}= Wait Until Keyword Succeeds 15 min 15 sec Get Dump ID ${task_id}
+ ${status}= Get Task Status ${task_id}
+ [Return] ${dump_id} ${status}