blob: bcc37bd51b797779e821c7e734477dd4ee37868c [file] [log] [blame]
George Keishingcae6e902017-09-07 13:35:59 -05001*** Settings ***
2Documentation Open power domain keywords.
3
George Keishing7e825d82019-12-13 00:38:15 -06004Variables ../data/variables.py
George Keishingcae6e902017-09-07 13:35:59 -05005Resource ../lib/utils.robot
Michael Sheposd66cd552020-08-20 16:24:21 -05006Resource ../lib/connection_client.robot
George Keishingcae6e902017-09-07 13:35:59 -05007
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
George Keishing50cd0012017-09-14 12:23:41 -050022 ${occ_list}= Get Endpoint Paths ${OPENPOWER_CONTROL} occ*
George Keishingcae6e902017-09-07 13:35:59 -050023
24 [Return] ${occ_list}
25
26
27Get OCC Active State
28 [Documentation] Get the OCC "OccActive" and return the attribute value.
George Keishing9f487012021-08-19 12:18:10 -050029 [Arguments] ${value}
George Keishingcae6e902017-09-07 13:35:59 -050030
31 # Description of argument(s):
George Keishing9f487012021-08-19 12:18:10 -050032 # value CPU position (e.g. "0, 1, 2").
George Keishingcae6e902017-09-07 13:35:59 -050033
George Keishing9f487012021-08-19 12:18:10 -050034 ${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}
George Keishing50cd0012017-09-14 12:23:41 -050044
45
46Count Object Entries
Gunnar Mills28e403b2017-10-25 16:16:38 -050047 [Documentation] Count the occurrence number of a given object.
George Keishing50cd0012017-09-14 12:23:41 -050048 [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
George Keishing5c96d1a2018-02-02 10:59:58 -060076
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:
George Keishing0ad13a12021-06-18 14:15:14 -050084 # /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*
George Keishing5c96d1a2018-02-02 10:59:58 -060088
Marissa Garza522a0c22020-02-05 12:49:29 -060089 FOR ${endpoint_path} IN @{cpu_list}
George Keishing0ad13a12021-06-18 14:15:14 -050090 # {'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}
Marissa Garza522a0c22020-02-05 12:49:29 -060094 ${num}= Set Variable ${endpoint_path[-1]}
George Keishing9f487012021-08-19 12:18:10 -050095 ${occ_active}= Get OCC Active State ${num}
Marissa Garza522a0c22020-02-05 12:49:29 -060096 Should Be Equal ${occ_active} ${expected_occ_active}
97 ... msg=OCC not in right state
98 END
George Keishingac512252018-02-05 02:04:30 -060099
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
Marissa Garza522a0c22020-02-05 12:49:29 -0600128 FOR ${entry} IN @{resp}
129 Append To List ${power_sensors_value_list} ${entry[1]}
130 END
George Keishingac512252018-02-05 02:04:30 -0600131 [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
Marissa Garza522a0c22020-02-05 12:49:29 -0600168 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
George Keishingac512252018-02-05 02:04:30 -0600172
173 [Return] ${power_supply_avg_list} ${power_supply_max_list}
Sweta Potthuri39255032018-03-28 10:12:14 -0500174
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.
Michael Sheposd66cd552020-08-20 16:24:21 -0500182
183
184Inject OPAL TI
185 [Documentation] OPAL terminate immediate procedure.
186 [Arguments] ${stable_branch}=master
Michael Shepos8381f732021-04-20 12:03:08 -0500187 ... ${repo_dir_path}=/tmp/repository
Michael Sheposd66cd552020-08-20 16:24:21 -0500188 ... ${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}