George Keishing | cae6e90 | 2017-09-07 13:35:59 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Open power domain keywords. |
| 3 | |
George Keishing | 7e825d8 | 2019-12-13 00:38:15 -0600 | [diff] [blame] | 4 | Variables ../data/variables.py |
George Keishing | cae6e90 | 2017-09-07 13:35:59 -0500 | [diff] [blame] | 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 | |
George Keishing | 5c96d1a | 2018-02-02 10:59:58 -0600 | [diff] [blame] | 68 | |
| 69 | Verify OCC State |
| 70 | [Documentation] Check OCC active state. |
| 71 | [Arguments] ${expected_occ_active}=${1} |
| 72 | # Description of Argument(s): |
| 73 | # expected_occ_active The expected occ_active value (i.e. 1/0). |
| 74 | |
| 75 | # Example cpu_list data output: |
| 76 | # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0 |
| 77 | # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1 |
| 78 | ${cpu_list}= Get Endpoint Paths |
| 79 | ... ${HOST_INVENTORY_URI}system/chassis/motherboard/ cpu* |
| 80 | |
Marissa Garza | 522a0c2 | 2020-02-05 12:49:29 -0600 | [diff] [blame] | 81 | FOR ${endpoint_path} IN @{cpu_list} |
| 82 | ${is_functional}= Read Object Attribute ${endpoint_path} Functional |
| 83 | Continue For Loop If ${is_functional} == ${0} |
| 84 | ${num}= Set Variable ${endpoint_path[-1]} |
| 85 | ${occ_active}= Get OCC Active State ${OPENPOWER_CONTROL}occ${num} |
| 86 | Should Be Equal ${occ_active} ${expected_occ_active} |
| 87 | ... msg=OCC not in right state |
| 88 | END |
George Keishing | ac51225 | 2018-02-05 02:04:30 -0600 | [diff] [blame] | 89 | |
| 90 | |
| 91 | Get Sensors Aggregation Data |
| 92 | [Documentation] Return open power sensors aggregation value list. |
| 93 | [Arguments] ${object_base_uri_path} |
| 94 | |
| 95 | # Description of argument(s): |
| 96 | # object_base_uri_path An object path such as one of the elements |
| 97 | # returned by 'Get Sensors Aggregation URL List' |
| 98 | # (e.g. "/org/open_power/sensors/aggregation/per_30s/ps0_input_power/average"). |
| 99 | |
| 100 | # Example of aggregation [epoch,time] data: |
| 101 | # "Values": [ |
| 102 | # [ |
| 103 | # 1517815708479, <-- EPOCH |
| 104 | # 282 <-- Power value in watts |
| 105 | # ], |
| 106 | # [ |
| 107 | # 1517815678238, |
| 108 | # 282 |
| 109 | # ], |
| 110 | # [ |
| 111 | # 1517815648102, |
| 112 | # 282 |
| 113 | # ], |
| 114 | # ], |
| 115 | |
| 116 | ${resp}= Read Attribute ${object_base_uri_path} Values quiet=${1} |
| 117 | ${power_sensors_value_list}= Create List |
Marissa Garza | 522a0c2 | 2020-02-05 12:49:29 -0600 | [diff] [blame] | 118 | FOR ${entry} IN @{resp} |
| 119 | Append To List ${power_sensors_value_list} ${entry[1]} |
| 120 | END |
George Keishing | ac51225 | 2018-02-05 02:04:30 -0600 | [diff] [blame] | 121 | [Return] ${power_sensors_value_list} |
| 122 | |
| 123 | |
| 124 | Get Sensors Aggregation URL List |
| 125 | [Documentation] Return the open power aggregation maximum list and the |
| 126 | ... average list URIs. |
| 127 | [Arguments] ${object_base_uri_path} |
| 128 | |
| 129 | # Example of the 2 lists returned by this keyword: |
| 130 | # avgs: |
| 131 | # avgs[0]: /org/open_power/sensors/aggregation/per_30s/ps0_input_power/average |
| 132 | # avgs[1]: /org/open_power/sensors/aggregation/per_30s/ps1_input_power/average |
| 133 | # maxs: |
| 134 | # maxs[0]: /org/open_power/sensors/aggregation/per_30s/ps1_input_power/maximum |
| 135 | # maxs[1]: /org/open_power/sensors/aggregation/per_30s/ps0_input_power/maximum |
| 136 | |
| 137 | # Description of argument(s): |
| 138 | # object_base_uri_path Object path. |
| 139 | # base path "/org/open_power/sensors/" |
| 140 | # (e.g. "base path + aggregation/per_30s/ps0_input_power/average") |
| 141 | |
| 142 | # Example of open power sensor aggregation data as returned by the get |
| 143 | # request: |
| 144 | # /org/open_power/sensors/list |
| 145 | # [ |
| 146 | # "/org/open_power/sensors/aggregation/per_30s/ps0_input_power/average", |
| 147 | # "/org/open_power/sensors/aggregation/per_30s/ps1_input_power/maximum", |
| 148 | # "/org/open_power/sensors/aggregation/per_30s/ps0_input_power/maximum", |
| 149 | # "/org/open_power/sensors/aggregation/per_30s/ps1_input_power/average" |
| 150 | # ] |
| 151 | |
| 152 | ${resp}= OpenBMC Get Request ${object_base_uri_path}list quiet=${1} |
| 153 | ${content}= To JSON ${resp.content} |
| 154 | |
| 155 | ${power_supply_avg_list}= Create List |
| 156 | ${power_supply_max_list}= Create List |
| 157 | |
Marissa Garza | 522a0c2 | 2020-02-05 12:49:29 -0600 | [diff] [blame] | 158 | FOR ${entry} IN @{content["data"]} |
| 159 | Run Keyword If 'average' in '${entry}' Append To List ${power_supply_avg_list} ${entry} |
| 160 | Run Keyword If 'maximum' in '${entry}' Append To List ${power_supply_max_list} ${entry} |
| 161 | END |
George Keishing | ac51225 | 2018-02-05 02:04:30 -0600 | [diff] [blame] | 162 | |
| 163 | [Return] ${power_supply_avg_list} ${power_supply_max_list} |
Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 164 | |
| 165 | |
| 166 | REST Verify No Gard Records |
| 167 | [Documentation] Verify no gard records are present. |
| 168 | |
| 169 | ${resp}= Read Properties ${OPENPOWER_CONTROL}gard/enumerate |
| 170 | Log Dictionary ${resp} |
| 171 | Should Be Empty ${resp} msg=Found gard records. |