blob: 76c8686fe11a2185a52ee99eff936aa7a3c6aca6 [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
TorstenThiemeb198c482020-12-14 19:45:23 +000027*** Variables ***
28@{connection_list}
29
Kailash6f5acb62019-08-28 14:38:45 -070030*** Keywords ***
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070031
32Open ONOS SSH Connection
33 [Documentation] Establishes an ssh connection to ONOS contoller
34 [Arguments] ${host} ${port} ${user}=karaf ${pass}=karaf
35 ${conn_id}= SSHLibrary.Open Connection ${host} port=${port} timeout=300s alias=ONOS_SSH
36 SSHLibrary.Login ${user} ${pass}
TorstenThiemeb198c482020-12-14 19:45:23 +000037 ${conn_list_entry}= Create Dictionary conn_id=${conn_id} user=${user} pass=${pass}
38 Append To List ${connection_list} ${conn_list_entry}
39 ${conn_list_id}= Get Index From List ${connection_list} ${conn_list_entry}
40 Set Global Variable ${connection_list}
41 [Return] ${conn_list_id}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070042
43Execute ONOS CLI Command on open connection
44 [Documentation] Execute ONOS CLI Command On an Open Connection
TorstenThiemeb198c482020-12-14 19:45:23 +000045 [Arguments] ${connection_list_id} ${cmd}
46 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
47 SSHLibrary.Switch Connection ${connection_entry.conn_id}
48 ${PassOrFail} @{result_values} Run Keyword And Ignore Error SSHLibrary.Execute Command ${cmd}
49 ... return_rc=True return_stderr=True return_stdout=True
50 Run Keyword If '${PassOrFail}'=='FAIL' Reconnect ONOS SSH Connection ${connection_list_id}
51 @{result_values}= Run Keyword If '${PassOrFail}'=='FAIL'
52 ... SSHLibrary.Execute Command ${cmd} return_rc=True return_stderr=True return_stdout=True
53 ... ELSE Set Variable @{result_values}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070054 ${output} Set Variable @{result_values}[0]
Matteo Scandolo50be75c2020-11-12 11:14:12 -080055 Log Command output: ${output}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070056 Should Be Empty @{result_values}[1]
57 Should Be Equal As Integers @{result_values}[2] 0
58 [Return] ${output}
59
TorstenThiemeb198c482020-12-14 19:45:23 +000060Reconnect ONOS SSH Connection
61 [Documentation] Reconnect an SSH Connection
62 [Arguments] ${connection_list_id}
63 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
64 ${user}= Get From Dictionary ${connection_entry} user
65 ${pass}= Get From Dictionary ${connection_entry} pass
66 ${oldconndata}= Get Connection ${connection_entry.conn_id}
67 SSHLibrary.Switch Connection ${connection_entry.conn_id}
TorstenThiemebcf14612021-01-27 10:19:18 +000068 Run Keyword And Ignore Error SSHLibrary.Close Connection
TorstenThiemeb198c482020-12-14 19:45:23 +000069 ${conn_id}= SSHLibrary.Open Connection ${oldconndata.host} port=${oldconndata.port}
70 ... timeout=300s alias=ONOS_SSH
71 SSHLibrary.Login ${user} ${pass}
72 ${conn_list_entry}= Create Dictionary conn_id=${conn_id} user=${user} pass=${pass}
73 Set List Value ${connection_list} ${connection_list_id} ${conn_list_entry}
74 Set Global Variable ${connection_list}
75
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070076Close ONOS SSH Connection
77 [Documentation] Close an SSH Connection
TorstenThiemeb198c482020-12-14 19:45:23 +000078 [Arguments] ${connection_list_id}
79 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
80 ${connection_alias}= Get From Dictionary ${connection_entry} conn_id
81 ${oldconndata}= Get Connection ${connection_entry.conn_id}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070082 SSHLibrary.Switch Connection ${connection_alias}
TorstenThiemebcf14612021-01-27 10:19:18 +000083 Run Keyword And Ignore Error SSHLibrary.Close Connection
TorstenThiemeb198c482020-12-14 19:45:23 +000084 Remove From List ${connection_list} ${connection_list_id}
85 Set Global Variable ${connection_list}
86
87Close All ONOS SSH Connections
88 [Documentation] Close all SSH Connection and clear connection list.
89 SSHLibrary.Close All Connections
90 @{connection_list} Create List
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070091
Kailash6f5acb62019-08-28 14:38:45 -070092Validate OLT Device in ONOS
Zack Williamsa8fe75a2020-01-10 14:25:27 -070093 # FIXME use volt-olts to check that the OLT is ONOS
Kailash6f5acb62019-08-28 14:38:45 -070094 [Arguments] ${serial_number}
Zack Williamsec53a1b2019-09-16 15:50:52 -070095 [Documentation] Checks if olt has been connected to ONOS
Kailash6f5acb62019-08-28 14:38:45 -070096 ${resp}= Get Request ONOS onos/v1/devices
97 ${jsondata}= To Json ${resp.content}
98 Should Not Be Empty ${jsondata['devices']}
99 ${length}= Get Length ${jsondata['devices']}
100 @{serial_numbers}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -0700101 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700102 FOR ${INDEX} IN RANGE 0 ${length}
103 ${value}= Get From List ${jsondata['devices']} ${INDEX}
104 ${of_id}= Get From Dictionary ${value} id
105 ${sn}= Get From Dictionary ${value} serial
Andy Bavierb63f6d22020-03-12 15:34:37 -0700106 ${matched}= Set Variable If '${sn}' == '${serial_number}' True False
107 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700108 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700109 Should Be True ${matched} No match for ${serial_number} found
Kailash57210eb2019-08-30 13:27:19 -0700110 [Return] ${of_id}
Kailash6f5acb62019-08-28 14:38:45 -0700111
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700112Get ONU Port in ONOS
Zack Williamsec53a1b2019-09-16 15:50:52 -0700113 [Arguments] ${onu_serial_number} ${olt_of_id}
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700114 [Documentation] Retrieves ONU port for the ONU in ONOS
Suchitra Vemuria50c1c12019-09-30 19:54:26 -0700115 ${onu_serial_number}= Catenate SEPARATOR=- ${onu_serial_number} 1
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700116 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
117 ${jsondata}= To Json ${resp.content}
118 Should Not Be Empty ${jsondata['ports']}
119 ${length}= Get Length ${jsondata['ports']}
120 @{ports}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -0700121 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700122 FOR ${INDEX} IN RANGE 0 ${length}
123 ${value}= Get From List ${jsondata['ports']} ${INDEX}
124 ${annotations}= Get From Dictionary ${value} annotations
125 ${onu_port}= Get From Dictionary ${value} port
126 ${portName}= Get From Dictionary ${annotations} portName
Andy Bavierb63f6d22020-03-12 15:34:37 -0700127 ${matched}= Set Variable If '${portName}' == '${onu_serial_number}' True False
128 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700129 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700130 Should Be True ${matched} No match for ${onu_serial_number} found
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700131 [Return] ${onu_port}
132
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530133Get NNI Port in ONOS
134 [Arguments] ${olt_of_id}
135 [Documentation] Retrieves NNI port for the OLT in ONOS
136 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
137 ${jsondata}= To Json ${resp.content}
138 Should Not Be Empty ${jsondata['ports']}
139 ${length}= Get Length ${jsondata['ports']}
140 @{ports}= Create List
141 ${matched}= Set Variable False
142 FOR ${INDEX} IN RANGE 0 ${length}
143 ${value}= Get From List ${jsondata['ports']} ${INDEX}
144 ${annotations}= Get From Dictionary ${value} annotations
145 ${nni_port}= Get From Dictionary ${value} port
146 ${nniPortName}= Catenate SEPARATOR= nni- ${nni_port}
147 ${portName}= Get From Dictionary ${annotations} portName
148 ${matched}= Set Variable If '${portName}' == '${nniPortName}' True False
149 Exit For Loop If ${matched}
150 END
151 Should Be True ${matched} No match for NNI found for ${olt_of_id}
152 [Return] ${nni_port}
153
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700154Get FabricSwitch in ONOS
155 [Documentation] Returns of_id of the Fabric Switch in ONOS
156 ${resp}= Get Request ONOS onos/v1/devices
157 ${jsondata}= To Json ${resp.content}
158 Should Not Be Empty ${jsondata['devices']}
159 ${length}= Get Length ${jsondata['devices']}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700160 ${matched}= Set Variable False
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700161 FOR ${INDEX} IN RANGE 0 ${length}
162 ${value}= Get From List ${jsondata['devices']} ${INDEX}
163 ${of_id}= Get From Dictionary ${value} id
164 ${type}= Get From Dictionary ${value} type
Andy Bavierb63f6d22020-03-12 15:34:37 -0700165 ${matched}= Set Variable If '${type}' == "SWITCH" True False
166 Exit For Loop If ${matched}
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700167 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700168 Should Be True ${matched} No fabric switch found
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700169 [Return] ${of_id}
170
Andrea Campanella4c404632020-08-26 14:41:36 +0200171Get Master Instace in ONOS
172 [Arguments] ${of_id}
173 [Documentation] Returns nodeId of the Master instace for a giver device in ONOS
174 ${resp}= Get Request ONOS onos/v1/mastership/${of_id}/master
175 ${jsondata}= To Json ${resp.content}
176 Should Not Be Empty ${jsondata['nodeId']}
177 ${master_node}= Get From Dictionary ${jsondata} nodeId
178 [Return] ${master_node}
179
Hardik Windlass21807632020-04-14 16:24:55 +0530180Verify Subscriber Access Flows Added for ONU
181 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${c_tag} ${s_tag}
182 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
183 # Verify upstream table=0 flow
184 ${upstream_flow_0_cmd}= Catenate SEPARATOR=
185 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:0 |
186 ... grep VLAN_ID:${c_tag} | grep transition=TABLE:1
187 ${upstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
188 ... ${upstream_flow_0_cmd}
189 Should Not Be Empty ${upstream_flow_0_added}
190 # Verify upstream table=1 flow
191 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
192 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
193 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
194 ${upstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
195 ... ${flow_vlan_push_cmd}
196 Should Not Be Empty ${upstream_flow_1_added}
197 # Verify downstream table=0 flow
198 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
199 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
200 ... grep VLAN_POP | grep transition=TABLE:1
201 ${downstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
202 ... ${flow_vlan_pop_cmd}
203 Should Not Be Empty ${downstream_flow_0_added}
204 # Verify downstream table=1 flow
205 ${downstream_flow_1_cmd}= Catenate SEPARATOR=
206 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${c_tag} |
207 ... grep VLAN_ID:0 | grep OUTPUT:${onu_port}
208 ${downstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
209 ... ${downstream_flow_1_cmd}
210 Should Not Be Empty ${downstream_flow_1_added}
211 # Verify ipv4 dhcp upstream flow
212 ${upstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200213 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:ipv4 |
Andrea Campanella08678e12020-09-18 17:40:22 +0200214 ... grep IP_PROTO:17 | grep UDP_SRC:68 | grep UDP_DST:67 | grep VLAN_ID:${c_tag} |
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200215 ... grep OUTPUT:CONTROLLER
Hardik Windlass21807632020-04-14 16:24:55 +0530216 ${upstream_flow_ipv4_added}= Execute ONOS CLI Command ${ip} ${port}
217 ... ${upstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200218 Should Not Be Empty ${upstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530219 # Verify ipv4 dhcp downstream flow
220 # Note: This flow will be one per nni per olt
221 ${downstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200222 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep ETH_TYPE:ipv4 |
223 ... grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 | grep OUTPUT:CONTROLLER
Hardik Windlass21807632020-04-14 16:24:55 +0530224 ${downstream_flow_ipv4_added}= Execute ONOS CLI Command ${ip} ${port}
225 ... ${downstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200226 Should Not Be Empty ${downstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530227
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530228Verify Subscriber Access Flows Added for ONU DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530229 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530230 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
231 # Verify upstream table=0 flow
232 ${upstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530233 ... 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 +0530234 Should Not Be Empty ${upstream_flow_0_added}
235 # Verify upstream table=1 flow
236 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530237 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:Any |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530238 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
239 ${upstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
240 ... ${flow_vlan_push_cmd}
241 Should Not Be Empty ${upstream_flow_1_added}
242 # Verify downstream table=0 flow
243 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530244 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530245 ... grep VLAN_POP | grep transition=TABLE:1
246 ${downstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
247 ... ${flow_vlan_pop_cmd}
248 Should Not Be Empty ${downstream_flow_0_added}
249 # Verify downstream table=1 flow
250 ${downstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530251 ... 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 +0530252 Should Not Be Empty ${downstream_flow_1_added}
253
254Verify Subscriber Access Flows Added Count DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530255 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530256 [Documentation] Matches for total number of subscriber access flows added for all onus
257 ${access_flows_added}= Execute ONOS CLI Command ${ip} ${port}
Girish Gowdra89f73772021-03-08 14:29:36 -0800258 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep -v ETH_TYPE:lldp | grep -v ETH_TYPE:arp | wc -l
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530259 Should Be Equal As Integers ${access_flows_added} ${expected_flows}
260
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000261Verify Default Downstream Flows are added in ONOS for OLT TT
262 [Arguments] ${ip} ${port} ${olt_of_id} ${nni_port}
263 [Documentation] Verifies if the Default Downstream Flows are added in ONOS for the OLT
264 # Verify lldp flow
265 ${downstream_flow_lldp_cmd}= Catenate SEPARATOR=
266 ... flows -s ADDED ${olt_of_id} | grep lldp |
267 ... grep OUTPUT:CONTROLLER
268 ${downstream_flow_lldp_added}= Execute ONOS CLI Command ${ip} ${port}
269 ... ${downstream_flow_lldp_cmd}
270 Should Not Be Empty ${downstream_flow_lldp_added}
271 # Verify downstream dhcp flow
272 ${downstream_flow_dhcp_cmd}= Catenate SEPARATOR=
273 ... flows -s ADDED ${olt_of_id} | grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 |
274 ... grep OUTPUT:CONTROLLER
275 ${downstream_flow_dhcp_added}= Execute ONOS CLI Command ${ip} ${port}
276 ... ${downstream_flow_dhcp_cmd}
277 Should Not Be Empty ${downstream_flow_dhcp_added}
278 # Verify downstream igmp flow
279 ${downstream_flow_igmp_cmd}= Catenate SEPARATOR=
280 ... flows -s ADDED ${olt_of_id} | grep IP_PROTO:2 |
281 ... grep OUTPUT:CONTROLLER
282 ${downstream_flow_igmp_added}= Execute ONOS CLI Command ${ip} ${port}
283 ... ${downstream_flow_igmp_cmd}
284 Should Not Be Empty ${downstream_flow_igmp_added}
285
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530286Get Programmed Subscribers
287 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
288 [Documentation] Retrieves the subscriber details at a given location
289 ${sub_location}= Catenate SEPARATOR=/ ${olt_of_id} ${onu_port}
290 ${programmed_sub}= Execute ONOS CLI Command ${ip} ${port}
291 ... volt-programmed-subscribers | grep ${sub_location}
292 [Return] ${programmed_sub}
293
294Get Upstream and Downstream Bandwidth Profile Name
295 [Arguments] ${programmed_sub}
296 [Documentation] Retrieves the upstream and downstream bandwidth profile name
297 ... from the programmed subscriber
298 @{programmed_sub_array}= Split String ${programmed_sub} ,
299 # Get upstream bandwidth profile name for the subscriber
300 @{param_val_pair}= Split String ${programmed_sub_array[9]} =
301 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
302 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
303 ${us_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' upstreamBandwidthProfile'
304 ... Set Variable ${programmed_sub_val}
305 Log ${us_bw_profile}
306 # Get downstream bandwidth profile name for the subscriber
307 @{param_val_pair}= Split String ${programmed_sub_array[10]} =
308 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
309 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
310 ${ds_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' downstreamBandwidthProfile'
311 ... Set Variable ${programmed_sub_val}
312 Log ${ds_bw_profile}
313 [Return] ${us_bw_profile} ${ds_bw_profile}
314
315Get Bandwidth Profile Details
316 [Arguments] ${ip} ${port} ${bw_profile}
317 [Documentation] Retrieves the details of the given bandwidth profile
318 ${bw_profile_values}= Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
319 ... bandwidthprofile ${bw_profile}
320 @{bw_profile_array}= Split String ${bw_profile_values} ,
321 @{param_val_pair}= Split String ${bw_profile_array[1]} =
322 ${bw_param}= Set Variable ${param_val_pair[0]}
323 ${bw_val}= Set Variable ${param_val_pair[1]}
324 ${cir} Run Keyword If '${bw_param}' == ' committedInformationRate'
325 ... Set Variable ${bw_val}
326 @{param_val_pair}= Split String ${bw_profile_array[2]} =
327 ${bw_param}= Set Variable ${param_val_pair[0]}
328 ${bw_val}= Set Variable ${param_val_pair[1]}
329 ${cbs} Run Keyword If '${bw_param}' == ' committedBurstSize'
330 ... Set Variable ${bw_val}
331 @{param_val_pair}= Split String ${bw_profile_array[3]} =
332 ${bw_param}= Set Variable ${param_val_pair[0]}
333 ${bw_val}= Set Variable ${param_val_pair[1]}
334 ${eir} Run Keyword If '${bw_param}' == ' exceededInformationRate'
335 ... Set Variable ${bw_val}
336 @{param_val_pair}= Split String ${bw_profile_array[4]} =
337 ${bw_param}= Set Variable ${param_val_pair[0]}
338 ${bw_val}= Set Variable ${param_val_pair[1]}
339 ${ebs} Run Keyword If '${bw_param}' == ' exceededBurstSize'
340 ... Set Variable ${bw_val}
341 @{param_val_pair}= Split String ${bw_profile_array[5]} =
342 ${bw_param}= Set Variable ${param_val_pair[0]}
343 ${bw_val}= Set Variable ${param_val_pair[1]}
344 @{bw_val_air}= Split String ${bw_val} }
345 ${air} Run Keyword If '${bw_param}' == ' assuredInformationRate'
346 ... Set Variable ${bw_val_air[0]}
347 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
348
Hardik Windlassba5add42021-05-04 12:41:29 +0000349Get Bandwidth Profile Details Rest
350 [Arguments] ${bw_profile_id}
351 [Documentation] Retrieves the details of the given bandwidth profile using REST API
352 ${resp}= Get Request ONOS onos/sadis/bandwidthprofile/${bw_profile_id}
353 ${jsondata}= To Json ${resp.content}
354 Should Not Be Empty ${jsondata['entry']}
355 ${length}= Get Length ${jsondata['entry']}
356 ${matched}= Set Variable False
357 FOR ${INDEX} IN RANGE 0 ${length}
358 ${value}= Get From List ${jsondata['entry']} ${INDEX}
359 ${bw_id}= Get From Dictionary ${value} id
360 ${matched}= Set Variable If '${bw_id}' == '${bw_profile_id}' True False
361 ${eir}= Get From Dictionary ${value} eir
362 ${ebs}= Get From Dictionary ${value} ebs
363 ${cir}= Get From Dictionary ${value} cir
364 ${cbs}= Get From Dictionary ${value} cbs
365 ${air}= Get From Dictionary ${value} air
366 Exit For Loop If ${matched}
367 END
368 Should Be True ${matched} No bandwidth profile found for id: ${bw_profile_id}
369 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
370
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530371Verify Meters in ONOS
372 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
373 [Documentation] Verifies the meters
374 # Get programmed subscriber
375 ${programmed_sub}= Get Programmed Subscribers ${ip} ${port}
376 ... ${olt_of_id} ${onu_port}
377 Log ${programmed_sub}
378 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
379 ... ${programmed_sub}
380 # Get upstream bandwidth profile details
381 ${us_cir} ${us_cbs} ${us_eir} ${us_ebs} ${us_air} Get Bandwidth Profile Details
382 ... ${ip} ${port} ${us_bw_profile}
383 Sleep 1s
Andrea Campanella2b367102021-05-04 19:33:46 +0200384 ${us_pbs}= Evaluate ${us_cbs}+${us_ebs}
385 ${us_pir}= Evaluate ${us_eir}+${us_cir}+${us_air}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530386 # Verify meter for upstream bandwidth profile
387 ${us_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530388 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200389 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | grep "rate=${us_air}, burst-size=0" | wc -l
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530390 ${upstream_meter_added}= Execute ONOS CLI Command ${ip} ${port}
391 ... ${us_meter_cmd}
392 Should Be Equal As Integers ${upstream_meter_added} 1
393 Sleep 1s
394 # Get downstream bandwidth profile details
395 ${ds_cir} ${ds_cbs} ${ds_eir} ${ds_ebs} ${ds_air} Get Bandwidth Profile Details
396 ... ${ip} ${port} ${ds_bw_profile}
397 Sleep 1s
398 # Verify meter for downstream bandwidth profile
Andrea Campanella2b367102021-05-04 19:33:46 +0200399 ${ds_pbs}= Evaluate ${ds_cbs}+${ds_ebs}
400 ${ds_pir}= Evaluate ${ds_eir}+${ds_cir}+${ds_air}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530401 ${ds_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530402 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200403 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | grep "rate=${ds_air}, burst-size=0" | wc -l
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530404 ${downstream_meter_added}= Execute ONOS CLI Command ${ip} ${port}
405 ... ${ds_meter_cmd}
406 Should Be Equal As Integers ${downstream_meter_added} 1
407
408Verify Default Meter Present in ONOS
409 [Arguments] ${ip} ${port} ${olt_of_id}
410 [Documentation] Verifies the single default meter entry is present
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530411 # Get default bandwidth profile details
412 ${cir} ${cbs} ${eir} ${ebs} ${air} Get Bandwidth Profile Details
413 ... ${ip} ${port} 'Default'
414 Sleep 1s
Andrea Campanella2b367102021-05-04 19:33:46 +0200415 ${pbs}= Evaluate ${cbs}+${ebs}
416 ${pir}= Evaluate ${eir}+${cir}+${air}
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530417 # Verify meter for default bandwidth profile
418 ${meter_cmd}= Catenate SEPARATOR=
419 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${cir}, burst-size=${cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200420 ... | grep "rate=${pir}, burst-size=${pbs}" | grep "rate=${air}, burst-size=0" | wc -l
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530421 ${default_meter_added}= Execute ONOS CLI Command ${ip} ${port}
422 ... ${meter_cmd}
423 Should Be Equal As Integers ${default_meter_added} 1
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530424
Hardik Windlass480f3e22020-04-02 20:14:14 +0530425Verify Device Flows Removed
426 [Arguments] ${ip} ${port} ${olt_of_id}
427 [Documentation] Verifies all flows are removed from the device
428 ${device_flows}= Execute ONOS CLI Command ${ip} ${port}
429 ... flows -s -f ${olt_of_id} | grep -v deviceId | wc -l
430 Should Be Equal As Integers ${device_flows} 0
431
Kailash6f5acb62019-08-28 14:38:45 -0700432Verify Eapol Flows Added
Andy Bavierb0c06232019-08-29 12:58:53 -0700433 [Arguments] ${ip} ${port} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700434 [Documentation] Matches for number of eapol flows based on number of onus
Gilles Depatie675a2062019-10-22 12:44:42 -0400435 ${eapol_flows_added}= Execute ONOS CLI Command ${ip} ${port}
436 ... flows -s -f ADDED | grep eapol | grep IN_PORT | wc -l
Andy Bavierb0c06232019-08-29 12:58:53 -0700437 Should Contain ${eapol_flows_added} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700438
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800439Verify No Pending Flows For ONU
440 [Arguments] ${ip} ${port} ${onu_port}
441 [Documentation] Verifies that there are no flows "PENDING" state for the ONU in ONOS
442 ${pending_flows}= Execute ONOS CLI Command ${ip} ${port}
443 ... flows -s | grep IN_PORT:${onu_port} | grep PENDING
444 Should Be Empty ${pending_flows}
445
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700446Verify Eapol Flows Added For ONU
447 [Arguments] ${ip} ${port} ${onu_port}
448 [Documentation] Verifies if the Eapol Flows are added in ONOS for the ONU
Gilles Depatie675a2062019-10-22 12:44:42 -0400449 ${eapol_flows_added}= Execute ONOS CLI Command ${ip} ${port}
450 ... flows -s -f ADDED | grep eapol | grep IN_PORT:${onu_port}
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700451 Should Not Be Empty ${eapol_flows_added}
452
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800453Verify ONU Port Is Enabled
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700454 [Arguments] ${ip} ${port} ${onu_name}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800455 [Documentation] Verifies if the ONU port is enabled in ONOS
456 ${onu_port_enabled}= Execute ONOS CLI Command ${ip} ${port}
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700457 ... ports -e | grep portName=${onu_name}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800458 Log ${onu_port_enabled}
459 Should Not Be Empty ${onu_port_enabled}
460
Hardik Windlass63d5e002020-03-06 21:07:09 +0530461Verify ONU Port Is Disabled
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700462 [Arguments] ${ip} ${port} ${onu_name}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530463 [Documentation] Verifies if the ONU port is disabled in ONOS
464 ${onu_port_disabled}= Execute ONOS CLI Command ${ip} ${port}
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700465 ... ports -e | grep portName=${onu_name}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530466 Log ${onu_port_disabled}
467 Should Be Empty ${onu_port_disabled}
468
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700469Verify ONU in AAA-Users
470 [Arguments] ${ip} ${port} ${onu_port}
471 [Documentation] Verifies that the specified onu_port exists in aaa-users output
472 ${aaa_users}= Execute ONOS CLI Command ${ip} ${port} aaa-users | grep AUTHORIZED | grep ${onu_port}
473 Should Not Be Empty ${aaa_users} ONU port ${onu_port} not found in aaa-users
474
Hardik Windlass513afd12021-02-03 15:19:46 +0000475Verify Empty Group in ONOS
476 [Documentation] Verifies zero group count on the device
477 [Arguments] ${onos_ssh_connection} ${deviceId}
478 ${groups}= Execute ONOS CLI Command on open connection ${onos_ssh_connection} groups | grep ${deviceId}
479 @{groups_arr}= Split String ${groups} ,
480 @{group_count_arr}= Split String ${groups_arr[1]} =
481 ${group_count}= Set Variable ${group_count_arr[1]}
482 Should Be Equal As Integers ${group_count} 0
483
484Verify ONUs in Group Count in ONOS
485 [Documentation] Verifies there exists a group bucket list with certain entries/count
486 ... Note: Currently, this validates only if all ONUs of an OLT joined the same igmp group
487 [Arguments] ${onos_ssh_connection} ${count} ${deviceId}
Matteo Scandolofd36e212021-03-02 11:36:10 -0800488 ${result}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
489 ... groups added ${deviceId} | grep bucket | wc -l
490 Should Be Equal As Integers ${result} ${count} Bucket list count for a group: Found=${result} Expected=${count}
Hardik Windlass513afd12021-02-03 15:19:46 +0000491
492Verify ONU in Group Bucket
493 [Documentation] Matches if ONU port in Group Bucket
494 [Arguments] ${group_bucket_values} ${onu_port}
495 ${len}= Get Length ${group_bucket_values}
496 ${matched}= Set Variable False
497 FOR ${INDEX} IN RANGE 0 ${len}
498 ${value_bucket}= Get From List ${group_bucket_values} ${INDEX}
499 ${treatment}= Get From Dictionary ${value_bucket} treatment
500 ${instructions}= Get From Dictionary ${treatment} instructions
501 ${instructions_val}= Get From List ${instructions} 0
502 ${port}= Get From Dictionary ${instructions_val} port
503 ${matched}= Set Variable If '${port}'=='${onu_port}' True False
504 Exit For Loop If ${matched}
505 END
506 [Return] ${matched}
507
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700508Verify ONU in Groups
509 [Arguments] ${ip_onos} ${port_onos} ${deviceId} ${onu_port} ${group_exist}=True
510 [Documentation] Verifies that the specified onu_port exists in groups output
511 ${result}= Execute ONOS CLI Command ${ip_onos} ${port_onos} groups -j
512 Log Groups: ${result}
513 ${groups}= To Json ${result}
514 ${length}= Get Length ${groups}
515 ${buckets}= Create List
516 ${matched}= Set Variable False
517 FOR ${INDEX} IN RANGE 0 ${length}
518 ${value}= Get From List ${groups} ${INDEX}
519 ${devId}= Get From Dictionary ${value} deviceId
520 ${bucket}= Get From Dictionary ${value} buckets
521 Run Keyword If '${devId}'=='${deviceId}'
522 ... Append To List ${buckets} ${bucket}
523 END
524 ${bucket_len}= Get Length ${buckets}
Hardik Windlass513afd12021-02-03 15:19:46 +0000525 FOR ${INDEX_1} IN RANGE 0 ${bucket_len}
526 ${value}= Get From List ${buckets} ${INDEX_1}
527 ${matched}= Verify ONU in Group Bucket ${value} ${onu_port}
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700528 Exit For Loop If ${matched}
529 END
530 Run Keyword If ${group_exist}
531 ... Should Be True ${matched} No match for ${deviceId} and ${onu_port} found in ONOS groups
532 ... ELSE
533 ... Should Be True '${matched}'=='False' Match for ${deviceId} and ${onu_port} found in ONOS groups
534
Matteo Scandolo142e6272020-04-29 17:36:59 -0700535Assert Number of AAA-Users
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800536 [Arguments] ${onos_ssh_connection} ${expected_onus} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700537 [Documentation] Matches for number of aaa-users authorized based on number of onus
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700538 ${aaa_users}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800539 ... aaa-users | grep ${deviceId} | grep AUTHORIZED | wc -l
540 Log Found ${aaa_users} of ${expected_onus} expected authenticated users on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700541 Should Be Equal As Integers ${aaa_users} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700542
543Validate DHCP Allocations
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800544 [Arguments] ${onos_ssh_connection} ${count} ${workflow} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700545 [Documentation] Matches for number of dhcpacks based on number of onus
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700546 ${allocations}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800547 ... dhcpl2relay-allocations | grep ${deviceId} | grep DHCPACK | wc -l
Matteo Scandoloda854b02020-09-01 16:20:51 -0700548 # if the workflow is TT we'll have 2 allocations for each ONU
549 ${ttAllocations}= Evaluate (${count} * 2)
550 ${count}= Set Variable If $workflow=='tt' ${ttAllocations} ${count}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800551 Log Found ${allocations} of ${count} expected DHCPACK on device ${deviceId}
Matteo Scandoloda854b02020-09-01 16:20:51 -0700552 Should Be Equal As Integers ${allocations} ${count}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700553
554Validate Subscriber DHCP Allocation
Suchitra Vemuri42819412020-10-01 17:45:43 -0700555 [Arguments] ${ip} ${port} ${onu_port} ${vlan}=''
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700556 [Documentation] Verifies that the specified subscriber is found in DHCP allocations
557 ##TODO: Enhance the keyword to include DHCP allocated address is not 0.0.0.0
Gilles Depatie675a2062019-10-22 12:44:42 -0400558 ${allocations}= Execute ONOS CLI Command ${ip} ${port}
Suchitra Vemuri42819412020-10-01 17:45:43 -0700559 ... dhcpl2relay-allocations | grep DHCPACK | grep ${onu_port} | grep ${vlan}
Gilles Depatie675a2062019-10-22 12:44:42 -0400560 Should Not Be Empty ${allocations} ONU port ${onu_port} not found in dhcpl2relay-allocations
David Bainbridgef81cd642019-11-20 00:14:47 +0000561
562Device Is Available In ONOS
563 [Arguments] ${url} ${dpid}
564 [Documentation] Validates the device exists and it available in ONOS
565 ${rc} ${json} Run And Return Rc And Output curl --fail -sSL ${url}/onos/v1/devices/${dpid}
566 Should Be Equal As Integers 0 ${rc}
567 ${rc} ${value} Run And Return Rc And Output echo '${json}' | jq -r .available
568 Should Be Equal As Integers 0 ${rc}
569 Should Be Equal 'true' '${value}'
570
571Remove All Devices From ONOS
572 [Arguments] ${url}
573 [Documentation] Executes the device-remove command on each device in ONOS
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000574 ${rc} ${output} Run And Return Rc And Output
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700575 ... curl --fail -sSL ${url}/onos/v1/devices | jq -r '.devices[].id'
David Bainbridgef81cd642019-11-20 00:14:47 +0000576 Should Be Equal As Integers ${rc} 0
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000577 @{dpids} Split String ${output}
David Bainbridgef81cd642019-11-20 00:14:47 +0000578 ${count}= Get length ${dpids}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700579 FOR ${dpid} IN @{dpids}
580 ${rc}= Run Keyword If '${dpid}' != ''
581 ... Run And Return Rc curl -XDELETE --fail -sSL ${url}/onos/v1/devices/${dpid}
582 Run Keyword If '${dpid}' != ''
583 ... Should Be Equal As Integers ${rc} 0
584 END
Matteo Scandolo142e6272020-04-29 17:36:59 -0700585
TorstenThieme440b7c02020-12-18 15:42:57 +0000586Assert ONU Port Is Disabled
587 [Arguments] ${onos_ssh_connection} ${deviceId} ${onu_port}
588 [Documentation] Verifies if the ONU port is disabled in ONOS
589 ${onu_port_disabled}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
590 ... ports -d ${deviceId} | grep port=${onu_port}
591 Log ${onu_port_disabled}
592 Should Not Be Empty ${onu_port_disabled}
593
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700594Assert Olts in ONOS
595 [Arguments] ${onos_ssh_connection} ${count}
596 [Documentation] Check that a certain number of olts are known to ONOS
597 ${olts}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
598 ... volt-olts | wc -l
599 Log Found ${olts} of ${count} expected Olts
600 Should Be Equal As Integers ${olts} ${count}
601
602Wait for Olts in ONOS
603 [Arguments] ${onos_ssh_connection} ${count} ${max_wait_time}=10m
604 [Documentation] Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
605 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Olts in ONOS
606 ... ${onos_ssh_connection} ${count}
607
Matteo Scandolo142e6272020-04-29 17:36:59 -0700608Assert Ports in ONOS
TorstenThiemed4f48962020-12-08 12:17:19 +0000609 [Arguments] ${onos_ssh_connection} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700610 [Documentation] Check that a certain number of ports are enabled in ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700611 ${ports}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800612 ... ports -e ${deviceId} | grep ${filter} | wc -l
613 Log Found ${ports} of ${count} expected ports on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700614 Should Be Equal As Integers ${ports} ${count}
615
616Wait for Ports in ONOS
TorstenThiemed4f48962020-12-08 12:17:19 +0000617 [Arguments] ${onos_ssh_connection} ${count} ${deviceId} ${filter} ${max_wait_time}=10m
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800618 [Documentation] Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
TorstenThiemed4f48962020-12-08 12:17:19 +0000619 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Ports in ONOS
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800620 ... ${onos_ssh_connection} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700621
622Wait for AAA Authentication
TorstenThiemed4f48962020-12-08 12:17:19 +0000623 [Arguments] ${onos_ssh_connection} ${count} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700624 [Documentation] Waits untill a certain number of subscribers are authenticated in ONOS
TorstenThiemed4f48962020-12-08 12:17:19 +0000625 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Number of AAA-Users
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800626 ... ${onos_ssh_connection} ${count} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700627
628Wait for DHCP Ack
TorstenThiemed4f48962020-12-08 12:17:19 +0000629 [Arguments] ${onos_ssh_connection} ${count} ${workflow} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700630 [Documentation] Waits untill a certain number of subscribers have received a DHCP_ACK
TorstenThiemed4f48962020-12-08 12:17:19 +0000631 Wait Until Keyword Succeeds ${max_wait_time} 5s Validate DHCP Allocations
632 ... ${onos_ssh_connection} ${count} ${workflow} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700633
634Provision subscriber
635 [Documentation] Calls volt-add-subscriber-access in ONOS
636 [Arguments] ${onos_ip} ${onos_port} ${of_id} ${onu_port}
637 Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
638 ... volt-add-subscriber-access ${of_id} ${onu_port}
639
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700640Provision subscriber REST
641 [Documentation] Uses the rest APIs to provision a subscriber
642 [Arguments] ${onos_ip} ${onos_port} ${of_id} ${onu_port}
643 ${resp}= Post Request ONOS
644 ... /onos/olt/oltapp/${of_id}/${onu_port}
645 Should Be Equal As Strings ${resp.status_code} 200
646
647
Matteo Scandolo142e6272020-04-29 17:36:59 -0700648List Enabled UNI Ports
649 [Documentation] List all the UNI Ports, the only way we have is to filter out the one called NNI
650 ... Creates a list of dictionaries
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700651 [Arguments] ${onos_ssh_connection} ${of_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700652 [Return] [{'port': '16', 'of_id': 'of:00000a0a0a0a0a00'}, {'port': '32', 'of_id': 'of:00000a0a0a0a0a00'}]
653 ${result}= Create List
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700654 ${out}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700655 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000656 @{unis}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700657 FOR ${uni} IN @{unis}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000658 ${matches} = Get Regexp Matches ${uni} .*port=([0-9]+),.* 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700659 &{portDict} Create Dictionary of_id=${of_id} port=${matches[0]}
660 Append To List ${result} ${portDict}
661 END
662 Log ${result}
663 Return From Keyword ${result}
664
665Provision all subscribers on device
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700666 [Documentation] Provisions a subscriber in ONOS for all the enabled UNI ports on a particular device
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700667 [Arguments] ${onos_ssh_connection} ${onos_ip} ${onos_rest_port} ${of_id}
668 ${unis}= List Enabled UNI Ports ${onos_ssh_connection} ${of_id}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700669 ${onos_auth}= Create List karaf karaf
670 Create Session ONOS http://${onos_ip}:${onos_rest_port} auth=${onos_auth}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700671 FOR ${uni} IN @{unis}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700672 Provision Subscriber REST ${onos_ip} ${onos_rest_port} ${uni['of_id']} ${uni['port']}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700673 END
674
675List OLTs
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800676 # NOTE this method is not currently used but it can come useful in the future
677 [Documentation] Returns a list of all OLTs known to ONOS
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700678 [Arguments] ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700679 [Return] ['of:00000a0a0a0a0a00', 'of:00000a0a0a0a0a01']
680 ${result}= Create List
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700681 ${out}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700682 ... volt-olts
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000683 @{olts}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700684 FOR ${olt} IN @{olts}
685 Log ${olt}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000686 ${matches} = Get Regexp Matches ${olt} ^OLT (.+)$ 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700687 # there may be some logs mixed with the output so only append if we have a match
688 ${matches_length}= Get Length ${matches}
689 Run Keyword If ${matches_length}==1
690 ... Append To List ${result} ${matches[0]}
691 END
692 Return From Keyword ${result}
693
694Count ADDED flows
695 [Documentation] Count the flows in ADDED state in ONOS
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800696 [Arguments] ${onos_ssh_connection} ${targetFlows} ${deviceId}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700697 ${flows}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800698 ... flows -s any ${deviceId} | grep ADDED | wc -l
699 Log Found ${flows} of ${targetFlows} expected flows on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700700 Should Be Equal As Integers ${targetFlows} ${flows}
701
702Wait for all flows to in ADDED state
703 [Documentation] Waits until the flows have been provisioned
TorstenThiemeb198c482020-12-14 19:45:23 +0000704 [Arguments] ${onos_ssh_connection} ${deviceId} ${workflow} ${uni_count} ${olt_count}
705 ... ${provisioned} ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700706 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200707 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700708 Wait Until Keyword Succeeds 10m 5s Count ADDED flows
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800709 ... ${onos_ssh_connection} ${targetFlows} ${deviceId}
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000710
Girish Gowdrad769b412021-05-16 11:09:46 -0700711Get Limiting Bandwidth Details
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000712 [Arguments] ${bandwidth_profile_name}
713 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
714 ... returns the limiting bandwidth
Girish Gowdrad769b412021-05-16 11:09:46 -0700715 ${cir} ${cbs} ${eir} ${ebs} ${air} Get Bandwidth Profile Details
716 ... ${ONOS_SSH_IP} ${ONOS_SSH_PORT} ${bandwidth_profile_name}
717 ${limiting_BW}= Evaluate ${eir}+${cir}+${air}
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000718 [Return] ${limiting_BW}
Hardik Windlasse8b99222021-01-25 10:03:14 +0000719
720Validate Deleted Device Cleanup In ONOS
721 [Arguments] ${ip} ${port} ${olt_serial_number}
722 [Documentation] The keyword verifies that ports, flows, meters, subscribers, dhcp are all cleared in ONOS
723 # Fetch OF Id for OLT
724 ${olt_of_id}= Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device in ONOS ${olt_serial_number}
725 # Open ONOS SSH Connection
726 ${onos_ssh_connection} Open ONOS SSH Connection ${ip} ${port}
727 # Verify Ports are Removed
728 ${port_count}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
729 ... ports ${olt_of_id} | grep -v ${olt_of_id} | wc -l
730 Should Be Equal As Integers ${port_count} 0
731 # Verify Subscribers are Removed
732 ${sub_count}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
733 ... volt-programmed-subscribers | grep ${olt_of_id} | wc -l
734 Should Be Equal As Integers ${sub_count} 0
735 # Verify Flows are Removed
736 ${flow_count}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
737 ... flows -s -f ${olt_of_id} | grep -v deviceId | wc -l
738 Should Be Equal As Integers ${flow_count} 0
739 # Verify Meters are Removed
740 ${meter_count}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
741 ... meters ${olt_of_id} | wc -l
742 Should Be Equal As Integers ${meter_count} 0
743 # Verify AAA-Users are Removed
744 ${aaa_count}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
745 ... aaa-users ${olt_of_id} | wc -l
746 Should Be Equal As Integers ${aaa_count} 0
747 # Verify Dhcp-Allocations are Removed
748 ${dhcp_count}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
749 ... dhcpl2relay-allocations ${olt_of_id} | wc -l
750 Should Be Equal As Integers ${dhcp_count} 0
751 # Close ONOS SSH Connection
752 Close ONOS SSH Connection ${onos_ssh_connection}
Hardik Windlassdd1a9a12021-02-23 15:34:50 +0000753
754Delete ONOS App
755 [Arguments] ${url} ${app_name}
756 [Documentation] This keyword deactivates and uninstalls the given ONOS App
757 ${rc}= Run And Return Rc curl --fail -sSL -X DELETE ${url}/onos/v1/applications/${app_name}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -0700758 Should Be Equal As Integers ${rc} 0 Can't delete ${app_name} from ONOS
Hardik Windlassdd1a9a12021-02-23 15:34:50 +0000759
760Verify ONOS App Active
761 [Arguments] ${url} ${app_name} ${app_version}=${EMPTY}
762 [Documentation] This keyword verifies that the given ONOS App status is Active
763 ${rc} ${output} Run And Return Rc And Output
764 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name} | jq -r .state
765 Should Be Equal As Integers ${rc} 0
766 Should Be Equal '${output}' 'ACTIVE'
767 ${rc1} ${output1} Run And Return Rc And Output
768 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name} | jq -r .version
769 Run Keyword If '${app_version}'!='${EMPTY}'
770 ... Run Keywords
Matteo Scandolo2769d2b2021-04-14 10:29:24 -0700771 ... Should Be Equal As Integers ${rc1} 0 Can't read app ${app_name} status from ONOS
Hardik Windlassdd1a9a12021-02-23 15:34:50 +0000772 ... AND Should Be Equal '${output1}' '${app_version}'
773
774Install And Activate ONOS App
775 [Arguments] ${url} ${app_oar_file}
776 [Documentation] This keyword installs and activates the given ONOS App
777 ${cmd}= Catenate SEPARATOR=
778 ... curl --fail -sSL -H Content-Type:application/octet-stream -
779 ... X POST ${url}/onos/v1/applications?activate=true --data-binary \@${app_oar_file}
780 ${rc} ${output} Run And Return Rc And Output ${cmd}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -0700781 Should Be Equal As Integers ${rc} 0 Can't load onos app ${app_oar_file} to ONOS"
Hardik Windlassdd1a9a12021-02-23 15:34:50 +0000782 Log ${output}
Hardik Windlassdc2610f2021-03-09 07:33:51 +0000783
784Get ONOS App Details
785 [Arguments] ${url} ${app_name}
786 [Documentation] Retrieves ONOS App Details
787 ${rc} ${output} Run And Return Rc And Output
788 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -0700789 Should Be Equal As Integers ${rc} 0 Can't read app ${app_name} details from ONOS
Hardik Windlassdc2610f2021-03-09 07:33:51 +0000790 [Return] ${output}