blob: 6629e2fc8ac5ba9d00fe9740ca61fb7ebc5ca351 [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.
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 Keishing50cd0012017-09-14 12:23:41 -050037
38
39Count Object Entries
Gunnar Mills28e403b2017-10-25 16:16:38 -050040 [Documentation] Count the occurrence number of a given object.
George Keishing50cd0012017-09-14 12:23:41 -050041 [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
George Keishing5c96d1a2018-02-02 10:59:58 -060069
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:
George Keishing0ad13a12021-06-18 14:15:14 -050077 # /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 Keishing5c96d1a2018-02-02 10:59:58 -060081
Marissa Garza522a0c22020-02-05 12:49:29 -060082 FOR ${endpoint_path} IN @{cpu_list}
George Keishing0ad13a12021-06-18 14:15:14 -050083 # {'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 Garza522a0c22020-02-05 12:49:29 -060087 ${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 Keishingac512252018-02-05 02:04:30 -060092
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
Marissa Garza522a0c22020-02-05 12:49:29 -0600121 FOR ${entry} IN @{resp}
122 Append To List ${power_sensors_value_list} ${entry[1]}
123 END
George Keishingac512252018-02-05 02:04:30 -0600124 [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
Marissa Garza522a0c22020-02-05 12:49:29 -0600161 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 Keishingac512252018-02-05 02:04:30 -0600165
166 [Return] ${power_supply_avg_list} ${power_supply_max_list}
Sweta Potthuri39255032018-03-28 10:12:14 -0500167
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.
Michael Sheposd66cd552020-08-20 16:24:21 -0500175
176
177Inject OPAL TI
178 [Documentation] OPAL terminate immediate procedure.
179 [Arguments] ${stable_branch}=master
Michael Shepos8381f732021-04-20 12:03:08 -0500180 ... ${repo_dir_path}=/tmp/repository
Michael Sheposd66cd552020-08-20 16:24:21 -0500181 ... ${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}