1*** Settings ***
2Documentation  This module provides general keywords for dump.
3
4
5*** Variables ***
6
7*** Keywords ***
8
9Create User Initiated Dump
10    [Documentation]  Generate user initiated dump and return
11    ...  dump id (e.g 1, 2 etc).
12
13    ${data}=  Create Dictionary  data=@{EMPTY}
14    ${resp}=  OpenBMC Post Request
15    ...  ${DUMP_URI}/action/CreateDump  data=${data}
16
17    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
18    ${json}=  To JSON  ${resp.content}
19    ${dump_id}=  Set Variable  ${json["data"]}
20
21    Wait Until Keyword Succeeds  3 min  15 sec  Check Dump Existence
22    ...  ${dump_id}
23
24    [Return]  ${dump_id}
25
26
27Verify No Dump In Progress
28    [Documentation]  Verify no dump in progress.
29
30    ${dump_progress}  ${stderr}  ${rc}=  BMC Execute Command  ls /tmp
31    Should Not Contain  ${dump_progress}  obmcdump
32
33
34Check Dump Existence
35    [Documentation]  Verify if given dump exist.
36    [Arguments]  ${dump_id}
37
38    # Description of Argument(s):
39    # dump_id  An integer value that identifies a particular dump
40    #          object(e.g. 1, 3, 5).
41
42    ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}/${dump_id}
43    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
44
45
46Delete BMC Dump
47    [Documentation]  Deletes a given bmc dump.
48    [Arguments]  ${dump_id}
49
50    # Description of Argument(s):
51    # dump_id  An integer value that identifies a particular dump (e.g. 1, 3).
52
53    ${data}=  Create Dictionary  data=@{EMPTY}
54    ${resp}=  OpenBMC Post Request
55    ...  ${DUMP_ENTRY_URI}/${dump_id}/action/Delete  data=${data}
56
57    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
58
59Delete All Dumps
60    [Documentation]  Delete all dumps.
61
62    # Check if dump entries exist, if not return.
63    ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}list  quiet=${1}
64    Return From Keyword If  ${resp.status_code} == ${HTTP_NOT_FOUND}
65
66    # Get the list of dump entries and delete them all.
67    ${dump_entries}=  Get URL List  ${DUMP_ENTRY_URI}
68    :FOR  ${entry}  IN  @{dump_entries}
69    \  ${dump_id}=  Fetch From Right  ${entry}  /
70    \  Delete BMC Dump  ${dump_id}
71
72
73Delete All BMC Dump
74    [Documentation]  Delete all BMC dump entries using "DeleteAll" interface.
75
76    ${data}=  Create Dictionary  data=@{EMPTY}
77    ${resp}=  Openbmc Post Request  ${DUMP_URI}action/DeleteAll  data=${data}
78    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
79
80
81Dump Should Not Exist
82    [Documentation]  Verify that BMC dumps do not exist.
83
84    ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}/list  quiet=${1}
85    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_NOT_FOUND}
86
87