blob: bd9e6719ce14152ed879505d900e517901658f0e [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# onos 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 Scandoloeb26a842020-05-08 10:06:24 -070025Resource ./flows.robot
Kailash6f5acb62019-08-28 14:38:45 -070026
27*** Keywords ***
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070028
29Open ONOS SSH Connection
30 [Documentation] Establishes an ssh connection to ONOS contoller
31 [Arguments] ${host} ${port} ${user}=karaf ${pass}=karaf
32 ${conn_id}= SSHLibrary.Open Connection ${host} port=${port} timeout=300s alias=ONOS_SSH
33 SSHLibrary.Login ${user} ${pass}
34 [Return] ${conn_id}
35
36Execute ONOS CLI Command on open connection
37 [Documentation] Execute ONOS CLI Command On an Open Connection
38 [Arguments] ${connection_alias} ${cmd}
39 SSHLibrary.Switch Connection ${connection_alias}
40 @{result_values} SSHLibrary.Execute Command ${cmd} return_rc=True
41 ... return_stderr=True return_stdout=True
42 ${output} Set Variable @{result_values}[0]
Matteo Scandolo50be75c2020-11-12 11:14:12 -080043 Log Command output: ${output}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070044 Should Be Empty @{result_values}[1]
45 Should Be Equal As Integers @{result_values}[2] 0
46 [Return] ${output}
47
48Close ONOS SSH Connection
49 [Documentation] Close an SSH Connection
50 [Arguments] ${connection_alias}
51 SSHLibrary.Switch Connection ${connection_alias}
52 SSHLibrary.Close Connection
53
Kailash6f5acb62019-08-28 14:38:45 -070054Validate OLT Device in ONOS
Zack Williamsa8fe75a2020-01-10 14:25:27 -070055 # FIXME use volt-olts to check that the OLT is ONOS
Kailash6f5acb62019-08-28 14:38:45 -070056 [Arguments] ${serial_number}
Zack Williamsec53a1b2019-09-16 15:50:52 -070057 [Documentation] Checks if olt has been connected to ONOS
Kailash6f5acb62019-08-28 14:38:45 -070058 ${resp}= Get Request ONOS onos/v1/devices
59 ${jsondata}= To Json ${resp.content}
60 Should Not Be Empty ${jsondata['devices']}
61 ${length}= Get Length ${jsondata['devices']}
62 @{serial_numbers}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -070063 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -070064 FOR ${INDEX} IN RANGE 0 ${length}
65 ${value}= Get From List ${jsondata['devices']} ${INDEX}
66 ${of_id}= Get From Dictionary ${value} id
67 ${sn}= Get From Dictionary ${value} serial
Andy Bavierb63f6d22020-03-12 15:34:37 -070068 ${matched}= Set Variable If '${sn}' == '${serial_number}' True False
69 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -070070 END
Andy Bavierb63f6d22020-03-12 15:34:37 -070071 Should Be True ${matched} No match for ${serial_number} found
Kailash57210eb2019-08-30 13:27:19 -070072 [Return] ${of_id}
Kailash6f5acb62019-08-28 14:38:45 -070073
Suchitra Vemuri102912a2019-09-24 00:35:42 -070074Get ONU Port in ONOS
Zack Williamsec53a1b2019-09-16 15:50:52 -070075 [Arguments] ${onu_serial_number} ${olt_of_id}
Suchitra Vemuri102912a2019-09-24 00:35:42 -070076 [Documentation] Retrieves ONU port for the ONU in ONOS
Suchitra Vemuria50c1c12019-09-30 19:54:26 -070077 ${onu_serial_number}= Catenate SEPARATOR=- ${onu_serial_number} 1
Suchitra Vemuri102912a2019-09-24 00:35:42 -070078 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
79 ${jsondata}= To Json ${resp.content}
80 Should Not Be Empty ${jsondata['ports']}
81 ${length}= Get Length ${jsondata['ports']}
82 @{ports}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -070083 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -070084 FOR ${INDEX} IN RANGE 0 ${length}
85 ${value}= Get From List ${jsondata['ports']} ${INDEX}
86 ${annotations}= Get From Dictionary ${value} annotations
87 ${onu_port}= Get From Dictionary ${value} port
88 ${portName}= Get From Dictionary ${annotations} portName
Andy Bavierb63f6d22020-03-12 15:34:37 -070089 ${matched}= Set Variable If '${portName}' == '${onu_serial_number}' True False
90 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -070091 END
Andy Bavierb63f6d22020-03-12 15:34:37 -070092 Should Be True ${matched} No match for ${onu_serial_number} found
Suchitra Vemuri102912a2019-09-24 00:35:42 -070093 [Return] ${onu_port}
94
Hardik Windlassfb5eace2020-03-26 14:49:01 +053095Get NNI Port in ONOS
96 [Arguments] ${olt_of_id}
97 [Documentation] Retrieves NNI port for the OLT in ONOS
98 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
99 ${jsondata}= To Json ${resp.content}
100 Should Not Be Empty ${jsondata['ports']}
101 ${length}= Get Length ${jsondata['ports']}
102 @{ports}= Create List
103 ${matched}= Set Variable False
104 FOR ${INDEX} IN RANGE 0 ${length}
105 ${value}= Get From List ${jsondata['ports']} ${INDEX}
106 ${annotations}= Get From Dictionary ${value} annotations
107 ${nni_port}= Get From Dictionary ${value} port
108 ${nniPortName}= Catenate SEPARATOR= nni- ${nni_port}
109 ${portName}= Get From Dictionary ${annotations} portName
110 ${matched}= Set Variable If '${portName}' == '${nniPortName}' True False
111 Exit For Loop If ${matched}
112 END
113 Should Be True ${matched} No match for NNI found for ${olt_of_id}
114 [Return] ${nni_port}
115
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700116Get FabricSwitch in ONOS
117 [Documentation] Returns of_id of the Fabric Switch in ONOS
118 ${resp}= Get Request ONOS onos/v1/devices
119 ${jsondata}= To Json ${resp.content}
120 Should Not Be Empty ${jsondata['devices']}
121 ${length}= Get Length ${jsondata['devices']}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700122 ${matched}= Set Variable False
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700123 FOR ${INDEX} IN RANGE 0 ${length}
124 ${value}= Get From List ${jsondata['devices']} ${INDEX}
125 ${of_id}= Get From Dictionary ${value} id
126 ${type}= Get From Dictionary ${value} type
Andy Bavierb63f6d22020-03-12 15:34:37 -0700127 ${matched}= Set Variable If '${type}' == "SWITCH" True False
128 Exit For Loop If ${matched}
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700129 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700130 Should Be True ${matched} No fabric switch found
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700131 [Return] ${of_id}
132
Andrea Campanella4c404632020-08-26 14:41:36 +0200133Get Master Instace in ONOS
134 [Arguments] ${of_id}
135 [Documentation] Returns nodeId of the Master instace for a giver device in ONOS
136 ${resp}= Get Request ONOS onos/v1/mastership/${of_id}/master
137 ${jsondata}= To Json ${resp.content}
138 Should Not Be Empty ${jsondata['nodeId']}
139 ${master_node}= Get From Dictionary ${jsondata} nodeId
140 [Return] ${master_node}
141
Hardik Windlass21807632020-04-14 16:24:55 +0530142Verify Subscriber Access Flows Added for ONU
143 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${c_tag} ${s_tag}
144 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
145 # Verify upstream table=0 flow
146 ${upstream_flow_0_cmd}= Catenate SEPARATOR=
147 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:0 |
148 ... grep VLAN_ID:${c_tag} | grep transition=TABLE:1
149 ${upstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
150 ... ${upstream_flow_0_cmd}
151 Should Not Be Empty ${upstream_flow_0_added}
152 # Verify upstream table=1 flow
153 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
154 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
155 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
156 ${upstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
157 ... ${flow_vlan_push_cmd}
158 Should Not Be Empty ${upstream_flow_1_added}
159 # Verify downstream table=0 flow
160 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
161 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
162 ... grep VLAN_POP | grep transition=TABLE:1
163 ${downstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
164 ... ${flow_vlan_pop_cmd}
165 Should Not Be Empty ${downstream_flow_0_added}
166 # Verify downstream table=1 flow
167 ${downstream_flow_1_cmd}= Catenate SEPARATOR=
168 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${c_tag} |
169 ... grep VLAN_ID:0 | grep OUTPUT:${onu_port}
170 ${downstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
171 ... ${downstream_flow_1_cmd}
172 Should Not Be Empty ${downstream_flow_1_added}
173 # Verify ipv4 dhcp upstream flow
174 ${upstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200175 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:ipv4 |
Andrea Campanella08678e12020-09-18 17:40:22 +0200176 ... grep IP_PROTO:17 | grep UDP_SRC:68 | grep UDP_DST:67 | grep VLAN_ID:${c_tag} |
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200177 ... grep OUTPUT:CONTROLLER
Hardik Windlass21807632020-04-14 16:24:55 +0530178 ${upstream_flow_ipv4_added}= Execute ONOS CLI Command ${ip} ${port}
179 ... ${upstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200180 Should Not Be Empty ${upstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530181 # Verify ipv4 dhcp downstream flow
182 # Note: This flow will be one per nni per olt
183 ${downstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200184 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep ETH_TYPE:ipv4 |
185 ... grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 | grep OUTPUT:CONTROLLER
Hardik Windlass21807632020-04-14 16:24:55 +0530186 ${downstream_flow_ipv4_added}= Execute ONOS CLI Command ${ip} ${port}
187 ... ${downstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200188 Should Not Be Empty ${downstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530189
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530190Verify Subscriber Access Flows Added for ONU DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530191 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530192 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
193 # Verify upstream table=0 flow
194 ${upstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530195 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:Any | grep transition=TABLE:1
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530196 Should Not Be Empty ${upstream_flow_0_added}
197 # Verify upstream table=1 flow
198 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530199 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:Any |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530200 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
201 ${upstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
202 ... ${flow_vlan_push_cmd}
203 Should Not Be Empty ${upstream_flow_1_added}
204 # Verify downstream table=0 flow
205 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530206 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530207 ... grep VLAN_POP | grep transition=TABLE:1
208 ${downstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
209 ... ${flow_vlan_pop_cmd}
210 Should Not Be Empty ${downstream_flow_0_added}
211 # Verify downstream table=1 flow
212 ${downstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530213 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:Any | grep OUTPUT:${onu_port}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530214 Should Not Be Empty ${downstream_flow_1_added}
215
216Verify Subscriber Access Flows Added Count DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530217 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530218 [Documentation] Matches for total number of subscriber access flows added for all onus
219 ${access_flows_added}= Execute ONOS CLI Command ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530220 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep -v ETH_TYPE:lldp | wc -l
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530221 Should Be Equal As Integers ${access_flows_added} ${expected_flows}
222
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530223Get Programmed Subscribers
224 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
225 [Documentation] Retrieves the subscriber details at a given location
226 ${sub_location}= Catenate SEPARATOR=/ ${olt_of_id} ${onu_port}
227 ${programmed_sub}= Execute ONOS CLI Command ${ip} ${port}
228 ... volt-programmed-subscribers | grep ${sub_location}
229 [Return] ${programmed_sub}
230
231Get Upstream and Downstream Bandwidth Profile Name
232 [Arguments] ${programmed_sub}
233 [Documentation] Retrieves the upstream and downstream bandwidth profile name
234 ... from the programmed subscriber
235 @{programmed_sub_array}= Split String ${programmed_sub} ,
236 # Get upstream bandwidth profile name for the subscriber
237 @{param_val_pair}= Split String ${programmed_sub_array[9]} =
238 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
239 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
240 ${us_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' upstreamBandwidthProfile'
241 ... Set Variable ${programmed_sub_val}
242 Log ${us_bw_profile}
243 # Get downstream bandwidth profile name for the subscriber
244 @{param_val_pair}= Split String ${programmed_sub_array[10]} =
245 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
246 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
247 ${ds_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' downstreamBandwidthProfile'
248 ... Set Variable ${programmed_sub_val}
249 Log ${ds_bw_profile}
250 [Return] ${us_bw_profile} ${ds_bw_profile}
251
252Get Bandwidth Profile Details
253 [Arguments] ${ip} ${port} ${bw_profile}
254 [Documentation] Retrieves the details of the given bandwidth profile
255 ${bw_profile_values}= Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
256 ... bandwidthprofile ${bw_profile}
257 @{bw_profile_array}= Split String ${bw_profile_values} ,
258 @{param_val_pair}= Split String ${bw_profile_array[1]} =
259 ${bw_param}= Set Variable ${param_val_pair[0]}
260 ${bw_val}= Set Variable ${param_val_pair[1]}
261 ${cir} Run Keyword If '${bw_param}' == ' committedInformationRate'
262 ... Set Variable ${bw_val}
263 @{param_val_pair}= Split String ${bw_profile_array[2]} =
264 ${bw_param}= Set Variable ${param_val_pair[0]}
265 ${bw_val}= Set Variable ${param_val_pair[1]}
266 ${cbs} Run Keyword If '${bw_param}' == ' committedBurstSize'
267 ... Set Variable ${bw_val}
268 @{param_val_pair}= Split String ${bw_profile_array[3]} =
269 ${bw_param}= Set Variable ${param_val_pair[0]}
270 ${bw_val}= Set Variable ${param_val_pair[1]}
271 ${eir} Run Keyword If '${bw_param}' == ' exceededInformationRate'
272 ... Set Variable ${bw_val}
273 @{param_val_pair}= Split String ${bw_profile_array[4]} =
274 ${bw_param}= Set Variable ${param_val_pair[0]}
275 ${bw_val}= Set Variable ${param_val_pair[1]}
276 ${ebs} Run Keyword If '${bw_param}' == ' exceededBurstSize'
277 ... Set Variable ${bw_val}
278 @{param_val_pair}= Split String ${bw_profile_array[5]} =
279 ${bw_param}= Set Variable ${param_val_pair[0]}
280 ${bw_val}= Set Variable ${param_val_pair[1]}
281 @{bw_val_air}= Split String ${bw_val} }
282 ${air} Run Keyword If '${bw_param}' == ' assuredInformationRate'
283 ... Set Variable ${bw_val_air[0]}
284 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
285
286Verify Meters in ONOS
287 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
288 [Documentation] Verifies the meters
289 # Get programmed subscriber
290 ${programmed_sub}= Get Programmed Subscribers ${ip} ${port}
291 ... ${olt_of_id} ${onu_port}
292 Log ${programmed_sub}
293 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
294 ... ${programmed_sub}
295 # Get upstream bandwidth profile details
296 ${us_cir} ${us_cbs} ${us_eir} ${us_ebs} ${us_air} Get Bandwidth Profile Details
297 ... ${ip} ${port} ${us_bw_profile}
298 Sleep 1s
299 # Verify meter for upstream bandwidth profile
300 ${us_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530301 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
302 ... | grep "rate=${us_eir}, burst-size=${us_ebs}" | grep "rate=${us_air}, burst-size=0" | wc -l
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530303 ${upstream_meter_added}= Execute ONOS CLI Command ${ip} ${port}
304 ... ${us_meter_cmd}
305 Should Be Equal As Integers ${upstream_meter_added} 1
306 Sleep 1s
307 # Get downstream bandwidth profile details
308 ${ds_cir} ${ds_cbs} ${ds_eir} ${ds_ebs} ${ds_air} Get Bandwidth Profile Details
309 ... ${ip} ${port} ${ds_bw_profile}
310 Sleep 1s
311 # Verify meter for downstream bandwidth profile
312 ${ds_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530313 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
314 ... | grep "rate=${ds_eir}, burst-size=${ds_ebs}" | grep "rate=${ds_air}, burst-size=0" | wc -l
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530315 ${downstream_meter_added}= Execute ONOS CLI Command ${ip} ${port}
316 ... ${ds_meter_cmd}
317 Should Be Equal As Integers ${downstream_meter_added} 1
318
319Verify Default Meter Present in ONOS
320 [Arguments] ${ip} ${port} ${olt_of_id}
321 [Documentation] Verifies the single default meter entry is present
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530322 # Get default bandwidth profile details
323 ${cir} ${cbs} ${eir} ${ebs} ${air} Get Bandwidth Profile Details
324 ... ${ip} ${port} 'Default'
325 Sleep 1s
326 # Verify meter for default bandwidth profile
327 ${meter_cmd}= Catenate SEPARATOR=
328 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${cir}, burst-size=${cbs}"
329 ... | grep "rate=${eir}, burst-size=${ebs}" | grep "rate=${air}, burst-size=0" | wc -l
330 ${default_meter_added}= Execute ONOS CLI Command ${ip} ${port}
331 ... ${meter_cmd}
332 Should Be Equal As Integers ${default_meter_added} 1
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530333
Hardik Windlass480f3e22020-04-02 20:14:14 +0530334Verify Device Flows Removed
335 [Arguments] ${ip} ${port} ${olt_of_id}
336 [Documentation] Verifies all flows are removed from the device
337 ${device_flows}= Execute ONOS CLI Command ${ip} ${port}
338 ... flows -s -f ${olt_of_id} | grep -v deviceId | wc -l
339 Should Be Equal As Integers ${device_flows} 0
340
Kailash6f5acb62019-08-28 14:38:45 -0700341Verify Eapol Flows Added
Andy Bavierb0c06232019-08-29 12:58:53 -0700342 [Arguments] ${ip} ${port} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700343 [Documentation] Matches for number of eapol flows based on number of onus
Gilles Depatie675a2062019-10-22 12:44:42 -0400344 ${eapol_flows_added}= Execute ONOS CLI Command ${ip} ${port}
345 ... flows -s -f ADDED | grep eapol | grep IN_PORT | wc -l
Andy Bavierb0c06232019-08-29 12:58:53 -0700346 Should Contain ${eapol_flows_added} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700347
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800348Verify No Pending Flows For ONU
349 [Arguments] ${ip} ${port} ${onu_port}
350 [Documentation] Verifies that there are no flows "PENDING" state for the ONU in ONOS
351 ${pending_flows}= Execute ONOS CLI Command ${ip} ${port}
352 ... flows -s | grep IN_PORT:${onu_port} | grep PENDING
353 Should Be Empty ${pending_flows}
354
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700355Verify Eapol Flows Added For ONU
356 [Arguments] ${ip} ${port} ${onu_port}
357 [Documentation] Verifies if the Eapol Flows are added in ONOS for the ONU
Gilles Depatie675a2062019-10-22 12:44:42 -0400358 ${eapol_flows_added}= Execute ONOS CLI Command ${ip} ${port}
359 ... flows -s -f ADDED | grep eapol | grep IN_PORT:${onu_port}
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700360 Should Not Be Empty ${eapol_flows_added}
361
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800362Verify ONU Port Is Enabled
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700363 [Arguments] ${ip} ${port} ${onu_name}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800364 [Documentation] Verifies if the ONU port is enabled in ONOS
365 ${onu_port_enabled}= Execute ONOS CLI Command ${ip} ${port}
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700366 ... ports -e | grep portName=${onu_name}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800367 Log ${onu_port_enabled}
368 Should Not Be Empty ${onu_port_enabled}
369
Hardik Windlass63d5e002020-03-06 21:07:09 +0530370Verify ONU Port Is Disabled
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700371 [Arguments] ${ip} ${port} ${onu_name}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530372 [Documentation] Verifies if the ONU port is disabled in ONOS
373 ${onu_port_disabled}= Execute ONOS CLI Command ${ip} ${port}
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700374 ... ports -e | grep portName=${onu_name}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530375 Log ${onu_port_disabled}
376 Should Be Empty ${onu_port_disabled}
377
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700378Verify ONU in AAA-Users
379 [Arguments] ${ip} ${port} ${onu_port}
380 [Documentation] Verifies that the specified onu_port exists in aaa-users output
381 ${aaa_users}= Execute ONOS CLI Command ${ip} ${port} aaa-users | grep AUTHORIZED | grep ${onu_port}
382 Should Not Be Empty ${aaa_users} ONU port ${onu_port} not found in aaa-users
383
Matteo Scandolo142e6272020-04-29 17:36:59 -0700384Assert Number of AAA-Users
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800385 [Arguments] ${onos_ssh_connection} ${expected_onus} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700386 [Documentation] Matches for number of aaa-users authorized based on number of onus
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700387 ${aaa_users}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800388 ... aaa-users | grep ${deviceId} | grep AUTHORIZED | wc -l
389 Log Found ${aaa_users} of ${expected_onus} expected authenticated users on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700390 Should Be Equal As Integers ${aaa_users} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700391
392Validate DHCP Allocations
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800393 [Arguments] ${onos_ssh_connection} ${count} ${workflow} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700394 [Documentation] Matches for number of dhcpacks based on number of onus
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700395 ${allocations}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800396 ... dhcpl2relay-allocations | grep ${deviceId} | grep DHCPACK | wc -l
Matteo Scandoloda854b02020-09-01 16:20:51 -0700397 # if the workflow is TT we'll have 2 allocations for each ONU
398 ${ttAllocations}= Evaluate (${count} * 2)
399 ${count}= Set Variable If $workflow=='tt' ${ttAllocations} ${count}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800400 Log Found ${allocations} of ${count} expected DHCPACK on device ${deviceId}
Matteo Scandoloda854b02020-09-01 16:20:51 -0700401 Should Be Equal As Integers ${allocations} ${count}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700402
403Validate Subscriber DHCP Allocation
Suchitra Vemuri42819412020-10-01 17:45:43 -0700404 [Arguments] ${ip} ${port} ${onu_port} ${vlan}=''
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700405 [Documentation] Verifies that the specified subscriber is found in DHCP allocations
406 ##TODO: Enhance the keyword to include DHCP allocated address is not 0.0.0.0
Gilles Depatie675a2062019-10-22 12:44:42 -0400407 ${allocations}= Execute ONOS CLI Command ${ip} ${port}
Suchitra Vemuri42819412020-10-01 17:45:43 -0700408 ... dhcpl2relay-allocations | grep DHCPACK | grep ${onu_port} | grep ${vlan}
Gilles Depatie675a2062019-10-22 12:44:42 -0400409 Should Not Be Empty ${allocations} ONU port ${onu_port} not found in dhcpl2relay-allocations
David Bainbridgef81cd642019-11-20 00:14:47 +0000410
411Device Is Available In ONOS
412 [Arguments] ${url} ${dpid}
413 [Documentation] Validates the device exists and it available in ONOS
414 ${rc} ${json} Run And Return Rc And Output curl --fail -sSL ${url}/onos/v1/devices/${dpid}
415 Should Be Equal As Integers 0 ${rc}
416 ${rc} ${value} Run And Return Rc And Output echo '${json}' | jq -r .available
417 Should Be Equal As Integers 0 ${rc}
418 Should Be Equal 'true' '${value}'
419
420Remove All Devices From ONOS
421 [Arguments] ${url}
422 [Documentation] Executes the device-remove command on each device in ONOS
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000423 ${rc} ${output} Run And Return Rc And Output
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700424 ... curl --fail -sSL ${url}/onos/v1/devices | jq -r '.devices[].id'
David Bainbridgef81cd642019-11-20 00:14:47 +0000425 Should Be Equal As Integers ${rc} 0
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000426 @{dpids} Split String ${output}
David Bainbridgef81cd642019-11-20 00:14:47 +0000427 ${count}= Get length ${dpids}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700428 FOR ${dpid} IN @{dpids}
429 ${rc}= Run Keyword If '${dpid}' != ''
430 ... Run And Return Rc curl -XDELETE --fail -sSL ${url}/onos/v1/devices/${dpid}
431 Run Keyword If '${dpid}' != ''
432 ... Should Be Equal As Integers ${rc} 0
433 END
Matteo Scandolo142e6272020-04-29 17:36:59 -0700434
435Assert Ports in ONOS
TorstenThiemed4f48962020-12-08 12:17:19 +0000436 [Arguments] ${onos_ssh_connection} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700437 [Documentation] Check that a certain number of ports are enabled in ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700438 ${ports}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800439 ... ports -e ${deviceId} | grep ${filter} | wc -l
440 Log Found ${ports} of ${count} expected ports on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700441 Should Be Equal As Integers ${ports} ${count}
442
443Wait for Ports in ONOS
TorstenThiemed4f48962020-12-08 12:17:19 +0000444 [Arguments] ${onos_ssh_connection} ${count} ${deviceId} ${filter} ${max_wait_time}=10m
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800445 [Documentation] Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
TorstenThiemed4f48962020-12-08 12:17:19 +0000446 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Ports in ONOS
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800447 ... ${onos_ssh_connection} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700448
449Wait for AAA Authentication
TorstenThiemed4f48962020-12-08 12:17:19 +0000450 [Arguments] ${onos_ssh_connection} ${count} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700451 [Documentation] Waits untill a certain number of subscribers are authenticated in ONOS
TorstenThiemed4f48962020-12-08 12:17:19 +0000452 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Number of AAA-Users
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800453 ... ${onos_ssh_connection} ${count} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700454
455Wait for DHCP Ack
TorstenThiemed4f48962020-12-08 12:17:19 +0000456 [Arguments] ${onos_ssh_connection} ${count} ${workflow} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700457 [Documentation] Waits untill a certain number of subscribers have received a DHCP_ACK
TorstenThiemed4f48962020-12-08 12:17:19 +0000458 Wait Until Keyword Succeeds ${max_wait_time} 5s Validate DHCP Allocations
459 ... ${onos_ssh_connection} ${count} ${workflow} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700460
461Provision subscriber
462 [Documentation] Calls volt-add-subscriber-access in ONOS
463 [Arguments] ${onos_ip} ${onos_port} ${of_id} ${onu_port}
464 Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
465 ... volt-add-subscriber-access ${of_id} ${onu_port}
466
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700467Provision subscriber REST
468 [Documentation] Uses the rest APIs to provision a subscriber
469 [Arguments] ${onos_ip} ${onos_port} ${of_id} ${onu_port}
470 ${resp}= Post Request ONOS
471 ... /onos/olt/oltapp/${of_id}/${onu_port}
472 Should Be Equal As Strings ${resp.status_code} 200
473
474
Matteo Scandolo142e6272020-04-29 17:36:59 -0700475List Enabled UNI Ports
476 [Documentation] List all the UNI Ports, the only way we have is to filter out the one called NNI
477 ... Creates a list of dictionaries
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700478 [Arguments] ${onos_ssh_connection} ${of_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700479 [Return] [{'port': '16', 'of_id': 'of:00000a0a0a0a0a00'}, {'port': '32', 'of_id': 'of:00000a0a0a0a0a00'}]
480 ${result}= Create List
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700481 ${out}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700482 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000483 @{unis}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700484 FOR ${uni} IN @{unis}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000485 ${matches} = Get Regexp Matches ${uni} .*port=([0-9]+),.* 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700486 &{portDict} Create Dictionary of_id=${of_id} port=${matches[0]}
487 Append To List ${result} ${portDict}
488 END
489 Log ${result}
490 Return From Keyword ${result}
491
492Provision all subscribers on device
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700493 [Documentation] Provisions a subscriber in ONOS for all the enabled UNI ports on a particular device
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700494 [Arguments] ${onos_ssh_connection} ${onos_ip} ${onos_rest_port} ${of_id}
495 ${unis}= List Enabled UNI Ports ${onos_ssh_connection} ${of_id}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700496 ${onos_auth}= Create List karaf karaf
497 Create Session ONOS http://${onos_ip}:${onos_rest_port} auth=${onos_auth}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700498 FOR ${uni} IN @{unis}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700499 Provision Subscriber REST ${onos_ip} ${onos_rest_port} ${uni['of_id']} ${uni['port']}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700500 END
501
502List OLTs
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800503 # NOTE this method is not currently used but it can come useful in the future
504 [Documentation] Returns a list of all OLTs known to ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700505 [Arguments] ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700506 [Return] ['of:00000a0a0a0a0a00', 'of:00000a0a0a0a0a01']
507 ${result}= Create List
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700508 ${out}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700509 ... volt-olts
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000510 @{olts}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700511 FOR ${olt} IN @{olts}
512 Log ${olt}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000513 ${matches} = Get Regexp Matches ${olt} ^OLT (.+)$ 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700514 # there may be some logs mixed with the output so only append if we have a match
515 ${matches_length}= Get Length ${matches}
516 Run Keyword If ${matches_length}==1
517 ... Append To List ${result} ${matches[0]}
518 END
519 Return From Keyword ${result}
520
521Count ADDED flows
522 [Documentation] Count the flows in ADDED state in ONOS
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800523 [Arguments] ${onos_ssh_connection} ${targetFlows} ${deviceId}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700524 ${flows}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800525 ... flows -s any ${deviceId} | grep ADDED | wc -l
526 Log Found ${flows} of ${targetFlows} expected flows on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700527 Should Be Equal As Integers ${targetFlows} ${flows}
528
529Wait for all flows to in ADDED state
530 [Documentation] Waits until the flows have been provisioned
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800531 [Arguments] ${onos_ssh_connection} ${deviceId} ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200532 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700533 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200534 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700535 Wait Until Keyword Succeeds 10m 5s Count ADDED flows
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800536 ... ${onos_ssh_connection} ${targetFlows} ${deviceId}
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000537
538Get Bandwidth Details
539 [Arguments] ${bandwidth_profile_name}
540 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
541 ... returns the limiting bandwidth
542 ${bandwidth_profile_values}= Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
543 ... bandwidthprofile ${bandwidth_profile_name}
544 @{bandwidth_profile_array}= Split String ${bandwidth_profile_values} ,
545 @{parameter_value_pair}= Split String ${bandwidth_profile_array[1]} =
546 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
547 ${value}= Set Variable ${parameter_value_pair[1]}
548 ${cir_value} Run Keyword If '${bandwidthparameter}' == ' committedInformationRate'
549 ... Set Variable ${value}
550 @{parameter_value_pair}= Split String ${bandwidth_profile_array[2]} =
551 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
552 ${value}= Set Variable ${parameter_value_pair[1]}
553 ${cbs_value} Run Keyword If '${bandwidthparameter}' == ' committedBurstSize' Set Variable ${value}
554 @{parameter_value_pair}= Split String ${bandwidth_profile_array[3]} =
555 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
556 ${value}= Set Variable ${parameter_value_pair[1]}
557 ${eir_value} Run Keyword If '${bandwidthparameter}' == ' exceededInformationRate' Set Variable ${value}
558 @{parameter_value_pair}= Split String ${bandwidth_profile_array[4]} =
559 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
560 ${value}= Set Variable ${parameter_value_pair[1]}
561 ${ebs_value} Run Keyword If '${bandwidthparameter}' == ' exceededBurstSize' Set Variable ${value}
562 ${limiting_BW}= Evaluate ${cir_value}+${eir_value}
563 [Return] ${limiting_BW}