blob: 527453424cf3bf2c5be1b86da8fe8abd02672b7d [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:
77 # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0
78 # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1
79 ${cpu_list}= Get Endpoint Paths
80 ... ${HOST_INVENTORY_URI}system/chassis/motherboard/ cpu*
81
Marissa Garza522a0c22020-02-05 12:49:29 -060082 FOR ${endpoint_path} IN @{cpu_list}
83 ${is_functional}= Read Object Attribute ${endpoint_path} Functional
84 Continue For Loop If ${is_functional} == ${0}
85 ${num}= Set Variable ${endpoint_path[-1]}
86 ${occ_active}= Get OCC Active State ${OPENPOWER_CONTROL}occ${num}
87 Should Be Equal ${occ_active} ${expected_occ_active}
88 ... msg=OCC not in right state
89 END
George Keishingac512252018-02-05 02:04:30 -060090
91
92Get Sensors Aggregation Data
93 [Documentation] Return open power sensors aggregation value list.
94 [Arguments] ${object_base_uri_path}
95
96 # Description of argument(s):
97 # object_base_uri_path An object path such as one of the elements
98 # returned by 'Get Sensors Aggregation URL List'
99 # (e.g. "/org/open_power/sensors/aggregation/per_30s/ps0_input_power/average").
100
101 # Example of aggregation [epoch,time] data:
102 # "Values": [
103 # [
104 # 1517815708479, <-- EPOCH
105 # 282 <-- Power value in watts
106 # ],
107 # [
108 # 1517815678238,
109 # 282
110 # ],
111 # [
112 # 1517815648102,
113 # 282
114 # ],
115 # ],
116
117 ${resp}= Read Attribute ${object_base_uri_path} Values quiet=${1}
118 ${power_sensors_value_list}= Create List
Marissa Garza522a0c22020-02-05 12:49:29 -0600119 FOR ${entry} IN @{resp}
120 Append To List ${power_sensors_value_list} ${entry[1]}
121 END
George Keishingac512252018-02-05 02:04:30 -0600122 [Return] ${power_sensors_value_list}
123
124
125Get Sensors Aggregation URL List
126 [Documentation] Return the open power aggregation maximum list and the
127 ... average list URIs.
128 [Arguments] ${object_base_uri_path}
129
130 # Example of the 2 lists returned by this keyword:
131 # avgs:
132 # avgs[0]: /org/open_power/sensors/aggregation/per_30s/ps0_input_power/average
133 # avgs[1]: /org/open_power/sensors/aggregation/per_30s/ps1_input_power/average
134 # maxs:
135 # maxs[0]: /org/open_power/sensors/aggregation/per_30s/ps1_input_power/maximum
136 # maxs[1]: /org/open_power/sensors/aggregation/per_30s/ps0_input_power/maximum
137
138 # Description of argument(s):
139 # object_base_uri_path Object path.
140 # base path "/org/open_power/sensors/"
141 # (e.g. "base path + aggregation/per_30s/ps0_input_power/average")
142
143 # Example of open power sensor aggregation data as returned by the get
144 # request:
145 # /org/open_power/sensors/list
146 # [
147 # "/org/open_power/sensors/aggregation/per_30s/ps0_input_power/average",
148 # "/org/open_power/sensors/aggregation/per_30s/ps1_input_power/maximum",
149 # "/org/open_power/sensors/aggregation/per_30s/ps0_input_power/maximum",
150 # "/org/open_power/sensors/aggregation/per_30s/ps1_input_power/average"
151 # ]
152
153 ${resp}= OpenBMC Get Request ${object_base_uri_path}list quiet=${1}
154 ${content}= To JSON ${resp.content}
155
156 ${power_supply_avg_list}= Create List
157 ${power_supply_max_list}= Create List
158
Marissa Garza522a0c22020-02-05 12:49:29 -0600159 FOR ${entry} IN @{content["data"]}
160 Run Keyword If 'average' in '${entry}' Append To List ${power_supply_avg_list} ${entry}
161 Run Keyword If 'maximum' in '${entry}' Append To List ${power_supply_max_list} ${entry}
162 END
George Keishingac512252018-02-05 02:04:30 -0600163
164 [Return] ${power_supply_avg_list} ${power_supply_max_list}
Sweta Potthuri39255032018-03-28 10:12:14 -0500165
166
167REST Verify No Gard Records
168 [Documentation] Verify no gard records are present.
169
170 ${resp}= Read Properties ${OPENPOWER_CONTROL}gard/enumerate
171 Log Dictionary ${resp}
172 Should Be Empty ${resp} msg=Found gard records.
Michael Sheposd66cd552020-08-20 16:24:21 -0500173
174
175Inject OPAL TI
176 [Documentation] OPAL terminate immediate procedure.
177 [Arguments] ${stable_branch}=master
178 ... ${repo_dir_path}=${EXECDIR}/repository
179 ... ${repo_github_url}=https://github.com/open-power/op-test
180
181 # Description of arguments:
182 # stable_branch Git branch to clone. (default: master)
183 # repo_dir_path Directory path for repo tool (e.g. "op-test").
184 # repo_github_url Github URL link (e.g. "https://github.com/open-power/op-test").
185
186 ${value}= Generate Random String 4 [NUMBERS]
187
188 ${cmd_buf}= Catenate git clone --branch ${stable_branch} ${repo_github_url} ${repo_dir_path}/${value}
189 Shell Cmd ${cmd_buf}
190
191 Open Connection for SCP
192 scp.Put File ${repo_dir_path}/${value}/test_binaries/deadbeef /tmp
193 Pdbg -a putmem 0x300000f8 < /tmp/deadbeef
194
195 # Clean up the repo once done.
196 ${cmd_buf}= Catenate rm -rf ${repo_dir_path}${/}${value}
197 Shell Cmd ${cmd_buf}