blob: 75388744403bfb686d10cd4b39d6740310b86b6d [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
Andrea Campanella28989d12022-01-11 09:49:21 +010082 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 32MB ${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
Andrea Campanella28989d12022-01-11 09:49:21 +010093 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 32MB --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
Andrea Campanella28989d12022-01-11 09:49:21 +0100103 ... voltctl -c ${VOLTCTL_CONFIG} device list ${arg} -m 32MB --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
Andrea Campanella28989d12022-01-11 09:49:21 +0100113 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m 32MB
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
Andrea Campanella28989d12022-01-11 09:49:21 +0100133 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m 32MB
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700134 ${rc2} ${ports}= Run and Return Rc and Output
Andrea Campanella28989d12022-01-11 09:49:21 +0100135 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${device_id} -m 32MB
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
Andrea Campanella28989d12022-01-11 09:49:21 +0100143 ${rc1} ${devices}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -m 32MB
Suchitra Vemuri1a970a62019-11-26 12:52:16 -0800144 Log ${devices}
145 Should Be Equal As Integers ${rc1} 0
146
Hardik Windlassf8b3ee62022-01-24 16:36:32 +0000147Get ONUs Device IDs from Voltha
148 [Documentation] Fetches the ONU Device Ids from Voltha
149 ${rc} ${onus}= Run and Return Rc and Output
150 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 32MB -f Type=brcm_openomci_onu -q
151 Should Be Equal as Integers ${rc} 0
152 @{onuDevList}= Split To Lines ${onus}
153 [Return] ${onuDevList}
154
Matteo Scandolo616daab2020-05-13 11:49:24 -0700155Get Device List from Voltha by type
156 [Documentation] Gets Device List Output from Voltha applying filtering by device type
157 [Arguments] ${type}
158 ${rc1} ${devices}= Run and Return Rc and Output
Andrea Campanella28989d12022-01-11 09:49:21 +0100159 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 32MB -f Type=${type} -o json
Matteo Scandolo616daab2020-05-13 11:49:24 -0700160 Log ${devices}
161 Should Be Equal As Integers ${rc1} 0
162 Return From Keyword ${devices}
163
Matteo Scandolo142e6272020-04-29 17:36:59 -0700164Get Logical Device List from Voltha
165 [Documentation] Gets Logical Device List Output from Voltha (in json format)
Andrea Campanella80655eb2020-07-10 15:49:22 +0200166 ${rc1} ${devices}= Run and Return Rc and Output
Andrea Campanella28989d12022-01-11 09:49:21 +0100167 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice list -m 32MB -o json
Matteo Scandolo142e6272020-04-29 17:36:59 -0700168 Log ${devices}
169 Should Be Equal As Integers ${rc1} 0
170 Return From Keyword ${devices}
171
Kailash6f5acb62019-08-28 14:38:45 -0700172Validate Device
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700173 [Documentation]
ubuntu6b6e7d42020-03-02 12:35:42 -0800174 ... Parses the output of "voltctl device list" and inspects a device ${id}, specified as either
175 ... the serial number or device ID. Arguments are matched for device states of: "admin_state",
176 ... "oper_status", and "connect_status"
Hardik Windlass8b446492021-06-10 06:25:23 +0000177 ... Note: Set "by_dev_id" to True if Device Id is passed for validation
178 ... otherwise look up will be based on Device Serial Number
ubuntu6b6e7d42020-03-02 12:35:42 -0800179 [Arguments] ${admin_state} ${oper_status} ${connect_status}
Hardik Windlass8b446492021-06-10 06:25:23 +0000180 ... ${id} ${onu_reason}=${EMPTY} ${onu}=False ${by_dev_id}=False
181 ${rc} ${output}= Run Keyword If ${by_dev_id} Run and Return Rc and Output
Andrea Campanella28989d12022-01-11 09:49:21 +0100182 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 32MB -f Id=${id} -o json
Hardik Windlass8b446492021-06-10 06:25:23 +0000183 ... ELSE Run and Return Rc and Output
Andrea Campanella28989d12022-01-11 09:49:21 +0100184 ... voltctl -c ${VOLTCTL_CONFIG} device list -m 32MB -f SerialNumber=${id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400185 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700186 ${jsondata}= To Json ${output}
Matteo Scandolobfb74382021-05-10 15:45:16 -0700187 Log ${output}
Kailash6f5acb62019-08-28 14:38:45 -0700188 ${length}= Get Length ${jsondata}
ubuntu6b6e7d42020-03-02 12:35:42 -0800189 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700190 FOR ${INDEX} IN RANGE 0 ${length}
191 ${value}= Get From List ${jsondata} ${INDEX}
Scott Baker780b65f2020-05-22 14:03:15 -0700192 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
193 ... Dictionary Should Contain Key ${value} adminState
194 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
195 ... Get From Dictionary ${value} adminState
196 ... ELSE
197 ... Get From Dictionary ${value} adminstate
198 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
199 ... Get From Dictionary ${value} operStatus
200 ... ELSE
201 ... Get From Dictionary ${value} operstatus
202 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
203 ... Get From Dictionary ${value} connectStatus
204 ... ELSE
205 ... Get From Dictionary ${value} connectstatus
206 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
207 ... Get From Dictionary ${value} serialNumber
208 ... ELSE
209 ... Get From Dictionary ${value} serialnumber
Gilles Depatieb5682f82019-10-31 10:39:45 -0400210 ${devId}= Get From Dictionary ${value} id
Zack Williamsec53a1b2019-09-16 15:50:52 -0700211 ${mib_state}= Get From Dictionary ${value} reason
ubuntu6b6e7d42020-03-02 12:35:42 -0800212 ${matched}= Set Variable If '${sn}' == '${id}' or '${devId}' == '${id}' True False
Andy Bavierb63f6d22020-03-12 15:34:37 -0700213 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700214 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700215 Should Be True ${matched} No match found for ${id} to validate device
Matteo Scandolo5e10b282019-11-25 10:54:32 -0700216 Log ${value}
ubuntu6b6e7d42020-03-02 12:35:42 -0800217 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
Gilles Depatie675a2062019-10-22 12:44:42 -0400218 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800219 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400220 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800221 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400222 ... values=False
Matteo Scandolo74bd5c32020-12-08 09:52:19 -0800223 Run Keyword If '${onu}' == 'True' Should Contain '${onu_reason}' '${mib_state}'
ubuntu6b6e7d42020-03-02 12:35:42 -0800224 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400225
226Validate OLT Device
Hardik Windlass8b446492021-06-10 06:25:23 +0000227 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${id} ${by_dev_id}=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800228 [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
Hardik Windlass8b446492021-06-10 06:25:23 +0000230 ... Note: Set "by_dev_id" to True if Device Id is passed for validation
231 ... otherwise look up will be based on Device Serial Number
232 Validate Device ${admin_state} ${oper_status} ${connect_status} ${id} by_dev_id=${by_dev_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400233
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800234Validate OLT Devices
235 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${ids}=${EMPTY}
236 [Documentation] Parses the output of "voltctl device list" and inspects device ${id}, specified
237 ... as either its serial numbner or device ID. Match on OLT Serial number or Device Id and inspect states
238 FOR ${I} IN RANGE 0 ${olt_count}
239 ${olt_serial_number}= Get From Dictionary ${olt_ids}[${I}] sn
240 ${olt_device_id}= Get OLTDeviceID From OLT List ${olt_serial_number}
Hardik Windlass8b446492021-06-10 06:25:23 +0000241 Validate Device ${admin_state} ${oper_status} ${connect_status} ${olt_device_id} by_dev_id=True
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800242 END
243
Gilles Depatieb5682f82019-10-31 10:39:45 -0400244Validate ONU Devices
245 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${List_ONU_Serial}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700246 ... ${onu_reason}=omci-flows-pushed
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700247 [Documentation] Parses the output of "voltctl device list" and inspects device ${List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400248 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
249 ... states including MIB state
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700250 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400251 Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number}
Andy Bavierf1f26ed2020-03-18 10:59:07 -0700252 ... onu_reason=${onu_reason} onu=True
Debasish28130d02020-03-16 11:05:26 +0000253 END
254
Gilles Depatieb5682f82019-10-31 10:39:45 -0400255Validate Device Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700256 [Documentation]
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800257 ... Parses the output of voltctl device port list <device_id> and matches the port types listed
Andy Bavier90eb1a12020-03-26 11:54:35 -0700258 [Arguments] ${device_id} ${pon_type} ${ethernet_type} ${all_active}=True
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700259 ${rc} ${output}= Run and Return Rc and Output
Andrea Campanella28989d12022-01-11 09:49:21 +0100260 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${device_id} -m 32MB -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400261 Should Be Equal As Integers ${rc} 0
262 ${jsondata}= To Json ${output}
263 Log ${jsondata}
264 ${length}= Get Length ${jsondata}
265 FOR ${INDEX} IN RANGE 0 ${length}
266 ${value}= Get From List ${jsondata} ${INDEX}
Scott Baker780b65f2020-05-22 14:03:15 -0700267 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
268 ... Dictionary Should Contain Key ${value} adminState
269 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
Hardik Windlass2b37e712020-06-12 02:13:17 +0530270 ... Get From Dictionary ${value} adminState
Scott Baker780b65f2020-05-22 14:03:15 -0700271 ... ELSE
Hardik Windlass2b37e712020-06-12 02:13:17 +0530272 ... Get From Dictionary ${value} adminstate
Scott Baker780b65f2020-05-22 14:03:15 -0700273 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
274 ... Get From Dictionary ${value} operStatus
275 ... ELSE
Hardik Windlass2b37e712020-06-12 02:13:17 +0530276 ... Get From Dictionary ${value} operstatus
Gilles Depatieb5682f82019-10-31 10:39:45 -0400277 ${type}= Get From Dictionary ${value} type
Hemaf64d34c2020-03-25 00:40:17 +0530278 Should Be Equal '${astate}' 'ENABLED' Device ${device_id} port admin_state != ENABLED values=False
Andy Bavier90eb1a12020-03-26 11:54:35 -0700279 Run Keyword If ${all_active} Should Be Equal '${opstatus}' 'ACTIVE'
280 ... Device ${device_id} port oper_status != ACTIVE values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400281 Should Be True '${type}' == '${pon_type}' or '${type}' == '${ethernet_type}'
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700282 ... Device ${device_id} port type is neither ${pon_type} or ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400283 END
284
285Validate OLT Port Types
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800286 [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 -0700287 [Arguments] ${pon_type} ${ethernet_type}
288 Validate Device Port Types ${olt_device_id} ${pon_type} ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400289
290Validate ONU Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700291 [Arguments] ${List_ONU_Serial} ${pon_type} ${ethernet_type}
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800292 [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 -0700293 ... and matches the port types listed
Gilles Depatieb5682f82019-10-31 10:39:45 -0400294 FOR ${serial_number} IN @{List_ONU_Serial}
295 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Andy Bavier90eb1a12020-03-26 11:54:35 -0700296 # Only first UNI port is ACTIVE; the rest are in DISCOVERED operstatus
297 Validate Device Port Types ${onu_dev_id} ${pon_type} ${ethernet_type} all_active=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400298 END
299
300Validate Device Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000301 [Arguments] ${device_id} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400302 [Documentation] Parses the output of voltctl device flows <device_id> and expects flow count > 0
Andrea Campanella80655eb2020-07-10 15:49:22 +0200303 ${rc} ${output}= Run and Return Rc and Output
Andrea Campanella28989d12022-01-11 09:49:21 +0100304 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device_id} -m 32MB -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400305 Should Be Equal As Integers ${rc} 0
306 ${jsondata}= To Json ${output}
307 Log ${jsondata}
308 ${length}= Get Length ${jsondata}
309 Log 'Number of flows = ' ${length}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000310 Run Keyword If '${flow_count}' == '${EMPTY}' Should Be True ${length} > 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400311 ... Number of flows for ${device_id} was 0
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000312 ... ELSE Should Be True ${length} == ${flow_count}
313 ... Number of flows for ${device_id} was not ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400314
315Validate OLT Flows
Suchitra Vemuria6879aa2020-11-03 11:03:11 -0800316 [Arguments] ${flow_count}=${EMPTY} ${olt_device_id}=${EMPTY}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000317 [Documentation] Parses the output of voltctl device flows ${olt_device_id}
318 ... and expects flow count == ${flow_count}
319 Validate Device Flows ${olt_device_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400320
321Validate ONU Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000322 [Arguments] ${List_ONU_Serial} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400323 [Documentation] Parses the output of voltctl device flows for each ONU SN listed in ${List_ONU_Serial}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000324 ... and expects flow count == ${flow_count}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700325 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400326 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000327 Validate Device Flows ${onu_dev_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400328 END
329
TorstenThieme401af432020-06-11 15:53:53 +0000330Validate ONU Devices With Duration
331 [Documentation]
332 ... Parses the output of "voltctl device list" and inspects all devices ${List_ONU_Serial},
333 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
334 ... states including MIB state.
335 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${onu_reason}
336 ... ${List_ONU_Serial} ${startTime} ${print2console}=False ${output_file}=${EMPTY}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000337 ... ${alternate_reason}=${EMPTY}
Andrea Campanella28989d12022-01-11 09:49:21 +0100338 ${cmd}= Catenate voltctl -c ${VOLTCTL_CONFIG} device list -m 32MB -f Type=brcm_openomci_onu
Matteo Scandolo6f24ea92021-04-29 11:55:50 -0700339 ... --format "{{.SerialNumber}}\t{{.AdminState}}\t{{.OperStatus}}\t{{.ConnectStatus}}\t{{.Reason}}" | grep -v SERIALNUMBER
TorstenThiemef78a9d82021-03-05 13:42:09 +0000340 ${rc} ${output}= Run and Return Rc and Output ${cmd}
Matteo Scandolo741d4fd2021-09-23 17:08:34 -0700341 Should Be Equal As Integers ${rc} 0 Failed Validate ONU Devices because of ${output}
342 Log ${output}
TorstenThieme401af432020-06-11 15:53:53 +0000343 ${timeCurrent} = Get Current Date
344 ${timeTotalMs} = Subtract Date From Date ${timeCurrent} ${startTime} result_format=number
TorstenThiemef78a9d82021-03-05 13:42:09 +0000345 @{Results}= Split String ${output} \n
346 FOR ${Line} IN @{Results}
TorstenThieme401af432020-06-11 15:53:53 +0000347 ${matched}= Set Variable False
TorstenThiemef78a9d82021-03-05 13:42:09 +0000348 @{words}= Split String ${Line} \t
349 ${sn}= Set Variable ${words[0]}
350 ${astate}= Set Variable ${words[1]}
351 ${opstatus}= Set Variable ${words[2]}
352 ${cstatus}= Set Variable ${words[3]}
353 ${mib_state}= Set Variable ${words[4]}
TorstenThieme401af432020-06-11 15:53:53 +0000354 ${onu_id}= Get Index From List ${List_ONU_Serial} ${sn}
355 ${matched}= Set Variable If -1 != ${onu_id} True False
356 ${matched}= Set Variable If '${astate}' == '${admin_state}' ${matched} False
357 ${matched}= Set Variable If '${opstatus}' == '${oper_status}' ${matched} False
358 ${matched}= Set Variable If '${cstatus}' == '${connect_status}' ${matched} False
TorstenThiemec3c23232021-01-13 13:06:31 +0000359 ${len}= Get Length ${alternate_reason}
TorstenThieme105c5982021-01-21 09:50:27 +0000360 ${matches}= Run Keyword If ${len} >= 1 Get Match Count ${alternate_reason} ${mib_state}
361 ... ELSE Set Variable 0
TorstenThiemec3c23232021-01-13 13:06:31 +0000362 ${matched}= Set Variable If '${mib_state}' == '${onu_reason}' or ${matches} >= 1
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000363 ... ${matched} False
TorstenThieme401af432020-06-11 15:53:53 +0000364 Run Keyword If ${matched} and ${print2console} Log
365 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec. console=yes
366 Run Keyword If ${matched} and ('${output_file}'!='${EMPTY}') Append To File ${output_file}
367 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec.
368 Run Keyword If ${matched} Remove Values From List ${List_ONU_Serial} ${sn}
369 END
370 Should Be Empty ${List_ONU_Serial} List ${List_ONU_Serial} not empty
371
TorstenThieme9949b172020-06-16 10:00:15 +0000372Validate ONU Devices MIB State With Duration
373 [Documentation]
374 ... Parses the output of "voltctl device list" and inspects all devices ${List_ONU_Serial},
375 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect MIB state.
376 [Arguments] ${onu_reason}
377 ... ${List_ONU_Serial} ${startTime} ${print2console}=False ${output_file}=${EMPTY}
378 ${type} = Set Variable brcm_openomci_onu
Andrea Campanella80655eb2020-07-10 15:49:22 +0200379 ${voltctl_commad} = Catenate SEPARATOR=
Andrea Campanella28989d12022-01-11 09:49:21 +0100380 ... voltctl device list -m 32MB -f Type=${type} -f Reason=${onu_reason} --format '{{.SerialNumber}}'
Andrea Campanella80655eb2020-07-10 15:49:22 +0200381 ${rc} ${output}= Run and Return Rc and Output ${voltctl_commad}
TorstenThieme9949b172020-06-16 10:00:15 +0000382 Should Be Equal As Integers ${rc} 0
383 ${timeCurrent} = Get Current Date
384 ${timeTotalMs} = Subtract Date From Date ${timeCurrent} ${startTime} result_format=number
385 @{outputdata} = Split String ${output}
386 ${outputlength} = Get Length ${outputdata}
387 ${onulength} = Get Length ${List_ONU_Serial}
388 ${Matches} = Run Keyword If ${outputlength}<=${onulength}
389 ... Compare Lists ${outputdata} ${List_ONU_Serial}
390 ... ELSE Compare Lists ${List_ONU_Serial} ${outputdata}
391 ${length} = Get Length ${Matches}
392 FOR ${INDEX} IN RANGE 0 ${length}
393 ${sn}= Get From List ${Matches} ${INDEX}
394 Run Keyword If ${print2console} Log
395 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec. console=yes
396 Run Keyword If ('${output_file}'!='${EMPTY}') Append To File ${output_file}
397 ... \r\nONU ${sn} reached the state ${onu_reason} after ${timeTotalMs} sec.
398 Remove Values From List ${List_ONU_Serial} ${sn}
399 END
400 Should Be Empty ${List_ONU_Serial} List ${List_ONU_Serial} not empty
401
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000402Validate ONU Device By Device Id
403 [Documentation]
404 ... Parses the output of "voltctl device list" filtered by device id and inspects states including reason.
405 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${onu_reason} ${onu_id}
Andrea Campanella28989d12022-01-11 09:49:21 +0100406 ${cmd} Catenate voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${onu_id} -m 32MB -o json
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000407 ${rc} ${output}= Run and Return Rc and Output ${cmd}
408 Should Be Equal As Integers ${rc} 0
409 ${jsondata}= To Json ${output}
410 ${length}= Get Length ${jsondata}
411 Should Be Equal As Integers ${length} 1 No match found for ${onu_id} to validate device
412 ${value}= Get From List ${jsondata} 0
413 Log ${value}
414 ${jsonCamelCaseFieldnames}= Run Keyword And Return Status
415 ... Dictionary Should Contain Key ${value} adminState
416 ${astate}= Run Keyword If ${jsonCamelCaseFieldNames}
417 ... Get From Dictionary ${value} adminState
418 ... ELSE
419 ... Get From Dictionary ${value} adminstate
420 ${opstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
421 ... Get From Dictionary ${value} operStatus
422 ... ELSE
423 ... Get From Dictionary ${value} operstatus
424 ${cstatus}= Run Keyword If ${jsonCamelCaseFieldNames}
425 ... Get From Dictionary ${value} connectStatus
426 ... ELSE
427 ... Get From Dictionary ${value} connectstatus
428 ${sn}= Run Keyword If ${jsonCamelCaseFieldNames}
429 ... Get From Dictionary ${value} serialNumber
430 ... ELSE
431 ... Get From Dictionary ${value} serialnumber
432 ${devId}= Get From Dictionary ${value} id
433 ${mib_state}= Get From Dictionary ${value} reason
434 Should Be Equal '${devId}' '${onu_id}' No match found for ${onu_id} to validate device
435 ... values=False
436 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
437 ... values=False
438 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
439 ... values=False
440 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
441 ... values=False
442 Should Be Equal '${mib_state}' '${onu_reason}'
443 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
444
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000445Check all ONU OperStatus
446 [Documentation] Checks that all ONUs OperStatus is the required one.
447 [Arguments] ${List_ONU_Serial} ${oper_status}
Andrea Campanella28989d12022-01-11 09:49:21 +0100448 ${cmd}= Catenate voltctl -c ${VOLTCTL_CONFIG} device list -m 32MB -f Type=brcm_openomci_onu
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000449 ... --format "{{.SerialNumber}}\t{{.AdminState}}\t{{.OperStatus}}\t{{.ConnectStatus}}\t{{.Reason}}"
450 ... | grep -v SERIALNUMBER | grep ${oper_status}
451 ${rc} ${output}= Run and Return Rc and Output ${cmd}
452 Should Be Equal As Integers ${rc} 0
453 @{Results}= Split String ${output} \n
454 FOR ${Line} IN @{Results}
455 @{words}= Split String ${Line} \t
456 ${sn}= Set Variable ${words[0]}
457 Remove Values From List ${List_ONU_Serial} ${sn}
458 END
459 Should Be Empty ${List_ONU_Serial} For ONUs ${List_ONU_Serial} OperStatus ${oper_status} not matched!
460
461Validate Last ONU Communication
462 [Documentation] Validates last communication with ONU.
463 [Arguments] ${validation_duration}=5s
464 ${cmd}= Catenate voltctl -c ${VOLTCTL_CONFIG} adapter list -f Type=brcm_openomci_onu
465 ... --format '{{gosince .LastCommunication}}'
466 ${rc} ${output}= Run and Return Rc and Output ${cmd}
467 Should Be Equal As Integers ${rc} 0
TorstenThieme70790282021-11-19 10:26:25 +0000468 ${lastcomm}= Convert Time ${output}
469 ${validduration}= Convert Time ${validation_duration}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000470 Should Be True ${lastcomm}<=${validduration}
471
472Get Onu Image List
473 [Documentation] Delivers the ONU device image list
474 [Arguments] ${dev_id}
475 ${rc} ${output}= Run and Return Rc and Output
476 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage list ${dev_id}
477 [return] ${rc} ${output}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000478
TorstenThieme9949b172020-06-16 10:00:15 +0000479Compare Lists
480 [Documentation]
481 ... Compares both lists and put all matches in the returned list
482 [Arguments] ${ListIterate} ${ListCompare}
483 @{list} = Create List
484 ${length} = Get Length ${ListIterate}
485 FOR ${INDEX} IN RANGE 0 ${length}
486 ${sn}= Get From List ${ListIterate} ${INDEX}
487 ${onu_id}= Get Index From List ${ListCompare} ${sn}
488 Run Keyword If -1 != ${onu_id} Append To List ${list} ${sn}
489 END
490 [Return] ${list}
491
Gilles Depatieb5682f82019-10-31 10:39:45 -0400492Validate Logical Device
493 [Documentation] Validate Logical Device is listed
Matteo Scandolo5899be12020-11-11 15:38:07 -0800494 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} logicaldevice list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400495 Should Be Equal As Integers ${rc} 0
496 ${jsondata}= To Json ${output}
497 Log ${jsondata}
498 ${length}= Get Length ${jsondata}
499 FOR ${INDEX} IN RANGE 0 ${length}
500 ${value}= Get From List ${jsondata} ${INDEX}
501 ${devid}= Get From Dictionary ${value} id
Scott Baker2ab2a0c2020-06-05 12:51:47 -0700502 ${rootdev}= Get From Dictionary ${value} rootDeviceId
503 ${desc}= Get From Dictionary ${value} desc
504 ${sn}= Get From Dictionary ${desc} serialNum
Gilles Depatieb5682f82019-10-31 10:39:45 -0400505 Exit For Loop
506 END
507 Should Be Equal '${rootdev}' '${olt_device_id}' Root Device does not match ${olt_device_id} values=False
508 Should Be Equal '${sn}' '${BBSIM_OLT_SN}' Logical Device ${sn} does not match ${BBSIM_OLT_SN}
509 ... values=False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700510 [Return] ${devid}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400511
512Validate Logical Device Ports
513 [Arguments] ${logical_device_id}
514 [Documentation] Validate Logical Device Ports are listed and are > 0
515 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800516 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice port list ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400517 Should Be Equal As Integers ${rc} 0
518 ${jsondata}= To Json ${output}
519 Log ${jsondata}
520 ${length}= Get Length ${jsondata}
521 Should Be True ${length} > 0 Number of ports for ${logical_device_id} was 0
522
523Validate Logical Device Flows
524 [Arguments] ${logical_device_id}
525 [Documentation] Validate Logical Device Flows are listed and are > 0
526 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800527 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice flows ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400528 Should Be Equal As Integers ${rc} 0
529 ${jsondata}= To Json ${output}
530 Log ${jsondata}
531 ${length}= Get Length ${jsondata}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700532 Should Be True ${length} > 0 Number of flows for ${logical_device_id} was 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400533
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000534Retrieve ONU UNI Ports
535 [Arguments] ${onu_device_id}
536 [Documentation] Retrieves the list of Active and Enabled UNI ports from the ONU device
537 ${rc} ${output}= Run and Return Rc and Output
538 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${onu_device_id} -o json
539 Should Be Equal As Integers ${rc} 0
540 ${jsondata}= To Json ${output}
541 Log ${jsondata}
542 ${length}= Get Length ${jsondata}
543 ${onu_uni_list}= Create List
544 FOR ${INDEX} IN RANGE 0 ${length}
545 ${value}= Get From List ${jsondata} ${INDEX}
546 ${type}= Get From Dictionary ${value} type
547 ${portno}= Get From Dictionary ${value} portNo
548 ${adminstate}= Get From Dictionary ${value} adminState
549 ${operstate}= Get From Dictionary ${value} operStatus
550 Run Keyword If '${type}'=='ETHERNET_UNI' and '${adminstate}'=='ENABLED' and '${operstate}'=='ACTIVE'
551 ... Append To List ${onu_uni_list} ${portno}
552 END
553 [Return] ${onu_uni_list}
554
Hardik Windlass16cdf962020-04-29 15:26:50 +0530555Retrieve OLT PON Ports
556 [Arguments] ${olt_device_id}
557 [Documentation] Retrieves the list of PON ports from the OLT device
558 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800559 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530560 Should Be Equal As Integers ${rc} 0
561 ${jsondata}= To Json ${output}
562 Log ${jsondata}
563 ${length}= Get Length ${jsondata}
564 ${olt_pon_list}= Create List
565 FOR ${INDEX} IN RANGE 0 ${length}
566 ${value}= Get From List ${jsondata} ${INDEX}
567 ${type}= Get From Dictionary ${value} type
568 ${portno}= Get From Dictionary ${value} portNo
569 ${peers}= Get From Dictionary ${value} peers
570 ${len_peers}= Get Length ${peers}
571 Run Keyword If '${type}' == 'PON_OLT' and ${len_peers} > 0
572 ... Append To List ${olt_pon_list} ${portno}
573 END
574 [Return] ${olt_pon_list}
575
576Retrieve Peer List From OLT PON Port
TorstenThieme17d6fd22021-09-23 10:00:08 +0000577 [Arguments] ${olt_device_id} ${pon_port} ${expected_num_peers}=0
Hardik Windlass16cdf962020-04-29 15:26:50 +0530578 [Documentation] Retrieves the list of peer device ids list from the OLT PON port
579 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800580 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530581 Should Be Equal As Integers ${rc} 0
582 ${jsondata}= To Json ${output}
583 Log ${jsondata}
584 ${length}= Get Length ${jsondata}
585 ${matched}= Set Variable False
586 FOR ${INDEX} IN RANGE 0 ${length}
587 ${value}= Get From List ${jsondata} ${INDEX}
588 ${type}= Get From Dictionary ${value} type
589 ${portno}= Get From Dictionary ${value} portNo
590 ${peers}= Get From Dictionary ${value} peers
591 ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
592 Exit For Loop If ${matched}
593 END
594 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
595 ${length}= Get Length ${peers}
TorstenThieme17d6fd22021-09-23 10:00:08 +0000596 Run Keyword If ${expected_num_peers}>0 Should Be Equal As Integers ${length} ${expected_num_peers}
597 ... Number of found peers does not match expected number ${length}:${expected_num_peers}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530598 ${olt_peer_list}= Create List
599 FOR ${INDEX} IN RANGE 0 ${length}
600 ${value}= Get From List ${peers} ${INDEX}
601 ${peer_id}= Get From Dictionary ${value} deviceId
602 Append To List ${olt_peer_list} ${peer_id}
603 END
604 [Return] ${olt_peer_list}
605
606Validate OLT PON Port Status
607 [Arguments] ${olt_device_id} ${pon_port} ${admin_state} ${oper_status}
608 [Documentation] Verifies the state of the PON port of the OLT
609 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800610 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Hardik Windlass16cdf962020-04-29 15:26:50 +0530611 Should Be Equal As Integers ${rc} 0
612 ${jsondata}= To Json ${output}
613 Log ${jsondata}
614 ${length}= Get Length ${jsondata}
615 ${matched}= Set Variable False
616 FOR ${INDEX} IN RANGE 0 ${length}
617 ${value}= Get From List ${jsondata} ${INDEX}
618 ${type}= Get From Dictionary ${value} type
619 ${portno}= Get From Dictionary ${value} portNo
620 ${astate}= Get From Dictionary ${value} adminState
621 ${opstatus}= Get From Dictionary ${value} operStatus
622 ${matched}= Set Variable If '${type}' == 'PON_OLT' and '${portno}' == '${pon_port}' True False
623 Exit For Loop If ${matched}
624 END
625 Should Be True ${matched} No PON port found for OLT ${olt_device_id} ${pon_port}
626 Log ${value}
627 Should Be Equal '${astate}' '${admin_state}' OLT PON Port admin_state != ${admin_state}
628 ... values=False
629 Should Be Equal '${opstatus}' '${oper_status}' OLT PON Port oper_status != ${oper_status}
630 ... values=False
631
632DisableOrEnable OLT PON Port
633 [Arguments] ${operation} ${olt_device_id} ${portno}
634 [Documentation] Disables or Enables the PON port of the OLT
635 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800636 ... voltctl -c ${VOLTCTL_CONFIG} device port ${operation} ${olt_device_id} ${portno}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530637 Should Be Equal As Integers ${rc} 0
638
Gilles Depatieb5682f82019-10-31 10:39:45 -0400639Retrieve Peer List From OLT
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700640 [Arguments] ${olt_peer_list}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400641 [Documentation] Retrieve the list of peer device id list from port list
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700642 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800643 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${olt_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400644 Should Be Equal As Integers ${rc} 0
645 ${jsondata}= To Json ${output}
646 Log ${jsondata}
647 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700648 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400649 FOR ${INDEX} IN RANGE 0 ${length}
650 ${value}= Get From List ${jsondata} ${INDEX}
651 ${type}= Get From Dictionary ${value} type
652 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700653 ${matched}= Set Variable If '${type}' == 'PON_OLT' True False
654 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400655 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700656 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400657 ${length}= Get Length ${peers}
658 FOR ${INDEX} IN RANGE 0 ${length}
659 ${value}= Get From List ${peers} ${INDEX}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530660 ${peer_id}= Get From Dictionary ${value} deviceId
Gilles Depatieb5682f82019-10-31 10:39:45 -0400661 Append To List ${olt_peer_list} ${peer_id}
662 END
663
664Validate OLT Peer Id List
665 [Arguments] ${olt_peer_id_list}
666 [Documentation] Match each entry in the ${olt_peer_id_list} against ONU device ids.
667 FOR ${peer_id} IN @{olt_peer_id_list}
668 Match OLT Peer Id ${peer_id}
669 END
670
671Match OLT Peer Id
672 [Arguments] ${olt_peer_id}
673 [Documentation] Lookup the OLT Peer Id in against the list of ONU device Ids
Matteo Scandolo5899be12020-11-11 15:38:07 -0800674 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400675 Should Be Equal As Integers ${rc} 0
676 ${jsondata}= To Json ${output}
677 Log ${jsondata}
678 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700679 ${matched}= Set Variable False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700680 FOR ${INDEX} IN RANGE 0 ${length}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400681 ${value}= Get From List ${jsondata} ${INDEX}
682 ${devid}= Get From Dictionary ${value} id
Andy Bavierb63f6d22020-03-12 15:34:37 -0700683 ${matched}= Set Variable If '${devid}' == '${olt_peer_id}' True False
684 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400685 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700686 Should Be True ${matched} Peer id ${olt_peer_id} does not match any ONU device id
Gilles Depatieb5682f82019-10-31 10:39:45 -0400687
688Validate ONU Peer Id
689 [Arguments] ${olt_device_id} ${List_ONU_Serial}
690 [Documentation] Match each ONU peer to that of the OLT device id
691 FOR ${onu_serial} IN @{List_ONU_Serial}
692 ${onu_dev_id}= Get Device ID From SN ${onu_serial}
693 Match ONU Peer Id ${onu_dev_id}
694 END
695
696Match ONU Peer Id
697 [Arguments] ${onu_dev_id}
698 [Documentation] Match an ONU peer to that of the OLT device id
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800699 ${rc} ${output}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800700 ... voltctl -c ${VOLTCTL_CONFIG} device port list ${onu_dev_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400701 Should Be Equal As Integers ${rc} 0
702 ${jsondata}= To Json ${output}
703 Log ${jsondata}
704 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700705 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400706 FOR ${INDEX} IN RANGE 0 ${length}
707 ${value}= Get From List ${jsondata} ${INDEX}
708 ${type}= Get From Dictionary ${value} type
709 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700710 ${matched}= Set Variable If '${type}' == 'PON_ONU' True False
711 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400712 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700713 Should Be True ${matched} No PON port found for ONU ${onu_dev_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400714 ${length}= Get Length ${peers}
715 FOR ${INDEX} IN RANGE 0 ${length}
716 ${value}= Get From List ${peers} ${INDEX}
Hardik Windlass16cdf962020-04-29 15:26:50 +0530717 ${peer_id}= Get From Dictionary ${value} deviceId
Gilles Depatieb5682f82019-10-31 10:39:45 -0400718 END
719 Should Be Equal '${peer_id}' '${olt_device_id}'
720 ... Mismatch between ONU peer ${peer_id} and OLT device id ${olt_device_id} values=False
Kailash6f5acb62019-08-28 14:38:45 -0700721
Kailash6f5acb62019-08-28 14:38:45 -0700722Get Device ID From SN
723 [Arguments] ${serial_number}
724 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700725 ${rc} ${id}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800726 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=SerialNumber=${serial_number} --format='{{.Id}}'
Matteo Scandolo2769d2b2021-04-14 10:29:24 -0700727 Should Be Equal As Integers ${rc} 0 "Error while fetching device list from VOLTHA"
Andy Bavier8fca0452019-12-16 15:30:11 -0700728 Log ${id}
Kailash6f5acb62019-08-28 14:38:45 -0700729 [Return] ${id}
730
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700731Get Logical Device ID From SN
732 [Arguments] ${serial_number}
733 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700734 ${rc} ${id}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800735 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice list --filter=Desc.SerialNum=${serial_number} --format='{{.Id}}'
Andy Bavier8fca0452019-12-16 15:30:11 -0700736 Should Be Equal As Integers ${rc} 0
737 Log ${id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700738 [Return] ${id}
739
Gilles Depatieb5682f82019-10-31 10:39:45 -0400740Build ONU SN List
Andrea Campanella6391f842020-11-16 10:01:18 +0100741 [Arguments] ${serial_numbers} ${olt_serial_number}=${EMPTY} ${num_onus}=${num_all_onus}
742 [Documentation] Appends all ONU SNs for the given OLT to the ${serial_numbers} list
Gilles Depatieb5682f82019-10-31 10:39:45 -0400743 FOR ${INDEX} IN RANGE 0 ${num_onus}
TorstenThieme96fe9ee2021-10-21 10:24:08 +0000744 ${onu_sn}= Set Variable ${hosts.src[${INDEX}]['onu']}
745 # skip if we have already append this ONU
746 ${onu_id}= Get Index From List ${serial_numbers} ${onu_sn}
747 Continue For Loop If -1 != ${onu_id}
748 Run Keyword IF "${olt_serial_number}"=="${hosts.src[${INDEX}].olt}" or "${olt_serial_number}"=="${EMPTY}"
749 ... Append To List ${serial_numbers} ${onu_sn}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400750 END
751
TorstenThiemef3e492c2021-11-08 15:25:48 +0000752Build ONU Device Id List
753 [Arguments] ${device_ids} ${olt_serial_number}=${EMPTY} ${num_onus}=${num_all_onus}
754 [Documentation] Appends all ONU Device IDs for the given OLT to the ${serial_numbers} list
755 FOR ${INDEX} IN RANGE 0 ${num_onus}
756 ${onu_device_id}= Get Device ID From SN ${hosts.src[${INDEX}]['onu']}
757 # skip if we have already append this ONU
758 ${onu_id}= Get Index From List ${device_ids} ${onu_device_id}
759 Continue For Loop If -1 != ${onu_id}
760 Run Keyword IF "${olt_serial_number}"=="${hosts.src[${INDEX}].olt}" or "${olt_serial_number}"=="${EMPTY}"
761 ... Append To List ${device_ids} ${onu_device_id}
762 END
763
Gilles Depatieb5682f82019-10-31 10:39:45 -0400764Get SN From Device ID
765 [Arguments] ${device_id}
766 [Documentation] Gets the device id by matching for ${device_id}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700767 ${rc} ${sn}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800768 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${device_id} --format='{{.SerialNumber}}'
Gilles Depatieb5682f82019-10-31 10:39:45 -0400769 Should Be Equal As Integers ${rc} 0
Andy Bavier8fca0452019-12-16 15:30:11 -0700770 Log ${sn}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400771 [Return] ${sn}
772
Scott Baker60e570d2020-02-02 22:10:13 -0800773Get Parent ID From Device ID
774 [Arguments] ${device_id}
775 [Documentation] Gets the device id by matching for ${device_id}
776 ${rc} ${pid}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800777 ... voltctl -c ${VOLTCTL_CONFIG} device list --filter=Id=${device_id} --format='{{.ParentId}}'
Scott Baker60e570d2020-02-02 22:10:13 -0800778 Should Be Equal As Integers ${rc} 0
779 Log ${pid}
780 [Return] ${pid}
781
Kailash6f5acb62019-08-28 14:38:45 -0700782Validate Device Removed
TorstenThieme4489b512021-12-16 09:41:50 +0000783 [Arguments] ${serialNumber}
Kailash6f5acb62019-08-28 14:38:45 -0700784 [Documentation] Verifys that device, ${serial_number}, has been removed
Matteo Scandolo5899be12020-11-11 15:38:07 -0800785 ${rc} ${output}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device list -o json
Andy Bavier8fca0452019-12-16 15:30:11 -0700786 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700787 ${jsondata}= To Json ${output}
788 Log ${jsondata}
789 ${length}= Get Length ${jsondata}
TorstenThieme4489b512021-12-16 09:41:50 +0000790 @{sns}= Create List
Zack Williamsec53a1b2019-09-16 15:50:52 -0700791 FOR ${INDEX} IN RANGE 0 ${length}
792 ${value}= Get From List ${jsondata} ${INDEX}
TorstenThieme4489b512021-12-16 09:41:50 +0000793 ${device_sn}= Get From Dictionary ${value} serialNumber
794 Append To List ${sns} ${device_sn}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700795 END
TorstenThieme4489b512021-12-16 09:41:50 +0000796 List Should Not Contain Value ${sns} ${serialNumber}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800797
Andrea Campanella4e507882020-11-26 11:33:11 +0100798Validate all ONUS for OLT Removed
799 [Arguments] ${num_all_onus} ${hosts} ${olt_serial_number} ${timeout}
800 [Documentation] Verifys that all the ONUS for OLT ${serial_number}, has been removed
TorstenThieme4489b512021-12-16 09:41:50 +0000801 @{onu_list}= Create List
Andrea Campanella4e507882020-11-26 11:33:11 +0100802 FOR ${J} IN RANGE 0 ${num_all_onus}
803 ${src}= Set Variable ${hosts.src[${J}]}
804 Continue For Loop If "${olt_serial_number}"!="${src['olt']}"
TorstenThieme4489b512021-12-16 09:41:50 +0000805 ${sn}= Set Variable ${src['onu']}
806 ${onu_id}= Get Index From List ${onu_list} ${sn}
807 Continue For Loop If -1 != ${onu_id}
808 Append To List ${onu_list} ${sn}
809 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 5s Validate Device Removed ${sn}
Andrea Campanella4e507882020-11-26 11:33:11 +0100810 END
811
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800812Reboot ONU
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000813 [Arguments] ${onu_id} ${validate_device}=True
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800814 [Documentation] Using voltctl command reboot ONU and verify that ONU comes up to running state
Matteo Scandolo5899be12020-11-11 15:38:07 -0800815 ${rc} ${devices}= Run and Return Rc and Output voltctl -c ${VOLTCTL_CONFIG} device reboot ${onu_id}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800816 Should Be Equal As Integers ${rc} 0
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000817 Run Keyword If ${validate_device} Run Keyword And Continue On Failure Wait Until Keyword Succeeds
818 ... 60s 1s Validate ONU Device By Device Id ENABLED DISCOVERED REACHABLE rebooting ${onu_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700819
820Assert ONUs in Voltha
821 [Arguments] ${count}
822 [Documentation] Check that a certain number of devices reached the ACTIVE/ENABLE state
823 ${rc1} ${devices}= Run and Return Rc and Output
Andrea Campanella28989d12022-01-11 09:49:21 +0100824 ... voltctl -c ${VOLTCTL_CONFIG} -m 32MB device list | grep -v OLT | grep ACTIVE | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700825 Should Be Equal As Integers ${rc1} 0
826 Should Be Equal As Integers ${devices} ${count}
827
828Wait for ONUs in VOLTHA
Andrea Campanella4ec9b832022-02-09 13:21:54 +0100829 [Arguments] ${count} ${timeout}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700830 [Documentation] Waits until a certain number of devices reached the ACTIVE/ENABLE state
Andrea Campanella4ec9b832022-02-09 13:21:54 +0100831 Wait Until Keyword Succeeds ${timeout} 5s Assert ONUs In Voltha ${count}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700832
833Count Logical Devices flows
834 [Documentation] Count the flows across logical devices in VOLTHA
835 [Arguments] ${targetFlows}
836 ${output}= Get Logical Device List From Voltha
837 ${logical_devices}= To Json ${output}
838 ${total_flows}= Set Variable 0
839 FOR ${device} IN @{logical_devices}
840 ${rc} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800841 ... voltctl -c ${VOLTCTL_CONFIG} logicaldevice flows ${device['id']} | grep -v ID | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700842 Should Be Equal As Integers ${rc} 0
843 ${total_flows}= Evaluate ${total_flows} + ${flows}
844 END
Matteo Scandolo616daab2020-05-13 11:49:24 -0700845 ${msg}= Format String Found {total_flows} flows of {targetFlows} expected
846 ... total_flows=${total_flows} targetFlows=${targetFlows}
847 Log ${msg}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700848 Should Be Equal As Integers ${targetFlows} ${total_flows}
849
850Wait for Logical Devices flows
851 [Documentation] Waits until the flows have been provisioned in the logical device
852 [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella4ec9b832022-02-09 13:21:54 +0100853 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp} ${timeout}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700854 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200855 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700856 Log ${targetFlows}
857 # TODO extend Validate Logical Device Flows to check the correct number of flows
Andrea Campanella4ec9b832022-02-09 13:21:54 +0100858 Wait Until Keyword Succeeds ${timeout} 5s Count Logical Devices flows ${targetFlows}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700859
Matteo Scandolo616daab2020-05-13 11:49:24 -0700860Count OpenOLT Device Flows
861 [Documentation] Count the flows across openolt devices in VOLTHA
862 [Arguments] ${targetFlows}
863 ${output}= Get Device List from Voltha by type openolt
864 ${devices}= To Json ${output}
865 ${total_flows}= Set Variable 0
866 FOR ${device} IN @{devices}
867 ${rc} ${flows}= Run and Return Rc and Output
Matteo Scandolo5899be12020-11-11 15:38:07 -0800868 ... voltctl -c ${VOLTCTL_CONFIG} device flows ${device['id']} | grep -v ID | wc -l
Matteo Scandolo616daab2020-05-13 11:49:24 -0700869 Should Be Equal As Integers ${rc} 0
870 ${total_flows}= Evaluate ${total_flows} + ${flows}
871 END
872 ${msg}= Format String Found {total_flows} flows of {targetFlows} expected
873 ... total_flows=${total_flows} targetFlows=${targetFlows}
874 Log ${msg}
875 Should Be Equal As Integers ${targetFlows} ${total_flows}
876
877Wait for OpenOLT Devices flows
878 [Documentation] Waits until the flows have been provisioned in the openolt devices
879 [Arguments] ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200880 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700881 ${beforeFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
882 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandoloda854b02020-09-01 16:20:51 -0700883 # In the physical device we only have 2 data plane flows (on the PON) instead of 4
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700884 ${afterFlows}= Evaluate ${beforeFlows} - (${uni_count} * 2)
Matteo Scandoloda854b02020-09-01 16:20:51 -0700885 # In the TT workflow we have multiple service,
886 # so we need to remove 6 flows per each UNI that are only on the ONU device
887 ${ttFlows}= Evaluate ${beforeFlows} - (${uni_count} * 6)
888 ${afterFlows}= Set Variable If $workflow=='tt' ${ttFlows} ${afterFlows}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700889 ${targetFlows}= Set Variable If $provisioned=='true' ${afterFlows} ${beforeFlows}
Matteo Scandolo616daab2020-05-13 11:49:24 -0700890 Log ${targetFlows}
Hardik Windlass2b37e712020-06-12 02:13:17 +0530891 Wait Until Keyword Succeeds 10m 5s Count OpenOLT Device Flows ${targetFlows}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000892
Hardik Windlassba1bd272021-06-22 08:29:33 +0000893Validate ONU Device Image
894 [Documentation] Validates the ONU device image
895 [Arguments] ${data} ${image_version} ${dev_id} ${download_state} ${expected_reason} ${image_status}
896 ${jsondata}= To Json ${data}
897 ${length}= Get Length ${jsondata}
TorstenThiemef3e492c2021-11-08 15:25:48 +0000898 Should Not Be Equal As Integers ${length} 0 No record to validate device image
899 FOR ${J} IN RANGE 0 ${length}
900 ${value}= Get From List ${jsondata} ${J}
901 Log ${value}
902 ${deviceId}= Get From Dictionary ${value} deviceId
903 Should Contain ${dev_id} ${deviceId} No match found for ${deviceId} to validate device image!
904 ${imageState}= Get From Dictionary ${value} imageState
905 ${version}= Get From Dictionary ${imageState} version
906 ${dwlState}= Get From Dictionary ${imageState} downloadState
907 ${reason}= Get From Dictionary ${imageState} reason
908 ${imgStatus}= Get From Dictionary ${imageState} imageState
Hardik Windlassca8ce7c2022-02-01 09:01:23 +0000909 Should Be Equal '${version}' '${image_version}' Device ${deviceId}: '${version}' != '${image_version}'
TorstenThiemef3e492c2021-11-08 15:25:48 +0000910 ... values=False
Hardik Windlassca8ce7c2022-02-01 09:01:23 +0000911 Should Be Equal '${dwlState}' '${download_state}' Device ${deviceId}: '${dwlState}' != '${download_state}'
TorstenThiemef3e492c2021-11-08 15:25:48 +0000912 ... values=False
Hardik Windlassca8ce7c2022-02-01 09:01:23 +0000913 Should Be Equal '${reason}' '${expected_reason}' Device ${deviceId}: '${reason}' != '${expected_reason}'
TorstenThiemef3e492c2021-11-08 15:25:48 +0000914 ... values=False
Hardik Windlassca8ce7c2022-02-01 09:01:23 +0000915 Should Be Equal '${imgStatus}' '${image_status}' Device ${deviceId}: '${imgStatus}' != '${image_status}'
TorstenThiemef3e492c2021-11-08 15:25:48 +0000916 ... values=False
917 END
Hardik Windlassba1bd272021-06-22 08:29:33 +0000918
Hardik Windlass17bd1142021-03-12 08:15:25 +0000919Download ONU Device Image
920 [Documentation] Downloads the given ONU software image
Hardik Windlassba1bd272021-06-22 08:29:33 +0000921 [Arguments] ${ver} ${url} ${vendor} ${active} ${commit} ${crc} ${id}
TorstenThieme7cb9de72021-08-24 09:40:57 +0000922 ... ${download_state}=DOWNLOAD_STARTED ${expected_reason}=NO_ERROR ${image_state}=IMAGE_UNKNOWN
Hardik Windlassba1bd272021-06-22 08:29:33 +0000923 ${rc} ${output}= Run and Return Rc and Output
924 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage download ${ver} ${url} ${vendor} ${active} ${commit} ${crc} ${id} -o json
925 Log ${output}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000926 Should Be Equal As Integers ${rc} 0
TorstenThieme7cb9de72021-08-24 09:40:57 +0000927 Validate ONU Device Image ${output} ${ver} ${id} ${download_state} ${expected_reason} ${image_state}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000928
929Activate ONU Device Image
Hardik Windlassba1bd272021-06-22 08:29:33 +0000930 [Documentation] Activates the given ONU software image
931 [Arguments] ${ver} ${commit} ${id}
Hardik Windlass17bd1142021-03-12 08:15:25 +0000932 ${rc} ${output}= Run and Return Rc and Output
Hardik Windlassba1bd272021-06-22 08:29:33 +0000933 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage activate ${ver} ${commit} ${id} -o json
934 Log ${output}
935 Should Be Equal As Integers ${rc} 0
Andrea Campanellaf3b88f62021-10-01 18:43:03 +0200936 Validate ONU Device Image ${output} ${ver} ${id} DOWNLOAD_SUCCEEDED NO_ERROR IMAGE_ACTIVATING
Hardik Windlassba1bd272021-06-22 08:29:33 +0000937
938Commit ONU Device Image
939 [Documentation] Commits the given ONU software image
940 [Arguments] ${ver} ${id}
941 ${rc} ${output}= Run and Return Rc and Output
942 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage commit ${ver} ${id} -o json
943 Log ${output}
944 Should Be Equal As Integers ${rc} 0
Andrea Campanellaf3b88f62021-10-01 18:43:03 +0200945 Validate ONU Device Image ${output} ${ver} ${id} DOWNLOAD_SUCCEEDED NO_ERROR IMAGE_COMMITTING
Hardik Windlassba1bd272021-06-22 08:29:33 +0000946
TorstenThieme37165402021-09-03 11:39:40 +0000947Abort ONU Device Image
948 [Documentation] Aborts the given ONU software image
949 [Arguments] ${ver} ${id} ${download_state} ${expected_reason} ${image_state}
950 ${rc} ${output}= Run and Return Rc and Output
951 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage abort ${ver} ${id} -o json
952 Log ${output}
953 Should Be Equal As Integers ${rc} 0
954 Validate ONU Device Image ${output} ${ver} ${id} ${download_state} ${expected_reason} ${image_state}
955
Andrea Campanellaf3b88f62021-10-01 18:43:03 +0200956Remove Adapter Image
957 [Documentation] Aborts the upgrade processing for a given ONU software image and thus removes the image from adapter
958 [Arguments] ${ver} ${id}
959 ${rc} ${output}= Run and Return Rc and Output
960 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage abort ${ver} ${id} -o json
961 Log ${output}
962
TorstenThiemef3e492c2021-11-08 15:25:48 +0000963Remove Adapter Image from ONUs
964 [Documentation] Aborts the upgrade processing for a given ONU software image and thus removes the image from adapter
965 ... for the passed ONUs
966 [Arguments] ${ver} ${onu_id_list}
967 FOR ${onu_device_id} IN @{onu_id_list}
968 Remove Adapter Image ${ver} ${onu_device_id}
969 END
970
Hardik Windlassba1bd272021-06-22 08:29:33 +0000971Verify ONU Device Image Status
972 [Documentation] Verfies the ONU device image state
973 [Arguments] ${image_version} ${dev_id} ${download_state} ${expected_reason} ${image_state}
974 ${rc} ${output}= Run and Return Rc and Output
975 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage status ${image_version} ${dev_id} -o json
976 Log ${output}
977 Should Be Equal As Integers ${rc} 0
978 Validate ONU Device Image ${output} ${image_version} ${dev_id} ${download_state} ${expected_reason}
979 ... ${image_state}
980
981Verify ONU Device Image List
982 [Documentation] Verfies the ONU device image list
TorstenThieme70790282021-11-19 10:26:25 +0000983 [Arguments] ${dev_id} ${image_version} ${committed} ${activated} ${valid} ${image_should_not_in_list}=False
Hardik Windlassba1bd272021-06-22 08:29:33 +0000984 ${rc} ${output}= Run and Return Rc and Output
985 ... voltctl -c ${VOLTCTL_CONFIG} device onuimage list ${dev_id} -o json
Hardik Windlass17bd1142021-03-12 08:15:25 +0000986 Should Be Equal As Integers ${rc} 0
987 ${jsondata}= To Json ${output}
988 Log ${jsondata}
989 ${length}= Get Length ${jsondata}
990 ${matched}= Set Variable False
991 FOR ${INDEX} IN RANGE 0 ${length}
992 ${value}= Get From List ${jsondata} ${INDEX}
Hardik Windlassba1bd272021-06-22 08:29:33 +0000993 ${version}= Get From Dictionary ${value} version
994 ${isCommited}= Get From Dictionary ${value} isCommited
995 ${isActive}= Get From Dictionary ${value} isActive
996 ${isValid}= Get From Dictionary ${value} isValid
997 ${matched}= Set Variable If '${version}' == '${image_version}' True False
Hardik Windlass17bd1142021-03-12 08:15:25 +0000998 Exit For Loop If ${matched}
999 END
TorstenThieme70790282021-11-19 10:26:25 +00001000 Run Keyword If ${image_should_not_in_list}
1001 ... Should Not Be True ${matched} ONU Image found unexpectedly with Version ${image_version}
1002 ... ELSE Should Be True ${matched} No ONU Image found with Version ${image_version}
1003 Run Keyword If ${matched} Should Be Equal '${isCommited}' '${committed}'
1004 ... Device ${dev_id}: '${isCommited}' != '${committed}' values=False
1005 Run Keyword If ${matched} Should Be Equal '${isActive}' '${activated}'
1006 ... Device ${dev_id}: '${isActive}' != '${activated}' values=False
1007 Run Keyword If ${matched} Should Be Equal '${isValid}' '${valid}'
1008 ... Device ${dev_id}: '${isValid}' != '${valid}' values=False
TorstenThiemeff9c9142021-04-08 07:21:34 +00001009
1010# pm-data relevant keywords
1011Read Default Interval From Pmconfig
1012 [Documentation] Reads default interval from pm config
1013 [Arguments] ${device_id}
1014 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig get ${device_id}
1015 Should Be Equal As Integers ${rc} 0
1016 log ${result}
1017 @{words}= Split String ${result}
1018 ${interval}= Get From List ${words} 3
1019 log ${interval}
1020 [return] ${interval}
1021
1022Read Group Interval From Pmconfig
1023 [Documentation] Reads default interval from pm config
1024 [Arguments] ${device_id} ${group}
1025 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group list ${device_id} | grep ${group}
1026 Should Be Equal As Integers ${rc} 0
1027 log ${result}
1028 @{words}= Split String ${result}
1029 ${interval}= Get From List ${words} -1
1030 log ${interval}
1031 [return] ${interval}
1032
1033Set and Validate Default Interval
1034 [Documentation] Sets and validates default interval of pm data
1035 [Arguments] ${device_id} ${interval}
1036 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig frequency set ${device_id} ${interval}
1037 Should Be Equal As Integers ${rc} 0
1038 log ${result}
1039 # workaround until unit will be printed out in voltctl - remove unit
1040 ${interval}= Get Substring ${interval} 0 -1
1041 Should Contain ${result} ${interval}
1042
1043Set and Validate Group Interval
1044 [Documentation] Sets and validates group interval of pm data
1045 [Arguments] ${device_id} ${interval} ${group}
1046 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group set ${device_id} ${group} ${interval}
1047 Should Be Equal As Integers ${rc} 0
1048 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group list ${device_id} | grep ${group}
1049 Should Be Equal As Integers ${rc} 0
1050 log ${result}
1051 # workaround until unit will be printed out in voltctl - remove unit
1052 ${interval}= Get Substring ${interval} 0 -1
1053 Should Contain ${result} ${interval}
1054
1055Read Group List
1056 [Documentation] Reads metric group list of given device
1057 [Arguments] ${device_id}
1058 ${rc} ${result}= Run and Return Rc and Output voltctl device pmconfig group list ${device_id} | grep -v GROUPNAME
1059 Should Be Equal As Integers ${rc} 0
1060 ${group_list} Create List
1061 ${interval_dict} Create Dictionary
1062 @{output}= Split String ${result} \n
1063 FOR ${Line} IN @{output}
1064 @{words}= Split String ${Line}
1065 ${group}= Set Variable ${words[0]}
1066 ${interval}= Set Variable ${words[2]}
1067 Append To List ${group_list} ${group}
1068 Set To Dictionary ${interval_dict} ${group}=${interval}
1069 END
1070 [return] ${group_list} ${interval_dict}
1071
1072Read Group Metric List
1073 [Documentation] Reads group metric list of given device and group
1074 [Arguments] ${device_id} ${group}
1075 ${cmd}= Catenate voltctl device pmconfig groupmetric list ${device_id} ${group} | grep -v SAMPLEFREQ
1076 ${rc} ${result}= Run and Return Rc and Output ${cmd}
1077 Should Be Equal As Integers ${rc} 0
1078 ${groupmetric_list} Create List
1079 @{output}= Split String ${result} \n
1080 FOR ${Line} IN @{output}
1081 @{words}= Split String ${Line}
1082 ${name}= Set Variable ${words[0]}
1083 ${type}= Set Variable ${words[1]}
1084 ${enabled}= Set Variable ${words[2]}
1085 ${subdict}= Create Dictionary type=${type} enabled=${enabled}
1086 ${dict}= Create Dictionary ${name}=${subdict}
1087 Append To List ${groupmetric_list} ${dict}
1088 END
1089 [return] ${groupmetric_list}
1090
1091Read Group Metric Dict
1092 [Documentation] Reads group metric list of given device and group
1093 [Arguments] ${device_id} ${group}
1094 ${cmd}= Catenate voltctl device pmconfig groupmetric list ${device_id} ${group} | grep -v SAMPLEFREQ
1095 ${rc} ${result}= Run and Return Rc and Output ${cmd}
1096 Should Be Equal As Integers ${rc} 0
1097 ${groupmetric_dict} Create Dictionary
1098 @{output}= Split String ${result} \n
1099 FOR ${Line} IN @{output}
1100 @{words}= Split String ${Line}
1101 ${name}= Set Variable ${words[0]}
1102 ${type}= Set Variable ${words[1]}
1103 ${enabled}= Set Variable ${words[2]}
1104 ${subdict}= Create Dictionary type=${type} enabled=${enabled}
1105 Set To Dictionary ${groupmetric_dict} ${name}=${subdict}
1106 END
1107 [return] ${groupmetric_dict}