blob: 11aa85deedc1dea777121eda58dbb39400b44022 [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]
43 Log ${output}
44 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
Hardik Windlass21807632020-04-14 16:24:55 +0530133Verify Subscriber Access Flows Added for ONU
134 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${c_tag} ${s_tag}
135 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
136 # Verify upstream table=0 flow
137 ${upstream_flow_0_cmd}= Catenate SEPARATOR=
138 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:0 |
139 ... grep VLAN_ID:${c_tag} | grep transition=TABLE:1
140 ${upstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
141 ... ${upstream_flow_0_cmd}
142 Should Not Be Empty ${upstream_flow_0_added}
143 # Verify upstream table=1 flow
144 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
145 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
146 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
147 ${upstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
148 ... ${flow_vlan_push_cmd}
149 Should Not Be Empty ${upstream_flow_1_added}
150 # Verify downstream table=0 flow
151 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
152 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
153 ... grep VLAN_POP | grep transition=TABLE:1
154 ${downstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
155 ... ${flow_vlan_pop_cmd}
156 Should Not Be Empty ${downstream_flow_0_added}
157 # Verify downstream table=1 flow
158 ${downstream_flow_1_cmd}= Catenate SEPARATOR=
159 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${c_tag} |
160 ... grep VLAN_ID:0 | grep OUTPUT:${onu_port}
161 ${downstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
162 ... ${downstream_flow_1_cmd}
163 Should Not Be Empty ${downstream_flow_1_added}
164 # Verify ipv4 dhcp upstream flow
165 ${upstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200166 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:ipv4 |
167 ... grep IP_PROTO:17 | grep UDP_SRC:68 | grep UDP_DST:67 | grep VLAN_VID:${c_tag} |
168 ... grep OUTPUT:CONTROLLER
Hardik Windlass21807632020-04-14 16:24:55 +0530169 ${upstream_flow_ipv4_added}= Execute ONOS CLI Command ${ip} ${port}
170 ... ${upstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200171 Should Not Be Empty ${upstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530172 # Verify ipv4 dhcp downstream flow
173 # Note: This flow will be one per nni per olt
174 ${downstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200175 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep ETH_TYPE:ipv4 |
176 ... grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 | grep OUTPUT:CONTROLLER
Hardik Windlass21807632020-04-14 16:24:55 +0530177 ${downstream_flow_ipv4_added}= Execute ONOS CLI Command ${ip} ${port}
178 ... ${downstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200179 Should Not Be Empty ${downstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530180
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530181Verify Subscriber Access Flows Added for ONU DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530182 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530183 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
184 # Verify upstream table=0 flow
185 ${upstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530186 ... 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 +0530187 Should Not Be Empty ${upstream_flow_0_added}
188 # Verify upstream table=1 flow
189 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530190 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:Any |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530191 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
192 ${upstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
193 ... ${flow_vlan_push_cmd}
194 Should Not Be Empty ${upstream_flow_1_added}
195 # Verify downstream table=0 flow
196 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530197 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530198 ... grep VLAN_POP | grep transition=TABLE:1
199 ${downstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
200 ... ${flow_vlan_pop_cmd}
201 Should Not Be Empty ${downstream_flow_0_added}
202 # Verify downstream table=1 flow
203 ${downstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530204 ... 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 +0530205 Should Not Be Empty ${downstream_flow_1_added}
206
207Verify Subscriber Access Flows Added Count DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530208 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530209 [Documentation] Matches for total number of subscriber access flows added for all onus
210 ${access_flows_added}= Execute ONOS CLI Command ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530211 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep -v ETH_TYPE:lldp | wc -l
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530212 Should Be Equal As Integers ${access_flows_added} ${expected_flows}
213
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530214Get Programmed Subscribers
215 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
216 [Documentation] Retrieves the subscriber details at a given location
217 ${sub_location}= Catenate SEPARATOR=/ ${olt_of_id} ${onu_port}
218 ${programmed_sub}= Execute ONOS CLI Command ${ip} ${port}
219 ... volt-programmed-subscribers | grep ${sub_location}
220 [Return] ${programmed_sub}
221
222Get Upstream and Downstream Bandwidth Profile Name
223 [Arguments] ${programmed_sub}
224 [Documentation] Retrieves the upstream and downstream bandwidth profile name
225 ... from the programmed subscriber
226 @{programmed_sub_array}= Split String ${programmed_sub} ,
227 # Get upstream bandwidth profile name for the subscriber
228 @{param_val_pair}= Split String ${programmed_sub_array[9]} =
229 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
230 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
231 ${us_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' upstreamBandwidthProfile'
232 ... Set Variable ${programmed_sub_val}
233 Log ${us_bw_profile}
234 # Get downstream bandwidth profile name for the subscriber
235 @{param_val_pair}= Split String ${programmed_sub_array[10]} =
236 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
237 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
238 ${ds_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' downstreamBandwidthProfile'
239 ... Set Variable ${programmed_sub_val}
240 Log ${ds_bw_profile}
241 [Return] ${us_bw_profile} ${ds_bw_profile}
242
243Get Bandwidth Profile Details
244 [Arguments] ${ip} ${port} ${bw_profile}
245 [Documentation] Retrieves the details of the given bandwidth profile
246 ${bw_profile_values}= Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
247 ... bandwidthprofile ${bw_profile}
248 @{bw_profile_array}= Split String ${bw_profile_values} ,
249 @{param_val_pair}= Split String ${bw_profile_array[1]} =
250 ${bw_param}= Set Variable ${param_val_pair[0]}
251 ${bw_val}= Set Variable ${param_val_pair[1]}
252 ${cir} Run Keyword If '${bw_param}' == ' committedInformationRate'
253 ... Set Variable ${bw_val}
254 @{param_val_pair}= Split String ${bw_profile_array[2]} =
255 ${bw_param}= Set Variable ${param_val_pair[0]}
256 ${bw_val}= Set Variable ${param_val_pair[1]}
257 ${cbs} Run Keyword If '${bw_param}' == ' committedBurstSize'
258 ... Set Variable ${bw_val}
259 @{param_val_pair}= Split String ${bw_profile_array[3]} =
260 ${bw_param}= Set Variable ${param_val_pair[0]}
261 ${bw_val}= Set Variable ${param_val_pair[1]}
262 ${eir} Run Keyword If '${bw_param}' == ' exceededInformationRate'
263 ... Set Variable ${bw_val}
264 @{param_val_pair}= Split String ${bw_profile_array[4]} =
265 ${bw_param}= Set Variable ${param_val_pair[0]}
266 ${bw_val}= Set Variable ${param_val_pair[1]}
267 ${ebs} Run Keyword If '${bw_param}' == ' exceededBurstSize'
268 ... Set Variable ${bw_val}
269 @{param_val_pair}= Split String ${bw_profile_array[5]} =
270 ${bw_param}= Set Variable ${param_val_pair[0]}
271 ${bw_val}= Set Variable ${param_val_pair[1]}
272 @{bw_val_air}= Split String ${bw_val} }
273 ${air} Run Keyword If '${bw_param}' == ' assuredInformationRate'
274 ... Set Variable ${bw_val_air[0]}
275 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
276
277Verify Meters in ONOS
278 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
279 [Documentation] Verifies the meters
280 # Get programmed subscriber
281 ${programmed_sub}= Get Programmed Subscribers ${ip} ${port}
282 ... ${olt_of_id} ${onu_port}
283 Log ${programmed_sub}
284 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
285 ... ${programmed_sub}
286 # Get upstream bandwidth profile details
287 ${us_cir} ${us_cbs} ${us_eir} ${us_ebs} ${us_air} Get Bandwidth Profile Details
288 ... ${ip} ${port} ${us_bw_profile}
289 Sleep 1s
290 # Verify meter for upstream bandwidth profile
291 ${us_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530292 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
293 ... | grep "rate=${us_eir}, burst-size=${us_ebs}" | grep "rate=${us_air}, burst-size=0" | wc -l
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530294 ${upstream_meter_added}= Execute ONOS CLI Command ${ip} ${port}
295 ... ${us_meter_cmd}
296 Should Be Equal As Integers ${upstream_meter_added} 1
297 Sleep 1s
298 # Get downstream bandwidth profile details
299 ${ds_cir} ${ds_cbs} ${ds_eir} ${ds_ebs} ${ds_air} Get Bandwidth Profile Details
300 ... ${ip} ${port} ${ds_bw_profile}
301 Sleep 1s
302 # Verify meter for downstream bandwidth profile
303 ${ds_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530304 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
305 ... | grep "rate=${ds_eir}, burst-size=${ds_ebs}" | grep "rate=${ds_air}, burst-size=0" | wc -l
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530306 ${downstream_meter_added}= Execute ONOS CLI Command ${ip} ${port}
307 ... ${ds_meter_cmd}
308 Should Be Equal As Integers ${downstream_meter_added} 1
309
310Verify Default Meter Present in ONOS
311 [Arguments] ${ip} ${port} ${olt_of_id}
312 [Documentation] Verifies the single default meter entry is present
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530313 # Get default bandwidth profile details
314 ${cir} ${cbs} ${eir} ${ebs} ${air} Get Bandwidth Profile Details
315 ... ${ip} ${port} 'Default'
316 Sleep 1s
317 # Verify meter for default bandwidth profile
318 ${meter_cmd}= Catenate SEPARATOR=
319 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${cir}, burst-size=${cbs}"
320 ... | grep "rate=${eir}, burst-size=${ebs}" | grep "rate=${air}, burst-size=0" | wc -l
321 ${default_meter_added}= Execute ONOS CLI Command ${ip} ${port}
322 ... ${meter_cmd}
323 Should Be Equal As Integers ${default_meter_added} 1
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530324
Hardik Windlass480f3e22020-04-02 20:14:14 +0530325Verify Device Flows Removed
326 [Arguments] ${ip} ${port} ${olt_of_id}
327 [Documentation] Verifies all flows are removed from the device
328 ${device_flows}= Execute ONOS CLI Command ${ip} ${port}
329 ... flows -s -f ${olt_of_id} | grep -v deviceId | wc -l
330 Should Be Equal As Integers ${device_flows} 0
331
Kailash6f5acb62019-08-28 14:38:45 -0700332Verify Eapol Flows Added
Andy Bavierb0c06232019-08-29 12:58:53 -0700333 [Arguments] ${ip} ${port} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700334 [Documentation] Matches for number of eapol flows based on number of onus
Gilles Depatie675a2062019-10-22 12:44:42 -0400335 ${eapol_flows_added}= Execute ONOS CLI Command ${ip} ${port}
336 ... flows -s -f ADDED | grep eapol | grep IN_PORT | wc -l
Andy Bavierb0c06232019-08-29 12:58:53 -0700337 Should Contain ${eapol_flows_added} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700338
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800339Verify No Pending Flows For ONU
340 [Arguments] ${ip} ${port} ${onu_port}
341 [Documentation] Verifies that there are no flows "PENDING" state for the ONU in ONOS
342 ${pending_flows}= Execute ONOS CLI Command ${ip} ${port}
343 ... flows -s | grep IN_PORT:${onu_port} | grep PENDING
344 Should Be Empty ${pending_flows}
345
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700346Verify Eapol Flows Added For ONU
347 [Arguments] ${ip} ${port} ${onu_port}
348 [Documentation] Verifies if the Eapol Flows are added in ONOS for the ONU
Gilles Depatie675a2062019-10-22 12:44:42 -0400349 ${eapol_flows_added}= Execute ONOS CLI Command ${ip} ${port}
350 ... flows -s -f ADDED | grep eapol | grep IN_PORT:${onu_port}
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700351 Should Not Be Empty ${eapol_flows_added}
352
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800353Verify ONU Port Is Enabled
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700354 [Arguments] ${ip} ${port} ${onu_name}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800355 [Documentation] Verifies if the ONU port is enabled in ONOS
356 ${onu_port_enabled}= Execute ONOS CLI Command ${ip} ${port}
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700357 ... ports -e | grep portName=${onu_name}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800358 Log ${onu_port_enabled}
359 Should Not Be Empty ${onu_port_enabled}
360
Hardik Windlass63d5e002020-03-06 21:07:09 +0530361Verify ONU Port Is Disabled
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700362 [Arguments] ${ip} ${port} ${onu_name}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530363 [Documentation] Verifies if the ONU port is disabled in ONOS
364 ${onu_port_disabled}= Execute ONOS CLI Command ${ip} ${port}
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700365 ... ports -e | grep portName=${onu_name}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530366 Log ${onu_port_disabled}
367 Should Be Empty ${onu_port_disabled}
368
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700369Verify ONU in AAA-Users
370 [Arguments] ${ip} ${port} ${onu_port}
371 [Documentation] Verifies that the specified onu_port exists in aaa-users output
372 ${aaa_users}= Execute ONOS CLI Command ${ip} ${port} aaa-users | grep AUTHORIZED | grep ${onu_port}
373 Should Not Be Empty ${aaa_users} ONU port ${onu_port} not found in aaa-users
374
Matteo Scandolo142e6272020-04-29 17:36:59 -0700375Assert Number of AAA-Users
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700376 [Arguments] ${onos_ssh_connection} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700377 [Documentation] Matches for number of aaa-users authorized based on number of onus
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700378 ${aaa_users}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
379 ... aaa-users | grep AUTHORIZED | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700380 Should Be Equal As Integers ${aaa_users} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700381
382Validate DHCP Allocations
Matteo Scandoloda854b02020-09-01 16:20:51 -0700383 [Arguments] ${onos_ssh_connection} ${count} ${workflow}
Kailash6f5acb62019-08-28 14:38:45 -0700384 [Documentation] Matches for number of dhcpacks based on number of onus
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700385 ${allocations}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
386 ... dhcpl2relay-allocations | grep DHCPACK | wc -l
Matteo Scandoloda854b02020-09-01 16:20:51 -0700387 # if the workflow is TT we'll have 2 allocations for each ONU
388 ${ttAllocations}= Evaluate (${count} * 2)
389 ${count}= Set Variable If $workflow=='tt' ${ttAllocations} ${count}
390 Should Be Equal As Integers ${allocations} ${count}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700391
392Validate Subscriber DHCP Allocation
393 [Arguments] ${ip} ${port} ${onu_port}
394 [Documentation] Verifies that the specified subscriber is found in DHCP allocations
395 ##TODO: Enhance the keyword to include DHCP allocated address is not 0.0.0.0
Gilles Depatie675a2062019-10-22 12:44:42 -0400396 ${allocations}= Execute ONOS CLI Command ${ip} ${port}
397 ... dhcpl2relay-allocations | grep DHCPACK | grep ${onu_port}
398 Should Not Be Empty ${allocations} ONU port ${onu_port} not found in dhcpl2relay-allocations
David Bainbridgef81cd642019-11-20 00:14:47 +0000399
400Device Is Available In ONOS
401 [Arguments] ${url} ${dpid}
402 [Documentation] Validates the device exists and it available in ONOS
403 ${rc} ${json} Run And Return Rc And Output curl --fail -sSL ${url}/onos/v1/devices/${dpid}
404 Should Be Equal As Integers 0 ${rc}
405 ${rc} ${value} Run And Return Rc And Output echo '${json}' | jq -r .available
406 Should Be Equal As Integers 0 ${rc}
407 Should Be Equal 'true' '${value}'
408
409Remove All Devices From ONOS
410 [Arguments] ${url}
411 [Documentation] Executes the device-remove command on each device in ONOS
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000412 ${rc} ${output} Run And Return Rc And Output
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700413 ... curl --fail -sSL ${url}/onos/v1/devices | jq -r '.devices[].id'
David Bainbridgef81cd642019-11-20 00:14:47 +0000414 Should Be Equal As Integers ${rc} 0
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000415 @{dpids} Split String ${output}
David Bainbridgef81cd642019-11-20 00:14:47 +0000416 ${count}= Get length ${dpids}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700417 FOR ${dpid} IN @{dpids}
418 ${rc}= Run Keyword If '${dpid}' != ''
419 ... Run And Return Rc curl -XDELETE --fail -sSL ${url}/onos/v1/devices/${dpid}
420 Run Keyword If '${dpid}' != ''
421 ... Should Be Equal As Integers ${rc} 0
422 END
Matteo Scandolo142e6272020-04-29 17:36:59 -0700423
424Assert Ports in ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700425 [Arguments] ${onos_ssh_connection} ${count} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700426 [Documentation] Check that a certain number of ports are enabled in ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700427 ${ports}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700428 ... ports -e | grep ${filter} | wc -l
429 Should Be Equal As Integers ${ports} ${count}
430
431Wait for Ports in ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700432 [Arguments] ${onos_ssh_connection} ${count} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700433 [Documentation] Waits untill a certain number of ports are enabled in ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700434 Wait Until Keyword Succeeds 10m 5s Assert Ports in ONOS
435 ... ${onos_ssh_connection} ${count} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700436
437Wait for AAA Authentication
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700438 [Arguments] ${onos_ssh_connection} ${count}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700439 [Documentation] Waits untill a certain number of subscribers are authenticated in ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700440 Wait Until Keyword Succeeds 10m 5s Assert Number of AAA-Users ${onos_ssh_connection} ${count}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700441
442Wait for DHCP Ack
Matteo Scandoloda854b02020-09-01 16:20:51 -0700443 [Arguments] ${onos_ssh_connection} ${count} ${workflow}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700444 [Documentation] Waits untill a certain number of subscribers have received a DHCP_ACK
Matteo Scandoloda854b02020-09-01 16:20:51 -0700445 Wait Until Keyword Succeeds 10m 5s Validate DHCP Allocations
446 ... ${onos_ssh_connection} ${count} ${workflow}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700447
448Provision subscriber
449 [Documentation] Calls volt-add-subscriber-access in ONOS
450 [Arguments] ${onos_ip} ${onos_port} ${of_id} ${onu_port}
451 Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
452 ... volt-add-subscriber-access ${of_id} ${onu_port}
453
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700454Provision subscriber REST
455 [Documentation] Uses the rest APIs to provision a subscriber
456 [Arguments] ${onos_ip} ${onos_port} ${of_id} ${onu_port}
457 ${resp}= Post Request ONOS
458 ... /onos/olt/oltapp/${of_id}/${onu_port}
459 Should Be Equal As Strings ${resp.status_code} 200
460
461
Matteo Scandolo142e6272020-04-29 17:36:59 -0700462List Enabled UNI Ports
463 [Documentation] List all the UNI Ports, the only way we have is to filter out the one called NNI
464 ... Creates a list of dictionaries
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700465 [Arguments] ${onos_ssh_connection} ${of_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700466 [Return] [{'port': '16', 'of_id': 'of:00000a0a0a0a0a00'}, {'port': '32', 'of_id': 'of:00000a0a0a0a0a00'}]
467 ${result}= Create List
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700468 ${out}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700469 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000470 @{unis}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700471 FOR ${uni} IN @{unis}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000472 ${matches} = Get Regexp Matches ${uni} .*port=([0-9]+),.* 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700473 &{portDict} Create Dictionary of_id=${of_id} port=${matches[0]}
474 Append To List ${result} ${portDict}
475 END
476 Log ${result}
477 Return From Keyword ${result}
478
479Provision all subscribers on device
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700480 [Documentation] Provisions a subscriber in ONOS for all the enabled UNI ports on a particular device
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700481 [Arguments] ${onos_ssh_connection} ${onos_ip} ${onos_rest_port} ${of_id}
482 ${unis}= List Enabled UNI Ports ${onos_ssh_connection} ${of_id}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700483 ${onos_auth}= Create List karaf karaf
484 Create Session ONOS http://${onos_ip}:${onos_rest_port} auth=${onos_auth}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700485 FOR ${uni} IN @{unis}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700486 Provision Subscriber REST ${onos_ip} ${onos_rest_port} ${uni['of_id']} ${uni['port']}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700487 END
488
489List OLTs
490 [Documentation] Returns a list of OLTs known to ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700491 [Arguments] ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700492 [Return] ['of:00000a0a0a0a0a00', 'of:00000a0a0a0a0a01']
493 ${result}= Create List
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700494 ${out}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700495 ... volt-olts
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000496 @{olts}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700497 FOR ${olt} IN @{olts}
498 Log ${olt}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000499 ${matches} = Get Regexp Matches ${olt} ^OLT (.+)$ 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700500 # there may be some logs mixed with the output so only append if we have a match
501 ${matches_length}= Get Length ${matches}
502 Run Keyword If ${matches_length}==1
503 ... Append To List ${result} ${matches[0]}
504 END
505 Return From Keyword ${result}
506
507Count ADDED flows
508 [Documentation] Count the flows in ADDED state in ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700509 [Arguments] ${onos_ssh_connection} ${targetFlows}
510 ${flows}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700511 ... flows -s | grep ADDED | wc -l
512 Should Be Equal As Integers ${targetFlows} ${flows}
513
514Wait for all flows to in ADDED state
515 [Documentation] Waits until the flows have been provisioned
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700516 [Arguments] ${onos_ssh_connection} ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200517 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700518 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200519 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700520 Wait Until Keyword Succeeds 10m 5s Count ADDED flows
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700521 ... ${onos_ssh_connection} ${targetFlows}
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000522
523Get Bandwidth Details
524 [Arguments] ${bandwidth_profile_name}
525 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
526 ... returns the limiting bandwidth
527 ${bandwidth_profile_values}= Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
528 ... bandwidthprofile ${bandwidth_profile_name}
529 @{bandwidth_profile_array}= Split String ${bandwidth_profile_values} ,
530 @{parameter_value_pair}= Split String ${bandwidth_profile_array[1]} =
531 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
532 ${value}= Set Variable ${parameter_value_pair[1]}
533 ${cir_value} Run Keyword If '${bandwidthparameter}' == ' committedInformationRate'
534 ... Set Variable ${value}
535 @{parameter_value_pair}= Split String ${bandwidth_profile_array[2]} =
536 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
537 ${value}= Set Variable ${parameter_value_pair[1]}
538 ${cbs_value} Run Keyword If '${bandwidthparameter}' == ' committedBurstSize' Set Variable ${value}
539 @{parameter_value_pair}= Split String ${bandwidth_profile_array[3]} =
540 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
541 ${value}= Set Variable ${parameter_value_pair[1]}
542 ${eir_value} Run Keyword If '${bandwidthparameter}' == ' exceededInformationRate' Set Variable ${value}
543 @{parameter_value_pair}= Split String ${bandwidth_profile_array[4]} =
544 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
545 ${value}= Set Variable ${parameter_value_pair[1]}
546 ${ebs_value} Run Keyword If '${bandwidthparameter}' == ' exceededBurstSize' Set Variable ${value}
547 ${limiting_BW}= Evaluate ${cir_value}+${eir_value}
548 [Return] ${limiting_BW}