blob: 95b0874c2a47c016101b1f393d7a9986134515b6 [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
25
26*** Keywords ***
Gilles Depatieb5682f82019-10-31 10:39:45 -040027Test Empty Device List
Zack Williamsa8fe75a2020-01-10 14:25:27 -070028 [Documentation] Verify that there are no devices in the system
29 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -040030 Should Be Equal As Integers ${rc} 0
31 ${jsondata}= To Json ${output}
32 Log ${jsondata}
33 ${length}= Get Length ${jsondata}
David Bainbridgef81cd642019-11-20 00:14:47 +000034 Should Be Equal As Integers ${length} 0
Gilles Depatieb5682f82019-10-31 10:39:45 -040035
Kailash6f5acb62019-08-28 14:38:45 -070036Create Device
37 [Arguments] ${ip} ${port}
You Wang2b550642019-10-07 14:39:48 -070038 [Documentation] Creates a device in VOLTHA
Kailash6f5acb62019-08-28 14:38:45 -070039 #create/preprovision device
Gilles Depatie675a2062019-10-22 12:44:42 -040040 ${rc} ${device_id}= Run and Return Rc and Output
41 ... ${VOLTCTL_CONFIG}; voltctl device create -t openolt -H ${ip}:${port}
Kailash6f5acb62019-08-28 14:38:45 -070042 Should Be Equal As Integers ${rc} 0
43 [Return] ${device_id}
44
45Enable Device
46 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -070047 [Documentation] Enables a device in VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -070048 ${rc} ${output}= Run and Return Rc and Output
49 ... ${VOLTCTL_CONFIG}; voltctl device enable ${device_id}
Kailash6f5acb62019-08-28 14:38:45 -070050 Should Be Equal As Integers ${rc} 0
51
Suchitra Vemuri6db89412019-11-14 14:52:54 -080052Disable Device
53 [Arguments] ${device_id}
Hardik Windlassaaea3402020-03-10 19:45:45 +053054 [Documentation] Disables a device in VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -070055 ${rc} ${output}= Run and Return Rc and Output
56 ... ${VOLTCTL_CONFIG}; voltctl device disable ${device_id}
Suchitra Vemuri6db89412019-11-14 14:52:54 -080057 Should Be Equal As Integers ${rc} 0
58
Hardik Windlassaaea3402020-03-10 19:45:45 +053059Delete Device
60 [Arguments] ${device_id}
61 [Documentation] Deletes a device in VOLTHA
62 ${rc} ${output}= Run and Return Rc and Output
63 ... ${VOLTCTL_CONFIG}; voltctl device delete ${device_id}
64 Should Be Equal As Integers ${rc} 0
65
David Bainbridgef81cd642019-11-20 00:14:47 +000066Disable Devices In Voltha
67 [Documentation] Disables all the known devices in voltha
68 [Arguments] ${filter}
69 ${arg}= Set Variable ${EMPTY}
70 ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070071 ${rc} ${devices}= Run and Return Rc and Output
72 ... ${VOLTCTL_CONFIG}; voltctl device list ${arg} --orderby Root -q | xargs echo -n
David Bainbridgef81cd642019-11-20 00:14:47 +000073 Should Be Equal As Integers ${rc} 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -070074 ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output
75 ... ${VOLTCTL_CONFIG}; voltctl device disable ${devices}
David Bainbridgef81cd642019-11-20 00:14:47 +000076 Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0
77
78Test Devices Disabled In Voltha
79 [Documentation] Tests to verify that all devices in VOLTHA are disabled
80 [Arguments] ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070081 ${rc} ${count}= Run and Return Rc and Output
82 ... ${VOLTCTL_CONFIG}; voltctl device list --filter '${filter},AdminState!=DISABLED' -q | wc -l
David Bainbridgef81cd642019-11-20 00:14:47 +000083 Should Be Equal As Integers ${rc} 0
84 Should Be Equal As Integers ${count} 0
85
86Delete Devices In Voltha
87 [Documentation] Disables all the known devices in voltha
88 [Arguments] ${filter}
89 ${arg}= Set Variable ${EMPTY}
90 ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070091 ${rc} ${devices}= Run and Return Rc and Output
92 ... ${VOLTCTL_CONFIG}; voltctl device list ${arg} --orderby Root -q | xargs echo -n
David Bainbridgef81cd642019-11-20 00:14:47 +000093 Should Be Equal As Integers ${rc} 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -070094 ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output
95 ... ${VOLTCTL_CONFIG}; voltctl device delete ${devices}
David Bainbridgef81cd642019-11-20 00:14:47 +000096 Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0
97
Suchitra Vemuri00d147d2019-09-13 13:07:32 -070098Get Device Flows from Voltha
99 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700100 [Documentation] Gets device flows from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700101 ${rc} ${output}= Run and Return Rc and Output
102 ... ${VOLTCTL_CONFIG}; voltctl device flows ${device_id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700103 Should Be Equal As Integers ${rc} 0
104 [Return] ${output}
105
106Get Logical Device Output from Voltha
107 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700108 [Documentation] Gets logicaldevice flows and ports from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700109 ${rc1} ${flows}= Run and Return Rc and Output
110 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${device_id}
111 ${rc2} ${ports}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800112 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice port list ${device_id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700113 Log ${flows}
114 Log ${ports}
115 Should Be Equal As Integers ${rc1} 0
116 Should Be Equal As Integers ${rc2} 0
117
118Get Device Output from Voltha
119 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700120 [Documentation] Gets device flows and ports from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700121 ${rc1} ${flows}= Run and Return Rc and Output
122 ... ${VOLTCTL_CONFIG}; voltctl device flows ${device_id}
123 ${rc2} ${ports}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800124 ... ${VOLTCTL_CONFIG}; voltctl device port list ${device_id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700125 Log ${flows}
126 Log ${ports}
127 Should Be Equal As Integers ${rc1} 0
128 Should Be Equal As Integers ${rc2} 0
129
Suchitra Vemuri1a970a62019-11-26 12:52:16 -0800130Get Device List from Voltha
131 [Documentation] Gets Device List Output from Voltha
132 ${rc1} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list
133 Log ${devices}
134 Should Be Equal As Integers ${rc1} 0
135
Kailash6f5acb62019-08-28 14:38:45 -0700136Validate Device
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700137 [Documentation]
ubuntu6b6e7d42020-03-02 12:35:42 -0800138 ... Parses the output of "voltctl device list" and inspects a device ${id}, specified as either
139 ... the serial number or device ID. Arguments are matched for device states of: "admin_state",
140 ... "oper_status", and "connect_status"
141 [Arguments] ${admin_state} ${oper_status} ${connect_status}
142 ... ${id}=${EMPTY} ${onu_reason}=${EMPTY} ${onu}=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400143 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
144 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700145 ${jsondata}= To Json ${output}
Kailash6f5acb62019-08-28 14:38:45 -0700146 ${length}= Get Length ${jsondata}
ubuntu6b6e7d42020-03-02 12:35:42 -0800147 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700148 FOR ${INDEX} IN RANGE 0 ${length}
149 ${value}= Get From List ${jsondata} ${INDEX}
150 ${astate}= Get From Dictionary ${value} adminstate
151 ${opstatus}= Get From Dictionary ${value} operstatus
152 ${cstatus}= Get From Dictionary ${value} connectstatus
153 ${sn}= Get From Dictionary ${value} serialnumber
Gilles Depatieb5682f82019-10-31 10:39:45 -0400154 ${devId}= Get From Dictionary ${value} id
Zack Williamsec53a1b2019-09-16 15:50:52 -0700155 ${mib_state}= Get From Dictionary ${value} reason
ubuntu6b6e7d42020-03-02 12:35:42 -0800156 ${matched}= Set Variable If '${sn}' == '${id}' or '${devId}' == '${id}' True False
Andy Bavierb63f6d22020-03-12 15:34:37 -0700157 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700158 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700159 Should Be True ${matched} No match found for ${id} to validate device
Matteo Scandolo5e10b282019-11-25 10:54:32 -0700160 Log ${value}
ubuntu6b6e7d42020-03-02 12:35:42 -0800161 Should Be Equal '${astate}' '${admin_state}' Device ${sn} admin_state != ${admin_state}
Gilles Depatie675a2062019-10-22 12:44:42 -0400162 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800163 Should Be Equal '${opstatus}' '${oper_status}' Device ${sn} oper_status != ${oper_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400164 ... values=False
ubuntu6b6e7d42020-03-02 12:35:42 -0800165 Should Be Equal '${cstatus}' '${connect_status}' Device ${sn} conn_status != ${connect_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400166 ... values=False
167 Run Keyword If '${onu}' == 'True' Should Be Equal '${mib_state}' '${onu_reason}'
ubuntu6b6e7d42020-03-02 12:35:42 -0800168 ... Device ${sn} mib_state incorrect (${mib_state}) values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400169
170Validate OLT Device
ubuntu6b6e7d42020-03-02 12:35:42 -0800171 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${id}=${EMPTY}
172 [Documentation] Parses the output of "voltctl device list" and inspects device ${id}, specified
173 ... as either its serial numbner or device ID. Match on OLT Serial number or Device Id and inspect states
174 Validate Device ${admin_state} ${oper_status} ${connect_status} ${id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400175
176Validate ONU Devices
177 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${List_ONU_Serial}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700178 [Documentation] Parses the output of "voltctl device list" and inspects device ${List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400179 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
180 ... states including MIB state
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700181 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400182 Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700183 ... onu_reason=omci-flows-pushed onu=True
Gilles Depatieb5682f82019-10-31 10:39:45 -0400184 END
185
Debasish28130d02020-03-16 11:05:26 +0000186Validate ONU Devices DisableEnable
187 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${List_ONU_Serial}
188 [Documentation] Parses the output of "voltctl device list" and inspects device ${List_ONU_Serial}
189 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspects ONU states
190 FOR ${serial_number} IN @{List_ONU_Serial}
191 Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number}
192 ... onu_reason=omci-flows-pushed onu=False
193 END
194
Gilles Depatieb5682f82019-10-31 10:39:45 -0400195Validate Device Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700196 [Documentation]
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800197 ... Parses the output of voltctl device port list <device_id> and matches the port types listed
Gilles Depatieb5682f82019-10-31 10:39:45 -0400198 [Arguments] ${device_id} ${pon_type} ${ethernet_type}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700199 ${rc} ${output}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800200 ... ${VOLTCTL_CONFIG}; voltctl device port list ${device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400201 Should Be Equal As Integers ${rc} 0
202 ${jsondata}= To Json ${output}
203 Log ${jsondata}
204 ${length}= Get Length ${jsondata}
205 FOR ${INDEX} IN RANGE 0 ${length}
206 ${value}= Get From List ${jsondata} ${INDEX}
207 ${astate}= Get From Dictionary ${value} adminstate
208 ${opstatus}= Get From Dictionary ${value} operstatus
209 ${type}= Get From Dictionary ${value} type
Andy Bavier7fe983e2020-01-21 10:45:02 -0700210 #Should Be Equal '${astate}' 'ENABLED' Device ${device_id} port admin_state != ENABLED values=False
211 #Should Be Equal '${opstatus}' 'ACTIVE' Device ${device_id} port oper_status != ACTIVE values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400212 Should Be True '${type}' == '${pon_type}' or '${type}' == '${ethernet_type}'
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700213 ... Device ${device_id} port type is neither ${pon_type} or ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400214 END
215
216Validate OLT Port Types
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800217 [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 -0700218 [Arguments] ${pon_type} ${ethernet_type}
219 Validate Device Port Types ${olt_device_id} ${pon_type} ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400220
221Validate ONU Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700222 [Arguments] ${List_ONU_Serial} ${pon_type} ${ethernet_type}
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800223 [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 -0700224 ... and matches the port types listed
Gilles Depatieb5682f82019-10-31 10:39:45 -0400225 FOR ${serial_number} IN @{List_ONU_Serial}
226 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700227 Validate Device Port Types ${onu_dev_id} ${pon_type} ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400228 END
229
230Validate Device Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000231 [Arguments] ${device_id} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400232 [Documentation] Parses the output of voltctl device flows <device_id> and expects flow count > 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700233 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device flows ${device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400234 Should Be Equal As Integers ${rc} 0
235 ${jsondata}= To Json ${output}
236 Log ${jsondata}
237 ${length}= Get Length ${jsondata}
238 Log 'Number of flows = ' ${length}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000239 Run Keyword If '${flow_count}' == '${EMPTY}' Should Be True ${length} > 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400240 ... Number of flows for ${device_id} was 0
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000241 ... ELSE Should Be True ${length} == ${flow_count}
242 ... Number of flows for ${device_id} was not ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400243
244Validate OLT Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000245 [Arguments] ${flow_count}=${EMPTY}
246 [Documentation] Parses the output of voltctl device flows ${olt_device_id}
247 ... and expects flow count == ${flow_count}
248 Validate Device Flows ${olt_device_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400249
250Validate ONU Flows
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000251 [Arguments] ${List_ONU_Serial} ${flow_count}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400252 [Documentation] Parses the output of voltctl device flows for each ONU SN listed in ${List_ONU_Serial}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000253 ... and expects flow count == ${flow_count}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700254 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400255 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Hardik Windlassa3d04b92020-02-17 15:06:05 +0000256 Validate Device Flows ${onu_dev_id} ${flow_count}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400257 END
258
259Validate Logical Device
260 [Documentation] Validate Logical Device is listed
261 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl logicaldevice list -o json
262 Should Be Equal As Integers ${rc} 0
263 ${jsondata}= To Json ${output}
264 Log ${jsondata}
265 ${length}= Get Length ${jsondata}
266 FOR ${INDEX} IN RANGE 0 ${length}
267 ${value}= Get From List ${jsondata} ${INDEX}
268 ${devid}= Get From Dictionary ${value} id
269 ${rootdev}= Get From Dictionary ${value} rootdeviceid
270 ${sn}= Get From Dictionary ${value} serialnumber
271 Exit For Loop
272 END
273 Should Be Equal '${rootdev}' '${olt_device_id}' Root Device does not match ${olt_device_id} values=False
274 Should Be Equal '${sn}' '${BBSIM_OLT_SN}' Logical Device ${sn} does not match ${BBSIM_OLT_SN}
275 ... values=False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700276 [Return] ${devid}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400277
278Validate Logical Device Ports
279 [Arguments] ${logical_device_id}
280 [Documentation] Validate Logical Device Ports are listed and are > 0
281 ${rc} ${output}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800282 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice port list ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400283 Should Be Equal As Integers ${rc} 0
284 ${jsondata}= To Json ${output}
285 Log ${jsondata}
286 ${length}= Get Length ${jsondata}
287 Should Be True ${length} > 0 Number of ports for ${logical_device_id} was 0
288
289Validate Logical Device Flows
290 [Arguments] ${logical_device_id}
291 [Documentation] Validate Logical Device Flows are listed and are > 0
292 ${rc} ${output}= Run and Return Rc and Output
293 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${logical_device_id} -o json
294 Should Be Equal As Integers ${rc} 0
295 ${jsondata}= To Json ${output}
296 Log ${jsondata}
297 ${length}= Get Length ${jsondata}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700298 Should Be True ${length} > 0 Number of flows for ${logical_device_id} was 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400299
300Retrieve Peer List From OLT
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700301 [Arguments] ${olt_peer_list}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400302 [Documentation] Retrieve the list of peer device id list from port list
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700303 ${rc} ${output}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800304 ... ${VOLTCTL_CONFIG}; voltctl device port list ${olt_device_id} -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}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700309 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400310 FOR ${INDEX} IN RANGE 0 ${length}
311 ${value}= Get From List ${jsondata} ${INDEX}
312 ${type}= Get From Dictionary ${value} type
313 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700314 ${matched}= Set Variable If '${type}' == 'PON_OLT' True False
315 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400316 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700317 Should Be True ${matched} No PON port found for OLT ${olt_device_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400318 ${length}= Get Length ${peers}
319 FOR ${INDEX} IN RANGE 0 ${length}
320 ${value}= Get From List ${peers} ${INDEX}
321 ${peer_id}= Get From Dictionary ${value} deviceid
322 Append To List ${olt_peer_list} ${peer_id}
323 END
324
325Validate OLT Peer Id List
326 [Arguments] ${olt_peer_id_list}
327 [Documentation] Match each entry in the ${olt_peer_id_list} against ONU device ids.
328 FOR ${peer_id} IN @{olt_peer_id_list}
329 Match OLT Peer Id ${peer_id}
330 END
331
332Match OLT Peer Id
333 [Arguments] ${olt_peer_id}
334 [Documentation] Lookup the OLT Peer Id in against the list of ONU device Ids
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700335 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400336 Should Be Equal As Integers ${rc} 0
337 ${jsondata}= To Json ${output}
338 Log ${jsondata}
339 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700340 ${matched}= Set Variable False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700341 FOR ${INDEX} IN RANGE 0 ${length}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400342 ${value}= Get From List ${jsondata} ${INDEX}
343 ${devid}= Get From Dictionary ${value} id
Andy Bavierb63f6d22020-03-12 15:34:37 -0700344 ${matched}= Set Variable If '${devid}' == '${olt_peer_id}' True False
345 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400346 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700347 Should Be True ${matched} Peer id ${olt_peer_id} does not match any ONU device id
Gilles Depatieb5682f82019-10-31 10:39:45 -0400348
349Validate ONU Peer Id
350 [Arguments] ${olt_device_id} ${List_ONU_Serial}
351 [Documentation] Match each ONU peer to that of the OLT device id
352 FOR ${onu_serial} IN @{List_ONU_Serial}
353 ${onu_dev_id}= Get Device ID From SN ${onu_serial}
354 Match ONU Peer Id ${onu_dev_id}
355 END
356
357Match ONU Peer Id
358 [Arguments] ${onu_dev_id}
359 [Documentation] Match an ONU peer to that of the OLT device id
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800360 ${rc} ${output}= Run and Return Rc and Output
361 ... ${VOLTCTL_CONFIG}; voltctl device port list ${onu_dev_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400362 Should Be Equal As Integers ${rc} 0
363 ${jsondata}= To Json ${output}
364 Log ${jsondata}
365 ${length}= Get Length ${jsondata}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700366 ${matched}= Set Variable False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400367 FOR ${INDEX} IN RANGE 0 ${length}
368 ${value}= Get From List ${jsondata} ${INDEX}
369 ${type}= Get From Dictionary ${value} type
370 ${peers}= Get From Dictionary ${value} peers
Andy Bavierb63f6d22020-03-12 15:34:37 -0700371 ${matched}= Set Variable If '${type}' == 'PON_ONU' True False
372 Exit For Loop If ${matched}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400373 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700374 Should Be True ${matched} No PON port found for ONU ${onu_dev_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400375 ${length}= Get Length ${peers}
376 FOR ${INDEX} IN RANGE 0 ${length}
377 ${value}= Get From List ${peers} ${INDEX}
378 ${peer_id}= Get From Dictionary ${value} deviceid
379 END
380 Should Be Equal '${peer_id}' '${olt_device_id}'
381 ... Mismatch between ONU peer ${peer_id} and OLT device id ${olt_device_id} values=False
Kailash6f5acb62019-08-28 14:38:45 -0700382
Kailash6f5acb62019-08-28 14:38:45 -0700383Get Device ID From SN
384 [Arguments] ${serial_number}
385 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700386 ${rc} ${id}= Run and Return Rc and Output
Andy Bavier8fca0452019-12-16 15:30:11 -0700387 ... ${VOLTCTL_CONFIG}; voltctl device list --filter=SerialNumber=${serial_number} --format='{{.Id}}'
388 Should Be Equal As Integers ${rc} 0
389 Log ${id}
Kailash6f5acb62019-08-28 14:38:45 -0700390 [Return] ${id}
391
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700392Get Logical Device ID From SN
393 [Arguments] ${serial_number}
394 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700395 ${rc} ${id}= Run and Return Rc and Output
Andy Bavier8fca0452019-12-16 15:30:11 -0700396 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice list --filter=SerialNumber=${serial_number} --format='{{.Id}}'
397 Should Be Equal As Integers ${rc} 0
398 Log ${id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700399 [Return] ${id}
400
Gilles Depatieb5682f82019-10-31 10:39:45 -0400401Build ONU SN List
402 [Arguments] ${serial_numbers}
403 [Documentation] Appends all ONU SNs to the ${serial_numbers} list
404 FOR ${INDEX} IN RANGE 0 ${num_onus}
405 Append To List ${serial_numbers} ${hosts.src[${INDEX}].onu}
406 END
407
408Get SN From Device ID
409 [Arguments] ${device_id}
410 [Documentation] Gets the device id by matching for ${device_id}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700411 ${rc} ${sn}= Run and Return Rc and Output
Andy Bavier8fca0452019-12-16 15:30:11 -0700412 ... ${VOLTCTL_CONFIG}; voltctl device list --filter=Id=${device_id} --format='{{.SerialNumber}}'
Gilles Depatieb5682f82019-10-31 10:39:45 -0400413 Should Be Equal As Integers ${rc} 0
Andy Bavier8fca0452019-12-16 15:30:11 -0700414 Log ${sn}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400415 [Return] ${sn}
416
Scott Baker60e570d2020-02-02 22:10:13 -0800417Get Parent ID From Device ID
418 [Arguments] ${device_id}
419 [Documentation] Gets the device id by matching for ${device_id}
420 ${rc} ${pid}= Run and Return Rc and Output
421 ... ${VOLTCTL_CONFIG}; voltctl device list --filter=Id=${device_id} --format='{{.ParentId}}'
422 Should Be Equal As Integers ${rc} 0
423 Log ${pid}
424 [Return] ${pid}
425
Kailash6f5acb62019-08-28 14:38:45 -0700426Validate Device Removed
427 [Arguments] ${id}
428 [Documentation] Verifys that device, ${serial_number}, has been removed
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700429 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
Andy Bavier8fca0452019-12-16 15:30:11 -0700430 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700431 ${jsondata}= To Json ${output}
432 Log ${jsondata}
433 ${length}= Get Length ${jsondata}
434 @{ids}= Create List
Zack Williamsec53a1b2019-09-16 15:50:52 -0700435 FOR ${INDEX} IN RANGE 0 ${length}
436 ${value}= Get From List ${jsondata} ${INDEX}
437 ${device_id}= Get From Dictionary ${value} id
438 Append To List ${ids} ${device_id}
439 END
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700440 List Should Not Contain Value ${ids} ${id}
Suchitra Vemuricd2f64f2020-02-18 18:30:27 -0800441
442Reboot ONU
443 [Arguments] ${onu_id} ${src} ${dst}
444 [Documentation] Using voltctl command reboot ONU and verify that ONU comes up to running state
445 ${rc} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device reboot ${onu_id}
446 Should Be Equal As Integers ${rc} 0
447 Run Keyword and Ignore Error Wait Until Keyword Succeeds 60s 1s Validate Device
448 ... ENABLED DISCOVERED UNREACHABLE ${onu_id} onu=True