blob: f0e873a4b5450c4cbe2260557093cc18a1ced93e [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}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -070045 Should Be Equal As Integers ${rc} 0 Failed to Create Device beause of ${device_id}
Kailash6f5acb62019-08-28 14:38:45 -070046 [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}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -070053 Should Be Equal As Integers ${rc} 0 Failed to Enable Device beause of ${output}
Kailash6f5acb62019-08-28 14:38:45 -070054
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}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -070060 Should Be Equal As Integers ${rc} 0 Failed to Disable Device beause of ${output}
Suchitra Vemuri6db89412019-11-14 14:52:54 -080061
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}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -070067 Should Be Equal As Integers ${rc} 0 Failed to Delete Device beause of ${output}
Hardik Windlassaaea3402020-03-10 19:45:45 +053068
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}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -070074 Should Be Equal As Integers ${rc} 0 Failed to Reboot Device beause of ${output}
Hemadf003682020-04-28 21:22:22 +053075
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}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -070086 Run Keyword If len('${devices}') != 0
87 ... Should Be Equal As Integers ${rc} 0 Failed to Disable Devices beause of ${output}
David Bainbridgef81cd642019-11-20 00:14:47 +000088
89Test Devices Disabled In Voltha
90 [Documentation] Tests to verify that all devices in VOLTHA are disabled
91 [Arguments] ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070092 ${rc} ${count}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -080093 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB --filter '${filter},AdminState!=DISABLED' -q | wc -l
David Bainbridgef81cd642019-11-20 00:14:47 +000094 Should Be Equal As Integers ${rc} 0
95 Should Be Equal As Integers ${count} 0
96
97Delete Devices In Voltha
98 [Documentation] Disables all the known devices in voltha
99 [Arguments] ${filter}
100 ${arg}= Set Variable ${EMPTY}
101 ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700102 ${rc} ${devices}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800103 ... voltctl -c ${VOLTCTL_CONFIG} device list ${arg} -m 8MB --orderby Root -q | xargs echo -n
David Bainbridgef81cd642019-11-20 00:14:47 +0000104 Should Be Equal As Integers ${rc} 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700105 ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800106 ... voltctl -c ${VOLTCTL_CONFIG} device delete ${devices}
David Bainbridgef81cd642019-11-20 00:14:47 +0000107 Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0
108
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700109Get Device Flows from Voltha
110 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700111 [Documentation] Gets device flows from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700112 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800113 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m 8MB
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700114 Should Be Equal As Integers ${rc} 0
115 [Return] ${output}
116
117Get Logical Device Output from Voltha
118 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700119 [Documentation] Gets logicaldevice flows and ports from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700120 ${rc1} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800121 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice flows ${device_id}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700122 ${rc2} ${ports}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800123 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice port list ${device_id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700124 Log ${flows}
125 Log ${ports}
126 Should Be Equal As Integers ${rc1} 0
127 Should Be Equal As Integers ${rc2} 0
128
129Get Device Output from Voltha
130 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700131 [Documentation] Gets device flows and ports from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700132 ${rc1} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800133 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m 8MB
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700134 ${rc2} ${ports}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800135 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${device_id} -m 8MB
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700136 Log ${flows}
137 Log ${ports}
138 Should Be Equal As Integers ${rc1} 0
139 Should Be Equal As Integers ${rc2} 0
140
Suchitra Vemuri1a970a62019-11-26 12:52:16 -0800141Get Device List from Voltha
142 [Documentation] Gets Device List Output from Voltha
Matteo Scandolo5899be12020-11-11 15:38:07 -0800143 ${rc1} ${devices}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB
Suchitra Vemuri1a970a62019-11-26 12:52:16 -0800144 Log ${devices}
145 Should Be Equal As Integers ${rc1} 0
146
Matteo Scandolo616daab2020-05-13 11:49:24 -0700147Get Device List from Voltha by type
148 [Documentation] Gets Device List Output from Voltha applying filtering by device type
149 [Arguments] ${type}
150 ${rc1} ${devices}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800151 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -f Type=${type} -o json
Matteo Scandolo616daab2020-05-13 11:49:24 -0700152 Log ${devices}
153 Should Be Equal As Integers ${rc1} 0
154 Return From Keyword ${devices}
155
Matteo Scandolo142e6272020-04-29 17:36:59 -0700156Get Logical Device List from Voltha
157 [Documentation] Gets Logical Device List Output from Voltha (in json format)
Andrea Campanella80655eb2020-07-10 15:49:22 +0200158 ${rc1} ${devices}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800159 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice list -m 8MB -o json
Matteo Scandolo142e6272020-04-29 17:36:59 -0700160 Log ${devices}
161 Should Be Equal As Integers ${rc1} 0
162 Return From Keyword ${devices}
163
Kailash6f5acb62019-08-28 14:38:45 -0700164Validate Device
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700165 [Documentation]
ubuntu6b6e7d42020-03-02 12:35:42 -0800166 ... Parses the output of "voltctl device list" and inspects a device ${id}, specified as either
167 ... the serial number or device ID. Arguments are matched for device states of: "admin_state",
168 ... "oper_status", and "connect_status"
Hardik Windlass8b446492021-06-10 06:25:23 +0000169 ... Note: Set "by_dev_id" to True if Device Id is passed for validation
170 ... otherwise look up will be based on Device Serial Number
ubuntu6b6e7d42020-03-02 12:35:42 -0800171 [Arguments] ${admin_state} ${oper_status} ${connect_status}
Hardik Windlass8b446492021-06-10 06:25:23 +0000172 ... ${id} ${onu_reason}=${EMPTY} ${onu}=False ${by_dev_id}=False
173 ${rc} ${output}= Run Keyword If ${by_dev_id} Run and Return Rc and Output
174 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -f Id=${id} -o json
175 ... ELSE Run and Return Rc and Output
176 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -f SerialNumber=${id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400177 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700178 ${jsondata}= To Json ${output}
Matteo Scandolobfb74382021-05-10 15:45:16 -0700179 Log ${output}
Kailash6f5acb62019-08-28 14:38:45 -0700180 ${length}= Get Length ${jsondata}
ubuntu6b6e7d42020-03-02 12:35:42 -0800181 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700182 FOR ${INDEX} IN RANGE 0 ${length}
183 ${value}= Get From List ${jsondata} ${INDEX}
Scott Baker780b65f2020-05-22 14:03:15 -0700184 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
185 ... Dictionary Should Contain Key ${value} adminState
186 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
187 ... Get From Dictionary ${value} adminState
188 ... ELSE
189 ... Get From Dictionary ${value} adminstate
190 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
191 ... Get From Dictionary ${value} operStatus
192 ... ELSE
193 ... Get From Dictionary ${value} operstatus
194 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
195 ... Get From Dictionary ${value} connectStatus
196 ... ELSE
197 ... Get From Dictionary ${value} connectstatus
198 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
199 ... Get From Dictionary ${value} serialNumber
200 ... ELSE
201 ... Get From Dictionary ${value} serialnumber
Gilles Depatieb5682f82019-10-31 10:39:45 -0400202 ${devId}= Get From Dictionary ${value} id
Zack Williamsec53a1b2019-09-16 15:50:52 -0700203 ${mib_state}= Get From Dictionary ${value} reason
ubuntu6b6e7d42020-03-02 12:35:42 -0800204 ${matched}= Set Variable If '${sn}' == '${id}' or '${devId}' == '${id}' True False
Andy Bavierb63f6d22020-03-12 15:34:37 -0700205 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700206 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700207 Should Be True ${matched} No match found for ${id} to validate device
Matteo Scandolo5e10b282019-11-25 10:54:32 -0700208 Log ${value}
ubuntu6b6e7d42020-03-02 12:35:42 -0800209 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
Gilles Depatie675a2062019-10-22 12:44:42 -0400210 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800211 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400212 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800213 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400214 ... values=False
Matteo Scandolo74bd5c32020-12-08 09:52:19 -0800215 Run Keyword If '${onu}' == 'True' Should Contain '${onu_reason}' '${mib_state}'
ubuntu6b6e7d42020-03-02 12:35:42 -0800216 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400217
218Validate OLT Device
Hardik Windlass8b446492021-06-10 06:25:23 +0000219 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${id} ${by_dev_id}=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800220 [Documentation] Parses the output of "voltctl device list" and inspects device ${id}, specified
221 ... 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 +0000222 ... Note: Set "by_dev_id" to True if Device Id is passed for validation
223 ... otherwise look up will be based on Device Serial Number
224 Validate Device ${admin_state} ${oper_status} ${connect_status} ${id} by_dev_id=${by_dev_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400225
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800226Validate OLT Devices
227 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${ids}=${EMPTY}
228 [Documentation] Parses the output of "voltctl device list" and inspects device ${id}, specified
229 ... as either its serial numbner or device ID. Match on OLT Serial number or Device Id and inspect states
230 FOR ${I} IN RANGE 0 ${olt_count}
231 ${olt_serial_number}= Get From Dictionary ${olt_ids}[${I}] sn
232 ${olt_device_id}= Get OLTDeviceID From OLT List ${olt_serial_number}
Hardik Windlass8b446492021-06-10 06:25:23 +0000233 Validate Device ${admin_state} ${oper_status} ${connect_status} ${olt_device_id} by_dev_id=True
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800234 END
235
Gilles Depatieb5682f82019-10-31 10:39:45 -0400236Validate ONU Devices
237 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${List_ONU_Serial}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700238 ... ${onu_reason}=omci-flows-pushed
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700239 [Documentation] Parses the output of "voltctl device list" and inspects device ${List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400240 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
241 ... states including MIB state
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700242 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400243 Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700244 ... onu_reason=${onu_reason} onu=True
Debasish28130d02020-03-16 11:05:26 +0000245 END
246
Gilles Depatieb5682f82019-10-31 10:39:45 -0400247Validate Device Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700248 [Documentation]
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800249 ... Parses the output of voltctl device port list <device_id> and matches the port types listed
Andy Bavier90eb1a12020-03-26 11:54:35 -0700250 [Arguments] ${device_id} ${pon_type} ${ethernet_type} ${all_active}=True
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700251 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800252 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${device_id} -m 8MB -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400253 Should Be Equal As Integers ${rc} 0
254 ${jsondata}= To Json ${output}
255 Log ${jsondata}
256 ${length}= Get Length ${jsondata}
257 FOR ${INDEX} IN RANGE 0 ${length}
258 ${value}= Get From List ${jsondata} ${INDEX}
Scott Baker780b65f2020-05-22 14:03:15 -0700259 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
260 ... Dictionary Should Contain Key ${value} adminState
261 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
Hardik Windlass2b37e712020-06-12 02:13:17 +0530262 ... Get From Dictionary ${value} adminState
Scott Baker780b65f2020-05-22 14:03:15 -0700263 ... ELSE
Hardik Windlass2b37e712020-06-12 02:13:17 +0530264 ... Get From Dictionary ${value} adminstate
Scott Baker780b65f2020-05-22 14:03:15 -0700265 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
266 ... Get From Dictionary ${value} operStatus
267 ... ELSE
Hardik Windlass2b37e712020-06-12 02:13:17 +0530268 ... Get From Dictionary ${value} operstatus
Gilles Depatieb5682f82019-10-31 10:39:45 -0400269 ${type}= Get From Dictionary ${value} type
Hemaf64d34c2020-03-25 00:40:17 +0530270 Should Be Equal '${astate}' 'ENABLED' Device ${device_id} port admin_state != ENABLED values=False
Andy Bavier90eb1a12020-03-26 11:54:35 -0700271 Run Keyword If ${all_active} Should Be Equal '${opstatus}' 'ACTIVE'
272 ... Device ${device_id} port oper_status != ACTIVE values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400273 Should Be True '${type}' == '${pon_type}' or '${type}' == '${ethernet_type}'
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700274 ... Device ${device_id} port type is neither ${pon_type} or ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400275 END
276
277Validate OLT Port Types
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800278 [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 -0700279 [Arguments] ${pon_type} ${ethernet_type}
280 Validate Device Port Types ${olt_device_id} ${pon_type} ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400281
282Validate ONU Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700283 [Arguments] ${List_ONU_Serial} ${pon_type} ${ethernet_type}
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800284 [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 -0700285 ... and matches the port types listed
Gilles Depatieb5682f82019-10-31 10:39:45 -0400286 FOR ${serial_number} IN @{List_ONU_Serial}
287 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Andy Bavier90eb1a12020-03-26 11:54:35 -0700288 # Only first UNI port is ACTIVE; the rest are in DISCOVERED operstatus
289 Validate Device Port Types ${onu_dev_id} ${pon_type} ${ethernet_type} all_active=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400290 END
291
292Validate Device Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000293 [Arguments] ${device_id} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400294 [Documentation] Parses the output of voltctl device flows <device_id> and expects flow count > 0
Andrea Campanella80655eb2020-07-10 15:49:22 +0200295 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800296 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m 8MB -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400297 Should Be Equal As Integers ${rc} 0
298 ${jsondata}= To Json ${output}
299 Log ${jsondata}
300 ${length}= Get Length ${jsondata}
301 Log 'Number of flows = ' ${length}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000302 Run Keyword If '${flow_count}' == '${EMPTY}' Should Be True ${length} > 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400303 ... Number of flows for ${device_id} was 0
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000304 ... ELSE Should Be True ${length} == ${flow_count}
305 ... Number of flows for ${device_id} was not ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400306
307Validate OLT Flows
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800308 [Arguments] ${flow_count}=${EMPTY} ${olt_device_id}=${EMPTY}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000309 [Documentation] Parses the output of voltctl device flows ${olt_device_id}
310 ... and expects flow count == ${flow_count}
311 Validate Device Flows ${olt_device_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400312
313Validate ONU Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000314 [Arguments] ${List_ONU_Serial} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400315 [Documentation] Parses the output of voltctl device flows for each ONU SN listed in ${List_ONU_Serial}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000316 ... and expects flow count == ${flow_count}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700317 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400318 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000319 Validate Device Flows ${onu_dev_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400320 END
321
TorstenThieme401af432020-06-11 15:53:53 +0000322Validate ONU Devices With Duration
323 [Documentation]
324 ... Parses the output of "voltctl device list" and inspects all devices ${List_ONU_Serial},
325 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
326 ... states including MIB state.
327 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${onu_reason}
328 ... ${List_ONU_Serial} ${startTime} ${print2console}=False ${output_file}=${EMPTY}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000329 ... ${alternate_reason}=${EMPTY}
TorstenThiemef78a9d82021-03-05 13:42:09 +0000330 ${cmd}= Catenate voltctl -c ${VOLTCTL_CONFIG} device list -m 8MB -f Type=brcm_openomci_onu
Matteo Scandolo6f24ea92021-04-29 11:55:50 -0700331 ... --format "{{.SerialNumber}}\t{{.AdminState}}\t{{.OperStatus}}\t{{.ConnectStatus}}\t{{.Reason}}" | grep -v SERIALNUMBER
TorstenThiemef78a9d82021-03-05 13:42:09 +0000332 ${rc} ${output}= Run and Return Rc and Output ${cmd}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700333 Should Be Equal As Integers ${rc} 0 Failed Validate ONU Devices because of ${output}
334 Log ${output}
TorstenThieme401af432020-06-11 15:53:53 +0000335 ${timeCurrent} = Get Current Date
336 ${timeTotalMs} = Subtract Date From Date ${timeCurrent} ${startTime} result_format=number
TorstenThiemef78a9d82021-03-05 13:42:09 +0000337 @{Results}= Split String ${output} \n
338 FOR ${Line} IN @{Results}
TorstenThieme401af432020-06-11 15:53:53 +0000339 ${matched}= Set Variable False
TorstenThiemef78a9d82021-03-05 13:42:09 +0000340 @{words}= Split String ${Line} \t
341 ${sn}= Set Variable ${words[0]}
342 ${astate}= Set Variable ${words[1]}
343 ${opstatus}= Set Variable ${words[2]}
344 ${cstatus}= Set Variable ${words[3]}
345 ${mib_state}= Set Variable ${words[4]}
TorstenThieme401af432020-06-11 15:53:53 +0000346 ${onu_id}= Get Index From List ${List_ONU_Serial} ${sn}
347 ${matched}= Set Variable If -1 != ${onu_id} True False
348 ${matched}= Set Variable If '${astate}' == '${admin_state}' ${matched} False
349 ${matched}= Set Variable If '${opstatus}' == '${oper_status}' ${matched} False
350 ${matched}= Set Variable If '${cstatus}' == '${connect_status}' ${matched} False
TorstenThiemec3c23232021-01-13 13:06:31 +0000351 ${len}= Get Length ${alternate_reason}
TorstenThieme105c5982021-01-21 09:50:27 +0000352 ${matches}= Run Keyword If ${len} >= 1 Get Match Count ${alternate_reason} ${mib_state}
353 ... ELSE Set Variable 0
TorstenThiemec3c23232021-01-13 13:06:31 +0000354 ${matched}= Set Variable If '${mib_state}' == '${onu_reason}' or ${matches} >= 1
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000355 ... ${matched} False
TorstenThieme401af432020-06-11 15:53:53 +0000356 Run Keyword If ${matched} and ${print2console} Log
357 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec. console=yes
358 Run Keyword If ${matched} and ('${output_file}'!='${EMPTY}') Append To File ${output_file}
359 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec.
360 Run Keyword If ${matched} Remove Values From List ${List_ONU_Serial} ${sn}
361 END
362 Should Be Empty ${List_ONU_Serial} List ${List_ONU_Serial} not empty
363
TorstenThieme9949b172020-06-16 10:00:15 +0000364Validate ONU Devices MIB State With Duration
365 [Documentation]
366 ... Parses the output of "voltctl device list" and inspects all devices ${List_ONU_Serial},
367 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect MIB state.
368 [Arguments] ${onu_reason}
369 ... ${List_ONU_Serial} ${startTime} ${print2console}=False ${output_file}=${EMPTY}
370 ${type} = Set Variable brcm_openomci_onu
Andrea Campanella80655eb2020-07-10 15:49:22 +0200371 ${voltctl_commad} = Catenate SEPARATOR=
372 ... voltctl device list -m 8MB -f Type=${type} -f Reason=${onu_reason} --format '{{.SerialNumber}}'
373 ${rc} ${output}= Run and Return Rc and Output ${voltctl_commad}
TorstenThieme9949b172020-06-16 10:00:15 +0000374 Should Be Equal As Integers ${rc} 0
375 ${timeCurrent} = Get Current Date
376 ${timeTotalMs} = Subtract Date From Date ${timeCurrent} ${startTime} result_format=number
377 @{outputdata} = Split String ${output}
378 ${outputlength} = Get Length ${outputdata}
379 ${onulength} = Get Length ${List_ONU_Serial}
380 ${Matches} = Run Keyword If ${outputlength}<=${onulength}
381 ... Compare Lists ${outputdata} ${List_ONU_Serial}
382 ... ELSE Compare Lists ${List_ONU_Serial} ${outputdata}
383 ${length} = Get Length ${Matches}
384 FOR ${INDEX} IN RANGE 0 ${length}
385 ${sn}= Get From List ${Matches} ${INDEX}
386 Run Keyword If ${print2console} Log
387 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec. console=yes
388 Run Keyword If ('${output_file}'!='${EMPTY}') Append To File ${output_file}
389 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec.
390 Remove Values From List ${List_ONU_Serial} ${sn}
391 END
392 Should Be Empty ${List_ONU_Serial} List ${List_ONU_Serial} not empty
393
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000394Validate ONU Device By Device Id
395 [Documentation]
396 ... Parses the output of "voltctl device list" filtered by device id and inspects states including reason.
397 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${onu_reason} ${onu_id}
Matteo Scandolo5899be12020-11-11 15:38:07 -0800398 ${cmd} Catenate voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${onu_id} -m 8MB -o json
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000399 ${rc} ${output}= Run and Return Rc and Output ${cmd}
400 Should Be Equal As Integers ${rc} 0
401 ${jsondata}= To Json ${output}
402 ${length}= Get Length ${jsondata}
403 Should Be Equal As Integers ${length} 1 No match found for ${onu_id} to validate device
404 ${value}= Get From List ${jsondata} 0
405 Log ${value}
406 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
407 ... Dictionary Should Contain Key ${value} adminState
408 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
409 ... Get From Dictionary ${value} adminState
410 ... ELSE
411 ... Get From Dictionary ${value} adminstate
412 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
413 ... Get From Dictionary ${value} operStatus
414 ... ELSE
415 ... Get From Dictionary ${value} operstatus
416 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
417 ... Get From Dictionary ${value} connectStatus
418 ... ELSE
419 ... Get From Dictionary ${value} connectstatus
420 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
421 ... Get From Dictionary ${value} serialNumber
422 ... ELSE
423 ... Get From Dictionary ${value} serialnumber
424 ${devId}= Get From Dictionary ${value} id
425 ${mib_state}= Get From Dictionary ${value} reason
426 Should Be Equal '${devId}' '${onu_id}' No match found for ${onu_id} to validate device
427 ... values=False
428 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
429 ... values=False
430 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
431 ... values=False
432 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
433 ... values=False
434 Should Be Equal '${mib_state}' '${onu_reason}'
435 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
436
437
TorstenThieme9949b172020-06-16 10:00:15 +0000438Compare Lists
439 [Documentation]
440 ... Compares both lists and put all matches in the returned list
441 [Arguments] ${ListIterate} ${ListCompare}
442 @{list} = Create List
443 ${length} = Get Length ${ListIterate}
444 FOR ${INDEX} IN RANGE 0 ${length}
445 ${sn}= Get From List ${ListIterate} ${INDEX}
446 ${onu_id}= Get Index From List ${ListCompare} ${sn}
447 Run Keyword If -1 != ${onu_id} Append To List ${list} ${sn}
448 END
449 [Return] ${list}
450
Gilles Depatieb5682f82019-10-31 10:39:45 -0400451Validate Logical Device
452 [Documentation] Validate Logical Device is listed
Matteo Scandolo5899be12020-11-11 15:38:07 -0800453 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} logicaldevice list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400454 Should Be Equal As Integers ${rc} 0
455 ${jsondata}= To Json ${output}
456 Log ${jsondata}
457 ${length}= Get Length ${jsondata}
458 FOR ${INDEX} IN RANGE 0 ${length}
459 ${value}= Get From List ${jsondata} ${INDEX}
460 ${devid}= Get From Dictionary ${value} id
Scott Baker2ab2a0c2020-06-05 12:51:47 -0700461 ${rootdev}= Get From Dictionary ${value} rootDeviceId
462 ${desc}= Get From Dictionary ${value} desc
463 ${sn}= Get From Dictionary ${desc} serialNum
Gilles Depatieb5682f82019-10-31 10:39:45 -0400464 Exit For Loop
465 END
466 Should Be Equal '${rootdev}' '${olt_device_id}' Root Device does not match ${olt_device_id} values=False
467 Should Be Equal '${sn}' '${BBSIM_OLT_SN}' Logical Device ${sn} does not match ${BBSIM_OLT_SN}
468 ... values=False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700469 [Return] ${devid}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400470
471Validate Logical Device Ports
472 [Arguments] ${logical_device_id}
473 [Documentation] Validate Logical Device Ports are listed and are > 0
474 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800475 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice port list ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400476 Should Be Equal As Integers ${rc} 0
477 ${jsondata}= To Json ${output}
478 Log ${jsondata}
479 ${length}= Get Length ${jsondata}
480 Should Be True ${length} > 0 Number of ports for ${logical_device_id} was 0
481
482Validate Logical Device Flows
483 [Arguments] ${logical_device_id}
484 [Documentation] Validate Logical Device Flows are listed and are > 0
485 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800486 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice flows ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400487 Should Be Equal As Integers ${rc} 0
488 ${jsondata}= To Json ${output}
489 Log ${jsondata}
490 ${length}= Get Length ${jsondata}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700491 Should Be True ${length} > 0 Number of flows for ${logical_device_id} was 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400492
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000493Retrieve ONU UNI Ports
494 [Arguments] ${onu_device_id}
495 [Documentation] Retrieves the list of Active and Enabled UNI ports from the ONU device
496 ${rc} ${output}= Run and Return Rc and Output
497 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${onu_device_id} -o json
498 Should Be Equal As Integers ${rc} 0
499 ${jsondata}= To Json ${output}
500 Log ${jsondata}
501 ${length}= Get Length ${jsondata}
502 ${onu_uni_list}= Create List
503 FOR ${INDEX} IN RANGE 0 ${length}
504 ${value}= Get From List ${jsondata} ${INDEX}
505 ${type}= Get From Dictionary ${value} type
506 ${portno}= Get From Dictionary ${value} portNo
507 ${adminstate}= Get From Dictionary ${value} adminState
508 ${operstate}= Get From Dictionary ${value} operStatus
509 Run Keyword If '${type}'=='ETHERNET_UNI' and '${adminstate}'=='ENABLED' and '${operstate}'=='ACTIVE'
510 ... Append To List ${onu_uni_list} ${portno}
511 END
512 [Return] ${onu_uni_list}
513
Hardik Windlass16cdf962020-04-29 15:26:50 +0530514Retrieve OLT PON Ports
515 [Arguments] ${olt_device_id}
516 [Documentation] Retrieves the list of PON ports from the OLT device
517 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800518 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530519 Should Be Equal As Integers ${rc} 0
520 ${jsondata}= To Json ${output}
521 Log ${jsondata}
522 ${length}= Get Length ${jsondata}
523 ${olt_pon_list}= Create List
524 FOR ${INDEX} IN RANGE 0 ${length}
525 ${value}= Get From List ${jsondata} ${INDEX}
526 ${type}= Get From Dictionary ${value} type
527 ${portno}= Get From Dictionary ${value} portNo
528 ${peers}= Get From Dictionary ${value} peers
529 ${len_peers}= Get Length ${peers}
530 Run Keyword If '${type}' == 'PON_OLT' and ${len_peers} > 0
531 ... Append To List ${olt_pon_list} ${portno}
532 END
533 [Return] ${olt_pon_list}
534
535Retrieve Peer List From OLT PON Port
TorstenThieme17d6fd22021-09-23 10:00:08 +0000536 [Arguments] ${olt_device_id} ${pon_port} ${expected_num_peers}=0
Hardik Windlass16cdf962020-04-29 15:26:50 +0530537 [Documentation] Retrieves the list of peer device ids list from the OLT PON port
538 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800539 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530540 Should Be Equal As Integers ${rc} 0
541 ${jsondata}= To Json ${output}
542 Log ${jsondata}
543 ${length}= Get Length ${jsondata}
544 ${matched}= Set Variable False
545 FOR ${INDEX} IN RANGE 0 ${length}
546 ${value}= Get From List ${jsondata} ${INDEX}
547 ${type}= Get From Dictionary ${value} type
548 ${portno}= Get From Dictionary ${value} portNo
549 ${peers}= Get From Dictionary ${value} peers
550 ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
551 Exit For Loop If ${matched}
552 END
553 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
554 ${length}= Get Length ${peers}
TorstenThieme17d6fd22021-09-23 10:00:08 +0000555 Run Keyword If ${expected_num_peers}>0 Should Be Equal As Integers ${length} ${expected_num_peers}
556 ... Number of found peers does not match expected number ${length}:${expected_num_peers}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530557 ${olt_peer_list}= Create List
558 FOR ${INDEX} IN RANGE 0 ${length}
559 ${value}= Get From List ${peers} ${INDEX}
560 ${peer_id}= Get From Dictionary ${value} deviceId
561 Append To List ${olt_peer_list} ${peer_id}
562 END
563 [Return] ${olt_peer_list}
564
565Validate OLT PON Port Status
566 [Arguments] ${olt_device_id} ${pon_port} ${admin_state} ${oper_status}
567 [Documentation] Verifies the state of the PON port of the OLT
568 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800569 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530570 Should Be Equal As Integers ${rc} 0
571 ${jsondata}= To Json ${output}
572 Log ${jsondata}
573 ${length}= Get Length ${jsondata}
574 ${matched}= Set Variable False
575 FOR ${INDEX} IN RANGE 0 ${length}
576 ${value}= Get From List ${jsondata} ${INDEX}
577 ${type}= Get From Dictionary ${value} type
578 ${portno}= Get From Dictionary ${value} portNo
579 ${astate}= Get From Dictionary ${value} adminState
580 ${opstatus}= Get From Dictionary ${value} operStatus
581 ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
582 Exit For Loop If ${matched}
583 END
584 Should Be True ${matched} No PON port found for OLT ${olt_device_id} ${pon_port}
585 Log ${value}
586 Should Be Equal '${astate}' '${admin_state}' OLT PON Port admin_state != ${admin_state}
587 ... values=False
588 Should Be Equal '${opstatus}' '${oper_status}' OLT PON Port oper_status != ${oper_status}
589 ... values=False
590
591DisableOrEnable OLT PON Port
592 [Arguments] ${operation} ${olt_device_id} ${portno}
593 [Documentation] Disables or Enables the PON port of the OLT
594 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800595 ... voltctl -c ${VOLTCTL_CONFIG} device port ${operation} ${olt_device_id} ${portno}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530596 Should Be Equal As Integers ${rc} 0
597
Gilles Depatieb5682f82019-10-31 10:39:45 -0400598Retrieve Peer List From OLT
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700599 [Arguments] ${olt_peer_list}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400600 [Documentation] Retrieve the list of peer device id list from port list
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700601 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800602 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400603 Should Be Equal As Integers ${rc} 0
604 ${jsondata}= To Json ${output}
605 Log ${jsondata}
606 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700607 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400608 FOR ${INDEX} IN RANGE 0 ${length}
609 ${value}= Get From List ${jsondata} ${INDEX}
610 ${type}= Get From Dictionary ${value} type
611 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700612 ${matched}= Set Variable If '${type}' == 'PON_OLT' True False
613 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400614 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700615 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400616 ${length}= Get Length ${peers}
617 FOR ${INDEX} IN RANGE 0 ${length}
618 ${value}= Get From List ${peers} ${INDEX}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530619 ${peer_id}= Get From Dictionary ${value} deviceId
Gilles Depatieb5682f82019-10-31 10:39:45 -0400620 Append To List ${olt_peer_list} ${peer_id}
621 END
622
623Validate OLT Peer Id List
624 [Arguments] ${olt_peer_id_list}
625 [Documentation] Match each entry in the ${olt_peer_id_list} against ONU device ids.
626 FOR ${peer_id} IN @{olt_peer_id_list}
627 Match OLT Peer Id ${peer_id}
628 END
629
630Match OLT Peer Id
631 [Arguments] ${olt_peer_id}
632 [Documentation] Lookup the OLT Peer Id in against the list of ONU device Ids
Matteo Scandolo5899be12020-11-11 15:38:07 -0800633 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400634 Should Be Equal As Integers ${rc} 0
635 ${jsondata}= To Json ${output}
636 Log ${jsondata}
637 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700638 ${matched}= Set Variable False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700639 FOR ${INDEX} IN RANGE 0 ${length}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400640 ${value}= Get From List ${jsondata} ${INDEX}
641 ${devid}= Get From Dictionary ${value} id
Andy Bavierb63f6d22020-03-12 15:34:37 -0700642 ${matched}= Set Variable If '${devid}' == '${olt_peer_id}' True False
643 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400644 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700645 Should Be True ${matched} Peer id ${olt_peer_id} does not match any ONU device id
Gilles Depatieb5682f82019-10-31 10:39:45 -0400646
647Validate ONU Peer Id
648 [Arguments] ${olt_device_id} ${List_ONU_Serial}
649 [Documentation] Match each ONU peer to that of the OLT device id
650 FOR ${onu_serial} IN @{List_ONU_Serial}
651 ${onu_dev_id}= Get Device ID From SN ${onu_serial}
652 Match ONU Peer Id ${onu_dev_id}
653 END
654
655Match ONU Peer Id
656 [Arguments] ${onu_dev_id}
657 [Documentation] Match an ONU peer to that of the OLT device id
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800658 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800659 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${onu_dev_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400660 Should Be Equal As Integers ${rc} 0
661 ${jsondata}= To Json ${output}
662 Log ${jsondata}
663 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700664 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400665 FOR ${INDEX} IN RANGE 0 ${length}
666 ${value}= Get From List ${jsondata} ${INDEX}
667 ${type}= Get From Dictionary ${value} type
668 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700669 ${matched}= Set Variable If '${type}' == 'PON_ONU' True False
670 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400671 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700672 Should Be True ${matched} No PON port found for ONU ${onu_dev_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400673 ${length}= Get Length ${peers}
674 FOR ${INDEX} IN RANGE 0 ${length}
675 ${value}= Get From List ${peers} ${INDEX}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530676 ${peer_id}= Get From Dictionary ${value} deviceId
Gilles Depatieb5682f82019-10-31 10:39:45 -0400677 END
678 Should Be Equal '${peer_id}' '${olt_device_id}'
679 ... Mismatch between ONU peer ${peer_id} and OLT device id ${olt_device_id} values=False
Kailash6f5acb62019-08-28 14:38:45 -0700680
Kailash6f5acb62019-08-28 14:38:45 -0700681Get Device ID From SN
682 [Arguments] ${serial_number}
683 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700684 ${rc} ${id}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800685 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=SerialNumber=${serial_number} --format='{{.Id}}'
Matteo Scandolo2769d2b2021-04-14 10:29:24 -0700686 Should Be Equal As Integers ${rc} 0 "Error while fetching device list from VOLTHA"
Andy Bavier8fca0452019-12-16 15:30:11 -0700687 Log ${id}
Kailash6f5acb62019-08-28 14:38:45 -0700688 [Return] ${id}
689
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700690Get Logical Device ID From SN
691 [Arguments] ${serial_number}
692 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700693 ${rc} ${id}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800694 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice list --filter=Desc.SerialNum=${serial_number} --format='{{.Id}}'
Andy Bavier8fca0452019-12-16 15:30:11 -0700695 Should Be Equal As Integers ${rc} 0
696 Log ${id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700697 [Return] ${id}
698
Gilles Depatieb5682f82019-10-31 10:39:45 -0400699Build ONU SN List
Andrea Campanella6391f842020-11-16 10:01:18 +0100700 [Arguments] ${serial_numbers} ${olt_serial_number}=${EMPTY} ${num_onus}=${num_all_onus}
701 [Documentation] Appends all ONU SNs for the given OLT to the ${serial_numbers} list
Gilles Depatieb5682f82019-10-31 10:39:45 -0400702 FOR ${INDEX} IN RANGE 0 ${num_onus}
Andrea Campanella6391f842020-11-16 10:01:18 +0100703 Run Keyword IF "${olt_serial_number}"=="${hosts.src[${INDEX}].olt}" or "${olt_serial_number}"=="${EMPTY}"
704 ... Append To List ${serial_numbers} ${hosts.src[${INDEX}].onu}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400705 END
706
707Get SN From Device ID
708 [Arguments] ${device_id}
709 [Documentation] Gets the device id by matching for ${device_id}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700710 ${rc} ${sn}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800711 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${device_id} --format='{{.SerialNumber}}'
Gilles Depatieb5682f82019-10-31 10:39:45 -0400712 Should Be Equal As Integers ${rc} 0
Andy Bavier8fca0452019-12-16 15:30:11 -0700713 Log ${sn}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400714 [Return] ${sn}
715
Scott Baker60e570d2020-02-02 22:10:13 -0800716Get Parent ID From Device ID
717 [Arguments] ${device_id}
718 [Documentation] Gets the device id by matching for ${device_id}
719 ${rc} ${pid}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800720 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${device_id} --format='{{.ParentId}}'
Scott Baker60e570d2020-02-02 22:10:13 -0800721 Should Be Equal As Integers ${rc} 0
722 Log ${pid}
723 [Return] ${pid}
724
Kailash6f5acb62019-08-28 14:38:45 -0700725Validate Device Removed
726 [Arguments] ${id}
727 [Documentation] Verifys that device, ${serial_number}, has been removed
Matteo Scandolo5899be12020-11-11 15:38:07 -0800728 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -o json
Andy Bavier8fca0452019-12-16 15:30:11 -0700729 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700730 ${jsondata}= To Json ${output}
731 Log ${jsondata}
732 ${length}= Get Length ${jsondata}
733 @{ids}= Create List
Zack Williamsec53a1b2019-09-16 15:50:52 -0700734 FOR ${INDEX} IN RANGE 0 ${length}
735 ${value}= Get From List ${jsondata} ${INDEX}
736 ${device_id}= Get From Dictionary ${value} id
737 Append To List ${ids} ${device_id}
738 END
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700739 List Should Not Contain Value ${ids} ${id}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800740
Andrea Campanella4e507882020-11-26 11:33:11 +0100741Validate all ONUS for OLT Removed
742 [Arguments] ${num_all_onus} ${hosts} ${olt_serial_number} ${timeout}
743 [Documentation] Verifys that all the ONUS for OLT ${serial_number}, has been removed
744 FOR ${J} IN RANGE 0 ${num_all_onus}
745 ${src}= Set Variable ${hosts.src[${J}]}
746 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
747 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s
748 ... Validate Device Removed ${src['onu']}
749 END
750
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800751Reboot ONU
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000752 [Arguments] ${onu_id} ${validate_device}=True
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800753 [Documentation] Using voltctl command reboot ONU and verify that ONU comes up to running state
Matteo Scandolo5899be12020-11-11 15:38:07 -0800754 ${rc} ${devices}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device reboot ${onu_id}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800755 Should Be Equal As Integers ${rc} 0
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000756 Run Keyword If ${validate_device} Run Keyword And Continue On Failure Wait Until Keyword Succeeds
757 ... 60s 1s Validate ONU Device By Device Id ENABLED DISCOVERED REACHABLE rebooting ${onu_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700758
759Assert ONUs in Voltha
760 [Arguments] ${count}
761 [Documentation] Check that a certain number of devices reached the ACTIVE/ENABLE state
762 ${rc1} ${devices}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800763 ... voltctl -c ${VOLTCTL_CONFIG} -m 8M device list | grep -v OLT | grep ACTIVE | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700764 Should Be Equal As Integers ${rc1} 0
765 Should Be Equal As Integers ${devices} ${count}
766
767Wait for ONUs in VOLTHA
768 [Arguments] ${count}
769 [Documentation] Waits until a certain number of devices reached the ACTIVE/ENABLE state
770 Wait Until Keyword Succeeds 10m 5s Assert ONUs In Voltha ${count}
771
772Count Logical Devices flows
773 [Documentation] Count the flows across logical devices in VOLTHA
774 [Arguments] ${targetFlows}
775 ${output}= Get Logical Device List From Voltha
776 ${logical_devices}= To Json ${output}
777 ${total_flows}= Set Variable 0
778 FOR ${device} IN @{logical_devices}
779 ${rc} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800780 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice flows ${device['id']} | grep -v ID | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700781 Should Be Equal As Integers ${rc} 0
782 ${total_flows}= Evaluate ${total_flows} + ${flows}
783 END
Matteo Scandolo616daab2020-05-13 11:49:24 -0700784 ${msg}= Format String Found {total_flows} flows of {targetFlows} expected
785 ... total_flows=${total_flows} targetFlows=${targetFlows}
786 Log ${msg}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700787 Should Be Equal As Integers ${targetFlows} ${total_flows}
788
789Wait for Logical Devices flows
790 [Documentation] Waits until the flows have been provisioned in the logical device
791 [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200792 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700793 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200794 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700795 Log ${targetFlows}
796 # TODO extend Validate Logical Device Flows to check the correct number of flows
797 Wait Until Keyword Succeeds 10m 5s Count Logical Devices flows ${targetFlows}
798
Matteo Scandolo616daab2020-05-13 11:49:24 -0700799Count OpenOLT Device Flows
800 [Documentation] Count the flows across openolt devices in VOLTHA
801 [Arguments] ${targetFlows}
802 ${output}= Get Device List from Voltha by type openolt
803 ${devices}= To Json ${output}
804 ${total_flows}= Set Variable 0
805 FOR ${device} IN @{devices}
806 ${rc} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800807 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device['id']} | grep -v ID | wc -l
Matteo Scandolo616daab2020-05-13 11:49:24 -0700808 Should Be Equal As Integers ${rc} 0
809 ${total_flows}= Evaluate ${total_flows} + ${flows}
810 END
811 ${msg}= Format String Found {total_flows} flows of {targetFlows} expected
812 ... total_flows=${total_flows} targetFlows=${targetFlows}
813 Log ${msg}
814 Should Be Equal As Integers ${targetFlows} ${total_flows}
815
816Wait for OpenOLT Devices flows
817 [Documentation] Waits until the flows have been provisioned in the openolt devices
818 [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200819 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700820 ${beforeFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
821 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandoloda854b02020-09-01 16:20:51 -0700822 # In the physical device we only have 2 data plane flows (on the PON) instead of 4
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700823 ${afterFlows}= Evaluate ${beforeFlows} - (${uni_count} * 2)
Matteo Scandoloda854b02020-09-01 16:20:51 -0700824 # In the TT workflow we have multiple service,
825 # so we need to remove 6 flows per each UNI that are only on the ONU device
826 ${ttFlows}= Evaluate ${beforeFlows} - (${uni_count} * 6)
827 ${afterFlows}= Set Variable If $workflow=='tt' ${ttFlows} ${afterFlows}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700828 ${targetFlows}= Set Variable If $provisioned=='true' ${afterFlows} ${beforeFlows}
Matteo Scandolo616daab2020-05-13 11:49:24 -0700829 Log ${targetFlows}
Hardik Windlass2b37e712020-06-12 02:13:17 +0530830 Wait Until Keyword Succeeds 10m 5s Count OpenOLT Device Flows ${targetFlows}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000831
Hardik Windlassba1bd272021-06-22 08:29:33 +0000832Validate ONU Device Image
833 [Documentation] Validates the ONU device image
834 [Arguments] ${data} ${image_version} ${dev_id} ${download_state} ${expected_reason} ${image_status}
835 ${jsondata}= To Json ${data}
836 ${length}= Get Length ${jsondata}
837 Should Be Equal As Integers ${length} 1 No record found for ${dev_id} to validate device image
838 ${value}= Get From List ${jsondata} 0
839 Log ${value}
840 ${deviceId}= Get From Dictionary ${value} deviceId
841 Should Be Equal '${deviceId}' '${dev_id}' No match found for ${dev_id} to validate device image
842 ... values=False
843 ${imageState}= Get From Dictionary ${value} imageState
844 ${version}= Get From Dictionary ${imageState} version
TorstenThiemeeb2440e2021-07-20 10:45:05 +0000845 ${dwlState}= Get From Dictionary ${imageState} downloadState
Hardik Windlassba1bd272021-06-22 08:29:33 +0000846 ${reason}= Get From Dictionary ${imageState} reason
TorstenThiemeeb2440e2021-07-20 10:45:05 +0000847 ${imgStatus}= Get From Dictionary ${imageState} imageState
Hardik Windlassba1bd272021-06-22 08:29:33 +0000848 Should Be Equal '${version}' '${image_version}' Device ${dev_id}: '${version}' != '${image_version}'
849 ... values=False
TorstenThiemeeb2440e2021-07-20 10:45:05 +0000850 Should Be Equal '${dwlState}' '${download_state}' Device ${dev_id}: '${dwlState}' != '${download_state}'
Hardik Windlassba1bd272021-06-22 08:29:33 +0000851 ... values=False
852 Should Be Equal '${reason}' '${expected_reason}' Device ${dev_id}: '${reason}' != '${expected_reason}'
853 ... values=False
TorstenThiemeeb2440e2021-07-20 10:45:05 +0000854 Should Be Equal '${imgStatus}' '${image_status}' Device ${dev_id}: '${imgStatus}' != '${image_status}'
Hardik Windlassba1bd272021-06-22 08:29:33 +0000855 ... values=False
856
Hardik Windlass17bd1142021-03-12 08:15:25 +0000857Download ONU Device Image
858 [Documentation] Downloads the given ONU software image
Hardik Windlassba1bd272021-06-22 08:29:33 +0000859 [Arguments] ${ver} ${url} ${vendor} ${active} ${commit} ${crc} ${id}
TorstenThieme7cb9de72021-08-24 09:40:57 +0000860 ... ${download_state}=DOWNLOAD_STARTED ${expected_reason}=NO_ERROR ${image_state}=IMAGE_UNKNOWN
Hardik Windlassba1bd272021-06-22 08:29:33 +0000861 ${rc} ${output}= Run and Return Rc and Output
862 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage download ${ver} ${url} ${vendor} ${active} ${commit} ${crc} ${id} -o json
863 Log ${output}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000864 Should Be Equal As Integers ${rc} 0
TorstenThieme7cb9de72021-08-24 09:40:57 +0000865 Validate ONU Device Image ${output} ${ver} ${id} ${download_state} ${expected_reason} ${image_state}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000866
867Activate ONU Device Image
Hardik Windlassba1bd272021-06-22 08:29:33 +0000868 [Documentation] Activates the given ONU software image
869 [Arguments] ${ver} ${commit} ${id}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000870 ${rc} ${output}= Run and Return Rc and Output
Hardik Windlassba1bd272021-06-22 08:29:33 +0000871 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage activate ${ver} ${commit} ${id} -o json
872 Log ${output}
873 Should Be Equal As Integers ${rc} 0
Andrea Campanellaf3b88f62021-10-01 18:43:03 +0200874 Validate ONU Device Image ${output} ${ver} ${id} DOWNLOAD_SUCCEEDED NO_ERROR IMAGE_ACTIVATING
Hardik Windlassba1bd272021-06-22 08:29:33 +0000875
876Commit ONU Device Image
877 [Documentation] Commits the given ONU software image
878 [Arguments] ${ver} ${id}
879 ${rc} ${output}= Run and Return Rc and Output
880 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage commit ${ver} ${id} -o json
881 Log ${output}
882 Should Be Equal As Integers ${rc} 0
Andrea Campanellaf3b88f62021-10-01 18:43:03 +0200883 Validate ONU Device Image ${output} ${ver} ${id} DOWNLOAD_SUCCEEDED NO_ERROR IMAGE_COMMITTING
Hardik Windlassba1bd272021-06-22 08:29:33 +0000884
TorstenThieme37165402021-09-03 11:39:40 +0000885Abort ONU Device Image
886 [Documentation] Aborts the given ONU software image
887 [Arguments] ${ver} ${id} ${download_state} ${expected_reason} ${image_state}
888 ${rc} ${output}= Run and Return Rc and Output
889 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage abort ${ver} ${id} -o json
890 Log ${output}
891 Should Be Equal As Integers ${rc} 0
892 Validate ONU Device Image ${output} ${ver} ${id} ${download_state} ${expected_reason} ${image_state}
893
Andrea Campanellaf3b88f62021-10-01 18:43:03 +0200894Remove Adapter Image
895 [Documentation] Aborts the upgrade processing for a given ONU software image and thus removes the image from adapter
896 [Arguments] ${ver} ${id}
897 ${rc} ${output}= Run and Return Rc and Output
898 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage abort ${ver} ${id} -o json
899 Log ${output}
900
Hardik Windlassba1bd272021-06-22 08:29:33 +0000901Verify ONU Device Image Status
902 [Documentation] Verfies the ONU device image state
903 [Arguments] ${image_version} ${dev_id} ${download_state} ${expected_reason} ${image_state}
904 ${rc} ${output}= Run and Return Rc and Output
905 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage status ${image_version} ${dev_id} -o json
906 Log ${output}
907 Should Be Equal As Integers ${rc} 0
908 Validate ONU Device Image ${output} ${image_version} ${dev_id} ${download_state} ${expected_reason}
909 ... ${image_state}
910
911Verify ONU Device Image List
912 [Documentation] Verfies the ONU device image list
913 [Arguments] ${dev_id} ${image_version} ${committed} ${activated} ${valid}
914 ${rc} ${output}= Run and Return Rc and Output
915 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage list ${dev_id} -o json
Hardik Windlass17bd1142021-03-12 08:15:25 +0000916 Should Be Equal As Integers ${rc} 0
917 ${jsondata}= To Json ${output}
918 Log ${jsondata}
919 ${length}= Get Length ${jsondata}
920 ${matched}= Set Variable False
921 FOR ${INDEX} IN RANGE 0 ${length}
922 ${value}= Get From List ${jsondata} ${INDEX}
Hardik Windlassba1bd272021-06-22 08:29:33 +0000923 ${version}= Get From Dictionary ${value} version
924 ${isCommited}= Get From Dictionary ${value} isCommited
925 ${isActive}= Get From Dictionary ${value} isActive
926 ${isValid}= Get From Dictionary ${value} isValid
927 ${matched}= Set Variable If '${version}' == '${image_version}' True False
Hardik Windlass17bd1142021-03-12 08:15:25 +0000928 Exit For Loop If ${matched}
929 END
Hardik Windlassba1bd272021-06-22 08:29:33 +0000930 Should Be True ${matched} No ONU Image found with Version ${image_version}
931 Should Be Equal '${isCommited}' '${committed}' Device ${dev_id}: '${isCommited}' != '${committed}'
932 ... values=False
933 Should Be Equal '${isActive}' '${activated}' Device ${dev_id}: '${isActive}' != '${activated}'
934 ... values=False
935 Should Be Equal '${isValid}' '${valid}' Device ${dev_id}: '${isValid}' != '${valid}'
936 ... values=False
TorstenThiemeff9c9142021-04-08 07:21:34 +0000937
938# pm-data relevant keywords
939Read Default Interval From Pmconfig
940 [Documentation] Reads default interval from pm config
941 [Arguments] ${device_id}
942 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig get ${device_id}
943 Should Be Equal As Integers ${rc} 0
944 log ${result}
945 @{words}= Split String ${result}
946 ${interval}= Get From List ${words} 3
947 log ${interval}
948 [return] ${interval}
949
950Read Group Interval From Pmconfig
951 [Documentation] Reads default interval from pm config
952 [Arguments] ${device_id} ${group}
953 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group list ${device_id} | grep ${group}
954 Should Be Equal As Integers ${rc} 0
955 log ${result}
956 @{words}= Split String ${result}
957 ${interval}= Get From List ${words} -1
958 log ${interval}
959 [return] ${interval}
960
961Set and Validate Default Interval
962 [Documentation] Sets and validates default interval of pm data
963 [Arguments] ${device_id} ${interval}
964 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig frequency set ${device_id} ${interval}
965 Should Be Equal As Integers ${rc} 0
966 log ${result}
967 # workaround until unit will be printed out in voltctl - remove unit
968 ${interval}= Get Substring ${interval} 0 -1
969 Should Contain ${result} ${interval}
970
971Set and Validate Group Interval
972 [Documentation] Sets and validates group interval of pm data
973 [Arguments] ${device_id} ${interval} ${group}
974 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group set ${device_id} ${group} ${interval}
975 Should Be Equal As Integers ${rc} 0
976 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group list ${device_id} | grep ${group}
977 Should Be Equal As Integers ${rc} 0
978 log ${result}
979 # workaround until unit will be printed out in voltctl - remove unit
980 ${interval}= Get Substring ${interval} 0 -1
981 Should Contain ${result} ${interval}
982
983Read Group List
984 [Documentation] Reads metric group list of given device
985 [Arguments] ${device_id}
986 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group list ${device_id} | grep -v GROUPNAME
987 Should Be Equal As Integers ${rc} 0
988 ${group_list} Create List
989 ${interval_dict} Create Dictionary
990 @{output}= Split String ${result} \n
991 FOR ${Line} IN @{output}
992 @{words}= Split String ${Line}
993 ${group}= Set Variable ${words[0]}
994 ${interval}= Set Variable ${words[2]}
995 Append To List ${group_list} ${group}
996 Set To Dictionary ${interval_dict} ${group}=${interval}
997 END
998 [return] ${group_list} ${interval_dict}
999
1000Read Group Metric List
1001 [Documentation] Reads group metric list of given device and group
1002 [Arguments] ${device_id} ${group}
1003 ${cmd}= Catenate voltctl device pmconfig groupmetric list ${device_id} ${group} | grep -v SAMPLEFREQ
1004 ${rc} ${result}= Run and Return Rc and Output ${cmd}
1005 Should Be Equal As Integers ${rc} 0
1006 ${groupmetric_list} Create List
1007 @{output}= Split String ${result} \n
1008 FOR ${Line} IN @{output}
1009 @{words}= Split String ${Line}
1010 ${name}= Set Variable ${words[0]}
1011 ${type}= Set Variable ${words[1]}
1012 ${enabled}= Set Variable ${words[2]}
1013 ${subdict}= Create Dictionary type=${type} enabled=${enabled}
1014 ${dict}= Create Dictionary ${name}=${subdict}
1015 Append To List ${groupmetric_list} ${dict}
1016 END
1017 [return] ${groupmetric_list}
1018
1019Read Group Metric Dict
1020 [Documentation] Reads group metric list of given device and group
1021 [Arguments] ${device_id} ${group}
1022 ${cmd}= Catenate voltctl device pmconfig groupmetric list ${device_id} ${group} | grep -v SAMPLEFREQ
1023 ${rc} ${result}= Run and Return Rc and Output ${cmd}
1024 Should Be Equal As Integers ${rc} 0
1025 ${groupmetric_dict} Create Dictionary
1026 @{output}= Split String ${result} \n
1027 FOR ${Line} IN @{output}
1028 @{words}= Split String ${Line}
1029 ${name}= Set Variable ${words[0]}
1030 ${type}= Set Variable ${words[1]}
1031 ${enabled}= Set Variable ${words[2]}
1032 ${subdict}= Create Dictionary type=${type} enabled=${enabled}
1033 Set To Dictionary ${groupmetric_dict} ${name}=${subdict}
1034 END
1035 [return] ${groupmetric_dict}