blob: 452730e665672efa1fb26b4377f4fc1b3adb21be [file] [log] [blame]
Kailash6f5acb62019-08-28 14:38:45 -07001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
Kailash6f5acb62019-08-28 14:38:45 -070014# voltctl common functions
15
16*** Settings ***
17Documentation Library for various utilities
18Library SSHLibrary
Kailash6f5acb62019-08-28 14:38:45 -070019Library String
20Library DateTime
21Library Process
22Library Collections
23Library RequestsLibrary
24Library OperatingSystem
Matteo Scandolo142e6272020-04-29 17:36:59 -070025Resource ./utils.robot
Matteo Scandoloeb26a842020-05-08 10:06:24 -070026Resource ./flows.robot
Kailash6f5acb62019-08-28 14:38:45 -070027
28*** Keywords ***
Gilles Depatieb5682f82019-10-31 10:39:45 -040029Test Empty Device List
Zack Williamsa8fe75a2020-01-10 14:25:27 -070030 [Documentation] Verify that there are no devices in the system
Matteo Scandolo5899be12020-11-11 15:38:07 -080031 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -040032 Should Be Equal As Integers ${rc} 0
33 ${jsondata}= To Json ${output}
34 Log ${jsondata}
35 ${length}= Get Length ${jsondata}
David Bainbridgef81cd642019-11-20 00:14:47 +000036 Should Be Equal As Integers ${length} 0
Gilles Depatieb5682f82019-10-31 10:39:45 -040037
Kailash6f5acb62019-08-28 14:38:45 -070038Create Device
Matteo Scandolo142e6272020-04-29 17:36:59 -070039 [Arguments] ${ip} ${port} ${type}=openolt
You Wang2b550642019-10-07 14:39:48 -070040 [Documentation] Creates a device in VOLTHA
Kailash6f5acb62019-08-28 14:38:45 -070041 #create/preprovision device
Gilles Depatie675a2062019-10-22 12:44:42 -040042 ${rc} ${device_id}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080043 ... voltctl -c ${VOLTCTL_CONFIG} device create -t ${type} -H ${ip}:${port}
44 Log ${device_id}
Kailash6f5acb62019-08-28 14:38:45 -070045 Should Be Equal As Integers ${rc} 0
46 [Return] ${device_id}
47
48Enable Device
49 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -070050 [Documentation] Enables a device in VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -070051 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080052 ... voltctl -c ${VOLTCTL_CONFIG} device enable ${device_id}
Kailash6f5acb62019-08-28 14:38:45 -070053 Should Be Equal As Integers ${rc} 0
54
Suchitra Vemuri6db89412019-11-14 14:52:54 -080055Disable Device
56 [Arguments] ${device_id}
Hardik Windlassaaea3402020-03-10 19:45:45 +053057 [Documentation] Disables a device in VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -070058 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080059 ... voltctl -c ${VOLTCTL_CONFIG} device disable ${device_id}
Suchitra Vemuri6db89412019-11-14 14:52:54 -080060 Should Be Equal As Integers ${rc} 0
61
Hardik Windlassaaea3402020-03-10 19:45:45 +053062Delete Device
63 [Arguments] ${device_id}
64 [Documentation] Deletes a device in VOLTHA
65 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080066 ... voltctl -c ${VOLTCTL_CONFIG} device delete ${device_id}
Hardik Windlassaaea3402020-03-10 19:45:45 +053067 Should Be Equal As Integers ${rc} 0
68
Hemadf003682020-04-28 21:22:22 +053069Reboot Device
70 [Arguments] ${device_id}
71 [Documentation] Reboot the OLT using voltctl command
72 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080073 ... voltctl -c ${VOLTCTL_CONFIG} device reboot ${device_id}
Hemadf003682020-04-28 21:22:22 +053074 Should Be Equal As Integers ${rc} 0
75
David Bainbridgef81cd642019-11-20 00:14:47 +000076Disable Devices In Voltha
77 [Documentation] Disables all the known devices in voltha
78 [Arguments] ${filter}
79 ${arg}= Set Variable ${EMPTY}
80 ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070081 ${rc} ${devices}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080082 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB ${arg} --orderby Root -q | xargs echo -n
David Bainbridgef81cd642019-11-20 00:14:47 +000083 Should Be Equal As Integers ${rc} 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -070084 ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080085 ... voltctl -c ${VOLTCTL_CONFIG} device disable ${devices}
David Bainbridgef81cd642019-11-20 00:14:47 +000086 Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0
87
88Test Devices Disabled In Voltha
89 [Documentation] Tests to verify that all devices in VOLTHA are disabled
90 [Arguments] ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070091 ${rc} ${count}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080092 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB --filter '${filter},AdminState!=DISABLED' -q | wc -l
David Bainbridgef81cd642019-11-20 00:14:47 +000093 Should Be Equal As Integers ${rc} 0
94 Should Be Equal As Integers ${count} 0
95
96Delete Devices In Voltha
97 [Documentation] Disables all the known devices in voltha
98 [Arguments] ${filter}
99 ${arg}= Set Variable ${EMPTY}
100 ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700101 ${rc} ${devices}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800102 ... voltctl -c ${VOLTCTL_CONFIG} device list ${arg} -m 8MB --orderby Root -q | xargs echo -n
David Bainbridgef81cd642019-11-20 00:14:47 +0000103 Should Be Equal As Integers ${rc} 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700104 ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800105 ... voltctl -c ${VOLTCTL_CONFIG} device delete ${devices}
David Bainbridgef81cd642019-11-20 00:14:47 +0000106 Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0
107
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700108Get Device Flows from Voltha
109 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700110 [Documentation] Gets device flows from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700111 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800112 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m 8MB
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700113 Should Be Equal As Integers ${rc} 0
114 [Return] ${output}
115
116Get Logical Device Output from Voltha
117 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700118 [Documentation] Gets logicaldevice flows and ports from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700119 ${rc1} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800120 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice flows ${device_id}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700121 ${rc2} ${ports}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800122 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice port list ${device_id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700123 Log ${flows}
124 Log ${ports}
125 Should Be Equal As Integers ${rc1} 0
126 Should Be Equal As Integers ${rc2} 0
127
128Get Device Output from Voltha
129 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700130 [Documentation] Gets device flows and ports from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700131 ${rc1} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800132 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m 8MB
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700133 ${rc2} ${ports}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800134 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${device_id} -m 8MB
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700135 Log ${flows}
136 Log ${ports}
137 Should Be Equal As Integers ${rc1} 0
138 Should Be Equal As Integers ${rc2} 0
139
Suchitra Vemuri1a970a62019-11-26 12:52:16 -0800140Get Device List from Voltha
141 [Documentation] Gets Device List Output from Voltha
Matteo Scandolo5899be12020-11-11 15:38:07 -0800142 ${rc1} ${devices}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB
Suchitra Vemuri1a970a62019-11-26 12:52:16 -0800143 Log ${devices}
144 Should Be Equal As Integers ${rc1} 0
145
Matteo Scandolo616daab2020-05-13 11:49:24 -0700146Get Device List from Voltha by type
147 [Documentation] Gets Device List Output from Voltha applying filtering by device type
148 [Arguments] ${type}
149 ${rc1} ${devices}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800150 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -f Type=${type} -o json
Matteo Scandolo616daab2020-05-13 11:49:24 -0700151 Log ${devices}
152 Should Be Equal As Integers ${rc1} 0
153 Return From Keyword ${devices}
154
Matteo Scandolo142e6272020-04-29 17:36:59 -0700155Get Logical Device List from Voltha
156 [Documentation] Gets Logical Device List Output from Voltha (in json format)
Andrea Campanella80655eb2020-07-10 15:49:22 +0200157 ${rc1} ${devices}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800158 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice list -m 8MB -o json
Matteo Scandolo142e6272020-04-29 17:36:59 -0700159 Log ${devices}
160 Should Be Equal As Integers ${rc1} 0
161 Return From Keyword ${devices}
162
Kailash6f5acb62019-08-28 14:38:45 -0700163Validate Device
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700164 [Documentation]
ubuntu6b6e7d42020-03-02 12:35:42 -0800165 ... Parses the output of "voltctl device list" and inspects a device ${id}, specified as either
166 ... the serial number or device ID. Arguments are matched for device states of: "admin_state",
167 ... "oper_status", and "connect_status"
Hardik Windlass8b446492021-06-10 06:25:23 +0000168 ... Note: Set "by_dev_id" to True if Device Id is passed for validation
169 ... otherwise look up will be based on Device Serial Number
ubuntu6b6e7d42020-03-02 12:35:42 -0800170 [Arguments] ${admin_state} ${oper_status} ${connect_status}
Hardik Windlass8b446492021-06-10 06:25:23 +0000171 ... ${id} ${onu_reason}=${EMPTY} ${onu}=False ${by_dev_id}=False
172 ${rc} ${output}= Run Keyword If ${by_dev_id} Run and Return Rc and Output
173 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -f Id=${id} -o json
174 ... ELSE Run and Return Rc and Output
175 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -f SerialNumber=${id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400176 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700177 ${jsondata}= To Json ${output}
Matteo Scandolobfb74382021-05-10 15:45:16 -0700178 Log ${output}
Kailash6f5acb62019-08-28 14:38:45 -0700179 ${length}= Get Length ${jsondata}
ubuntu6b6e7d42020-03-02 12:35:42 -0800180 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700181 FOR ${INDEX} IN RANGE 0 ${length}
182 ${value}= Get From List ${jsondata} ${INDEX}
Scott Baker780b65f2020-05-22 14:03:15 -0700183 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
184 ... Dictionary Should Contain Key ${value} adminState
185 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
186 ... Get From Dictionary ${value} adminState
187 ... ELSE
188 ... Get From Dictionary ${value} adminstate
189 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
190 ... Get From Dictionary ${value} operStatus
191 ... ELSE
192 ... Get From Dictionary ${value} operstatus
193 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
194 ... Get From Dictionary ${value} connectStatus
195 ... ELSE
196 ... Get From Dictionary ${value} connectstatus
197 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
198 ... Get From Dictionary ${value} serialNumber
199 ... ELSE
200 ... Get From Dictionary ${value} serialnumber
Gilles Depatieb5682f82019-10-31 10:39:45 -0400201 ${devId}= Get From Dictionary ${value} id
Zack Williamsec53a1b2019-09-16 15:50:52 -0700202 ${mib_state}= Get From Dictionary ${value} reason
ubuntu6b6e7d42020-03-02 12:35:42 -0800203 ${matched}= Set Variable If '${sn}' == '${id}' or '${devId}' == '${id}' True False
Andy Bavierb63f6d22020-03-12 15:34:37 -0700204 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700205 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700206 Should Be True ${matched} No match found for ${id} to validate device
Matteo Scandolo5e10b282019-11-25 10:54:32 -0700207 Log ${value}
ubuntu6b6e7d42020-03-02 12:35:42 -0800208 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
Gilles Depatie675a2062019-10-22 12:44:42 -0400209 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800210 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400211 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800212 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400213 ... values=False
Matteo Scandolo74bd5c32020-12-08 09:52:19 -0800214 Run Keyword If '${onu}' == 'True' Should Contain '${onu_reason}' '${mib_state}'
ubuntu6b6e7d42020-03-02 12:35:42 -0800215 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400216
217Validate OLT Device
Hardik Windlass8b446492021-06-10 06:25:23 +0000218 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${id} ${by_dev_id}=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800219 [Documentation] Parses the output of "voltctl device list" and inspects device ${id}, specified
220 ... as either its serial numbner or device ID. Match on OLT Serial number or Device Id and inspect states
Hardik Windlass8b446492021-06-10 06:25:23 +0000221 ... Note: Set "by_dev_id" to True if Device Id is passed for validation
222 ... otherwise look up will be based on Device Serial Number
223 Validate Device ${admin_state} ${oper_status} ${connect_status} ${id} by_dev_id=${by_dev_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400224
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800225Validate OLT Devices
226 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${ids}=${EMPTY}
227 [Documentation] Parses the output of "voltctl device list" and inspects device ${id}, specified
228 ... as either its serial numbner or device ID. Match on OLT Serial number or Device Id and inspect states
229 FOR ${I} IN RANGE 0 ${olt_count}
230 ${olt_serial_number}= Get From Dictionary ${olt_ids}[${I}] sn
231 ${olt_device_id}= Get OLTDeviceID From OLT List ${olt_serial_number}
Hardik Windlass8b446492021-06-10 06:25:23 +0000232 Validate Device ${admin_state} ${oper_status} ${connect_status} ${olt_device_id} by_dev_id=True
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800233 END
234
Gilles Depatieb5682f82019-10-31 10:39:45 -0400235Validate ONU Devices
236 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${List_ONU_Serial}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700237 ... ${onu_reason}=omci-flows-pushed
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700238 [Documentation] Parses the output of "voltctl device list" and inspects device ${List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400239 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
240 ... states including MIB state
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700241 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400242 Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700243 ... onu_reason=${onu_reason} onu=True
Debasish28130d02020-03-16 11:05:26 +0000244 END
245
Gilles Depatieb5682f82019-10-31 10:39:45 -0400246Validate Device Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700247 [Documentation]
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800248 ... Parses the output of voltctl device port list <device_id> and matches the port types listed
Andy Bavier90eb1a12020-03-26 11:54:35 -0700249 [Arguments] ${device_id} ${pon_type} ${ethernet_type} ${all_active}=True
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700250 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800251 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${device_id} -m 8MB -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400252 Should Be Equal As Integers ${rc} 0
253 ${jsondata}= To Json ${output}
254 Log ${jsondata}
255 ${length}= Get Length ${jsondata}
256 FOR ${INDEX} IN RANGE 0 ${length}
257 ${value}= Get From List ${jsondata} ${INDEX}
Scott Baker780b65f2020-05-22 14:03:15 -0700258 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
259 ... Dictionary Should Contain Key ${value} adminState
260 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
Hardik Windlass2b37e712020-06-12 02:13:17 +0530261 ... Get From Dictionary ${value} adminState
Scott Baker780b65f2020-05-22 14:03:15 -0700262 ... ELSE
Hardik Windlass2b37e712020-06-12 02:13:17 +0530263 ... Get From Dictionary ${value} adminstate
Scott Baker780b65f2020-05-22 14:03:15 -0700264 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
265 ... Get From Dictionary ${value} operStatus
266 ... ELSE
Hardik Windlass2b37e712020-06-12 02:13:17 +0530267 ... Get From Dictionary ${value} operstatus
Gilles Depatieb5682f82019-10-31 10:39:45 -0400268 ${type}= Get From Dictionary ${value} type
Hemaf64d34c2020-03-25 00:40:17 +0530269 Should Be Equal '${astate}' 'ENABLED' Device ${device_id} port admin_state != ENABLED values=False
Andy Bavier90eb1a12020-03-26 11:54:35 -0700270 Run Keyword If ${all_active} Should Be Equal '${opstatus}' 'ACTIVE'
271 ... Device ${device_id} port oper_status != ACTIVE values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400272 Should Be True '${type}' == '${pon_type}' or '${type}' == '${ethernet_type}'
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700273 ... Device ${device_id} port type is neither ${pon_type} or ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400274 END
275
276Validate OLT Port Types
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800277 [Documentation] Parses the output of voltctl device port list ${olt_device_id} and matches the port types listed
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700278 [Arguments] ${pon_type} ${ethernet_type}
279 Validate Device Port Types ${olt_device_id} ${pon_type} ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400280
281Validate ONU Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700282 [Arguments] ${List_ONU_Serial} ${pon_type} ${ethernet_type}
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800283 [Documentation] Parses the output of voltctl device port list for each ONU SN listed in ${List_ONU_Serial}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700284 ... and matches the port types listed
Gilles Depatieb5682f82019-10-31 10:39:45 -0400285 FOR ${serial_number} IN @{List_ONU_Serial}
286 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Andy Bavier90eb1a12020-03-26 11:54:35 -0700287 # Only first UNI port is ACTIVE; the rest are in DISCOVERED operstatus
288 Validate Device Port Types ${onu_dev_id} ${pon_type} ${ethernet_type} all_active=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400289 END
290
291Validate Device Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000292 [Arguments] ${device_id} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400293 [Documentation] Parses the output of voltctl device flows <device_id> and expects flow count > 0
Andrea Campanella80655eb2020-07-10 15:49:22 +0200294 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800295 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m 8MB -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400296 Should Be Equal As Integers ${rc} 0
297 ${jsondata}= To Json ${output}
298 Log ${jsondata}
299 ${length}= Get Length ${jsondata}
300 Log 'Number of flows = ' ${length}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000301 Run Keyword If '${flow_count}' == '${EMPTY}' Should Be True ${length} > 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400302 ... Number of flows for ${device_id} was 0
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000303 ... ELSE Should Be True ${length} == ${flow_count}
304 ... Number of flows for ${device_id} was not ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400305
306Validate OLT Flows
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800307 [Arguments] ${flow_count}=${EMPTY} ${olt_device_id}=${EMPTY}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000308 [Documentation] Parses the output of voltctl device flows ${olt_device_id}
309 ... and expects flow count == ${flow_count}
310 Validate Device Flows ${olt_device_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400311
312Validate ONU Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000313 [Arguments] ${List_ONU_Serial} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400314 [Documentation] Parses the output of voltctl device flows for each ONU SN listed in ${List_ONU_Serial}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000315 ... and expects flow count == ${flow_count}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700316 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400317 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000318 Validate Device Flows ${onu_dev_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400319 END
320
TorstenThieme401af432020-06-11 15:53:53 +0000321Validate ONU Devices With Duration
322 [Documentation]
323 ... Parses the output of "voltctl device list" and inspects all devices ${List_ONU_Serial},
324 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
325 ... states including MIB state.
326 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${onu_reason}
327 ... ${List_ONU_Serial} ${startTime} ${print2console}=False ${output_file}=${EMPTY}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000328 ... ${alternate_reason}=${EMPTY}
TorstenThiemef78a9d82021-03-05 13:42:09 +0000329 ${cmd}= Catenate voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -f Type=brcm_openomci_onu
Matteo Scandolo6f24ea92021-04-29 11:55:50 -0700330 ... --format "{{.SerialNumber}}\t{{.AdminState}}\t{{.OperStatus}}\t{{.ConnectStatus}}\t{{.Reason}}" | grep -v SERIALNUMBER
TorstenThiemef78a9d82021-03-05 13:42:09 +0000331 ${rc} ${output}= Run and Return Rc and Output ${cmd}
TorstenThieme401af432020-06-11 15:53:53 +0000332 Should Be Equal As Integers ${rc} 0
333 ${timeCurrent} = Get Current Date
334 ${timeTotalMs} = Subtract Date From Date ${timeCurrent} ${startTime} result_format=number
TorstenThiemef78a9d82021-03-05 13:42:09 +0000335 @{Results}= Split String ${output} \n
336 FOR ${Line} IN @{Results}
TorstenThieme401af432020-06-11 15:53:53 +0000337 ${matched}= Set Variable False
TorstenThiemef78a9d82021-03-05 13:42:09 +0000338 @{words}= Split String ${Line} \t
339 ${sn}= Set Variable ${words[0]}
340 ${astate}= Set Variable ${words[1]}
341 ${opstatus}= Set Variable ${words[2]}
342 ${cstatus}= Set Variable ${words[3]}
343 ${mib_state}= Set Variable ${words[4]}
TorstenThieme401af432020-06-11 15:53:53 +0000344 ${onu_id}= Get Index From List ${List_ONU_Serial} ${sn}
345 ${matched}= Set Variable If -1 != ${onu_id} True False
346 ${matched}= Set Variable If '${astate}' == '${admin_state}' ${matched} False
347 ${matched}= Set Variable If '${opstatus}' == '${oper_status}' ${matched} False
348 ${matched}= Set Variable If '${cstatus}' == '${connect_status}' ${matched} False
TorstenThiemec3c23232021-01-13 13:06:31 +0000349 ${len}= Get Length ${alternate_reason}
TorstenThieme105c5982021-01-21 09:50:27 +0000350 ${matches}= Run Keyword If ${len} >= 1 Get Match Count ${alternate_reason} ${mib_state}
351 ... ELSE Set Variable 0
TorstenThiemec3c23232021-01-13 13:06:31 +0000352 ${matched}= Set Variable If '${mib_state}' == '${onu_reason}' or ${matches} >= 1
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000353 ... ${matched} False
TorstenThieme401af432020-06-11 15:53:53 +0000354 Run Keyword If ${matched} and ${print2console} Log
355 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec. console=yes
356 Run Keyword If ${matched} and ('${output_file}'!='${EMPTY}') Append To File ${output_file}
357 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec.
358 Run Keyword If ${matched} Remove Values From List ${List_ONU_Serial} ${sn}
359 END
360 Should Be Empty ${List_ONU_Serial} List ${List_ONU_Serial} not empty
361
TorstenThieme9949b172020-06-16 10:00:15 +0000362Validate ONU Devices MIB State With Duration
363 [Documentation]
364 ... Parses the output of "voltctl device list" and inspects all devices ${List_ONU_Serial},
365 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect MIB state.
366 [Arguments] ${onu_reason}
367 ... ${List_ONU_Serial} ${startTime} ${print2console}=False ${output_file}=${EMPTY}
368 ${type} = Set Variable brcm_openomci_onu
Andrea Campanella80655eb2020-07-10 15:49:22 +0200369 ${voltctl_commad} = Catenate SEPARATOR=
370 ... voltctl device list -m 8MB -f Type=${type} -f Reason=${onu_reason} --format '{{.SerialNumber}}'
371 ${rc} ${output}= Run and Return Rc and Output ${voltctl_commad}
TorstenThieme9949b172020-06-16 10:00:15 +0000372 Should Be Equal As Integers ${rc} 0
373 ${timeCurrent} = Get Current Date
374 ${timeTotalMs} = Subtract Date From Date ${timeCurrent} ${startTime} result_format=number
375 @{outputdata} = Split String ${output}
376 ${outputlength} = Get Length ${outputdata}
377 ${onulength} = Get Length ${List_ONU_Serial}
378 ${Matches} = Run Keyword If ${outputlength}<=${onulength}
379 ... Compare Lists ${outputdata} ${List_ONU_Serial}
380 ... ELSE Compare Lists ${List_ONU_Serial} ${outputdata}
381 ${length} = Get Length ${Matches}
382 FOR ${INDEX} IN RANGE 0 ${length}
383 ${sn}= Get From List ${Matches} ${INDEX}
384 Run Keyword If ${print2console} Log
385 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec. console=yes
386 Run Keyword If ('${output_file}'!='${EMPTY}') Append To File ${output_file}
387 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec.
388 Remove Values From List ${List_ONU_Serial} ${sn}
389 END
390 Should Be Empty ${List_ONU_Serial} List ${List_ONU_Serial} not empty
391
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000392Validate ONU Device By Device Id
393 [Documentation]
394 ... Parses the output of "voltctl device list" filtered by device id and inspects states including reason.
395 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${onu_reason} ${onu_id}
Matteo Scandolo5899be12020-11-11 15:38:07 -0800396 ${cmd} Catenate voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${onu_id} -m 8MB -o json
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000397 ${rc} ${output}= Run and Return Rc and Output ${cmd}
398 Should Be Equal As Integers ${rc} 0
399 ${jsondata}= To Json ${output}
400 ${length}= Get Length ${jsondata}
401 Should Be Equal As Integers ${length} 1 No match found for ${onu_id} to validate device
402 ${value}= Get From List ${jsondata} 0
403 Log ${value}
404 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
405 ... Dictionary Should Contain Key ${value} adminState
406 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
407 ... Get From Dictionary ${value} adminState
408 ... ELSE
409 ... Get From Dictionary ${value} adminstate
410 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
411 ... Get From Dictionary ${value} operStatus
412 ... ELSE
413 ... Get From Dictionary ${value} operstatus
414 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
415 ... Get From Dictionary ${value} connectStatus
416 ... ELSE
417 ... Get From Dictionary ${value} connectstatus
418 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
419 ... Get From Dictionary ${value} serialNumber
420 ... ELSE
421 ... Get From Dictionary ${value} serialnumber
422 ${devId}= Get From Dictionary ${value} id
423 ${mib_state}= Get From Dictionary ${value} reason
424 Should Be Equal '${devId}' '${onu_id}' No match found for ${onu_id} to validate device
425 ... values=False
426 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
427 ... values=False
428 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
429 ... values=False
430 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
431 ... values=False
432 Should Be Equal '${mib_state}' '${onu_reason}'
433 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
434
435
TorstenThieme9949b172020-06-16 10:00:15 +0000436Compare Lists
437 [Documentation]
438 ... Compares both lists and put all matches in the returned list
439 [Arguments] ${ListIterate} ${ListCompare}
440 @{list} = Create List
441 ${length} = Get Length ${ListIterate}
442 FOR ${INDEX} IN RANGE 0 ${length}
443 ${sn}= Get From List ${ListIterate} ${INDEX}
444 ${onu_id}= Get Index From List ${ListCompare} ${sn}
445 Run Keyword If -1 != ${onu_id} Append To List ${list} ${sn}
446 END
447 [Return] ${list}
448
Gilles Depatieb5682f82019-10-31 10:39:45 -0400449Validate Logical Device
450 [Documentation] Validate Logical Device is listed
Matteo Scandolo5899be12020-11-11 15:38:07 -0800451 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} logicaldevice list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400452 Should Be Equal As Integers ${rc} 0
453 ${jsondata}= To Json ${output}
454 Log ${jsondata}
455 ${length}= Get Length ${jsondata}
456 FOR ${INDEX} IN RANGE 0 ${length}
457 ${value}= Get From List ${jsondata} ${INDEX}
458 ${devid}= Get From Dictionary ${value} id
Scott Baker2ab2a0c2020-06-05 12:51:47 -0700459 ${rootdev}= Get From Dictionary ${value} rootDeviceId
460 ${desc}= Get From Dictionary ${value} desc
461 ${sn}= Get From Dictionary ${desc} serialNum
Gilles Depatieb5682f82019-10-31 10:39:45 -0400462 Exit For Loop
463 END
464 Should Be Equal '${rootdev}' '${olt_device_id}' Root Device does not match ${olt_device_id} values=False
465 Should Be Equal '${sn}' '${BBSIM_OLT_SN}' Logical Device ${sn} does not match ${BBSIM_OLT_SN}
466 ... values=False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700467 [Return] ${devid}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400468
469Validate Logical Device Ports
470 [Arguments] ${logical_device_id}
471 [Documentation] Validate Logical Device Ports are listed and are > 0
472 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800473 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice port list ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400474 Should Be Equal As Integers ${rc} 0
475 ${jsondata}= To Json ${output}
476 Log ${jsondata}
477 ${length}= Get Length ${jsondata}
478 Should Be True ${length} > 0 Number of ports for ${logical_device_id} was 0
479
480Validate Logical Device Flows
481 [Arguments] ${logical_device_id}
482 [Documentation] Validate Logical Device Flows are listed and are > 0
483 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800484 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice flows ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400485 Should Be Equal As Integers ${rc} 0
486 ${jsondata}= To Json ${output}
487 Log ${jsondata}
488 ${length}= Get Length ${jsondata}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700489 Should Be True ${length} > 0 Number of flows for ${logical_device_id} was 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400490
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000491Retrieve ONU UNI Ports
492 [Arguments] ${onu_device_id}
493 [Documentation] Retrieves the list of Active and Enabled UNI ports from the ONU device
494 ${rc} ${output}= Run and Return Rc and Output
495 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${onu_device_id} -o json
496 Should Be Equal As Integers ${rc} 0
497 ${jsondata}= To Json ${output}
498 Log ${jsondata}
499 ${length}= Get Length ${jsondata}
500 ${onu_uni_list}= Create List
501 FOR ${INDEX} IN RANGE 0 ${length}
502 ${value}= Get From List ${jsondata} ${INDEX}
503 ${type}= Get From Dictionary ${value} type
504 ${portno}= Get From Dictionary ${value} portNo
505 ${adminstate}= Get From Dictionary ${value} adminState
506 ${operstate}= Get From Dictionary ${value} operStatus
507 Run Keyword If '${type}'=='ETHERNET_UNI' and '${adminstate}'=='ENABLED' and '${operstate}'=='ACTIVE'
508 ... Append To List ${onu_uni_list} ${portno}
509 END
510 [Return] ${onu_uni_list}
511
Hardik Windlass16cdf962020-04-29 15:26:50 +0530512Retrieve OLT PON Ports
513 [Arguments] ${olt_device_id}
514 [Documentation] Retrieves the list of PON ports from the OLT device
515 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800516 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530517 Should Be Equal As Integers ${rc} 0
518 ${jsondata}= To Json ${output}
519 Log ${jsondata}
520 ${length}= Get Length ${jsondata}
521 ${olt_pon_list}= Create List
522 FOR ${INDEX} IN RANGE 0 ${length}
523 ${value}= Get From List ${jsondata} ${INDEX}
524 ${type}= Get From Dictionary ${value} type
525 ${portno}= Get From Dictionary ${value} portNo
526 ${peers}= Get From Dictionary ${value} peers
527 ${len_peers}= Get Length ${peers}
528 Run Keyword If '${type}' == 'PON_OLT' and ${len_peers} > 0
529 ... Append To List ${olt_pon_list} ${portno}
530 END
531 [Return] ${olt_pon_list}
532
533Retrieve Peer List From OLT PON Port
534 [Arguments] ${olt_device_id} ${pon_port}
535 [Documentation] Retrieves the list of peer device ids list from the OLT PON port
536 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800537 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530538 Should Be Equal As Integers ${rc} 0
539 ${jsondata}= To Json ${output}
540 Log ${jsondata}
541 ${length}= Get Length ${jsondata}
542 ${matched}= Set Variable False
543 FOR ${INDEX} IN RANGE 0 ${length}
544 ${value}= Get From List ${jsondata} ${INDEX}
545 ${type}= Get From Dictionary ${value} type
546 ${portno}= Get From Dictionary ${value} portNo
547 ${peers}= Get From Dictionary ${value} peers
548 ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
549 Exit For Loop If ${matched}
550 END
551 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
552 ${length}= Get Length ${peers}
553 ${olt_peer_list}= Create List
554 FOR ${INDEX} IN RANGE 0 ${length}
555 ${value}= Get From List ${peers} ${INDEX}
556 ${peer_id}= Get From Dictionary ${value} deviceId
557 Append To List ${olt_peer_list} ${peer_id}
558 END
559 [Return] ${olt_peer_list}
560
561Validate OLT PON Port Status
562 [Arguments] ${olt_device_id} ${pon_port} ${admin_state} ${oper_status}
563 [Documentation] Verifies the state of the PON port of the OLT
564 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800565 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530566 Should Be Equal As Integers ${rc} 0
567 ${jsondata}= To Json ${output}
568 Log ${jsondata}
569 ${length}= Get Length ${jsondata}
570 ${matched}= Set Variable False
571 FOR ${INDEX} IN RANGE 0 ${length}
572 ${value}= Get From List ${jsondata} ${INDEX}
573 ${type}= Get From Dictionary ${value} type
574 ${portno}= Get From Dictionary ${value} portNo
575 ${astate}= Get From Dictionary ${value} adminState
576 ${opstatus}= Get From Dictionary ${value} operStatus
577 ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
578 Exit For Loop If ${matched}
579 END
580 Should Be True ${matched} No PON port found for OLT ${olt_device_id} ${pon_port}
581 Log ${value}
582 Should Be Equal '${astate}' '${admin_state}' OLT PON Port admin_state != ${admin_state}
583 ... values=False
584 Should Be Equal '${opstatus}' '${oper_status}' OLT PON Port oper_status != ${oper_status}
585 ... values=False
586
587DisableOrEnable OLT PON Port
588 [Arguments] ${operation} ${olt_device_id} ${portno}
589 [Documentation] Disables or Enables the PON port of the OLT
590 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800591 ... voltctl -c ${VOLTCTL_CONFIG} device port ${operation} ${olt_device_id} ${portno}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530592 Should Be Equal As Integers ${rc} 0
593
Gilles Depatieb5682f82019-10-31 10:39:45 -0400594Retrieve Peer List From OLT
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700595 [Arguments] ${olt_peer_list}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400596 [Documentation] Retrieve the list of peer device id list from port list
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700597 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800598 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400599 Should Be Equal As Integers ${rc} 0
600 ${jsondata}= To Json ${output}
601 Log ${jsondata}
602 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700603 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400604 FOR ${INDEX} IN RANGE 0 ${length}
605 ${value}= Get From List ${jsondata} ${INDEX}
606 ${type}= Get From Dictionary ${value} type
607 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700608 ${matched}= Set Variable If '${type}' == 'PON_OLT' True False
609 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400610 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700611 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400612 ${length}= Get Length ${peers}
613 FOR ${INDEX} IN RANGE 0 ${length}
614 ${value}= Get From List ${peers} ${INDEX}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530615 ${peer_id}= Get From Dictionary ${value} deviceId
Gilles Depatieb5682f82019-10-31 10:39:45 -0400616 Append To List ${olt_peer_list} ${peer_id}
617 END
618
619Validate OLT Peer Id List
620 [Arguments] ${olt_peer_id_list}
621 [Documentation] Match each entry in the ${olt_peer_id_list} against ONU device ids.
622 FOR ${peer_id} IN @{olt_peer_id_list}
623 Match OLT Peer Id ${peer_id}
624 END
625
626Match OLT Peer Id
627 [Arguments] ${olt_peer_id}
628 [Documentation] Lookup the OLT Peer Id in against the list of ONU device Ids
Matteo Scandolo5899be12020-11-11 15:38:07 -0800629 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400630 Should Be Equal As Integers ${rc} 0
631 ${jsondata}= To Json ${output}
632 Log ${jsondata}
633 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700634 ${matched}= Set Variable False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700635 FOR ${INDEX} IN RANGE 0 ${length}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400636 ${value}= Get From List ${jsondata} ${INDEX}
637 ${devid}= Get From Dictionary ${value} id
Andy Bavierb63f6d22020-03-12 15:34:37 -0700638 ${matched}= Set Variable If '${devid}' == '${olt_peer_id}' True False
639 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400640 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700641 Should Be True ${matched} Peer id ${olt_peer_id} does not match any ONU device id
Gilles Depatieb5682f82019-10-31 10:39:45 -0400642
643Validate ONU Peer Id
644 [Arguments] ${olt_device_id} ${List_ONU_Serial}
645 [Documentation] Match each ONU peer to that of the OLT device id
646 FOR ${onu_serial} IN @{List_ONU_Serial}
647 ${onu_dev_id}= Get Device ID From SN ${onu_serial}
648 Match ONU Peer Id ${onu_dev_id}
649 END
650
651Match ONU Peer Id
652 [Arguments] ${onu_dev_id}
653 [Documentation] Match an ONU peer to that of the OLT device id
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800654 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800655 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${onu_dev_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400656 Should Be Equal As Integers ${rc} 0
657 ${jsondata}= To Json ${output}
658 Log ${jsondata}
659 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700660 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400661 FOR ${INDEX} IN RANGE 0 ${length}
662 ${value}= Get From List ${jsondata} ${INDEX}
663 ${type}= Get From Dictionary ${value} type
664 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700665 ${matched}= Set Variable If '${type}' == 'PON_ONU' True False
666 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400667 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700668 Should Be True ${matched} No PON port found for ONU ${onu_dev_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400669 ${length}= Get Length ${peers}
670 FOR ${INDEX} IN RANGE 0 ${length}
671 ${value}= Get From List ${peers} ${INDEX}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530672 ${peer_id}= Get From Dictionary ${value} deviceId
Gilles Depatieb5682f82019-10-31 10:39:45 -0400673 END
674 Should Be Equal '${peer_id}' '${olt_device_id}'
675 ... Mismatch between ONU peer ${peer_id} and OLT device id ${olt_device_id} values=False
Kailash6f5acb62019-08-28 14:38:45 -0700676
Kailash6f5acb62019-08-28 14:38:45 -0700677Get Device ID From SN
678 [Arguments] ${serial_number}
679 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700680 ${rc} ${id}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800681 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=SerialNumber=${serial_number} --format='{{.Id}}'
Matteo Scandolo2769d2b2021-04-14 10:29:24 -0700682 Should Be Equal As Integers ${rc} 0 "Error while fetching device list from VOLTHA"
Andy Bavier8fca0452019-12-16 15:30:11 -0700683 Log ${id}
Kailash6f5acb62019-08-28 14:38:45 -0700684 [Return] ${id}
685
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700686Get Logical Device ID From SN
687 [Arguments] ${serial_number}
688 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700689 ${rc} ${id}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800690 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice list --filter=Desc.SerialNum=${serial_number} --format='{{.Id}}'
Andy Bavier8fca0452019-12-16 15:30:11 -0700691 Should Be Equal As Integers ${rc} 0
692 Log ${id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700693 [Return] ${id}
694
Gilles Depatieb5682f82019-10-31 10:39:45 -0400695Build ONU SN List
Andrea Campanella6391f842020-11-16 10:01:18 +0100696 [Arguments] ${serial_numbers} ${olt_serial_number}=${EMPTY} ${num_onus}=${num_all_onus}
697 [Documentation] Appends all ONU SNs for the given OLT to the ${serial_numbers} list
Gilles Depatieb5682f82019-10-31 10:39:45 -0400698 FOR ${INDEX} IN RANGE 0 ${num_onus}
Andrea Campanella6391f842020-11-16 10:01:18 +0100699 Run Keyword IF "${olt_serial_number}"=="${hosts.src[${INDEX}].olt}" or "${olt_serial_number}"=="${EMPTY}"
700 ... Append To List ${serial_numbers} ${hosts.src[${INDEX}].onu}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400701 END
702
703Get SN From Device ID
704 [Arguments] ${device_id}
705 [Documentation] Gets the device id by matching for ${device_id}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700706 ${rc} ${sn}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800707 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${device_id} --format='{{.SerialNumber}}'
Gilles Depatieb5682f82019-10-31 10:39:45 -0400708 Should Be Equal As Integers ${rc} 0
Andy Bavier8fca0452019-12-16 15:30:11 -0700709 Log ${sn}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400710 [Return] ${sn}
711
Scott Baker60e570d2020-02-02 22:10:13 -0800712Get Parent ID From Device ID
713 [Arguments] ${device_id}
714 [Documentation] Gets the device id by matching for ${device_id}
715 ${rc} ${pid}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800716 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${device_id} --format='{{.ParentId}}'
Scott Baker60e570d2020-02-02 22:10:13 -0800717 Should Be Equal As Integers ${rc} 0
718 Log ${pid}
719 [Return] ${pid}
720
Kailash6f5acb62019-08-28 14:38:45 -0700721Validate Device Removed
722 [Arguments] ${id}
723 [Documentation] Verifys that device, ${serial_number}, has been removed
Matteo Scandolo5899be12020-11-11 15:38:07 -0800724 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -o json
Andy Bavier8fca0452019-12-16 15:30:11 -0700725 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700726 ${jsondata}= To Json ${output}
727 Log ${jsondata}
728 ${length}= Get Length ${jsondata}
729 @{ids}= Create List
Zack Williamsec53a1b2019-09-16 15:50:52 -0700730 FOR ${INDEX} IN RANGE 0 ${length}
731 ${value}= Get From List ${jsondata} ${INDEX}
732 ${device_id}= Get From Dictionary ${value} id
733 Append To List ${ids} ${device_id}
734 END
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700735 List Should Not Contain Value ${ids} ${id}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800736
Andrea Campanella4e507882020-11-26 11:33:11 +0100737Validate all ONUS for OLT Removed
738 [Arguments] ${num_all_onus} ${hosts} ${olt_serial_number} ${timeout}
739 [Documentation] Verifys that all the ONUS for OLT ${serial_number}, has been removed
740 FOR ${J} IN RANGE 0 ${num_all_onus}
741 ${src}= Set Variable ${hosts.src[${J}]}
742 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
743 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
744 ... Validate Device Removed ${src['onu']}
745 END
746
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800747Reboot ONU
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000748 [Arguments] ${onu_id} ${validate_device}=True
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800749 [Documentation] Using voltctl command reboot ONU and verify that ONU comes up to running state
Matteo Scandolo5899be12020-11-11 15:38:07 -0800750 ${rc} ${devices}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device reboot ${onu_id}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800751 Should Be Equal As Integers ${rc} 0
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000752 Run Keyword If ${validate_device} Run Keyword And Continue On Failure Wait Until Keyword Succeeds
753 ... 60s 1s Validate ONU Device By Device Id ENABLED DISCOVERED REACHABLE rebooting ${onu_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700754
755Assert ONUs in Voltha
756 [Arguments] ${count}
757 [Documentation] Check that a certain number of devices reached the ACTIVE/ENABLE state
758 ${rc1} ${devices}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800759 ... voltctl -c ${VOLTCTL_CONFIG} -m 8M device list | grep -v OLT | grep ACTIVE | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700760 Should Be Equal As Integers ${rc1} 0
761 Should Be Equal As Integers ${devices} ${count}
762
763Wait for ONUs in VOLTHA
764 [Arguments] ${count}
765 [Documentation] Waits until a certain number of devices reached the ACTIVE/ENABLE state
766 Wait Until Keyword Succeeds 10m 5s Assert ONUs In Voltha ${count}
767
768Count Logical Devices flows
769 [Documentation] Count the flows across logical devices in VOLTHA
770 [Arguments] ${targetFlows}
771 ${output}= Get Logical Device List From Voltha
772 ${logical_devices}= To Json ${output}
773 ${total_flows}= Set Variable 0
774 FOR ${device} IN @{logical_devices}
775 ${rc} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800776 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice flows ${device['id']} | grep -v ID | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700777 Should Be Equal As Integers ${rc} 0
778 ${total_flows}= Evaluate ${total_flows} + ${flows}
779 END
Matteo Scandolo616daab2020-05-13 11:49:24 -0700780 ${msg}= Format String Found {total_flows} flows of {targetFlows} expected
781 ... total_flows=${total_flows} targetFlows=${targetFlows}
782 Log ${msg}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700783 Should Be Equal As Integers ${targetFlows} ${total_flows}
784
785Wait for Logical Devices flows
786 [Documentation] Waits until the flows have been provisioned in the logical device
787 [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200788 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700789 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200790 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700791 Log ${targetFlows}
792 # TODO extend Validate Logical Device Flows to check the correct number of flows
793 Wait Until Keyword Succeeds 10m 5s Count Logical Devices flows ${targetFlows}
794
Matteo Scandolo616daab2020-05-13 11:49:24 -0700795Count OpenOLT Device Flows
796 [Documentation] Count the flows across openolt devices in VOLTHA
797 [Arguments] ${targetFlows}
798 ${output}= Get Device List from Voltha by type openolt
799 ${devices}= To Json ${output}
800 ${total_flows}= Set Variable 0
801 FOR ${device} IN @{devices}
802 ${rc} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800803 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device['id']} | grep -v ID | wc -l
Matteo Scandolo616daab2020-05-13 11:49:24 -0700804 Should Be Equal As Integers ${rc} 0
805 ${total_flows}= Evaluate ${total_flows} + ${flows}
806 END
807 ${msg}= Format String Found {total_flows} flows of {targetFlows} expected
808 ... total_flows=${total_flows} targetFlows=${targetFlows}
809 Log ${msg}
810 Should Be Equal As Integers ${targetFlows} ${total_flows}
811
812Wait for OpenOLT Devices flows
813 [Documentation] Waits until the flows have been provisioned in the openolt devices
814 [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200815 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700816 ${beforeFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
817 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandoloda854b02020-09-01 16:20:51 -0700818 # In the physical device we only have 2 data plane flows (on the PON) instead of 4
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700819 ${afterFlows}= Evaluate ${beforeFlows} - (${uni_count} * 2)
Matteo Scandoloda854b02020-09-01 16:20:51 -0700820 # In the TT workflow we have multiple service,
821 # so we need to remove 6 flows per each UNI that are only on the ONU device
822 ${ttFlows}= Evaluate ${beforeFlows} - (${uni_count} * 6)
823 ${afterFlows}= Set Variable If $workflow=='tt' ${ttFlows} ${afterFlows}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700824 ${targetFlows}= Set Variable If $provisioned=='true' ${afterFlows} ${beforeFlows}
Matteo Scandolo616daab2020-05-13 11:49:24 -0700825 Log ${targetFlows}
Hardik Windlass2b37e712020-06-12 02:13:17 +0530826 Wait Until Keyword Succeeds 10m 5s Count OpenOLT Device Flows ${targetFlows}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000827
Hardik Windlassba1bd272021-06-22 08:29:33 +0000828Validate ONU Device Image
829 [Documentation] Validates the ONU device image
830 [Arguments] ${data} ${image_version} ${dev_id} ${download_state} ${expected_reason} ${image_status}
831 ${jsondata}= To Json ${data}
832 ${length}= Get Length ${jsondata}
833 Should Be Equal As Integers ${length} 1 No record found for ${dev_id} to validate device image
834 ${value}= Get From List ${jsondata} 0
835 Log ${value}
836 ${deviceId}= Get From Dictionary ${value} deviceId
837 Should Be Equal '${deviceId}' '${dev_id}' No match found for ${dev_id} to validate device image
838 ... values=False
839 ${imageState}= Get From Dictionary ${value} imageState
840 ${version}= Get From Dictionary ${imageState} version
841 ${downloadState}= Get From Dictionary ${imageState} downloadState
842 ${reason}= Get From Dictionary ${imageState} reason
843 ${imageStatus}= Get From Dictionary ${imageState} imageState
844 Should Be Equal '${version}' '${image_version}' Device ${dev_id}: '${version}' != '${image_version}'
845 ... values=False
846 Should Be Equal '${downloadState}' '${download_state}' Device ${dev_id}: '${downloadState}' != '${download_state}'
847 ... values=False
848 Should Be Equal '${reason}' '${expected_reason}' Device ${dev_id}: '${reason}' != '${expected_reason}'
849 ... values=False
850 Should Be Equal '${imageStatus}' '${image_status}' Device ${dev_id}: '${imageStatus}' != '${image_status}'
851 ... values=False
852
Hardik Windlass17bd1142021-03-12 08:15:25 +0000853Download ONU Device Image
854 [Documentation] Downloads the given ONU software image
Hardik Windlassba1bd272021-06-22 08:29:33 +0000855 [Arguments] ${ver} ${url} ${vendor} ${active} ${commit} ${crc} ${id}
856 ${rc} ${output}= Run and Return Rc and Output
857 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage download ${ver} ${url} ${vendor} ${active} ${commit} ${crc} ${id} -o json
858 Log ${output}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000859 Should Be Equal As Integers ${rc} 0
Hardik Windlassba1bd272021-06-22 08:29:33 +0000860 Validate ONU Device Image ${output} ${ver} ${id} DOWNLOAD_STARTED NO_ERROR IMAGE_INACTIVE
Hardik Windlass17bd1142021-03-12 08:15:25 +0000861
862Activate ONU Device Image
Hardik Windlassba1bd272021-06-22 08:29:33 +0000863 [Documentation] Activates the given ONU software image
864 [Arguments] ${ver} ${commit} ${id}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000865 ${rc} ${output}= Run and Return Rc and Output
Hardik Windlassba1bd272021-06-22 08:29:33 +0000866 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage activate ${ver} ${commit} ${id} -o json
867 Log ${output}
868 Should Be Equal As Integers ${rc} 0
869 Validate ONU Device Image ${output} ${ver} ${id} DOWNLOAD_SUCCEEDED NO_ERROR IMAGE_ACTIVATING
870
871Commit ONU Device Image
872 [Documentation] Commits the given ONU software image
873 [Arguments] ${ver} ${id}
874 ${rc} ${output}= Run and Return Rc and Output
875 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage commit ${ver} ${id} -o json
876 Log ${output}
877 Should Be Equal As Integers ${rc} 0
878 Validate ONU Device Image ${output} ${ver} ${id} DOWNLOAD_SUCCEEDED NO_ERROR IMAGE_COMMITTING
879
880Verify ONU Device Image Status
881 [Documentation] Verfies the ONU device image state
882 [Arguments] ${image_version} ${dev_id} ${download_state} ${expected_reason} ${image_state}
883 ${rc} ${output}= Run and Return Rc and Output
884 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage status ${image_version} ${dev_id} -o json
885 Log ${output}
886 Should Be Equal As Integers ${rc} 0
887 Validate ONU Device Image ${output} ${image_version} ${dev_id} ${download_state} ${expected_reason}
888 ... ${image_state}
889
890Verify ONU Device Image List
891 [Documentation] Verfies the ONU device image list
892 [Arguments] ${dev_id} ${image_version} ${committed} ${activated} ${valid}
893 ${rc} ${output}= Run and Return Rc and Output
894 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage list ${dev_id} -o json
Hardik Windlass17bd1142021-03-12 08:15:25 +0000895 Should Be Equal As Integers ${rc} 0
896 ${jsondata}= To Json ${output}
897 Log ${jsondata}
898 ${length}= Get Length ${jsondata}
899 ${matched}= Set Variable False
900 FOR ${INDEX} IN RANGE 0 ${length}
901 ${value}= Get From List ${jsondata} ${INDEX}
Hardik Windlassba1bd272021-06-22 08:29:33 +0000902 ${version}= Get From Dictionary ${value} version
903 ${isCommited}= Get From Dictionary ${value} isCommited
904 ${isActive}= Get From Dictionary ${value} isActive
905 ${isValid}= Get From Dictionary ${value} isValid
906 ${matched}= Set Variable If '${version}' == '${image_version}' True False
Hardik Windlass17bd1142021-03-12 08:15:25 +0000907 Exit For Loop If ${matched}
908 END
Hardik Windlassba1bd272021-06-22 08:29:33 +0000909 Should Be True ${matched} No ONU Image found with Version ${image_version}
910 Should Be Equal '${isCommited}' '${committed}' Device ${dev_id}: '${isCommited}' != '${committed}'
911 ... values=False
912 Should Be Equal '${isActive}' '${activated}' Device ${dev_id}: '${isActive}' != '${activated}'
913 ... values=False
914 Should Be Equal '${isValid}' '${valid}' Device ${dev_id}: '${isValid}' != '${valid}'
915 ... values=False
TorstenThiemeff9c9142021-04-08 07:21:34 +0000916
917# pm-data relevant keywords
918Read Default Interval From Pmconfig
919 [Documentation] Reads default interval from pm config
920 [Arguments] ${device_id}
921 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig get ${device_id}
922 Should Be Equal As Integers ${rc} 0
923 log ${result}
924 @{words}= Split String ${result}
925 ${interval}= Get From List ${words} 3
926 log ${interval}
927 [return] ${interval}
928
929Read Group Interval From Pmconfig
930 [Documentation] Reads default interval from pm config
931 [Arguments] ${device_id} ${group}
932 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group list ${device_id} | grep ${group}
933 Should Be Equal As Integers ${rc} 0
934 log ${result}
935 @{words}= Split String ${result}
936 ${interval}= Get From List ${words} -1
937 log ${interval}
938 [return] ${interval}
939
940Set and Validate Default Interval
941 [Documentation] Sets and validates default interval of pm data
942 [Arguments] ${device_id} ${interval}
943 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig frequency set ${device_id} ${interval}
944 Should Be Equal As Integers ${rc} 0
945 log ${result}
946 # workaround until unit will be printed out in voltctl - remove unit
947 ${interval}= Get Substring ${interval} 0 -1
948 Should Contain ${result} ${interval}
949
950Set and Validate Group Interval
951 [Documentation] Sets and validates group interval of pm data
952 [Arguments] ${device_id} ${interval} ${group}
953 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group set ${device_id} ${group} ${interval}
954 Should Be Equal As Integers ${rc} 0
955 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group list ${device_id} | grep ${group}
956 Should Be Equal As Integers ${rc} 0
957 log ${result}
958 # workaround until unit will be printed out in voltctl - remove unit
959 ${interval}= Get Substring ${interval} 0 -1
960 Should Contain ${result} ${interval}
961
962Read Group List
963 [Documentation] Reads metric group list of given device
964 [Arguments] ${device_id}
965 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group list ${device_id} | grep -v GROUPNAME
966 Should Be Equal As Integers ${rc} 0
967 ${group_list} Create List
968 ${interval_dict} Create Dictionary
969 @{output}= Split String ${result} \n
970 FOR ${Line} IN @{output}
971 @{words}= Split String ${Line}
972 ${group}= Set Variable ${words[0]}
973 ${interval}= Set Variable ${words[2]}
974 Append To List ${group_list} ${group}
975 Set To Dictionary ${interval_dict} ${group}=${interval}
976 END
977 [return] ${group_list} ${interval_dict}
978
979Read Group Metric List
980 [Documentation] Reads group metric list of given device and group
981 [Arguments] ${device_id} ${group}
982 ${cmd}= Catenate voltctl device pmconfig groupmetric list ${device_id} ${group} | grep -v SAMPLEFREQ
983 ${rc} ${result}= Run and Return Rc and Output ${cmd}
984 Should Be Equal As Integers ${rc} 0
985 ${groupmetric_list} Create List
986 @{output}= Split String ${result} \n
987 FOR ${Line} IN @{output}
988 @{words}= Split String ${Line}
989 ${name}= Set Variable ${words[0]}
990 ${type}= Set Variable ${words[1]}
991 ${enabled}= Set Variable ${words[2]}
992 ${subdict}= Create Dictionary type=${type} enabled=${enabled}
993 ${dict}= Create Dictionary ${name}=${subdict}
994 Append To List ${groupmetric_list} ${dict}
995 END
996 [return] ${groupmetric_list}
997
998Read Group Metric Dict
999 [Documentation] Reads group metric list of given device and group
1000 [Arguments] ${device_id} ${group}
1001 ${cmd}= Catenate voltctl device pmconfig groupmetric list ${device_id} ${group} | grep -v SAMPLEFREQ
1002 ${rc} ${result}= Run and Return Rc and Output ${cmd}
1003 Should Be Equal As Integers ${rc} 0
1004 ${groupmetric_dict} Create Dictionary
1005 @{output}= Split String ${result} \n
1006 FOR ${Line} IN @{output}
1007 @{words}= Split String ${Line}
1008 ${name}= Set Variable ${words[0]}
1009 ${type}= Set Variable ${words[1]}
1010 ${enabled}= Set Variable ${words[2]}
1011 ${subdict}= Create Dictionary type=${type} enabled=${enabled}
1012 Set To Dictionary ${groupmetric_dict} ${name}=${subdict}
1013 END
1014 [return] ${groupmetric_dict}