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