blob: 77f4091abf6afd82632ad61f36a1c253d99b0bf8 [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
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 Scandolo37bca8d2020-07-31 11:28:40 -0700385 [Arguments] ${onos_ssh_connection} ${expected_onus}
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}
388 ... aaa-users | grep AUTHORIZED | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700389 Should Be Equal As Integers ${aaa_users} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700390
391Validate DHCP Allocations
Matteo Scandoloda854b02020-09-01 16:20:51 -0700392 [Arguments] ${onos_ssh_connection} ${count} ${workflow}
Kailash6f5acb62019-08-28 14:38:45 -0700393 [Documentation] Matches for number of dhcpacks based on number of onus
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700394 ${allocations}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
395 ... dhcpl2relay-allocations | grep DHCPACK | wc -l
Matteo Scandoloda854b02020-09-01 16:20:51 -0700396 # if the workflow is TT we'll have 2 allocations for each ONU
397 ${ttAllocations}= Evaluate (${count} * 2)
398 ${count}= Set Variable If $workflow=='tt' ${ttAllocations} ${count}
399 Should Be Equal As Integers ${allocations} ${count}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700400
401Validate Subscriber DHCP Allocation
Suchitra Vemuri42819412020-10-01 17:45:43 -0700402 [Arguments] ${ip} ${port} ${onu_port} ${vlan}=''
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700403 [Documentation] Verifies that the specified subscriber is found in DHCP allocations
404 ##TODO: Enhance the keyword to include DHCP allocated address is not 0.0.0.0
Gilles Depatie675a2062019-10-22 12:44:42 -0400405 ${allocations}= Execute ONOS CLI Command ${ip} ${port}
Suchitra Vemuri42819412020-10-01 17:45:43 -0700406 ... dhcpl2relay-allocations | grep DHCPACK | grep ${onu_port} | grep ${vlan}
Gilles Depatie675a2062019-10-22 12:44:42 -0400407 Should Not Be Empty ${allocations} ONU port ${onu_port} not found in dhcpl2relay-allocations
David Bainbridgef81cd642019-11-20 00:14:47 +0000408
409Device Is Available In ONOS
410 [Arguments] ${url} ${dpid}
411 [Documentation] Validates the device exists and it available in ONOS
412 ${rc} ${json} Run And Return Rc And Output curl --fail -sSL ${url}/onos/v1/devices/${dpid}
413 Should Be Equal As Integers 0 ${rc}
414 ${rc} ${value} Run And Return Rc And Output echo '${json}' | jq -r .available
415 Should Be Equal As Integers 0 ${rc}
416 Should Be Equal 'true' '${value}'
417
418Remove All Devices From ONOS
419 [Arguments] ${url}
420 [Documentation] Executes the device-remove command on each device in ONOS
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000421 ${rc} ${output} Run And Return Rc And Output
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700422 ... curl --fail -sSL ${url}/onos/v1/devices | jq -r '.devices[].id'
David Bainbridgef81cd642019-11-20 00:14:47 +0000423 Should Be Equal As Integers ${rc} 0
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000424 @{dpids} Split String ${output}
David Bainbridgef81cd642019-11-20 00:14:47 +0000425 ${count}= Get length ${dpids}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700426 FOR ${dpid} IN @{dpids}
427 ${rc}= Run Keyword If '${dpid}' != ''
428 ... Run And Return Rc curl -XDELETE --fail -sSL ${url}/onos/v1/devices/${dpid}
429 Run Keyword If '${dpid}' != ''
430 ... Should Be Equal As Integers ${rc} 0
431 END
Matteo Scandolo142e6272020-04-29 17:36:59 -0700432
433Assert Ports in ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700434 [Arguments] ${onos_ssh_connection} ${count} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700435 [Documentation] Check that a certain number of ports are enabled in ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700436 ${ports}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700437 ... ports -e | grep ${filter} | wc -l
438 Should Be Equal As Integers ${ports} ${count}
439
440Wait for Ports in ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700441 [Arguments] ${onos_ssh_connection} ${count} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700442 [Documentation] Waits untill a certain number of ports are enabled in ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700443 Wait Until Keyword Succeeds 10m 5s Assert Ports in ONOS
444 ... ${onos_ssh_connection} ${count} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700445
446Wait for AAA Authentication
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700447 [Arguments] ${onos_ssh_connection} ${count}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700448 [Documentation] Waits untill a certain number of subscribers are authenticated in ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700449 Wait Until Keyword Succeeds 10m 5s Assert Number of AAA-Users ${onos_ssh_connection} ${count}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700450
451Wait for DHCP Ack
Matteo Scandoloda854b02020-09-01 16:20:51 -0700452 [Arguments] ${onos_ssh_connection} ${count} ${workflow}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700453 [Documentation] Waits untill a certain number of subscribers have received a DHCP_ACK
Matteo Scandoloda854b02020-09-01 16:20:51 -0700454 Wait Until Keyword Succeeds 10m 5s Validate DHCP Allocations
455 ... ${onos_ssh_connection} ${count} ${workflow}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700456
457Provision subscriber
458 [Documentation] Calls volt-add-subscriber-access in ONOS
459 [Arguments] ${onos_ip} ${onos_port} ${of_id} ${onu_port}
460 Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
461 ... volt-add-subscriber-access ${of_id} ${onu_port}
462
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700463Provision subscriber REST
464 [Documentation] Uses the rest APIs to provision a subscriber
465 [Arguments] ${onos_ip} ${onos_port} ${of_id} ${onu_port}
466 ${resp}= Post Request ONOS
467 ... /onos/olt/oltapp/${of_id}/${onu_port}
468 Should Be Equal As Strings ${resp.status_code} 200
469
470
Matteo Scandolo142e6272020-04-29 17:36:59 -0700471List Enabled UNI Ports
472 [Documentation] List all the UNI Ports, the only way we have is to filter out the one called NNI
473 ... Creates a list of dictionaries
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700474 [Arguments] ${onos_ssh_connection} ${of_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700475 [Return] [{'port': '16', 'of_id': 'of:00000a0a0a0a0a00'}, {'port': '32', 'of_id': 'of:00000a0a0a0a0a00'}]
476 ${result}= Create List
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700477 ${out}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700478 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000479 @{unis}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700480 FOR ${uni} IN @{unis}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000481 ${matches} = Get Regexp Matches ${uni} .*port=([0-9]+),.* 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700482 &{portDict} Create Dictionary of_id=${of_id} port=${matches[0]}
483 Append To List ${result} ${portDict}
484 END
485 Log ${result}
486 Return From Keyword ${result}
487
488Provision all subscribers on device
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700489 [Documentation] Provisions a subscriber in ONOS for all the enabled UNI ports on a particular device
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700490 [Arguments] ${onos_ssh_connection} ${onos_ip} ${onos_rest_port} ${of_id}
491 ${unis}= List Enabled UNI Ports ${onos_ssh_connection} ${of_id}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700492 ${onos_auth}= Create List karaf karaf
493 Create Session ONOS http://${onos_ip}:${onos_rest_port} auth=${onos_auth}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700494 FOR ${uni} IN @{unis}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700495 Provision Subscriber REST ${onos_ip} ${onos_rest_port} ${uni['of_id']} ${uni['port']}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700496 END
497
498List OLTs
499 [Documentation] Returns a list of OLTs known to ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700500 [Arguments] ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700501 [Return] ['of:00000a0a0a0a0a00', 'of:00000a0a0a0a0a01']
502 ${result}= Create List
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700503 ${out}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700504 ... volt-olts
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000505 @{olts}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700506 FOR ${olt} IN @{olts}
507 Log ${olt}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000508 ${matches} = Get Regexp Matches ${olt} ^OLT (.+)$ 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700509 # there may be some logs mixed with the output so only append if we have a match
510 ${matches_length}= Get Length ${matches}
511 Run Keyword If ${matches_length}==1
512 ... Append To List ${result} ${matches[0]}
513 END
514 Return From Keyword ${result}
515
516Count ADDED flows
517 [Documentation] Count the flows in ADDED state in ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700518 [Arguments] ${onos_ssh_connection} ${targetFlows}
519 ${flows}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700520 ... flows -s | grep ADDED | wc -l
521 Should Be Equal As Integers ${targetFlows} ${flows}
522
523Wait for all flows to in ADDED state
524 [Documentation] Waits until the flows have been provisioned
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700525 [Arguments] ${onos_ssh_connection} ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200526 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700527 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200528 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700529 Wait Until Keyword Succeeds 10m 5s Count ADDED flows
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700530 ... ${onos_ssh_connection} ${targetFlows}
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000531
532Get Bandwidth Details
533 [Arguments] ${bandwidth_profile_name}
534 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
535 ... returns the limiting bandwidth
536 ${bandwidth_profile_values}= Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
537 ... bandwidthprofile ${bandwidth_profile_name}
538 @{bandwidth_profile_array}= Split String ${bandwidth_profile_values} ,
539 @{parameter_value_pair}= Split String ${bandwidth_profile_array[1]} =
540 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
541 ${value}= Set Variable ${parameter_value_pair[1]}
542 ${cir_value} Run Keyword If '${bandwidthparameter}' == ' committedInformationRate'
543 ... Set Variable ${value}
544 @{parameter_value_pair}= Split String ${bandwidth_profile_array[2]} =
545 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
546 ${value}= Set Variable ${parameter_value_pair[1]}
547 ${cbs_value} Run Keyword If '${bandwidthparameter}' == ' committedBurstSize' Set Variable ${value}
548 @{parameter_value_pair}= Split String ${bandwidth_profile_array[3]} =
549 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
550 ${value}= Set Variable ${parameter_value_pair[1]}
551 ${eir_value} Run Keyword If '${bandwidthparameter}' == ' exceededInformationRate' Set Variable ${value}
552 @{parameter_value_pair}= Split String ${bandwidth_profile_array[4]} =
553 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
554 ${value}= Set Variable ${parameter_value_pair[1]}
555 ${ebs_value} Run Keyword If '${bandwidthparameter}' == ' exceededBurstSize' Set Variable ${value}
556 ${limiting_BW}= Evaluate ${cir_value}+${eir_value}
557 [Return] ${limiting_BW}