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] ${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} 37 38 39Count Object Entries 40 [Documentation] Count the occurrence number of a given object. 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 54Read 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 69 70Verify 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: 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* 81 82 FOR ${endpoint_path} IN @{cpu_list} 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} 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 92 93 94Get 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 121 FOR ${entry} IN @{resp} 122 Append To List ${power_sensors_value_list} ${entry[1]} 123 END 124 [Return] ${power_sensors_value_list} 125 126 127Get 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 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 165 166 [Return] ${power_supply_avg_list} ${power_supply_max_list} 167 168 169REST 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. 175 176 177Inject OPAL TI 178 [Documentation] OPAL terminate immediate procedure. 179 [Arguments] ${stable_branch}=master 180 ... ${repo_dir_path}=/tmp/repository 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} 200