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 |
Michael Shepos | d66cd55 | 2020-08-20 16:24:21 -0500 | [diff] [blame] | 6 | Resource ../lib/connection_client.robot |
George Keishing | cae6e90 | 2017-09-07 13:35:59 -0500 | [diff] [blame] | 7 | |
| 8 | *** Keywords *** |
| 9 | |
| 10 | Get OCC Objects |
| 11 | [Documentation] Get the OCC objects and return as a list. |
| 12 | |
| 13 | # Example: |
| 14 | # { |
| 15 | # "/org/open_power/control/occ0": { |
| 16 | # "OccActive": 0 |
| 17 | # }, |
| 18 | # "/org/open_power/control/occ1": { |
| 19 | # "OccActive": 1 |
| 20 | # } |
| 21 | |
George Keishing | 50cd001 | 2017-09-14 12:23:41 -0500 | [diff] [blame] | 22 | ${occ_list}= Get Endpoint Paths ${OPENPOWER_CONTROL} occ* |
George Keishing | cae6e90 | 2017-09-07 13:35:59 -0500 | [diff] [blame] | 23 | |
| 24 | [Return] ${occ_list} |
| 25 | |
| 26 | |
| 27 | Get OCC Active State |
| 28 | [Documentation] Get the OCC "OccActive" and return the attribute value. |
| 29 | [Arguments] ${occ_object} |
| 30 | |
| 31 | # Description of argument(s): |
| 32 | # occ_object OCC object path. |
| 33 | # (e.g. "/org/open_power/control/occ0"). |
| 34 | |
| 35 | ${occ_attribute}= Read Attribute ${occ_object} OccActive |
| 36 | [Return] ${occ_attribute} |
George Keishing | 50cd001 | 2017-09-14 12:23:41 -0500 | [diff] [blame] | 37 | |
| 38 | |
| 39 | Count Object Entries |
Gunnar Mills | 28e403b | 2017-10-25 16:16:38 -0500 | [diff] [blame] | 40 | [Documentation] Count the occurrence number of a given object. |
George Keishing | 50cd001 | 2017-09-14 12:23:41 -0500 | [diff] [blame] | 41 | [Arguments] ${object_base_uri_path} ${object_name} |
| 42 | |
| 43 | # Description of argument(s): |
| 44 | # object_base_uri_path Object base path |
| 45 | # (e.g. "/org/open_power/control/"). |
| 46 | # object_name Object name (e.g. "occ", "cpu" etc). |
| 47 | |
| 48 | ${object_list}= Get Endpoint Paths |
| 49 | ... ${object_base_uri_path} ${object_name} |
| 50 | ${list_count}= Get Length ${object_list} |
| 51 | [Return] ${list_count} |
| 52 | |
| 53 | |
| 54 | Read Object Attribute |
| 55 | [Documentation] Return object attribute data. |
| 56 | [Arguments] ${object_base_uri_path} ${attribute_name} |
| 57 | |
| 58 | # Description of argument(s): |
| 59 | # object_base_uri_path Object path. |
| 60 | # (e.g. "/org/open_power/control/occ0"). |
| 61 | # attribute_name Object attribute name. |
| 62 | |
| 63 | ${resp}= OpenBMC Get Request |
| 64 | ... ${object_base_uri_path}/attr/${attribute_name} quiet=${1} |
| 65 | Return From Keyword If ${resp.status_code} != ${HTTP_OK} |
| 66 | ${content}= To JSON ${resp.content} |
| 67 | [Return] ${content["data"]} |
| 68 | |
George Keishing | 5c96d1a | 2018-02-02 10:59:58 -0600 | [diff] [blame] | 69 | |
| 70 | Verify OCC State |
| 71 | [Documentation] Check OCC active state. |
| 72 | [Arguments] ${expected_occ_active}=${1} |
| 73 | # Description of Argument(s): |
| 74 | # expected_occ_active The expected occ_active value (i.e. 1/0). |
| 75 | |
| 76 | # Example cpu_list data output: |
George Keishing | 0ad13a1 | 2021-06-18 14:15:14 -0500 | [diff] [blame] | 77 | # /redfish/v1/Systems/system/Processors/cpu0 |
| 78 | # /redfish/v1/Systems/system/Processors/cpu1 |
| 79 | |
| 80 | ${cpu_list}= Redfish.Get Members List /redfish/v1/Systems/system/Processors/ cpu* |
George Keishing | 5c96d1a | 2018-02-02 10:59:58 -0600 | [diff] [blame] | 81 | |
Marissa Garza | 522a0c2 | 2020-02-05 12:49:29 -0600 | [diff] [blame] | 82 | FOR ${endpoint_path} IN @{cpu_list} |
George Keishing | 0ad13a1 | 2021-06-18 14:15:14 -0500 | [diff] [blame] | 83 | # {'Health': 'OK', 'State': 'Enabled'} get only matching status good. |
| 84 | ${cpu_status}= Redfish.Get Attribute ${endpoint_path} Status |
| 85 | Continue For Loop If '${cpu_status['Health']}' != 'OK' or '${cpu_status['State']}' != 'Enabled' |
| 86 | Log To Console ${cpu_status} |
Marissa Garza | 522a0c2 | 2020-02-05 12:49:29 -0600 | [diff] [blame] | 87 | ${num}= Set Variable ${endpoint_path[-1]} |
| 88 | ${occ_active}= Get OCC Active State ${OPENPOWER_CONTROL}occ${num} |
| 89 | Should Be Equal ${occ_active} ${expected_occ_active} |
| 90 | ... msg=OCC not in right state |
| 91 | END |
George Keishing | ac51225 | 2018-02-05 02:04:30 -0600 | [diff] [blame] | 92 | |
| 93 | |
| 94 | Get Sensors Aggregation Data |
| 95 | [Documentation] Return open power sensors aggregation value list. |
| 96 | [Arguments] ${object_base_uri_path} |
| 97 | |
| 98 | # Description of argument(s): |
| 99 | # object_base_uri_path An object path such as one of the elements |
| 100 | # returned by 'Get Sensors Aggregation URL List' |
| 101 | # (e.g. "/org/open_power/sensors/aggregation/per_30s/ps0_input_power/average"). |
| 102 | |
| 103 | # Example of aggregation [epoch,time] data: |
| 104 | # "Values": [ |
| 105 | # [ |
| 106 | # 1517815708479, <-- EPOCH |
| 107 | # 282 <-- Power value in watts |
| 108 | # ], |
| 109 | # [ |
| 110 | # 1517815678238, |
| 111 | # 282 |
| 112 | # ], |
| 113 | # [ |
| 114 | # 1517815648102, |
| 115 | # 282 |
| 116 | # ], |
| 117 | # ], |
| 118 | |
| 119 | ${resp}= Read Attribute ${object_base_uri_path} Values quiet=${1} |
| 120 | ${power_sensors_value_list}= Create List |
Marissa Garza | 522a0c2 | 2020-02-05 12:49:29 -0600 | [diff] [blame] | 121 | FOR ${entry} IN @{resp} |
| 122 | Append To List ${power_sensors_value_list} ${entry[1]} |
| 123 | END |
George Keishing | ac51225 | 2018-02-05 02:04:30 -0600 | [diff] [blame] | 124 | [Return] ${power_sensors_value_list} |
| 125 | |
| 126 | |
| 127 | Get Sensors Aggregation URL List |
| 128 | [Documentation] Return the open power aggregation maximum list and the |
| 129 | ... average list URIs. |
| 130 | [Arguments] ${object_base_uri_path} |
| 131 | |
| 132 | # Example of the 2 lists returned by this keyword: |
| 133 | # avgs: |
| 134 | # avgs[0]: /org/open_power/sensors/aggregation/per_30s/ps0_input_power/average |
| 135 | # avgs[1]: /org/open_power/sensors/aggregation/per_30s/ps1_input_power/average |
| 136 | # maxs: |
| 137 | # maxs[0]: /org/open_power/sensors/aggregation/per_30s/ps1_input_power/maximum |
| 138 | # maxs[1]: /org/open_power/sensors/aggregation/per_30s/ps0_input_power/maximum |
| 139 | |
| 140 | # Description of argument(s): |
| 141 | # object_base_uri_path Object path. |
| 142 | # base path "/org/open_power/sensors/" |
| 143 | # (e.g. "base path + aggregation/per_30s/ps0_input_power/average") |
| 144 | |
| 145 | # Example of open power sensor aggregation data as returned by the get |
| 146 | # request: |
| 147 | # /org/open_power/sensors/list |
| 148 | # [ |
| 149 | # "/org/open_power/sensors/aggregation/per_30s/ps0_input_power/average", |
| 150 | # "/org/open_power/sensors/aggregation/per_30s/ps1_input_power/maximum", |
| 151 | # "/org/open_power/sensors/aggregation/per_30s/ps0_input_power/maximum", |
| 152 | # "/org/open_power/sensors/aggregation/per_30s/ps1_input_power/average" |
| 153 | # ] |
| 154 | |
| 155 | ${resp}= OpenBMC Get Request ${object_base_uri_path}list quiet=${1} |
| 156 | ${content}= To JSON ${resp.content} |
| 157 | |
| 158 | ${power_supply_avg_list}= Create List |
| 159 | ${power_supply_max_list}= Create List |
| 160 | |
Marissa Garza | 522a0c2 | 2020-02-05 12:49:29 -0600 | [diff] [blame] | 161 | FOR ${entry} IN @{content["data"]} |
| 162 | Run Keyword If 'average' in '${entry}' Append To List ${power_supply_avg_list} ${entry} |
| 163 | Run Keyword If 'maximum' in '${entry}' Append To List ${power_supply_max_list} ${entry} |
| 164 | END |
George Keishing | ac51225 | 2018-02-05 02:04:30 -0600 | [diff] [blame] | 165 | |
| 166 | [Return] ${power_supply_avg_list} ${power_supply_max_list} |
Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 167 | |
| 168 | |
| 169 | REST Verify No Gard Records |
| 170 | [Documentation] Verify no gard records are present. |
| 171 | |
| 172 | ${resp}= Read Properties ${OPENPOWER_CONTROL}gard/enumerate |
| 173 | Log Dictionary ${resp} |
| 174 | Should Be Empty ${resp} msg=Found gard records. |
Michael Shepos | d66cd55 | 2020-08-20 16:24:21 -0500 | [diff] [blame] | 175 | |
| 176 | |
| 177 | Inject OPAL TI |
| 178 | [Documentation] OPAL terminate immediate procedure. |
| 179 | [Arguments] ${stable_branch}=master |
Michael Shepos | 8381f73 | 2021-04-20 12:03:08 -0500 | [diff] [blame] | 180 | ... ${repo_dir_path}=/tmp/repository |
Michael Shepos | d66cd55 | 2020-08-20 16:24:21 -0500 | [diff] [blame] | 181 | ... ${repo_github_url}=https://github.com/open-power/op-test |
| 182 | |
| 183 | # Description of arguments: |
| 184 | # stable_branch Git branch to clone. (default: master) |
| 185 | # repo_dir_path Directory path for repo tool (e.g. "op-test"). |
| 186 | # repo_github_url Github URL link (e.g. "https://github.com/open-power/op-test"). |
| 187 | |
| 188 | ${value}= Generate Random String 4 [NUMBERS] |
| 189 | |
| 190 | ${cmd_buf}= Catenate git clone --branch ${stable_branch} ${repo_github_url} ${repo_dir_path}/${value} |
| 191 | Shell Cmd ${cmd_buf} |
| 192 | |
| 193 | Open Connection for SCP |
| 194 | scp.Put File ${repo_dir_path}/${value}/test_binaries/deadbeef /tmp |
| 195 | Pdbg -a putmem 0x300000f8 < /tmp/deadbeef |
| 196 | |
| 197 | # Clean up the repo once done. |
| 198 | ${cmd_buf}= Catenate rm -rf ${repo_dir_path}${/}${value} |
| 199 | Shell Cmd ${cmd_buf} |