| 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 | 8ef9e72 | 2023-01-18 10:21:31 +0530 | [diff] [blame] | 7 | Library utilities.py |
| George Keishing | cae6e90 | 2017-09-07 13:35:59 -0500 | [diff] [blame] | 8 | |
| George Keishing | edd01e1 | 2021-08-31 14:01:12 -0500 | [diff] [blame] | 9 | *** Variables *** |
| 10 | ${functional_cpu_count} ${0} |
| 11 | ${active_occ_count} ${0} |
| George Keishing | 9c22309 | 2024-01-29 21:18:25 +0530 | [diff] [blame] | 12 | ${OCC_WAIT_TIMEOUT} 8 min |
| George Keishing | c23f387 | 2023-03-16 22:43:33 +0530 | [diff] [blame] | 13 | ${fan_json_msg} Unable to create dump on non-JSON config based system |
| George Keishing | edd01e1 | 2021-08-31 14:01:12 -0500 | [diff] [blame] | 14 | |
| George Keishing | cae6e90 | 2017-09-07 13:35:59 -0500 | [diff] [blame] | 15 | *** Keywords *** |
| 16 | |
| 17 | Get OCC Objects |
| 18 | [Documentation] Get the OCC objects and return as a list. |
| 19 | |
| 20 | # Example: |
| 21 | # { |
| 22 | # "/org/open_power/control/occ0": { |
| 23 | # "OccActive": 0 |
| 24 | # }, |
| 25 | # "/org/open_power/control/occ1": { |
| 26 | # "OccActive": 1 |
| 27 | # } |
| 28 | |
| George Keishing | 50cd001 | 2017-09-14 12:23:41 -0500 | [diff] [blame] | 29 | ${occ_list}= Get Endpoint Paths ${OPENPOWER_CONTROL} occ* |
| George Keishing | cae6e90 | 2017-09-07 13:35:59 -0500 | [diff] [blame] | 30 | |
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 31 | RETURN ${occ_list} |
| George Keishing | cae6e90 | 2017-09-07 13:35:59 -0500 | [diff] [blame] | 32 | |
| 33 | |
| 34 | Get OCC Active State |
| 35 | [Documentation] Get the OCC "OccActive" and return the attribute value. |
| George Keishing | 9f48701 | 2021-08-19 12:18:10 -0500 | [diff] [blame] | 36 | [Arguments] ${value} |
| George Keishing | cae6e90 | 2017-09-07 13:35:59 -0500 | [diff] [blame] | 37 | |
| 38 | # Description of argument(s): |
| George Keishing | 9f48701 | 2021-08-19 12:18:10 -0500 | [diff] [blame] | 39 | # value CPU position (e.g. "0, 1, 2"). |
| George Keishing | cae6e90 | 2017-09-07 13:35:59 -0500 | [diff] [blame] | 40 | |
| George Keishing | 9f48701 | 2021-08-19 12:18:10 -0500 | [diff] [blame] | 41 | ${cmd}= Catenate busctl get-property org.open_power.OCC.Control |
| 42 | ... /org/open_power/control/occ${value} org.open_power.OCC.Status OccActive |
| 43 | |
| 44 | ${cmd_output} ${stderr} ${rc} = BMC Execute Command ${cmd} |
| 45 | ... print_out=1 print_err=1 ignore_err=1 |
| 46 | |
| 47 | # The command returns format 'b true' |
| Sridevi Ramesh | fd8e5de | 2025-10-22 07:27:26 -0500 | [diff] [blame^] | 48 | IF '${cmd_output.split(' ')[-1]}' == 'true' |
| 49 | RETURN ${1} |
| 50 | END |
| George Keishing | 9f48701 | 2021-08-19 12:18:10 -0500 | [diff] [blame] | 51 | |
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 52 | RETURN ${0} |
| George Keishing | 50cd001 | 2017-09-14 12:23:41 -0500 | [diff] [blame] | 53 | |
| 54 | |
| 55 | Count Object Entries |
| Gunnar Mills | 28e403b | 2017-10-25 16:16:38 -0500 | [diff] [blame] | 56 | [Documentation] Count the occurrence number of a given object. |
| George Keishing | 50cd001 | 2017-09-14 12:23:41 -0500 | [diff] [blame] | 57 | [Arguments] ${object_base_uri_path} ${object_name} |
| 58 | |
| 59 | # Description of argument(s): |
| 60 | # object_base_uri_path Object base path |
| 61 | # (e.g. "/org/open_power/control/"). |
| 62 | # object_name Object name (e.g. "occ", "cpu" etc). |
| 63 | |
| 64 | ${object_list}= Get Endpoint Paths |
| 65 | ... ${object_base_uri_path} ${object_name} |
| 66 | ${list_count}= Get Length ${object_list} |
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 67 | RETURN ${list_count} |
| George Keishing | 50cd001 | 2017-09-14 12:23:41 -0500 | [diff] [blame] | 68 | |
| 69 | |
| 70 | Read Object Attribute |
| 71 | [Documentation] Return object attribute data. |
| 72 | [Arguments] ${object_base_uri_path} ${attribute_name} |
| 73 | |
| 74 | # Description of argument(s): |
| 75 | # object_base_uri_path Object path. |
| 76 | # (e.g. "/org/open_power/control/occ0"). |
| 77 | # attribute_name Object attribute name. |
| 78 | |
| 79 | ${resp}= OpenBMC Get Request |
| 80 | ... ${object_base_uri_path}/attr/${attribute_name} quiet=${1} |
| Sridevi Ramesh | fd8e5de | 2025-10-22 07:27:26 -0500 | [diff] [blame^] | 81 | |
| 82 | IF ${resp.status_code} != ${HTTP_OK} |
| 83 | RETURN |
| 84 | END |
| 85 | |
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 86 | RETURN ${resp.json()["data"]} |
| George Keishing | 50cd001 | 2017-09-14 12:23:41 -0500 | [diff] [blame] | 87 | |
| George Keishing | 5c96d1a | 2018-02-02 10:59:58 -0600 | [diff] [blame] | 88 | |
| George Keishing | edd01e1 | 2021-08-31 14:01:12 -0500 | [diff] [blame] | 89 | Get Functional Processor Count |
| 90 | [Documentation] Get functional processor count. |
| 91 | |
| Yi Hu | c32434a | 2024-01-11 17:33:10 -0800 | [diff] [blame] | 92 | ${cpu_list}= Redfish.Get Members List /redfish/v1/Systems/${SYSTEM_ID}/Processors/ *cpu* |
| George Keishing | edd01e1 | 2021-08-31 14:01:12 -0500 | [diff] [blame] | 93 | |
| 94 | FOR ${endpoint_path} IN @{cpu_list} |
| 95 | # {'Health': 'OK', 'State': 'Enabled'} get only matching status good. |
| 96 | ${cpu_status}= Redfish.Get Attribute ${endpoint_path} Status |
| Sridevi Ramesh | fd8e5de | 2025-10-22 07:27:26 -0500 | [diff] [blame^] | 97 | |
| 98 | IF '${cpu_status['Health']}' != 'OK' or '${cpu_status['State']}' != 'Enabled' |
| 99 | CONTINUE |
| 100 | END |
| George Keishing | edd01e1 | 2021-08-31 14:01:12 -0500 | [diff] [blame] | 101 | ${functional_cpu_count} = Evaluate ${functional_cpu_count} + 1 |
| 102 | END |
| 103 | |
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 104 | RETURN ${functional_cpu_count} |
| George Keishing | edd01e1 | 2021-08-31 14:01:12 -0500 | [diff] [blame] | 105 | |
| 106 | |
| 107 | Get Active OCC State Count |
| 108 | [Documentation] Get active OCC state count. |
| 109 | |
| Yi Hu | c32434a | 2024-01-11 17:33:10 -0800 | [diff] [blame] | 110 | ${cpu_list}= Redfish.Get Members List /redfish/v1/Systems/${SYSTEM_ID}/Processors/ *cpu* |
| George Keishing | edd01e1 | 2021-08-31 14:01:12 -0500 | [diff] [blame] | 111 | |
| 112 | FOR ${endpoint_path} IN @{cpu_list} |
| 113 | ${num}= Set Variable ${endpoint_path[-1]} |
| 114 | ${cmd}= Catenate busctl get-property org.open_power.OCC.Control |
| 115 | ... /org/open_power/control/occ${num} org.open_power.OCC.Status OccActive |
| 116 | |
| 117 | ${cmd_output} ${stderr} ${rc} = BMC Execute Command ${cmd} |
| 118 | ... print_out=1 print_err=1 ignore_err=1 |
| 119 | |
| 120 | # The command returns format 'b true' |
| Sridevi Ramesh | fd8e5de | 2025-10-22 07:27:26 -0500 | [diff] [blame^] | 121 | IF '${cmd_output.split(' ')[-1]}' != 'true' CONTINUE |
| George Keishing | edd01e1 | 2021-08-31 14:01:12 -0500 | [diff] [blame] | 122 | ${active_occ_count} = Evaluate ${active_occ_count} + 1 |
| 123 | END |
| 124 | |
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 125 | RETURN ${active_occ_count} |
| George Keishing | edd01e1 | 2021-08-31 14:01:12 -0500 | [diff] [blame] | 126 | |
| 127 | |
| 128 | Match OCC And CPU State Count |
| George Keishing | 8b38c1a | 2021-12-06 22:47:18 -0600 | [diff] [blame] | 129 | [Documentation] Get CPU functional count and verify OCC count active matches. |
| 130 | |
| George Keishing | edd01e1 | 2021-08-31 14:01:12 -0500 | [diff] [blame] | 131 | ${cpu_count}= Get Functional Processor Count |
| George Keishing | 8b38c1a | 2021-12-06 22:47:18 -0600 | [diff] [blame] | 132 | Log To Console Functional Processor count: ${cpu_count} |
| 133 | |
| 134 | FOR ${num} IN RANGE ${0} ${cpu_count} |
| 135 | ${cmd}= Catenate busctl get-property org.open_power.OCC.Control |
| 136 | ... /org/open_power/control/occ${num} org.open_power.OCC.Status OccActive |
| 137 | |
| 138 | ${cmd_output} ${stderr} ${rc} = BMC Execute Command ${cmd} |
| 139 | ... print_out=1 print_err=1 ignore_err=1 |
| 140 | |
| 141 | # The command returns format 'b true' |
| Sridevi Ramesh | fd8e5de | 2025-10-22 07:27:26 -0500 | [diff] [blame^] | 142 | IF '${cmd_output.split(' ')[-1]}' != 'true' CONTINUE |
| George Keishing | 8b38c1a | 2021-12-06 22:47:18 -0600 | [diff] [blame] | 143 | ${active_occ_count} = Evaluate ${active_occ_count} + 1 |
| 144 | END |
| 145 | |
| 146 | Log To Console OCC Active count: ${active_occ_count} |
| 147 | |
| 148 | Should Be Equal ${active_occ_count} ${cpu_count} |
| 149 | ... msg=OCC count ${active_occ_count} and CPU Count ${cpu_count} mismatched. |
| George Keishing | edd01e1 | 2021-08-31 14:01:12 -0500 | [diff] [blame] | 150 | |
| 151 | |
| George Keishing | 5c96d1a | 2018-02-02 10:59:58 -0600 | [diff] [blame] | 152 | Verify OCC State |
| 153 | [Documentation] Check OCC active state. |
| 154 | [Arguments] ${expected_occ_active}=${1} |
| 155 | # Description of Argument(s): |
| 156 | # expected_occ_active The expected occ_active value (i.e. 1/0). |
| 157 | |
| 158 | # Example cpu_list data output: |
| George Keishing | 0ad13a1 | 2021-06-18 14:15:14 -0500 | [diff] [blame] | 159 | # /redfish/v1/Systems/system/Processors/cpu0 |
| 160 | # /redfish/v1/Systems/system/Processors/cpu1 |
| 161 | |
| Yi Hu | c32434a | 2024-01-11 17:33:10 -0800 | [diff] [blame] | 162 | ${cpu_list}= Redfish.Get Members List /redfish/v1/Systems/${SYSTEM_ID}/Processors/ cpu* |
| George Keishing | 5c96d1a | 2018-02-02 10:59:58 -0600 | [diff] [blame] | 163 | |
| Marissa Garza | 522a0c2 | 2020-02-05 12:49:29 -0600 | [diff] [blame] | 164 | FOR ${endpoint_path} IN @{cpu_list} |
| George Keishing | 0ad13a1 | 2021-06-18 14:15:14 -0500 | [diff] [blame] | 165 | # {'Health': 'OK', 'State': 'Enabled'} get only matching status good. |
| 166 | ${cpu_status}= Redfish.Get Attribute ${endpoint_path} Status |
| Sridevi Ramesh | fd8e5de | 2025-10-22 07:27:26 -0500 | [diff] [blame^] | 167 | IF '${cpu_status['Health']}' != 'OK' or '${cpu_status['State']}' != 'Enabled' CONTINUE |
| George Keishing | 0ad13a1 | 2021-06-18 14:15:14 -0500 | [diff] [blame] | 168 | Log To Console ${cpu_status} |
| Marissa Garza | 522a0c2 | 2020-02-05 12:49:29 -0600 | [diff] [blame] | 169 | ${num}= Set Variable ${endpoint_path[-1]} |
| George Keishing | 9f48701 | 2021-08-19 12:18:10 -0500 | [diff] [blame] | 170 | ${occ_active}= Get OCC Active State ${num} |
| Marissa Garza | 522a0c2 | 2020-02-05 12:49:29 -0600 | [diff] [blame] | 171 | Should Be Equal ${occ_active} ${expected_occ_active} |
| 172 | ... msg=OCC not in right state |
| 173 | END |
| George Keishing | ac51225 | 2018-02-05 02:04:30 -0600 | [diff] [blame] | 174 | |
| 175 | |
| 176 | Get Sensors Aggregation Data |
| 177 | [Documentation] Return open power sensors aggregation value list. |
| 178 | [Arguments] ${object_base_uri_path} |
| 179 | |
| 180 | # Description of argument(s): |
| 181 | # object_base_uri_path An object path such as one of the elements |
| 182 | # returned by 'Get Sensors Aggregation URL List' |
| 183 | # (e.g. "/org/open_power/sensors/aggregation/per_30s/ps0_input_power/average"). |
| 184 | |
| 185 | # Example of aggregation [epoch,time] data: |
| 186 | # "Values": [ |
| 187 | # [ |
| 188 | # 1517815708479, <-- EPOCH |
| 189 | # 282 <-- Power value in watts |
| 190 | # ], |
| 191 | # [ |
| 192 | # 1517815678238, |
| 193 | # 282 |
| 194 | # ], |
| 195 | # [ |
| 196 | # 1517815648102, |
| 197 | # 282 |
| 198 | # ], |
| 199 | # ], |
| 200 | |
| 201 | ${resp}= Read Attribute ${object_base_uri_path} Values quiet=${1} |
| 202 | ${power_sensors_value_list}= Create List |
| Marissa Garza | 522a0c2 | 2020-02-05 12:49:29 -0600 | [diff] [blame] | 203 | FOR ${entry} IN @{resp} |
| 204 | Append To List ${power_sensors_value_list} ${entry[1]} |
| 205 | END |
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 206 | RETURN ${power_sensors_value_list} |
| George Keishing | ac51225 | 2018-02-05 02:04:30 -0600 | [diff] [blame] | 207 | |
| 208 | |
| 209 | Get Sensors Aggregation URL List |
| 210 | [Documentation] Return the open power aggregation maximum list and the |
| 211 | ... average list URIs. |
| 212 | [Arguments] ${object_base_uri_path} |
| 213 | |
| 214 | # Example of the 2 lists returned by this keyword: |
| 215 | # avgs: |
| 216 | # avgs[0]: /org/open_power/sensors/aggregation/per_30s/ps0_input_power/average |
| 217 | # avgs[1]: /org/open_power/sensors/aggregation/per_30s/ps1_input_power/average |
| 218 | # maxs: |
| 219 | # maxs[0]: /org/open_power/sensors/aggregation/per_30s/ps1_input_power/maximum |
| 220 | # maxs[1]: /org/open_power/sensors/aggregation/per_30s/ps0_input_power/maximum |
| 221 | |
| 222 | # Description of argument(s): |
| 223 | # object_base_uri_path Object path. |
| 224 | # base path "/org/open_power/sensors/" |
| 225 | # (e.g. "base path + aggregation/per_30s/ps0_input_power/average") |
| 226 | |
| 227 | # Example of open power sensor aggregation data as returned by the get |
| 228 | # request: |
| 229 | # /org/open_power/sensors/list |
| 230 | # [ |
| 231 | # "/org/open_power/sensors/aggregation/per_30s/ps0_input_power/average", |
| 232 | # "/org/open_power/sensors/aggregation/per_30s/ps1_input_power/maximum", |
| 233 | # "/org/open_power/sensors/aggregation/per_30s/ps0_input_power/maximum", |
| 234 | # "/org/open_power/sensors/aggregation/per_30s/ps1_input_power/average" |
| 235 | # ] |
| 236 | |
| 237 | ${resp}= OpenBMC Get Request ${object_base_uri_path}list quiet=${1} |
| George Keishing | ac51225 | 2018-02-05 02:04:30 -0600 | [diff] [blame] | 238 | |
| 239 | ${power_supply_avg_list}= Create List |
| 240 | ${power_supply_max_list}= Create List |
| 241 | |
| George Keishing | fbd6700 | 2022-08-01 11:24:03 -0500 | [diff] [blame] | 242 | FOR ${entry} IN @{resp.json()["data"]} |
| Sridevi Ramesh | fd8e5de | 2025-10-22 07:27:26 -0500 | [diff] [blame^] | 243 | IF 'average' in '${entry}' Append To List ${power_supply_avg_list} ${entry} |
| 244 | IF 'maximum' in '${entry}' Append To List ${power_supply_max_list} ${entry} |
| Marissa Garza | 522a0c2 | 2020-02-05 12:49:29 -0600 | [diff] [blame] | 245 | END |
| George Keishing | ac51225 | 2018-02-05 02:04:30 -0600 | [diff] [blame] | 246 | |
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 247 | RETURN ${power_supply_avg_list} ${power_supply_max_list} |
| Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 248 | |
| 249 | |
| 250 | REST Verify No Gard Records |
| 251 | [Documentation] Verify no gard records are present. |
| 252 | |
| 253 | ${resp}= Read Properties ${OPENPOWER_CONTROL}gard/enumerate |
| 254 | Log Dictionary ${resp} |
| 255 | Should Be Empty ${resp} msg=Found gard records. |
| Michael Shepos | d66cd55 | 2020-08-20 16:24:21 -0500 | [diff] [blame] | 256 | |
| 257 | |
| 258 | Inject OPAL TI |
| 259 | [Documentation] OPAL terminate immediate procedure. |
| 260 | [Arguments] ${stable_branch}=master |
| Michael Shepos | 8381f735 | 2021-04-20 12:03:08 -0500 | [diff] [blame] | 261 | ... ${repo_dir_path}=/tmp/repository |
| Michael Shepos | d66cd55 | 2020-08-20 16:24:21 -0500 | [diff] [blame] | 262 | ... ${repo_github_url}=https://github.com/open-power/op-test |
| 263 | |
| 264 | # Description of arguments: |
| 265 | # stable_branch Git branch to clone. (default: master) |
| 266 | # repo_dir_path Directory path for repo tool (e.g. "op-test"). |
| 267 | # repo_github_url Github URL link (e.g. "https://github.com/open-power/op-test"). |
| 268 | |
| 269 | ${value}= Generate Random String 4 [NUMBERS] |
| 270 | |
| 271 | ${cmd_buf}= Catenate git clone --branch ${stable_branch} ${repo_github_url} ${repo_dir_path}/${value} |
| 272 | Shell Cmd ${cmd_buf} |
| 273 | |
| 274 | Open Connection for SCP |
| 275 | scp.Put File ${repo_dir_path}/${value}/test_binaries/deadbeef /tmp |
| 276 | Pdbg -a putmem 0x300000f8 < /tmp/deadbeef |
| 277 | |
| 278 | # Clean up the repo once done. |
| 279 | ${cmd_buf}= Catenate rm -rf ${repo_dir_path}${/}${value} |
| 280 | Shell Cmd ${cmd_buf} |
| George Keishing | 2d4a810 | 2022-02-22 12:23:21 -0600 | [diff] [blame] | 281 | |
| 282 | |
| 283 | Trigger OCC Reset |
| 284 | [Documentation] Trigger OCC reset request on an active OCC. |
| 285 | [Arguments] ${occ_target}=${0} |
| 286 | |
| 287 | # Description of Argument(s): |
| 288 | # occ_target Target a valid given OCC number 0,1, etc. |
| 289 | |
| 290 | Log To Console OCC Reset Triggered on OCC ${occ_target} |
| 291 | |
| 292 | ${cmd}= Catenate busctl call org.open_power.OCC.Control |
| 293 | ... /org/open_power/control/occ${occ_target} org.open_power.OCC.PassThrough |
| 294 | ... Send ai 8 64 0 5 20 82 83 84 0 |
| 295 | |
| 296 | ${cmd_output} ${stderr} ${rc} = BMC Execute Command ${cmd} print_out=1 print_err=1 |
| 297 | |
| George Keishing | 5dd532a | 2022-03-07 11:14:42 -0600 | [diff] [blame] | 298 | Log To Console OCC wait check for disabled state. |
| 299 | Wait Until Keyword Succeeds 30 sec 5 sec Verify OCC Target State ${occ_target} |
| 300 | |
| 301 | |
| 302 | Verify OCC Target State |
| 303 | [Documentation] Verify that the user given state matches th current OCC state. |
| 304 | [Arguments] ${occ_target}=${0} ${expected_state}=${0} |
| 305 | |
| 306 | # Description of Argument(s): |
| 307 | # occ_target Target a valid given OCC number 0,1, etc. |
| 308 | # expected_state For OCC either 0 or 1. Default is 0. |
| George Keishing | 2d4a810 | 2022-02-22 12:23:21 -0600 | [diff] [blame] | 309 | |
| 310 | ${occ_active}= Get OCC Active State ${occ_target} |
| George Keishing | 5dd532a | 2022-03-07 11:14:42 -0600 | [diff] [blame] | 311 | Should Be Equal ${occ_active} ${expected_state} |
| George Keishing | 2d4a810 | 2022-02-22 12:23:21 -0600 | [diff] [blame] | 312 | Log To Console Target OCC ${occ_target} state is ${occ_active}. |
| 313 | |
| 314 | |
| 315 | Trigger OCC Reset And Wait For OCC Active State |
| 316 | [Documentation] Trigger OCC reset request and wait for OCC to reset back to active state. |
| 317 | |
| 318 | Trigger OCC Reset |
| 319 | |
| 320 | Log To Console OCC wait check for active state. |
| 321 | Wait Until Keyword Succeeds ${OCC_WAIT_TIMEOUT} 20 sec Match OCC And CPU State Count |
| George Keishing | d1baad6 | 2022-11-23 08:25:36 -0600 | [diff] [blame] | 322 | |
| 323 | |
| 324 | Get Sensors Dbus Tree List |
| 325 | [Documentation] Get the list dbus path of the given sensor object and |
| 326 | ... return the populatedlist. |
| 327 | |
| 328 | ${dbus_obj_var}= Set Variable |
| 329 | ... xyz.openbmc_project.HwmonTempSensor |
| 330 | ... xyz.openbmc_project.ADCSensor |
| 331 | ... xyz.openbmc_project.VirtualSensor |
| 332 | |
| 333 | # Filter only the dbus paths service by the sensor obj. |
| 334 | ${sensors_dbus_tree_dict}= Create Dictionary |
| 335 | FOR ${dbus_obj} IN @{dbus_obj_var} |
| 336 | ${cmd}= Catenate busctl tree ${dbus_obj} --list | grep /sensors/ |
| 337 | ${cmd_output} ${stderr} ${rc} = BMC Execute Command ${cmd} |
| 338 | ... print_out=0 print_err=0 ignore_err=1 |
| 339 | Set To Dictionary ${sensors_dbus_tree_dict} ${dbus_obj} ${cmd_output.splitlines()} |
| 340 | END |
| 341 | |
| 342 | Rprint Vars sensors_dbus_tree_dict |
| 343 | # Key Pair: 'sensor obj":[list of obj URI] |
| 344 | # Example: |
| 345 | # sensors_dbus_tree_dict: |
| 346 | # [xyz.openbmc_project.HwmonTempSensor]: |
| 347 | # [0]: /xyz/openbmc_project/sensors/temperature/Ambient_0_Temp |
| 348 | # [1]: /xyz/openbmc_project/sensors/temperature/PCIE_0_Temp |
| 349 | # [xyz.openbmc_project.ADCSensor]: |
| 350 | # [0]: /xyz/openbmc_project/sensors/voltage/Battery_Voltage |
| 351 | # [xyz.openbmc_project.VirtualSensor]: |
| 352 | # [0]: /xyz/openbmc_project/sensors/temperature/Ambient_Virtual_Temp |
| 353 | |
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 354 | RETURN ${sensors_dbus_tree_dict} |
| George Keishing | d1baad6 | 2022-11-23 08:25:36 -0600 | [diff] [blame] | 355 | |
| 356 | |
| 357 | Get Populated Sensors Dbus List |
| 358 | [Documentation] Perform GET operation on the attribute list and confirm it is |
| 359 | ... populated and does not error out during GET request.. |
| 360 | |
| 361 | ${sensor_dict}= Get Sensors Dbus Tree List |
| 362 | |
| 363 | # Loop through the dictionary and iterate item entries. |
| 364 | ${valid_dbus_list}= Create List |
| 365 | FOR ${key} IN @{sensor_dict.keys()} |
| 366 | FOR ${val} IN @{sensor_dict["${key}"]} |
| 367 | ${cmd}= Catenate |
| 368 | ... busctl get-property ${key} ${val} xyz.openbmc_project.Sensor.Value Value |
| 369 | ${cmd_output} ${stderr} ${rc} = BMC Execute Command ${cmd} |
| 370 | ... print_out=0 print_err=0 ignore_err=1 |
| 371 | # Skip failed to get property command on Dbus object. |
| Sridevi Ramesh | fd8e5de | 2025-10-22 07:27:26 -0500 | [diff] [blame^] | 372 | IF ${rc} == 0 Append To List ${valid_dbus_list} ${val} |
| George Keishing | d1baad6 | 2022-11-23 08:25:36 -0600 | [diff] [blame] | 373 | END |
| 374 | END |
| 375 | |
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 376 | RETURN ${valid_dbus_list} |
| George Keishing | d1baad6 | 2022-11-23 08:25:36 -0600 | [diff] [blame] | 377 | |
| 378 | |
| 379 | Verify Runtime Sensors Dbus List |
| 380 | [Documentation] Load pre-defined sensor JSON Dbus data and validate against |
| 381 | ... runtime sensor list generated. |
| 382 | |
| 383 | # Default path data/sensor_dbus.json else takes |
| 384 | # user CLI input -v SENSOR_DBUS_JSON_FILE_PATH:<path> |
| 385 | ${SENSOR_DBUS_JSON_FILE_PATH}= |
| 386 | ... Get Variable Value ${SENSOR_DBUS_JSON_FILE_PATH} data/sensor_dbus.json |
| 387 | |
| 388 | ${json_data}= OperatingSystem.Get File ${SENSOR_DBUS_JSON_FILE_PATH} |
| 389 | ${json_sensor_data}= Evaluate json.loads('''${json_data}''') json |
| 390 | |
| 391 | ${runtime_sensor_list}= Get Populated Sensors Dbus List |
| 392 | |
| 393 | ${system_model}= Get BMC System Model |
| 394 | Rprint Vars system_model |
| 395 | Rprint Vars runtime_sensor_list |
| 396 | |
| 397 | ${status}= Run Keyword And Return Status |
| 398 | ... Dictionary Should Contain Value ${json_sensor_data} ${runtime_sensor_list} |
| 399 | |
| Sridevi Ramesh | fd8e5de | 2025-10-22 07:27:26 -0500 | [diff] [blame^] | 400 | IF ${status} == ${False} Log And Fail ${json_sensor_data} |
| George Keishing | d1baad6 | 2022-11-23 08:25:36 -0600 | [diff] [blame] | 401 | |
| 402 | Log To Console Runtime Dbus sensor list matches. |
| 403 | |
| 404 | |
| 405 | Log And Fail |
| 406 | [Documentation] Log detailed failure log on the console. |
| 407 | [Arguments] ${json_sensor_data} |
| 408 | |
| 409 | # Description of Argument(s): |
| 410 | # json_sensor_data Sensor JSON data from data/sensor_dbus.json. |
| 411 | |
| 412 | Rprint Vars json_sensor_data |
| 413 | Fail Runtime generated Dbus sensors does not match |
| 414 | |
| George Keishing | 8ef9e72 | 2023-01-18 10:21:31 +0530 | [diff] [blame] | 415 | |
| 416 | Dump Fan Control JSON |
| 417 | [Documentation] Execute fan control on BMC to dump config with 'fanctl dump', |
| 418 | ... which makes it write a /tmp/fan_control_dump.json file. |
| 419 | |
| 420 | ${output} ${stderr} ${rc} = BMC Execute Command test -f /usr/bin/fanctl |
| 421 | ... print_err=1 ignore_err=1 |
| Sridevi Ramesh | fd8e5de | 2025-10-22 07:27:26 -0500 | [diff] [blame^] | 422 | |
| 423 | IF ${rc} == 1 RETURN fanctl application doesn't exist. |
| George Keishing | 8ef9e72 | 2023-01-18 10:21:31 +0530 | [diff] [blame] | 424 | |
| 425 | # This command will force a fan_control_dump.json file in temp path and |
| 426 | # takes few seconds to complete.. |
| 427 | BMC Execute Command fanctl dump |
| 428 | Sleep 10s |
| 429 | |
| George Keishing | c23f387 | 2023-03-16 22:43:33 +0530 | [diff] [blame] | 430 | |
| 431 | Get Fan JSON Data |
| 432 | [Documentation] Read the JSON string file from BMC and return. |
| 433 | |
| George Keishing | 8ef9e72 | 2023-01-18 10:21:31 +0530 | [diff] [blame] | 434 | # Check for the generated file and return the file data as JSON and fails if |
| 435 | # it doesn't find file generated. |
| 436 | ${cmd}= Catenate test -f /tmp/fan_control_dump.json; cat /tmp/fan_control_dump.json |
| 437 | ${json_string} ${stderr} ${rc} = BMC Execute Command ${cmd} |
| 438 | ... print_out=1 print_err=1 ignore_err=1 |
| 439 | |
| 440 | Should Be True ${rc} == 0 msg=No Fan control config JSON file is generated. |
| 441 | ${fan_json}= Evaluate json.loads('''${json_string}''') json |
| 442 | |
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 443 | RETURN ${fan_json} |
| George Keishing | 8ef9e72 | 2023-01-18 10:21:31 +0530 | [diff] [blame] | 444 | |
| 445 | |
| 446 | Get Fan Attribute Value |
| 447 | [Documentation] Return the specified value of the matched search key in |
| 448 | ... nested dictionary data. |
| George Keishing | c23f387 | 2023-03-16 22:43:33 +0530 | [diff] [blame] | 449 | [Arguments] ${fan_dict} ${key_value} |
| George Keishing | 8ef9e72 | 2023-01-18 10:21:31 +0530 | [diff] [blame] | 450 | |
| 451 | # Description of Argument(s): |
| 452 | # key_value User input attribute value in the dictionary. |
| 453 | |
| George Keishing | c23f387 | 2023-03-16 22:43:33 +0530 | [diff] [blame] | 454 | ${empty_dicts}= Create Dictionary |
| 455 | |
| 456 | # Check for JSON response data. |
| 457 | # { |
| 458 | # "msg": "Unable to create dump on non-JSON config based system" |
| 459 | # } |
| 460 | |
| 461 | ${status}= Run Keyword And Return Status |
| 462 | ... Should Be Equal ${fan_dict["msg"]} ${fan_json_msg} |
| 463 | IF ${status} |
| 464 | Log To Console Skipping attribute ${key_value} check. |
| 465 | Return From Keyword ${empty_dicts} |
| 466 | END |
| George Keishing | 8ef9e72 | 2023-01-18 10:21:31 +0530 | [diff] [blame] | 467 | |
| 468 | # Python module: get_value_from_nested_dict(key,dict) |
| 469 | ${value_list}= utilities.Get Value From Nested Dict ${key_value} ${fan_dict} |
| 470 | |
| 471 | Should Not Be Empty ${value_list} msg=${key_value} key attribute not found. |
| 472 | |
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 473 | RETURN ${value_list[0]} |