1*** Settings ***
2Documentation  Utilities for eSEL testing.
3
4Resource            ../lib/ipmi_client.robot
5Resource            ../lib/utils.robot
6Variables           ../data/variables.py
7
8
9*** Variables ***
10
11${RAW_PREFIX}       raw 0x3a 0xf0 0x
12
13${RESERVE_ID}       raw 0x0a 0x42
14
15${RAW_SUFFIX}       0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x00
16...  0xdf 0x00 0x00 0x00 0x00 0x20 0x00 0x04 0x12 0x35 0x6f 0xaa 0x00 0x00
17
18${RAW_SEL_COMMIT}   raw 0x0a 0x44 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x20
19...  0x00 0x04 0x12 0xA6 0x6f 0x02 0x00 0x01
20
21
22*** Keywords ***
23
24Create eSEL
25    [Documentation]  Create an eSEL.
26    Open Connection And Log In
27    ${Resv_id}=  Run Inband IPMI Standard Command  ${RESERVE_ID}
28    ${cmd}=  Catenate
29    ...  ${RAW_PREFIX}${Resv_id.strip().rsplit(' ', 1)[0]}  ${RAW_SUFFIX}
30    Run Inband IPMI Standard Command  ${cmd}
31    Run Inband IPMI Standard Command  ${RAW_SEL_COMMIT}
32
33
34Count eSEL Entries
35    [Documentation]  Count eSEL entries logged.
36    ${resp}=  OpenBMC Get Request  ${BMC_LOGGING_ENTRY}
37    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
38    ${jsondata}=  To JSON  ${resp.content}
39    ${count}=  Get Length  ${jsondata["data"]}
40    [Return]  ${count}
41
42
43Verify eSEL Entries
44    [Documentation]  Verify eSEL entries logged.
45    ${elog_entry}=  Get URL List  ${BMC_LOGGING_ENTRY}
46    ${resp}=  OpenBMC Get Request  ${elog_entry[0]}
47    #  "data": {
48    #       "AdditionalData": [
49    #           "ESEL=00 00 df 00 00 00 00 20 00 04 12 35 6f aa 00 00 "
50    #          ],
51    #       "Id": 1,
52    #       "Message": "org.open_power.Host.Error.Event",
53    #       "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error",
54    #       "Timestamp": 1485904869061
55    # }
56    ${entry_id}=  Read Attribute  ${elog_entry[0]}  Message
57    Should Be Equal  ${entry_id}
58    ...  org.open_power.Host.Error.Event
59
60    ${entry_id}=  Read Attribute  ${elog_entry[0]}  Severity
61    # Could be either xyz.openbmc_project.Logging.Entry.Level.Error
62    # or xyz.openbmc_project.Logging.Entry.Level.Warning.
63    Should Contain  ${entry_id}  xyz.openbmc_project.Logging.Entry.Level
64