blob: 778d08911c0dd771b91819b4e682dbf9c7ac1036 [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
12 ... dump id (e.g 1, 2 etc).
13
14 ${data}= Create Dictionary data=@{EMPTY}
15 ${resp}= OpenBMC Post Request
George Keishing8d693382018-12-18 12:15:04 -060016 ... ${DUMP_URI}action/CreateDump data=${data}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050017
18 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
19 ${json}= To JSON ${resp.content}
George Keishing73c4ebf2017-11-13 07:10:28 -060020
21 # REST "CreateDump" JSON response.
22 # {
23 # "data": null,
24 # "message": "200 OK",
25 # "status": "ok"
26 # }
27 Run Keyword If ${json["data"]} == ${None}
28 ... Fail Dump id returned null.
29
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050030 ${dump_id}= Set Variable ${json["data"]}
31
Rahul Maheshwarie2cd17f2017-09-26 21:26:50 -050032 Wait Until Keyword Succeeds 3 min 15 sec Check Dump Existence
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050033 ... ${dump_id}
34
35 [Return] ${dump_id}
36
37
Rahul Maheshwari953038b2017-10-17 05:08:59 -050038Verify No Dump In Progress
39 [Documentation] Verify no dump in progress.
40
Rahul Maheshwari4cfdc392017-10-25 09:44:47 -050041 ${dump_progress} ${stderr} ${rc}= BMC Execute Command ls /tmp
42 Should Not Contain ${dump_progress} obmcdump
Rahul Maheshwari953038b2017-10-17 05:08:59 -050043
44
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050045Check Dump Existence
46 [Documentation] Verify if given dump exist.
47 [Arguments] ${dump_id}
48
49 # Description of Argument(s):
50 # dump_id An integer value that identifies a particular dump
51 # object(e.g. 1, 3, 5).
52
George Keishing8d693382018-12-18 12:15:04 -060053 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}${dump_id}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050054 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
55
56
57Delete BMC Dump
58 [Documentation] Deletes a given bmc dump.
59 [Arguments] ${dump_id}
60
61 # Description of Argument(s):
Gunnar Mills28e403b2017-10-25 16:16:38 -050062 # dump_id An integer value that identifies a particular dump (e.g. 1, 3).
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050063
64 ${data}= Create Dictionary data=@{EMPTY}
65 ${resp}= OpenBMC Post Request
George Keishing8d693382018-12-18 12:15:04 -060066 ... ${DUMP_ENTRY_URI}${dump_id}/action/Delete data=${data}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050067
68 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
69
70Delete All Dumps
71 [Documentation] Delete all dumps.
72
73 # Check if dump entries exist, if not return.
George Keishing6a6e76d2017-09-14 08:19:17 -050074 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}list quiet=${1}
Rahul Maheshwariad676bf2017-06-22 15:06:05 -050075 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
76
77 # Get the list of dump entries and delete them all.
78 ${dump_entries}= Get URL List ${DUMP_ENTRY_URI}
79 :FOR ${entry} IN @{dump_entries}
80 \ ${dump_id}= Fetch From Right ${entry} /
81 \ Delete BMC Dump ${dump_id}
George Keishingc9fcd092017-09-20 09:24:37 -050082
83
84Delete All BMC Dump
85 [Documentation] Delete all BMC dump entries using "DeleteAll" interface.
86
87 ${data}= Create Dictionary data=@{EMPTY}
88 ${resp}= Openbmc Post Request ${DUMP_URI}action/DeleteAll data=${data}
89 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
George Keishingdc428762017-11-11 12:37:12 -060090
George Keishingdc428762017-11-11 12:37:12 -060091Dump Should Not Exist
92 [Documentation] Verify that BMC dumps do not exist.
93
George Keishing8d693382018-12-18 12:15:04 -060094 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}list quiet=${1}
George Keishingdc428762017-11-11 12:37:12 -060095 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
96
Sivas SRR7aabd792017-10-18 21:28:23 -050097Check Existence of BMC Dump file
98 [Documentation] Verify existence of BMC dump file.
99 [Arguments] ${dump_id}
100
101 # Description of argument(s):
102 # dump_id BMC dump identifier
103
104 ${dump_check_cmd}= Set Variable
105 ... ls /var/lib/phosphor-debug-collector/dumps
106
107 # Output of sample BMC Execute command with '2' as dump id is as follows
108 # ls /var/lib/phosphor-debug-collector/dumps/2
109 # obmcdump_2_XXXXXXXXXX.tar.xz
110 ${file_there} ${stderr} ${rc}= BMC Execute Command
111 ... ${dump_check_cmd}/${dump_id}
112 Should End With ${file_there} tar.xz msg=BMC dump file not found.
Rahul Maheshwari1612ac92017-08-30 14:42:32 -0500113
114Get Dump Entries
115 [Documentation] Return dump entries list.
116
117 ${dump_entries}= Get URL List ${DUMP_ENTRY_URI}
118 [Return] ${dump_entries}
119
120
121Trigger Core Dump
122 [Documentation] Trigger core dump.
123
124 # Find the pid of the active ipmid and kill it.
George Keishingbfd5c8f2018-07-11 10:27:28 -0500125 ${cmd_buf}= Catenate kill -s SEGV $(ps | egrep ' ipmid$' |
Rahul Maheshwari1612ac92017-08-30 14:42:32 -0500126 ... egrep -v grep | \ cut -c1-6)
127
128 ${cmd_output} ${stderr} ${rc}= BMC Execute Command ${cmd_buf}
129 Should Be Empty ${stderr} msg=BMC execute command error.
130 Should Be Equal As Integers ${rc} ${0}
131 ... msg=BMC execute command return code is not zero.