1*** Settings *** 2Documentation This module provides general keywords for dump. 3 4Library bmc_ssh_utils.py 5 6*** Variables *** 7 8*** Keywords *** 9 10Create User Initiated Dump 11 [Documentation] Generate user initiated dump and return 12 ... the dump id number (e.g., "5"). Optionally return EMPTY 13 ... if out of dump space. 14 [Arguments] ${check_out_of_space}=${False} 15 16 # Description of Argument(s): 17 # check_out_of_space If ${False}, a dump will be created and 18 # its dump_id will be returned. 19 # If ${True}, either the dump_id will be 20 # returned, or the value ${EMPTY} will be 21 # returned if out of dump space was 22 # detected when creating the dump. 23 24 ${data}= Create Dictionary data=@{EMPTY} 25 ${resp}= OpenBMC Post Request 26 ... ${DUMP_URI}action/CreateDump data=${data} quiet=${1} 27 28 Run Keyword If '${check_out_of_space}' == '${False}' 29 ... Run Keyword And Return Get The Dump Id ${resp} 30 ... ELSE 31 ... Run Keyword And Return Check For Too Many Dumps ${resp} 32 33 34Get The Dump Id 35 [Documentation] Wait for the dump to be created. Return the 36 ... dump id number (e.g., "5"). 37 [Arguments] ${resp} 38 39 # Description of Argument(s): 40 # resp Response object from action/Create Dump attempt. 41 # Example object: 42 # { 43 # "data": 5, 44 # "message": "200 OK", 45 # "status": "ok" 46 # }, 47 # The "data" field conveys the id number of the created dump. 48 49 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} 50 ${json}= To JSON ${resp.content} 51 52 Run Keyword If ${json["data"]} == ${None} 53 ... Fail Dump id returned null. 54 55 ${dump_id}= Set Variable ${json["data"]} 56 57 Wait Until Keyword Succeeds 3 min 15 sec Check Dump Existence 58 ... ${dump_id} 59 60 [Return] ${dump_id} 61 62 63Check For Too Many Dumps 64 [Documentation] Return the dump_id number, or return ${EMPTY} if dump 65 ... creation failed due to too many dumps. 66 [Arguments] ${resp} 67 68 # Description of Argument(s): 69 # resp Response object from action/Create Dump attempt. 70 # Example object if there are too many dumps: 71 # { 72 # "data": { 73 # "description": "xyz.openbmc_project.Dump.Create.Error.QuotaExceeded" 74 # }, 75 # "message": "Dump not captured due to a cap.", 76 # "status": "error" 77 # } 78 79 # If dump was created normally, return the dump_id number. 80 Run Keyword If '${resp.status_code}' == '${HTTP_OK}' 81 ... Run Keyword And Return Get The Dump Id ${resp} 82 83 ${json}= To JSON ${resp.content} 84 ${exception}= Set Variable ${json["message"]} 85 ${at_capacity}= Set Variable Dump not captured due to a cap 86 ${too_many_dumps}= Evaluate $at_capacity in $exception 87 Printn 88 Rprint Vars exception too_many_dumps 89 # If there are too many dumps, return ${EMPTY}, otherwise Fail. 90 ${status}= Run Keyword If ${too_many_dumps} Set Variable ${EMPTY} 91 ... ELSE Fail msg=${exception}. 92 93 [Return] ${status} 94 95 96Verify No Dump In Progress 97 [Documentation] Verify no dump in progress. 98 99 ${dump_progress} ${stderr} ${rc}= BMC Execute Command ls /tmp 100 Should Not Contain ${dump_progress} obmcdump 101 102 103Check Dump Existence 104 [Documentation] Verify if given dump exist. 105 [Arguments] ${dump_id} 106 107 # Description of Argument(s): 108 # dump_id An integer value that identifies a particular dump 109 # object(e.g. 1, 3, 5). 110 111 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}${dump_id} 112 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} 113 114 115Delete BMC Dump 116 [Documentation] Deletes a given bmc dump. 117 [Arguments] ${dump_id} 118 119 # Description of Argument(s): 120 # dump_id An integer value that identifies a particular dump (e.g. 1, 3). 121 122 ${data}= Create Dictionary data=@{EMPTY} 123 ${resp}= OpenBMC Post Request 124 ... ${DUMP_ENTRY_URI}${dump_id}/action/Delete data=${data} 125 126 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} 127 128Delete All Dumps 129 [Documentation] Delete all dumps. 130 131 # Check if dump entries exist, if not return. 132 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}list quiet=${1} 133 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND} 134 135 # Get the list of dump entries and delete them all. 136 ${dump_entries}= Get URL List ${DUMP_ENTRY_URI} 137 FOR ${entry} IN @{dump_entries} 138 ${dump_id}= Fetch From Right ${entry} / 139 Delete BMC Dump ${dump_id} 140 END 141 142 143Redfish Delete BMC Dump 144 [Documentation] Deletes a given BMC dump via Redfish.. 145 [Arguments] ${dump_id} 146 147 # Description of Argument(s): 148 # dump_id An integer value that identifies a particular dump (e.g. 1, 3). 149 150 Redfish.Delete /redfish/v1/Managers/bmc/LogServices/Dump/Entries/${dump_id} 151 152 153Redfish Delete All BMC Dumps 154 [Documentation] Delete all BMC dumps via Redfish. 155 156 # Check if dump entries exist, if not return. 157 ${resp}= Redfish.Get /redfish/v1/Managers/bmc/LogServices/Dump/Entries 158 Return From Keyword If ${resp.dict["Members@odata.count"]} == ${0} 159 160 Redfish.Post /redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.ClearLog 161 162 163Delete All BMC Dump 164 [Documentation] Delete all BMC dump entries using "DeleteAll" interface. 165 166 ${data}= Create Dictionary data=@{EMPTY} 167 ${resp}= Openbmc Post Request ${DUMP_URI}action/DeleteAll data=${data} 168 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} 169 170Dump Should Not Exist 171 [Documentation] Verify that BMC dumps do not exist. 172 173 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}list quiet=${1} 174 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND} 175 176Check Existence Of BMC Dump File 177 [Documentation] Verify existence of BMC dump file. 178 [Arguments] ${dump_id} 179 180 # Description of argument(s): 181 # dump_id BMC dump identifier 182 183 ${dump_check_cmd}= Set Variable 184 ... ls /var/lib/phosphor-debug-collector/dumps 185 186 # Output of sample BMC Execute command with '2' as dump id is as follows 187 # ls /var/lib/phosphor-debug-collector/dumps/2 188 # obmcdump_2_XXXXXXXXXX.tar.xz 189 ${file_there} ${stderr} ${rc}= BMC Execute Command 190 ... ${dump_check_cmd}/${dump_id} 191 Should End With ${file_there} tar.xz msg=BMC dump file not found. 192 193Get Dump Entries 194 [Documentation] Return dump entries list. 195 196 ${dump_entries}= Get URL List ${DUMP_ENTRY_URI} 197 [Return] ${dump_entries} 198 199 200Trigger Core Dump 201 [Documentation] Trigger core dump. 202 203 # Find the pid of the active ipmid and kill it. 204 ${cmd_buf}= Catenate kill -s SEGV $(ps | egrep ' ipmid$' | 205 ... egrep -v grep | \ cut -c1-6) 206 207 ${cmd_output} ${stderr} ${rc}= BMC Execute Command ${cmd_buf} 208 Should Be Empty ${stderr} msg=BMC execute command error. 209 Should Be Equal As Integers ${rc} ${0} 210 ... msg=BMC execute command return code is not zero. 211