George Keishing | cae6e90 | 2017-09-07 13:35:59 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Open power domain keywords. |
| 3 | |
| 4 | Library ../data/variables.py |
| 5 | Resource ../lib/utils.robot |
| 6 | |
| 7 | *** Keywords *** |
| 8 | |
| 9 | Get OCC Objects |
| 10 | [Documentation] Get the OCC objects and return as a list. |
| 11 | |
| 12 | # Example: |
| 13 | # { |
| 14 | # "/org/open_power/control/occ0": { |
| 15 | # "OccActive": 0 |
| 16 | # }, |
| 17 | # "/org/open_power/control/occ1": { |
| 18 | # "OccActive": 1 |
| 19 | # } |
| 20 | |
George Keishing | 50cd001 | 2017-09-14 12:23:41 -0500 | [diff] [blame] | 21 | ${occ_list}= Get Endpoint Paths ${OPENPOWER_CONTROL} occ* |
George Keishing | cae6e90 | 2017-09-07 13:35:59 -0500 | [diff] [blame] | 22 | |
| 23 | [Return] ${occ_list} |
| 24 | |
| 25 | |
| 26 | Get OCC Active State |
| 27 | [Documentation] Get the OCC "OccActive" and return the attribute value. |
| 28 | [Arguments] ${occ_object} |
| 29 | |
| 30 | # Description of argument(s): |
| 31 | # occ_object OCC object path. |
| 32 | # (e.g. "/org/open_power/control/occ0"). |
| 33 | |
| 34 | ${occ_attribute}= Read Attribute ${occ_object} OccActive |
| 35 | [Return] ${occ_attribute} |
George Keishing | 50cd001 | 2017-09-14 12:23:41 -0500 | [diff] [blame] | 36 | |
| 37 | |
| 38 | Count Object Entries |
Gunnar Mills | 28e403b | 2017-10-25 16:16:38 -0500 | [diff] [blame] | 39 | [Documentation] Count the occurrence number of a given object. |
George Keishing | 50cd001 | 2017-09-14 12:23:41 -0500 | [diff] [blame] | 40 | [Arguments] ${object_base_uri_path} ${object_name} |
| 41 | |
| 42 | # Description of argument(s): |
| 43 | # object_base_uri_path Object base path |
| 44 | # (e.g. "/org/open_power/control/"). |
| 45 | # object_name Object name (e.g. "occ", "cpu" etc). |
| 46 | |
| 47 | ${object_list}= Get Endpoint Paths |
| 48 | ... ${object_base_uri_path} ${object_name} |
| 49 | ${list_count}= Get Length ${object_list} |
| 50 | [Return] ${list_count} |
| 51 | |
| 52 | |
| 53 | Read Object Attribute |
| 54 | [Documentation] Return object attribute data. |
| 55 | [Arguments] ${object_base_uri_path} ${attribute_name} |
| 56 | |
| 57 | # Description of argument(s): |
| 58 | # object_base_uri_path Object path. |
| 59 | # (e.g. "/org/open_power/control/occ0"). |
| 60 | # attribute_name Object attribute name. |
| 61 | |
| 62 | ${resp}= OpenBMC Get Request |
| 63 | ... ${object_base_uri_path}/attr/${attribute_name} quiet=${1} |
| 64 | Return From Keyword If ${resp.status_code} != ${HTTP_OK} |
| 65 | ${content}= To JSON ${resp.content} |
| 66 | [Return] ${content["data"]} |
| 67 | |