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 All BMC Dumps 144 [Documentation] Delete all BMC dumps via Redfish. 145 146 # Check if dump entries exist, if not return. 147 ${resp}= Redfish.Get /redfish/v1/Managers/bmc/LogServices/Dump/Entries 148 Return From Keyword If ${resp.dict["Members@odata.count"]} == ${0} 149 150 Redfish.Post /redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.ClearLog 151 152 153Delete All BMC Dump 154 [Documentation] Delete all BMC dump entries using "DeleteAll" interface. 155 156 ${data}= Create Dictionary data=@{EMPTY} 157 ${resp}= Openbmc Post Request ${DUMP_URI}action/DeleteAll data=${data} 158 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} 159 160Dump Should Not Exist 161 [Documentation] Verify that BMC dumps do not exist. 162 163 ${resp}= OpenBMC Get Request ${DUMP_ENTRY_URI}list quiet=${1} 164 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND} 165 166Check Existence Of BMC Dump File 167 [Documentation] Verify existence of BMC dump file. 168 [Arguments] ${dump_id} 169 170 # Description of argument(s): 171 # dump_id BMC dump identifier 172 173 ${dump_check_cmd}= Set Variable 174 ... ls /var/lib/phosphor-debug-collector/dumps 175 176 # Output of sample BMC Execute command with '2' as dump id is as follows 177 # ls /var/lib/phosphor-debug-collector/dumps/2 178 # obmcdump_2_XXXXXXXXXX.tar.xz 179 ${file_there} ${stderr} ${rc}= BMC Execute Command 180 ... ${dump_check_cmd}/${dump_id} 181 Should End With ${file_there} tar.xz msg=BMC dump file not found. 182 183Get Dump Entries 184 [Documentation] Return dump entries list. 185 186 ${dump_entries}= Get URL List ${DUMP_ENTRY_URI} 187 [Return] ${dump_entries} 188 189 190Trigger Core Dump 191 [Documentation] Trigger core dump. 192 193 # Find the pid of the active ipmid and kill it. 194 ${cmd_buf}= Catenate kill -s SEGV $(ps | egrep ' ipmid$' | 195 ... egrep -v grep | \ cut -c1-6) 196 197 ${cmd_output} ${stderr} ${rc}= BMC Execute Command ${cmd_buf} 198 Should Be Empty ${stderr} msg=BMC execute command error. 199 Should Be Equal As Integers ${rc} ${0} 200 ... msg=BMC execute command return code is not zero. 201