blob: c657d0586c52689822438bc976ee88fd7c58197a [file] [log] [blame]
George Keishingcae6e902017-09-07 13:35:59 -05001*** Settings ***
2Documentation Open power domain keywords.
3
4Library ../data/variables.py
5Resource ../lib/utils.robot
6
7*** Keywords ***
8
9Get OCC Objects
10 [Documentation] Get the OCC objects and return as a list.
11
12 # Example:
13 # {
14 # "/org/open_power/control/occ0": {
15 # "OccActive": 0
16 # },
17 # "/org/open_power/control/occ1": {
18 # "OccActive": 1
19 # }
20
George Keishing50cd0012017-09-14 12:23:41 -050021 ${occ_list}= Get Endpoint Paths ${OPENPOWER_CONTROL} occ*
George Keishingcae6e902017-09-07 13:35:59 -050022
23 [Return] ${occ_list}
24
25
26Get OCC Active State
27 [Documentation] Get the OCC "OccActive" and return the attribute value.
28 [Arguments] ${occ_object}
29
30 # Description of argument(s):
31 # occ_object OCC object path.
32 # (e.g. "/org/open_power/control/occ0").
33
34 ${occ_attribute}= Read Attribute ${occ_object} OccActive
35 [Return] ${occ_attribute}
George Keishing50cd0012017-09-14 12:23:41 -050036
37
38Count Object Entries
Gunnar Mills28e403b2017-10-25 16:16:38 -050039 [Documentation] Count the occurrence number of a given object.
George Keishing50cd0012017-09-14 12:23:41 -050040 [Arguments] ${object_base_uri_path} ${object_name}
41
42 # Description of argument(s):
43 # object_base_uri_path Object base path
44 # (e.g. "/org/open_power/control/").
45 # object_name Object name (e.g. "occ", "cpu" etc).
46
47 ${object_list}= Get Endpoint Paths
48 ... ${object_base_uri_path} ${object_name}
49 ${list_count}= Get Length ${object_list}
50 [Return] ${list_count}
51
52
53Read Object Attribute
54 [Documentation] Return object attribute data.
55 [Arguments] ${object_base_uri_path} ${attribute_name}
56
57 # Description of argument(s):
58 # object_base_uri_path Object path.
59 # (e.g. "/org/open_power/control/occ0").
60 # attribute_name Object attribute name.
61
62 ${resp}= OpenBMC Get Request
63 ... ${object_base_uri_path}/attr/${attribute_name} quiet=${1}
64 Return From Keyword If ${resp.status_code} != ${HTTP_OK}
65 ${content}= To JSON ${resp.content}
66 [Return] ${content["data"]}
67
George Keishing5c96d1a2018-02-02 10:59:58 -060068
69Verify OCC State
70 [Documentation] Check OCC active state.
71 [Arguments] ${expected_occ_active}=${1}
72 # Description of Argument(s):
73 # expected_occ_active The expected occ_active value (i.e. 1/0).
74
75 # Example cpu_list data output:
76 # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0
77 # /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1
78 ${cpu_list}= Get Endpoint Paths
79 ... ${HOST_INVENTORY_URI}system/chassis/motherboard/ cpu*
80
81 :FOR ${endpoint_path} IN @{cpu_list}
82 \ ${is_functional}= Read Object Attribute ${endpoint_path} Functional
83 \ Continue For Loop If ${is_functional} == ${0}
84 \ ${num}= Set Variable ${endpoint_path[-1]}
85 \ ${occ_active}= Get OCC Active State ${OPENPOWER_CONTROL}occ${num}
86 \ Should Be Equal ${occ_active} ${expected_occ_active}
87 ... msg=OCC not in right state
George Keishingac512252018-02-05 02:04:30 -060088
89
90Get Sensors Aggregation Data
91 [Documentation] Return open power sensors aggregation value list.
92 [Arguments] ${object_base_uri_path}
93
94 # Description of argument(s):
95 # object_base_uri_path An object path such as one of the elements
96 # returned by 'Get Sensors Aggregation URL List'
97 # (e.g. "/org/open_power/sensors/aggregation/per_30s/ps0_input_power/average").
98
99 # Example of aggregation [epoch,time] data:
100 # "Values": [
101 # [
102 # 1517815708479, <-- EPOCH
103 # 282 <-- Power value in watts
104 # ],
105 # [
106 # 1517815678238,
107 # 282
108 # ],
109 # [
110 # 1517815648102,
111 # 282
112 # ],
113 # ],
114
115 ${resp}= Read Attribute ${object_base_uri_path} Values quiet=${1}
116 ${power_sensors_value_list}= Create List
117 :FOR ${entry} IN @{resp}
118 \ Append To List ${power_sensors_value_list} ${entry[1]}
119 [Return] ${power_sensors_value_list}
120
121
122Get Sensors Aggregation URL List
123 [Documentation] Return the open power aggregation maximum list and the
124 ... average list URIs.
125 [Arguments] ${object_base_uri_path}
126
127 # Example of the 2 lists returned by this keyword:
128 # avgs:
129 # avgs[0]: /org/open_power/sensors/aggregation/per_30s/ps0_input_power/average
130 # avgs[1]: /org/open_power/sensors/aggregation/per_30s/ps1_input_power/average
131 # maxs:
132 # maxs[0]: /org/open_power/sensors/aggregation/per_30s/ps1_input_power/maximum
133 # maxs[1]: /org/open_power/sensors/aggregation/per_30s/ps0_input_power/maximum
134
135 # Description of argument(s):
136 # object_base_uri_path Object path.
137 # base path "/org/open_power/sensors/"
138 # (e.g. "base path + aggregation/per_30s/ps0_input_power/average")
139
140 # Example of open power sensor aggregation data as returned by the get
141 # request:
142 # /org/open_power/sensors/list
143 # [
144 # "/org/open_power/sensors/aggregation/per_30s/ps0_input_power/average",
145 # "/org/open_power/sensors/aggregation/per_30s/ps1_input_power/maximum",
146 # "/org/open_power/sensors/aggregation/per_30s/ps0_input_power/maximum",
147 # "/org/open_power/sensors/aggregation/per_30s/ps1_input_power/average"
148 # ]
149
150 ${resp}= OpenBMC Get Request ${object_base_uri_path}list quiet=${1}
151 ${content}= To JSON ${resp.content}
152
153 ${power_supply_avg_list}= Create List
154 ${power_supply_max_list}= Create List
155
156 :FOR ${entry} IN @{content["data"]}
157 \ ${status}=
158 ... Run keyword And Return Status Should Contain ${entry} average
159 \ Run Keyword If ${status} == ${False}
160 ... Append To List ${power_supply_max_list} ${entry}
161 ... ELSE
162 ... Append To List ${power_supply_avg_list} ${entry}
163
164 [Return] ${power_supply_avg_list} ${power_supply_max_list}