George Keishing | c37fca6 | 2017-11-24 05:07:32 -0600 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Error logging utility keywords. |
| 3 | |
| 4 | Resource rest_client.robot |
| 5 | Variables ../data/variables.py |
| 6 | |
| 7 | *** Keywords *** |
| 8 | |
| 9 | Get Logging Entry List |
| 10 | [Documentation] Get logging entry and return the object list. |
| 11 | |
| 12 | ${entry_list}= Create List |
| 13 | ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1} |
| 14 | Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND} |
| 15 | ${jsondata}= To JSON ${resp.content} |
| 16 | |
| 17 | :FOR ${entry} IN @{jsondata["data"]} |
| 18 | \ Continue For Loop If '${entry.rsplit('/', 1)[1]}' == 'callout' |
| 19 | \ Append To List ${entry_list} ${entry} |
| 20 | |
| 21 | # Logging entries list. |
| 22 | # ['/xyz/openbmc_project/logging/entry/14', |
| 23 | # '/xyz/openbmc_project/logging/entry/15'] |
| 24 | [Return] ${entry_list} |
| 25 | |
| 26 | |
| 27 | Logging Entry Should Exist |
| 28 | [Documentation] Find the matching message id and return the entry id. |
| 29 | [Arguments] ${message_id} |
| 30 | |
| 31 | # Description of argument(s): |
| 32 | # message_id Logging message string. |
| 33 | # Example: "xyz.openbmc_project.Common.Error.InternalFailure" |
| 34 | |
| 35 | ${elog_entries}= Get Logging Entry List |
| 36 | |
| 37 | :FOR ${entry} IN @{elog_entries} |
| 38 | \ ${resp}= Read Properties ${entry} |
| 39 | \ ${status}= Run Keyword And Return Status |
| 40 | ... Should Be Equal As Strings ${message_id} ${resp["Message"]} |
| 41 | \ Return From Keyword If ${status} == ${TRUE} ${entry} |
| 42 | |
| 43 | Fail No ${message_id} logging entry found. |
| 44 | |
Steven Sombar | 9567294 | 2018-03-23 11:24:58 -0500 | [diff] [blame] | 45 | |
| 46 | Get Error Logs |
| 47 | [Documentation] Return a dictionary which contains the BMC error logs. |
| 48 | [Arguments] ${quiet}=1 |
| 49 | |
| 50 | # Description of argument(s): |
| 51 | # quiet Indicates whether this keyword should run without any output to |
| 52 | # the console, 0 = verbose, 1 = quiet. |
| 53 | |
| 54 | # The length of the returned dictionary indicates how many logs there are. |
| 55 | # Printing of error logs can be done with the keyword Print Error Logs, |
| 56 | # for example, Print Error Logs ${error_logs} Message. |
| 57 | |
| 58 | ${status} ${error_logs}= Run Keyword And Ignore Error Read Properties |
| 59 | ... /xyz/openbmc_project/logging/entry/enumerate quiet=${quiet} |
| 60 | |
| 61 | ${empty_dict}= Create Dictionary |
| 62 | Return From Keyword If '${status}' == 'FAIL' ${empty_dict} |
| 63 | [Return] ${error_logs} |