1*** Settings ***
2Documentation       This module is for OS checkstop opertions.
3Resource            ../../lib/rest_client.robot
4Resource            ../../lib/utils.robot
5Library             OperatingSystem
6
7*** Keywords ***
8
9Getscom Operations On OS
10    [Documentation]  Executes getscom command on OS with the given
11    ...              input command.
12    [Arguments]      ${input_cmd}
13    # Description of arguments:
14    # input_cmd      -l|--list-chips
15    #                -c|--chip <chip-id> <addr>
16
17    ${output}  ${stderr}=  Execute Command  getscom ${input_cmd}
18    ...        return_stderr=True
19    Should Be Empty  ${stderr}
20    [Return]  ${output}
21
22Gard Operations On OS
23    [Documentation]  Executes opal-gard command on OS with the given
24    ...              input command.
25    [Arguments]      ${input_cmd}
26    # Description of arguments:
27    # input_cmd      list/clear all/show <gard_record_id>
28
29    ${output}  ${stderr}=  Execute Command  opal-gard ${input_cmd}
30    ...        return_stderr=True
31    Should Be Empty  ${stderr}
32    [Return]  ${output}
33
34Putscom Through OS
35    [Documentation]  Executes putscom command on OS with the given
36    ...              input arguments.
37    [Arguments]      ${chip_id}  ${fru}  ${address}
38    # Description of arguments:
39    # chip_id        processor ID (e.g 00000000).
40    # fru            FRU value (e.g. 2011400).
41    # address        chip address (e.g 4000000000000000).
42
43    ${cmd}=  Catenate  putscom -c 0x${chip_id} 0x${fru} 0x${address}
44    Start Command  ${cmd}
45
46Get Cores Values From OS
47    [Documentation]  Check if cores present on HOST OS & return core values.
48    ${cmd}=  Catenate  cat /sys/firmware/opal/msglog|grep -i chip|grep -i core
49    ${output}=  Execute Command  ${cmd}
50    Should Not Be Empty  ${output}
51    [Return]  ${output}
52
53Get ChipID From OS
54    [Documentation]  Get chip ID values based on the input.
55    [Arguments]      ${chip_type}
56    # Description of arguments:
57    # chip_type      The chip type (Processor/Centaur).
58
59    ${cmd}=  Catenate  -l | grep -i ${chip_type} | cut -c1-8
60    ${chip_id}=  Getscom Operations On OS  ${cmd}
61    [Return]  ${chip_id}
62