blob: f1884ef060b0db943dfca5fc9faff72955315add [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
TorstenThieme4e2168e2021-06-22 14:01:47 +000043Execute ONOS CLI Command use single connection
44 [Documentation] Execute ONOS CLI Command use an Open Connection
45 ... In case no connection is open a connection will be opened
46 [Arguments] ${host} ${port} ${cmd}
47 ${connection_list_id}= Get Conn List Id ${host} ${port}
48 ${connection_list_id}= Run Keyword If "${connection_list_id}"=="${EMPTY}"
49 ... Open ONOS SSH Connection ${host} ${port}
50 ... ELSE Set Variable ${connection_list_id}
51 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
52 SSHLibrary.Switch Connection ${connection_entry.conn_id}
53 ${PassOrFail} @{result_values} Run Keyword And Ignore Error SSHLibrary.Execute Command ${cmd}
54 ... return_rc=True return_stderr=True return_stdout=True
55 Run Keyword If '${PassOrFail}'=='FAIL' Reconnect ONOS SSH Connection ${connection_list_id}
56 @{result_values}= Run Keyword If '${PassOrFail}'=='FAIL'
57 ... SSHLibrary.Execute Command ${cmd} return_rc=True return_stderr=True return_stdout=True
58 ... ELSE Set Variable @{result_values}
59 ${output} Set Variable @{result_values}[0]
60 Log Command output: ${output}
61 Should Be Empty @{result_values}[1]
62 Should Be Equal As Integers @{result_values}[2] 0
63 [Return] ${output}
64
65Get Conn List Id
66 [Documentation] Looks up for an Open Connection with passed host and port in conection list
67 ... First match connection will be used.
68 [Arguments] ${host} ${port}
69 ${connection_list_id}= Set Variable ${EMPTY}
70 ${match}= Set Variable False
71 ${length}= Get Length ${connection_list}
72 FOR ${INDEX} IN RANGE 0 ${length}
73 #${Item}= Get From List ${connection_list} ${INDEX}
74 ${conndata}= Get Connection ${connection_list[${INDEX}].conn_id}
75 ${match}= Set Variable If '${conndata.host}'=='${host}' and '${conndata.port}'=='${port}' True False
76 ${connection_list_id}= Set Variable If ${match} ${INDEX} ${EMPTY}
77 Exit For Loop If ${match}
78 END
79 [Return] ${connection_list_id}
80
TorstenThiemeb198c482020-12-14 19:45:23 +000081Reconnect ONOS SSH Connection
82 [Documentation] Reconnect an SSH Connection
83 [Arguments] ${connection_list_id}
84 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
85 ${user}= Get From Dictionary ${connection_entry} user
86 ${pass}= Get From Dictionary ${connection_entry} pass
87 ${oldconndata}= Get Connection ${connection_entry.conn_id}
88 SSHLibrary.Switch Connection ${connection_entry.conn_id}
TorstenThiemebcf14612021-01-27 10:19:18 +000089 Run Keyword And Ignore Error SSHLibrary.Close Connection
TorstenThiemeb198c482020-12-14 19:45:23 +000090 ${conn_id}= SSHLibrary.Open Connection ${oldconndata.host} port=${oldconndata.port}
91 ... timeout=300s alias=ONOS_SSH
92 SSHLibrary.Login ${user} ${pass}
93 ${conn_list_entry}= Create Dictionary conn_id=${conn_id} user=${user} pass=${pass}
94 Set List Value ${connection_list} ${connection_list_id} ${conn_list_entry}
95 Set Global Variable ${connection_list}
96
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070097Close ONOS SSH Connection
98 [Documentation] Close an SSH Connection
TorstenThiemeb198c482020-12-14 19:45:23 +000099 [Arguments] ${connection_list_id}
100 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
101 ${connection_alias}= Get From Dictionary ${connection_entry} conn_id
102 ${oldconndata}= Get Connection ${connection_entry.conn_id}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700103 SSHLibrary.Switch Connection ${connection_alias}
TorstenThiemebcf14612021-01-27 10:19:18 +0000104 Run Keyword And Ignore Error SSHLibrary.Close Connection
TorstenThiemeb198c482020-12-14 19:45:23 +0000105 Remove From List ${connection_list} ${connection_list_id}
106 Set Global Variable ${connection_list}
107
108Close All ONOS SSH Connections
109 [Documentation] Close all SSH Connection and clear connection list.
110 SSHLibrary.Close All Connections
111 @{connection_list} Create List
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700112
Kailash6f5acb62019-08-28 14:38:45 -0700113Validate OLT Device in ONOS
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700114 # FIXME use volt-olts to check that the OLT is ONOS
Kailash6f5acb62019-08-28 14:38:45 -0700115 [Arguments] ${serial_number}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700116 [Documentation] Checks if olt has been connected to ONOS
Kailash6f5acb62019-08-28 14:38:45 -0700117 ${resp}= Get Request ONOS onos/v1/devices
118 ${jsondata}= To Json ${resp.content}
119 Should Not Be Empty ${jsondata['devices']}
120 ${length}= Get Length ${jsondata['devices']}
121 @{serial_numbers}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -0700122 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700123 FOR ${INDEX} IN RANGE 0 ${length}
124 ${value}= Get From List ${jsondata['devices']} ${INDEX}
125 ${of_id}= Get From Dictionary ${value} id
126 ${sn}= Get From Dictionary ${value} serial
Andy Bavierb63f6d22020-03-12 15:34:37 -0700127 ${matched}= Set Variable If '${sn}' == '${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 ${serial_number} found
Kailash57210eb2019-08-30 13:27:19 -0700131 [Return] ${of_id}
Kailash6f5acb62019-08-28 14:38:45 -0700132
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700133Get ONU Port in ONOS
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000134 [Arguments] ${onu_serial_number} ${olt_of_id} ${onu_uni_id}=1
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700135 [Documentation] Retrieves ONU port for the ONU in ONOS
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000136 ${onu_serial_number}= Catenate SEPARATOR=- ${onu_serial_number} ${onu_uni_id}
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700137 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
138 ${jsondata}= To Json ${resp.content}
139 Should Not Be Empty ${jsondata['ports']}
140 ${length}= Get Length ${jsondata['ports']}
141 @{ports}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -0700142 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700143 FOR ${INDEX} IN RANGE 0 ${length}
144 ${value}= Get From List ${jsondata['ports']} ${INDEX}
145 ${annotations}= Get From Dictionary ${value} annotations
146 ${onu_port}= Get From Dictionary ${value} port
147 ${portName}= Get From Dictionary ${annotations} portName
Andy Bavierb63f6d22020-03-12 15:34:37 -0700148 ${matched}= Set Variable If '${portName}' == '${onu_serial_number}' True False
149 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700150 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700151 Should Be True ${matched} No match for ${onu_serial_number} found
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700152 [Return] ${onu_port}
153
TorstenThieme9b25aab2021-12-16 15:59:45 +0000154Get Onu Ports in ONOS For ALL UNI per ONU
155 [Documentation] Retrieves ONU port(s) for the ONU in ONOS for all UNI-IDs, list of ports will return!
156 [Arguments] ${onu_serial_number} ${olt_of_id}
157 @{uni_id_list}= Create List
158 @{port_list}= Create List
159 FOR ${I} IN RANGE 0 ${num_all_onus}
160 ${src}= Set Variable ${hosts.src[${I}]}
161 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
162 ${uni_id}= Set Variable ${src['uni_id']}
163 # make sure all actions do only once per uni_id
164 ${id}= Get Index From List ${uni_id_list} ${uni_id}
165 Continue For Loop If -1 != ${id}
166 Append To List ${uni_id_list} ${uni_id}
167 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${onu_serial_number}
168 ... ${olt_of_id} ${uni_id}
169 Append To List ${port_list} ${onu_port}
170 END
171 [return] ${port_list}
172
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530173Get NNI Port in ONOS
174 [Arguments] ${olt_of_id}
175 [Documentation] Retrieves NNI port for the OLT in ONOS
176 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
177 ${jsondata}= To Json ${resp.content}
178 Should Not Be Empty ${jsondata['ports']}
179 ${length}= Get Length ${jsondata['ports']}
180 @{ports}= Create List
181 ${matched}= Set Variable False
182 FOR ${INDEX} IN RANGE 0 ${length}
183 ${value}= Get From List ${jsondata['ports']} ${INDEX}
184 ${annotations}= Get From Dictionary ${value} annotations
185 ${nni_port}= Get From Dictionary ${value} port
186 ${nniPortName}= Catenate SEPARATOR= nni- ${nni_port}
187 ${portName}= Get From Dictionary ${annotations} portName
188 ${matched}= Set Variable If '${portName}' == '${nniPortName}' True False
189 Exit For Loop If ${matched}
190 END
191 Should Be True ${matched} No match for NNI found for ${olt_of_id}
192 [Return] ${nni_port}
193
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700194Get FabricSwitch in ONOS
195 [Documentation] Returns of_id of the Fabric Switch in ONOS
196 ${resp}= Get Request ONOS onos/v1/devices
197 ${jsondata}= To Json ${resp.content}
198 Should Not Be Empty ${jsondata['devices']}
199 ${length}= Get Length ${jsondata['devices']}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700200 ${matched}= Set Variable False
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700201 FOR ${INDEX} IN RANGE 0 ${length}
202 ${value}= Get From List ${jsondata['devices']} ${INDEX}
203 ${of_id}= Get From Dictionary ${value} id
204 ${type}= Get From Dictionary ${value} type
Andy Bavierb63f6d22020-03-12 15:34:37 -0700205 ${matched}= Set Variable If '${type}' == "SWITCH" True False
206 Exit For Loop If ${matched}
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700207 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700208 Should Be True ${matched} No fabric switch found
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700209 [Return] ${of_id}
210
Andrea Campanella4c404632020-08-26 14:41:36 +0200211Get Master Instace in ONOS
212 [Arguments] ${of_id}
213 [Documentation] Returns nodeId of the Master instace for a giver device in ONOS
214 ${resp}= Get Request ONOS onos/v1/mastership/${of_id}/master
215 ${jsondata}= To Json ${resp.content}
216 Should Not Be Empty ${jsondata['nodeId']}
217 ${master_node}= Get From Dictionary ${jsondata} nodeId
218 [Return] ${master_node}
219
Matteo Scandolo7bdbe2d2021-11-29 15:48:25 -0800220Verify LLDP Flow Added
221 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
222 [Documentation] Matches for total number of LLDP flows added for one OLT
223 ${lldp_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
224 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep ETH_TYPE:lldp | grep -v ETH_TYPE:arp
225 ${lldp_flows_added_count}= Get Line Count ${lldp_flows_added}
226 Should Be Equal As Integers ${lldp_flows_added_count} ${expected_flows}
227
Hardik Windlass21807632020-04-14 16:24:55 +0530228Verify Subscriber Access Flows Added for ONU
229 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${c_tag} ${s_tag}
230 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
231 # Verify upstream table=0 flow
232 ${upstream_flow_0_cmd}= Catenate SEPARATOR=
233 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:0 |
234 ... grep VLAN_ID:${c_tag} | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000235 ${upstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530236 ... ${upstream_flow_0_cmd}
237 Should Not Be Empty ${upstream_flow_0_added}
238 # Verify upstream table=1 flow
239 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
240 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
241 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000242 ${upstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530243 ... ${flow_vlan_push_cmd}
244 Should Not Be Empty ${upstream_flow_1_added}
245 # Verify downstream table=0 flow
246 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
247 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
248 ... grep VLAN_POP | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000249 ${downstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530250 ... ${flow_vlan_pop_cmd}
251 Should Not Be Empty ${downstream_flow_0_added}
252 # Verify downstream table=1 flow
253 ${downstream_flow_1_cmd}= Catenate SEPARATOR=
254 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${c_tag} |
255 ... grep VLAN_ID:0 | grep OUTPUT:${onu_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000256 ${downstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530257 ... ${downstream_flow_1_cmd}
258 Should Not Be Empty ${downstream_flow_1_added}
259 # Verify ipv4 dhcp upstream flow
260 ${upstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200261 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:ipv4 |
Andrea Campanella08678e12020-09-18 17:40:22 +0200262 ... grep IP_PROTO:17 | grep UDP_SRC:68 | grep UDP_DST:67 | grep VLAN_ID:${c_tag} |
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200263 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000264 ${upstream_flow_ipv4_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530265 ... ${upstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200266 Should Not Be Empty ${upstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530267 # Verify ipv4 dhcp downstream flow
268 # Note: This flow will be one per nni per olt
269 ${downstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200270 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep ETH_TYPE:ipv4 |
271 ... grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 | grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000272 ${downstream_flow_ipv4_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530273 ... ${downstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200274 Should Not Be Empty ${downstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530275
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530276Verify Subscriber Access Flows Added for ONU DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530277 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530278 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
279 # Verify upstream table=0 flow
TorstenThieme4e2168e2021-06-22 14:01:47 +0000280 ${upstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530281 ... 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 +0530282 Should Not Be Empty ${upstream_flow_0_added}
283 # Verify upstream table=1 flow
284 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530285 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:Any |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530286 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000287 ${upstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530288 ... ${flow_vlan_push_cmd}
289 Should Not Be Empty ${upstream_flow_1_added}
290 # Verify downstream table=0 flow
291 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530292 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530293 ... grep VLAN_POP | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000294 ${downstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530295 ... ${flow_vlan_pop_cmd}
296 Should Not Be Empty ${downstream_flow_0_added}
297 # Verify downstream table=1 flow
TorstenThieme4e2168e2021-06-22 14:01:47 +0000298 ${downstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530299 ... 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 +0530300 Should Not Be Empty ${downstream_flow_1_added}
301
302Verify Subscriber Access Flows Added Count DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530303 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530304 [Documentation] Matches for total number of subscriber access flows added for all onus
TorstenThieme4e2168e2021-06-22 14:01:47 +0000305 ${access_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700306 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep -v ETH_TYPE:lldp | grep -v ETH_TYPE:arp
307 ${access_flows_added_count}= Get Line Count ${access_flows_added}
308 Should Be Equal As Integers ${access_flows_added_count} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530309
Huseyin Ahmet AYDIN45922c82021-05-27 12:37:32 +0000310Verify Added Flow Count for OLT TT
311 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
312 [Documentation] Total number of added flows given OLT with subscriber flows
TorstenThieme4e2168e2021-06-22 14:01:47 +0000313 ${access_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700314 ... flows -s ADDED ${olt_of_id} | grep -v deviceId
315 ${access_flows_added_count}= Get Line Count ${access_flows_added}
316 Should Be Equal As Integers ${access_flows_added_count} ${expected_flows}
Huseyin Ahmet AYDIN45922c82021-05-27 12:37:32 +0000317
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000318Verify Default Downstream Flows are added in ONOS for OLT TT
319 [Arguments] ${ip} ${port} ${olt_of_id} ${nni_port}
320 [Documentation] Verifies if the Default Downstream Flows are added in ONOS for the OLT
321 # Verify lldp flow
322 ${downstream_flow_lldp_cmd}= Catenate SEPARATOR=
323 ... flows -s ADDED ${olt_of_id} | grep lldp |
324 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000325 ${downstream_flow_lldp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000326 ... ${downstream_flow_lldp_cmd}
327 Should Not Be Empty ${downstream_flow_lldp_added}
328 # Verify downstream dhcp flow
329 ${downstream_flow_dhcp_cmd}= Catenate SEPARATOR=
330 ... flows -s ADDED ${olt_of_id} | grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 |
331 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000332 ${downstream_flow_dhcp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000333 ... ${downstream_flow_dhcp_cmd}
334 Should Not Be Empty ${downstream_flow_dhcp_added}
335 # Verify downstream igmp flow
336 ${downstream_flow_igmp_cmd}= Catenate SEPARATOR=
337 ... flows -s ADDED ${olt_of_id} | grep IP_PROTO:2 |
338 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000339 ${downstream_flow_igmp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000340 ... ${downstream_flow_igmp_cmd}
341 Should Not Be Empty ${downstream_flow_igmp_added}
342
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530343Get Programmed Subscribers
344 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
345 [Documentation] Retrieves the subscriber details at a given location
346 ${sub_location}= Catenate SEPARATOR=/ ${olt_of_id} ${onu_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000347 ${programmed_sub}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530348 ... volt-programmed-subscribers | grep ${sub_location}
349 [Return] ${programmed_sub}
350
351Get Upstream and Downstream Bandwidth Profile Name
352 [Arguments] ${programmed_sub}
353 [Documentation] Retrieves the upstream and downstream bandwidth profile name
354 ... from the programmed subscriber
355 @{programmed_sub_array}= Split String ${programmed_sub} ,
356 # Get upstream bandwidth profile name for the subscriber
357 @{param_val_pair}= Split String ${programmed_sub_array[9]} =
358 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
359 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
360 ${us_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' upstreamBandwidthProfile'
361 ... Set Variable ${programmed_sub_val}
362 Log ${us_bw_profile}
363 # Get downstream bandwidth profile name for the subscriber
364 @{param_val_pair}= Split String ${programmed_sub_array[10]} =
365 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
366 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
367 ${ds_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' downstreamBandwidthProfile'
368 ... Set Variable ${programmed_sub_val}
369 Log ${ds_bw_profile}
370 [Return] ${us_bw_profile} ${ds_bw_profile}
371
372Get Bandwidth Profile Details
373 [Arguments] ${ip} ${port} ${bw_profile}
374 [Documentation] Retrieves the details of the given bandwidth profile
TorstenThieme4e2168e2021-06-22 14:01:47 +0000375 ${bw_profile_values}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530376 ... bandwidthprofile ${bw_profile}
377 @{bw_profile_array}= Split String ${bw_profile_values} ,
378 @{param_val_pair}= Split String ${bw_profile_array[1]} =
379 ${bw_param}= Set Variable ${param_val_pair[0]}
380 ${bw_val}= Set Variable ${param_val_pair[1]}
381 ${cir} Run Keyword If '${bw_param}' == ' committedInformationRate'
382 ... Set Variable ${bw_val}
383 @{param_val_pair}= Split String ${bw_profile_array[2]} =
384 ${bw_param}= Set Variable ${param_val_pair[0]}
385 ${bw_val}= Set Variable ${param_val_pair[1]}
386 ${cbs} Run Keyword If '${bw_param}' == ' committedBurstSize'
387 ... Set Variable ${bw_val}
388 @{param_val_pair}= Split String ${bw_profile_array[3]} =
389 ${bw_param}= Set Variable ${param_val_pair[0]}
390 ${bw_val}= Set Variable ${param_val_pair[1]}
391 ${eir} Run Keyword If '${bw_param}' == ' exceededInformationRate'
392 ... Set Variable ${bw_val}
393 @{param_val_pair}= Split String ${bw_profile_array[4]} =
394 ${bw_param}= Set Variable ${param_val_pair[0]}
395 ${bw_val}= Set Variable ${param_val_pair[1]}
396 ${ebs} Run Keyword If '${bw_param}' == ' exceededBurstSize'
397 ... Set Variable ${bw_val}
398 @{param_val_pair}= Split String ${bw_profile_array[5]} =
399 ${bw_param}= Set Variable ${param_val_pair[0]}
400 ${bw_val}= Set Variable ${param_val_pair[1]}
401 @{bw_val_air}= Split String ${bw_val} }
402 ${air} Run Keyword If '${bw_param}' == ' assuredInformationRate'
403 ... Set Variable ${bw_val_air[0]}
404 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
405
Hardik Windlassba5add42021-05-04 12:41:29 +0000406Get Bandwidth Profile Details Rest
407 [Arguments] ${bw_profile_id}
408 [Documentation] Retrieves the details of the given bandwidth profile using REST API
Girish Gowdracb8482a2021-05-27 09:06:13 -0700409 ${bw_profile_id}= Remove String ${bw_profile_id} ' "
Hardik Windlassba5add42021-05-04 12:41:29 +0000410 ${resp}= Get Request ONOS onos/sadis/bandwidthprofile/${bw_profile_id}
411 ${jsondata}= To Json ${resp.content}
412 Should Not Be Empty ${jsondata['entry']}
413 ${length}= Get Length ${jsondata['entry']}
414 ${matched}= Set Variable False
415 FOR ${INDEX} IN RANGE 0 ${length}
416 ${value}= Get From List ${jsondata['entry']} ${INDEX}
417 ${bw_id}= Get From Dictionary ${value} id
418 ${matched}= Set Variable If '${bw_id}' == '${bw_profile_id}' True False
419 ${eir}= Get From Dictionary ${value} eir
420 ${ebs}= Get From Dictionary ${value} ebs
421 ${cir}= Get From Dictionary ${value} cir
422 ${cbs}= Get From Dictionary ${value} cbs
423 ${air}= Get From Dictionary ${value} air
424 Exit For Loop If ${matched}
425 END
426 Should Be True ${matched} No bandwidth profile found for id: ${bw_profile_id}
427 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
428
Hardik Windlass841979a2021-05-25 05:30:27 +0000429Get Bandwidth Profile Details Ietf Rest
430 [Arguments] ${bw_profile_id}
431 [Documentation] Retrieves the details of the given Ietf standard based bandwidth profile using REST API
432 ${bw_profile_id}= Remove String ${bw_profile_id} ' "
433 ${resp}= Get Request ONOS onos/sadis/bandwidthprofile/${bw_profile_id}
434 ${jsondata}= To Json ${resp.content}
435 Should Not Be Empty ${jsondata['entry']}
436 ${length}= Get Length ${jsondata['entry']}
437 ${matched}= Set Variable False
438 FOR ${INDEX} IN RANGE 0 ${length}
439 ${value}= Get From List ${jsondata['entry']} ${INDEX}
440 ${bw_id}= Get From Dictionary ${value} id
441 ${matched}= Set Variable If '${bw_id}' == '${bw_profile_id}' True False
442 ${pir}= Get From Dictionary ${value} pir
443 ${pbs}= Get From Dictionary ${value} pbs
444 ${cir}= Get From Dictionary ${value} cir
445 ${cbs}= Get From Dictionary ${value} cbs
446 ${gir}= Get From Dictionary ${value} gir
447 Exit For Loop If ${matched}
448 END
449 Should Be True ${matched} No bandwidth profile found for id: ${bw_profile_id}
450 [Return] ${cir} ${cbs} ${pir} ${pbs} ${gir}
451
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700452Verify Meters in ONOS Ietf
453 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
454 [Documentation] Verifies the meters with BW Ietf format (currently, DT workflow uses this format)
455 # Get programmed subscriber
456 ${programmed_sub}= Get Programmed Subscribers ${ip} ${port}
457 ... ${olt_of_id} ${onu_port}
458 Log ${programmed_sub}
459 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
460 ... ${programmed_sub}
461 # Get upstream bandwidth profile details
462 ${us_cir} ${us_cbs} ${us_pir} ${us_pbs} ${us_gir} Get Bandwidth Profile Details Ietf Rest
463 ... ${us_bw_profile}
464 # Verify meter for upstream bandwidth profile
465 ${us_meter_cmd}= Run Keyword If ${us_gir} != 0 Catenate SEPARATOR=
466 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
467 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | grep "rate=${us_gir}, burst-size=0" | wc -l
468 ... ELSE Catenate SEPARATOR=
469 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
470 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000471 ${upstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700472 ... ${us_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700473 Should Be Equal As Integers ${upstream_meter_added} 1 Upstream meter is missing
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700474 # Get downstream bandwidth profile details
475 ${ds_cir} ${ds_cbs} ${ds_pir} ${ds_pbs} ${ds_gir} Get Bandwidth Profile Details Ietf Rest
476 ... ${ds_bw_profile}
477 # Verify meter for downstream bandwidth profile
478 ${ds_meter_cmd}= Run Keyword If ${ds_gir} != 0 Catenate SEPARATOR=
479 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
480 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | grep "rate=${ds_gir}, burst-size=0" | wc -l
481 ... ELSE Catenate SEPARATOR=
482 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
483 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000484 ${downstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700485 ... ${ds_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700486 Should Be Equal As Integers ${downstream_meter_added} 1 Downstream meter is missing
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700487
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530488Verify Meters in ONOS
489 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
490 [Documentation] Verifies the meters
491 # Get programmed subscriber
492 ${programmed_sub}= Get Programmed Subscribers ${ip} ${port}
493 ... ${olt_of_id} ${onu_port}
494 Log ${programmed_sub}
495 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
496 ... ${programmed_sub}
Matteo Scandolo2056ed72021-11-02 17:38:03 -0700497 # logging all meters to facilitate debug
498 ${all_meters}= Execute ONOS CLI Command use single connection ${ip} ${port} meters
499 Log ${all_meters}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530500 # Get upstream bandwidth profile details
501 ${us_cir} ${us_cbs} ${us_eir} ${us_ebs} ${us_air} Get Bandwidth Profile Details
502 ... ${ip} ${port} ${us_bw_profile}
503 Sleep 1s
Andrea Campanella2b367102021-05-04 19:33:46 +0200504 ${us_pbs}= Evaluate ${us_cbs}+${us_ebs}
505 ${us_pir}= Evaluate ${us_eir}+${us_cir}+${us_air}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530506 # Verify meter for upstream bandwidth profile
507 ${us_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530508 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200509 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | grep "rate=${us_air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000510 ${upstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530511 ... ${us_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700512 Should Be Equal As Integers ${upstream_meter_added} 1 Upstream meter is missing
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530513 Sleep 1s
514 # Get downstream bandwidth profile details
515 ${ds_cir} ${ds_cbs} ${ds_eir} ${ds_ebs} ${ds_air} Get Bandwidth Profile Details
516 ... ${ip} ${port} ${ds_bw_profile}
517 Sleep 1s
518 # Verify meter for downstream bandwidth profile
Andrea Campanella2b367102021-05-04 19:33:46 +0200519 ${ds_pbs}= Evaluate ${ds_cbs}+${ds_ebs}
520 ${ds_pir}= Evaluate ${ds_eir}+${ds_cir}+${ds_air}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530521 ${ds_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530522 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200523 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | grep "rate=${ds_air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000524 ${downstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530525 ... ${ds_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700526 Should Be Equal As Integers ${downstream_meter_added} 1 Downstream meter is missing
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530527
528Verify Default Meter Present in ONOS
529 [Arguments] ${ip} ${port} ${olt_of_id}
530 [Documentation] Verifies the single default meter entry is present
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530531 # Get default bandwidth profile details
532 ${cir} ${cbs} ${eir} ${ebs} ${air} Get Bandwidth Profile Details
533 ... ${ip} ${port} 'Default'
534 Sleep 1s
Andrea Campanella2b367102021-05-04 19:33:46 +0200535 ${pbs}= Evaluate ${cbs}+${ebs}
536 ${pir}= Evaluate ${eir}+${cir}+${air}
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530537 # Verify meter for default bandwidth profile
538 ${meter_cmd}= Catenate SEPARATOR=
539 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${cir}, burst-size=${cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200540 ... | grep "rate=${pir}, burst-size=${pbs}" | grep "rate=${air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000541 ${default_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530542 ... ${meter_cmd}
Matteo Scandolo2056ed72021-11-02 17:38:03 -0700543 # logging all meters to facilitate debug
544 ${all_meters}= Execute ONOS CLI Command use single connection ${ip} ${port} meters
545 Log ${all_meters}
546 # done logging all meters to facilitate debug
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700547 Should Be Equal As Integers ${default_meter_added} 1 Default Meter not present
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530548
Hardik Windlass480f3e22020-04-02 20:14:14 +0530549Verify Device Flows Removed
550 [Arguments] ${ip} ${port} ${olt_of_id}
551 [Documentation] Verifies all flows are removed from the device
TorstenThieme4e2168e2021-06-22 14:01:47 +0000552 ${device_flows}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700553 ... flows -s -f ${olt_of_id} | grep -v deviceId
554 ${flow_count}= Get Line Count ${device_flows}
555 Should Be Equal As Integers ${flow_count} 0 Flows not removed
Hardik Windlass480f3e22020-04-02 20:14:14 +0530556
Kailash6f5acb62019-08-28 14:38:45 -0700557Verify Eapol Flows Added
Andy Bavierb0c06232019-08-29 12:58:53 -0700558 [Arguments] ${ip} ${port} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700559 [Documentation] Matches for number of eapol flows based on number of onus
TorstenThieme4e2168e2021-06-22 14:01:47 +0000560 ${eapol_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Gilles Depatie675a2062019-10-22 12:44:42 -0400561 ... flows -s -f ADDED | grep eapol | grep IN_PORT | wc -l
Andy Bavierb0c06232019-08-29 12:58:53 -0700562 Should Contain ${eapol_flows_added} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700563
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800564Verify No Pending Flows For ONU
565 [Arguments] ${ip} ${port} ${onu_port}
566 [Documentation] Verifies that there are no flows "PENDING" state for the ONU in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000567 ${pending_flows}= Execute ONOS CLI Command use single connection ${ip} ${port}
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800568 ... flows -s | grep IN_PORT:${onu_port} | grep PENDING
569 Should Be Empty ${pending_flows}
570
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700571Verify Eapol Flows Added For ONU
Matteo Scandolo7e519fb2021-08-13 11:35:16 -0700572 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${c_tag}=4091
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700573 [Documentation] Verifies if the Eapol Flows are added in ONOS for the ONU
Matteo Scandolo7e519fb2021-08-13 11:35:16 -0700574 ${eapol_flow_cmd}= Catenate SEPARATOR=
575 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:eapol |
576 ... grep VLAN_ID:${c_tag} | grep OUTPUT:CONTROLLER
577 ${eapol_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port} ${eapol_flow_cmd}
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700578 Should Not Be Empty ${eapol_flows_added}
579
Hardik Windlass39015672021-07-05 05:48:08 +0000580Verify UNI Port Is Enabled
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000581 [Arguments] ${ip} ${port} ${onu_name} ${onu_uni_id}=1
Hardik Windlass39015672021-07-05 05:48:08 +0000582 [Documentation] Verifies if the ONU's UNI port is enabled in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000583 ${onu_port_enabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000584 ... ports -e | grep portName=${onu_name}-${onu_uni_id}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800585 Log ${onu_port_enabled}
586 Should Not Be Empty ${onu_port_enabled}
587
Hardik Windlass39015672021-07-05 05:48:08 +0000588Verify UNI Port Is Disabled
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000589 [Arguments] ${ip} ${port} ${onu_name} ${onu_uni_id}=1
Hardik Windlass39015672021-07-05 05:48:08 +0000590 [Documentation] Verifies if the ONU's UNI port is disabled in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000591 ${onu_port_disabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo02768532021-10-21 15:14:12 -0700592 ... ports | grep portName=${onu_name}-${onu_uni_id} | grep state=disabled
Hardik Windlass63d5e002020-03-06 21:07:09 +0530593 Log ${onu_port_disabled}
Matteo Scandolo02768532021-10-21 15:14:12 -0700594 Should Not Be Empty ${onu_port_disabled}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530595
TorstenThieme9b25aab2021-12-16 15:59:45 +0000596Wait For All UNI Ports Are Disabled per ONU
597 [Documentation] Verifies all UNI Ports of passed ONU are disabled
598 [Arguments] ${ip} ${port} ${onu_serial_number}
599 @{uni_id_list}= Create List
600 FOR ${I} IN RANGE 0 ${num_all_onus}
601 ${src}= Set Variable ${hosts.src[${I}]}
602 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
603 ${uni_id}= Set Variable ${src['uni_id']}
604 # make sure all actions do only once per uni_id
605 ${id}= Get Index From List ${uni_id_list} ${uni_id}
606 Continue For Loop If -1 != ${id}
607 Append To List ${uni_id_list} ${uni_id}
608 Wait Until Keyword Succeeds ${timeout} 2s
609 ... Verify UNI Port Is Disabled ${ip} ${port} ${onu_serial_number} ${uni_id}
610 END
611
612Wait For All UNI Ports Are Enabled per ONU
613 [Documentation] Verifies all UNI Ports of passed ONU are enabled
614 [Arguments] ${ip} ${port} ${onu_serial_number}
615 @{uni_id_list}= Create List
616 FOR ${I} IN RANGE 0 ${num_all_onus}
617 ${src}= Set Variable ${hosts.src[${I}]}
618 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
619 ${uni_id}= Set Variable ${src['uni_id']}
620 # make sure all actions do only once per uni_id
621 ${id}= Get Index From List ${uni_id_list} ${uni_id}
622 Continue For Loop If -1 != ${id}
623 Append To List ${uni_id_list} ${uni_id}
624 Wait Until Keyword Succeeds ${timeout} 2s
625 ... Verify UNI Port Is Enabled ${ip} ${port} ${onu_serial_number} ${uni_id}
626 END
627
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700628Verify ONU in AAA-Users
629 [Arguments] ${ip} ${port} ${onu_port}
630 [Documentation] Verifies that the specified onu_port exists in aaa-users output
TorstenThieme4e2168e2021-06-22 14:01:47 +0000631 ${aaa_users}= Execute ONOS CLI Command use single connection ${ip} ${port}
632 ... aaa-users | grep AUTHORIZED | grep ${onu_port}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700633 Should Not Be Empty ${aaa_users} ONU port ${onu_port} not found in aaa-users
634
Hardik Windlass513afd12021-02-03 15:19:46 +0000635Verify Empty Group in ONOS
636 [Documentation] Verifies zero group count on the device
TorstenThieme731a7592021-07-01 14:26:54 +0000637 [Arguments] ${ip} ${port} ${deviceId}
638 ${groups}= Execute ONOS CLI Command use single connection ${ip} ${port} groups | grep ${deviceId}
Hardik Windlass513afd12021-02-03 15:19:46 +0000639 @{groups_arr}= Split String ${groups} ,
640 @{group_count_arr}= Split String ${groups_arr[1]} =
641 ${group_count}= Set Variable ${group_count_arr[1]}
642 Should Be Equal As Integers ${group_count} 0
643
644Verify ONUs in Group Count in ONOS
645 [Documentation] Verifies there exists a group bucket list with certain entries/count
646 ... Note: Currently, this validates only if all ONUs of an OLT joined the same igmp group
TorstenThieme731a7592021-07-01 14:26:54 +0000647 [Arguments] ${ip} ${port} ${count} ${deviceId}
648 ${result}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolofd36e212021-03-02 11:36:10 -0800649 ... groups added ${deviceId} | grep bucket | wc -l
650 Should Be Equal As Integers ${result} ${count} Bucket list count for a group: Found=${result} Expected=${count}
Hardik Windlass513afd12021-02-03 15:19:46 +0000651
652Verify ONU in Group Bucket
653 [Documentation] Matches if ONU port in Group Bucket
654 [Arguments] ${group_bucket_values} ${onu_port}
655 ${len}= Get Length ${group_bucket_values}
656 ${matched}= Set Variable False
657 FOR ${INDEX} IN RANGE 0 ${len}
658 ${value_bucket}= Get From List ${group_bucket_values} ${INDEX}
659 ${treatment}= Get From Dictionary ${value_bucket} treatment
660 ${instructions}= Get From Dictionary ${treatment} instructions
661 ${instructions_val}= Get From List ${instructions} 0
662 ${port}= Get From Dictionary ${instructions_val} port
663 ${matched}= Set Variable If '${port}'=='${onu_port}' True False
664 Exit For Loop If ${matched}
665 END
666 [Return] ${matched}
667
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700668Verify ONU in Groups
669 [Arguments] ${ip_onos} ${port_onos} ${deviceId} ${onu_port} ${group_exist}=True
670 [Documentation] Verifies that the specified onu_port exists in groups output
TorstenThieme4e2168e2021-06-22 14:01:47 +0000671 ${result}= Execute ONOS CLI Command use single connection ${ip_onos} ${port_onos} groups -j
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700672 Log Groups: ${result}
673 ${groups}= To Json ${result}
674 ${length}= Get Length ${groups}
675 ${buckets}= Create List
676 ${matched}= Set Variable False
677 FOR ${INDEX} IN RANGE 0 ${length}
678 ${value}= Get From List ${groups} ${INDEX}
679 ${devId}= Get From Dictionary ${value} deviceId
680 ${bucket}= Get From Dictionary ${value} buckets
681 Run Keyword If '${devId}'=='${deviceId}'
682 ... Append To List ${buckets} ${bucket}
683 END
684 ${bucket_len}= Get Length ${buckets}
Hardik Windlass513afd12021-02-03 15:19:46 +0000685 FOR ${INDEX_1} IN RANGE 0 ${bucket_len}
686 ${value}= Get From List ${buckets} ${INDEX_1}
687 ${matched}= Verify ONU in Group Bucket ${value} ${onu_port}
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700688 Exit For Loop If ${matched}
689 END
690 Run Keyword If ${group_exist}
691 ... Should Be True ${matched} No match for ${deviceId} and ${onu_port} found in ONOS groups
692 ... ELSE
693 ... Should Be True '${matched}'=='False' Match for ${deviceId} and ${onu_port} found in ONOS groups
694
Matteo Scandolo142e6272020-04-29 17:36:59 -0700695Assert Number of AAA-Users
TorstenThieme731a7592021-07-01 14:26:54 +0000696 [Arguments] ${ip} ${port} ${expected_onus} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700697 [Documentation] Matches for number of aaa-users authorized based on number of onus
TorstenThieme731a7592021-07-01 14:26:54 +0000698 ${aaa_users}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800699 ... aaa-users | grep ${deviceId} | grep AUTHORIZED | wc -l
700 Log Found ${aaa_users} of ${expected_onus} expected authenticated users on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700701 Should Be Equal As Integers ${aaa_users} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700702
703Validate DHCP Allocations
TorstenThieme731a7592021-07-01 14:26:54 +0000704 [Arguments] ${ip} ${port} ${count} ${workflow} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700705 [Documentation] Matches for number of dhcpacks based on number of onus
TorstenThieme731a7592021-07-01 14:26:54 +0000706 ${allocations}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800707 ... dhcpl2relay-allocations | grep ${deviceId} | grep DHCPACK | wc -l
Matteo Scandoloda854b02020-09-01 16:20:51 -0700708 # if the workflow is TT we'll have 2 allocations for each ONU
709 ${ttAllocations}= Evaluate (${count} * 2)
710 ${count}= Set Variable If $workflow=='tt' ${ttAllocations} ${count}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800711 Log Found ${allocations} of ${count} expected DHCPACK on device ${deviceId}
Matteo Scandoloda854b02020-09-01 16:20:51 -0700712 Should Be Equal As Integers ${allocations} ${count}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700713
714Validate Subscriber DHCP Allocation
Suchitra Vemuri42819412020-10-01 17:45:43 -0700715 [Arguments] ${ip} ${port} ${onu_port} ${vlan}=''
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700716 [Documentation] Verifies that the specified subscriber is found in DHCP allocations
717 ##TODO: Enhance the keyword to include DHCP allocated address is not 0.0.0.0
TorstenThieme4e2168e2021-06-22 14:01:47 +0000718 ${allocations}= Execute ONOS CLI Command use single connection ${ip} ${port}
Suchitra Vemuri42819412020-10-01 17:45:43 -0700719 ... dhcpl2relay-allocations | grep DHCPACK | grep ${onu_port} | grep ${vlan}
Gilles Depatie675a2062019-10-22 12:44:42 -0400720 Should Not Be Empty ${allocations} ONU port ${onu_port} not found in dhcpl2relay-allocations
David Bainbridgef81cd642019-11-20 00:14:47 +0000721
722Device Is Available In ONOS
Matteo Scandolo3218d5b2021-05-26 11:50:10 -0700723 [Arguments] ${url} ${dpid} ${available}=true
724 [Documentation] Validates the device exists and it has the expected availability in ONOS
David Bainbridgef81cd642019-11-20 00:14:47 +0000725 ${rc} ${json} Run And Return Rc And Output curl --fail -sSL ${url}/onos/v1/devices/${dpid}
726 Should Be Equal As Integers 0 ${rc}
727 ${rc} ${value} Run And Return Rc And Output echo '${json}' | jq -r .available
728 Should Be Equal As Integers 0 ${rc}
Matteo Scandolo3218d5b2021-05-26 11:50:10 -0700729 Should Be Equal ${available} ${value}
David Bainbridgef81cd642019-11-20 00:14:47 +0000730
731Remove All Devices From ONOS
732 [Arguments] ${url}
733 [Documentation] Executes the device-remove command on each device in ONOS
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000734 ${rc} ${output} Run And Return Rc And Output
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700735 ... curl --fail -sSL ${url}/onos/v1/devices | jq -r '.devices[].id'
David Bainbridgef81cd642019-11-20 00:14:47 +0000736 Should Be Equal As Integers ${rc} 0
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000737 @{dpids} Split String ${output}
David Bainbridgef81cd642019-11-20 00:14:47 +0000738 ${count}= Get length ${dpids}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700739 FOR ${dpid} IN @{dpids}
740 ${rc}= Run Keyword If '${dpid}' != ''
741 ... Run And Return Rc curl -XDELETE --fail -sSL ${url}/onos/v1/devices/${dpid}
742 Run Keyword If '${dpid}' != ''
743 ... Should Be Equal As Integers ${rc} 0
744 END
Matteo Scandolo142e6272020-04-29 17:36:59 -0700745
TorstenThieme440b7c02020-12-18 15:42:57 +0000746Assert ONU Port Is Disabled
TorstenThieme731a7592021-07-01 14:26:54 +0000747 [Arguments] ${ip} ${port} ${deviceId} ${onu_port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000748 [Documentation] Verifies if the ONU port is disabled in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000749 ${onu_port_disabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000750 ... ports -d ${deviceId} | grep port=${onu_port}
751 Log ${onu_port_disabled}
752 Should Not Be Empty ${onu_port_disabled}
753
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700754Assert Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000755 [Arguments] ${ip} ${port} ${count}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700756 [Documentation] DEPRECATED use Assert Olt in ONOS
757 ... Check that a certain number of olts are known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000758 ${olts}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700759 ... volt-olts | wc -l
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700760 Log Found ${olts} of ${count} expected Olts
761 Should Be Equal As Integers ${olts} ${count}
762
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700763Assert Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000764 [Arguments] ${ip} ${port} ${deviceId}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700765 [Documentation] Check that a particular olt is known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000766 ${olts}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700767 ... volt-olts | grep ${deviceId} | wc -l
768 Should Be Equal As Integers ${olts} 1 "Device ${deviceId} is not recognized as an OLT"
769
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700770Wait for Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000771 [Arguments] ${ip} ${port} ${count} ${max_wait_time}=10m
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700772 [Documentation] DEPRECATED use Wait for Olt in ONOS
773 ... Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700774 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000775 ... ${ip} ${port} ${count}
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700776
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700777Wait for Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000778 [Arguments] ${ip} ${port} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700779 [Documentation] Waits until a particular deviceId is recognized by ONOS as an OLT
780 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000781 ... ${ip} ${port} ${deviceId}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700782
Matteo Scandolo142e6272020-04-29 17:36:59 -0700783Assert Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000784 [Arguments] ${ip} ${port} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700785 [Documentation] Check that a certain number of ports are enabled in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000786 ${ports}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800787 ... ports -e ${deviceId} | grep ${filter} | wc -l
788 Log Found ${ports} of ${count} expected ports on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700789 Should Be Equal As Integers ${ports} ${count}
790
791Wait for Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000792 [Arguments] ${ip} ${port} ${count} ${deviceId} ${filter} ${max_wait_time}=10m
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800793 [Documentation] Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
TorstenThiemed4f48962020-12-08 12:17:19 +0000794 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000795 ... ${ip} ${port} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700796
797Wait for AAA Authentication
TorstenThieme731a7592021-07-01 14:26:54 +0000798 [Arguments] ${ip} ${port} ${count} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700799 [Documentation] Waits untill a certain number of subscribers are authenticated in ONOS
TorstenThiemed4f48962020-12-08 12:17:19 +0000800 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Number of AAA-Users
TorstenThieme731a7592021-07-01 14:26:54 +0000801 ... ${ip} ${port} ${count} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700802
803Wait for DHCP Ack
TorstenThieme731a7592021-07-01 14:26:54 +0000804 [Arguments] ${ip} ${port} ${count} ${workflow} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700805 [Documentation] Waits untill a certain number of subscribers have received a DHCP_ACK
TorstenThiemed4f48962020-12-08 12:17:19 +0000806 Wait Until Keyword Succeeds ${max_wait_time} 5s Validate DHCP Allocations
TorstenThieme731a7592021-07-01 14:26:54 +0000807 ... ${ip} ${port} ${count} ${workflow} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700808
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700809Provision subscriber REST
810 [Documentation] Uses the rest APIs to provision a subscriber
TorstenThieme731a7592021-07-01 14:26:54 +0000811 [Arguments] ${of_id} ${onu_port}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700812 ${resp}= Post Request ONOS
813 ... /onos/olt/oltapp/${of_id}/${onu_port}
814 Should Be Equal As Strings ${resp.status_code} 200
815
Hardik Windlassea4caf72021-07-30 07:22:12 +0000816Count Enabled UNI Ports
817 [Documentation] Count all the UNI Ports on a Device
818 [Arguments] ${ip} ${port} ${of_id}
819 ${count}= Execute ONOS CLI Command use single connection ${ip} ${port}
820 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni | wc -l
821 Log ${count}
822 [Return] ${count}
823
Matteo Scandolo142e6272020-04-29 17:36:59 -0700824List Enabled UNI Ports
825 [Documentation] List all the UNI Ports, the only way we have is to filter out the one called NNI
826 ... Creates a list of dictionaries
TorstenThieme731a7592021-07-01 14:26:54 +0000827 [Arguments] ${ip} ${port} ${of_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700828 [Return] [{'port': '16', 'of_id': 'of:00000a0a0a0a0a00'}, {'port': '32', 'of_id': 'of:00000a0a0a0a0a00'}]
829 ${result}= Create List
TorstenThieme731a7592021-07-01 14:26:54 +0000830 ${out}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700831 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000832 @{unis}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700833 FOR ${uni} IN @{unis}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000834 ${matches} = Get Regexp Matches ${uni} .*port=([0-9]+),.* 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700835 &{portDict} Create Dictionary of_id=${of_id} port=${matches[0]}
836 Append To List ${result} ${portDict}
837 END
838 Log ${result}
839 Return From Keyword ${result}
840
841Provision all subscribers on device
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700842 [Documentation] Provisions a subscriber in ONOS for all the enabled UNI ports on a particular device
TorstenThieme731a7592021-07-01 14:26:54 +0000843 [Arguments] ${ip} ${port} ${onos_ip} ${onos_rest_port} ${of_id}
844 ${unis}= List Enabled UNI Ports ${ip} ${port} ${of_id}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700845 ${onos_auth}= Create List karaf karaf
846 Create Session ONOS http://${onos_ip}:${onos_rest_port} auth=${onos_auth}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700847 FOR ${uni} IN @{unis}
TorstenThieme731a7592021-07-01 14:26:54 +0000848 Provision Subscriber REST ${uni['of_id']} ${uni['port']}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700849 END
850
851List OLTs
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800852 # NOTE this method is not currently used but it can come useful in the future
853 [Documentation] Returns a list of all OLTs known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000854 [Arguments] ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700855 [Return] ['of:00000a0a0a0a0a00', 'of:00000a0a0a0a0a01']
856 ${result}= Create List
TorstenThieme731a7592021-07-01 14:26:54 +0000857 ${out}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700858 ... volt-olts
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000859 @{olts}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700860 FOR ${olt} IN @{olts}
861 Log ${olt}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000862 ${matches} = Get Regexp Matches ${olt} ^OLT (.+)$ 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700863 # there may be some logs mixed with the output so only append if we have a match
864 ${matches_length}= Get Length ${matches}
865 Run Keyword If ${matches_length}==1
866 ... Append To List ${result} ${matches[0]}
867 END
868 Return From Keyword ${result}
869
Matteo Scandolo75911092021-11-16 17:05:36 -0800870Count flows
871 [Documentation] Count flows in a particular ${state} in ONOS
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000872 ... Optionally for a certain onu-port.
873 [Arguments] ${ip} ${port} ${deviceId} ${state} ${onu_port}=${EMPTY}
874 ${cmd}= Catenate SEPARATOR= flows -s ${state} ${deviceId} | grep -v deviceId
875 ${cmd}= Run Keyword If "${onu_port}"!="${EMPTY}" Catenate SEPARATOR= ${cmd} | grep ${onu_port}
876 ... ELSE Set Variable ${cmd}
877 ${cmd}= Catenate SEPARATOR= ${cmd} | wc -l
878 ${flows}= Execute ONOS CLI Command use single connection ${ip} ${port} ${cmd}
879 [return] ${flows}
880
881Validate number of flows
882 [Documentation] Validates number of flows in a particular ${state} in ONOS
883 ... Optionally for a certain onu-port.
884 [Arguments] ${ip} ${port} ${targetFlows} ${deviceId} ${state} ${onu_port}=${EMPTY}
885 ${flows}= Count flows ${ip} ${port} ${deviceId} ${state} ${onu_port}
Matteo Scandolo75911092021-11-16 17:05:36 -0800886 Log Found ${state} ${flows} of ${targetFlows} expected flows on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700887 Should Be Equal As Integers ${targetFlows} ${flows}
888
889Wait for all flows to in ADDED state
890 [Documentation] Waits until the flows have been provisioned
TorstenThieme731a7592021-07-01 14:26:54 +0000891 [Arguments] ${ip} ${port} ${deviceId} ${workflow} ${uni_count} ${olt_count}
TorstenThiemeb198c482020-12-14 19:45:23 +0000892 ... ${provisioned} ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700893 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200894 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000895 Wait Until Keyword Succeeds 10m 5s Validate number of flows
Matteo Scandolo75911092021-11-16 17:05:36 -0800896 ... ${ip} ${port} ${targetFlows} ${deviceId} added
897
898Wait for all flows to be removed
899 [Documentation] Wait for all flows to be removed from a particular device
900 [Arguments] ${ip} ${port} ${deviceId}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000901 Wait Until Keyword Succeeds 10m 5s Validate number of flows
Matteo Scandolo75911092021-11-16 17:05:36 -0800902 ... ${ip} ${port} 0 ${deviceId} any
903
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000904
Girish Gowdrad769b412021-05-16 11:09:46 -0700905Get Limiting Bandwidth Details
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000906 [Arguments] ${bandwidth_profile_name}
907 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
908 ... returns the limiting bandwidth
Girish Gowdracb8482a2021-05-27 09:06:13 -0700909 ${cir} ${cbs} ${eir} ${ebs} ${air}= Get Bandwidth Profile Details Rest
910 ... ${bandwidth_profile_name}
Girish Gowdrad769b412021-05-16 11:09:46 -0700911 ${limiting_BW}= Evaluate ${eir}+${cir}+${air}
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000912 [Return] ${limiting_BW}
Hardik Windlasse8b99222021-01-25 10:03:14 +0000913
Emrehan UZUNd6f85892021-07-01 13:54:26 +0000914Get Limiting Bandwidth Details for Fixed and Committed
915 [Arguments] ${bandwidth_profile_name}
916 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
917 ... returns the limiting bandwidth for fixed and committed
918 ${cir} ${cbs} ${eir} ${ebs} ${air}= Get Bandwidth Profile Details Rest
919 ... ${bandwidth_profile_name}
920 ${limiting_BW}= Evaluate ${cir}+${air}
921 [Return] ${limiting_BW}
922
Hardik Windlasse8b99222021-01-25 10:03:14 +0000923Validate Deleted Device Cleanup In ONOS
924 [Arguments] ${ip} ${port} ${olt_serial_number}
925 [Documentation] The keyword verifies that ports, flows, meters, subscribers, dhcp are all cleared in ONOS
926 # Fetch OF Id for OLT
927 ${olt_of_id}= Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device in ONOS ${olt_serial_number}
Hardik Windlasse8b99222021-01-25 10:03:14 +0000928 # Verify Ports are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700929 ${ports}= Execute ONOS CLI Command use single connection ${ip} ${port}
930 ... ports ${olt_of_id} | grep -v ${olt_of_id}
931 ${port_count}= Get Line Count ${ports}
932 Should Be Equal As Integers ${port_count} 0 Ports have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000933 # Verify Subscribers are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700934 ${sub}= Execute ONOS CLI Command use single connection ${ip} ${port}
935 ... volt-programmed-subscribers | grep ${olt_of_id}
936 ${sub_count}= Get Line Count ${sub}
937 Should Be Equal As Integers ${sub_count} 0 Subscribers have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000938 # Verify Flows are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700939 ${flow}= Execute ONOS CLI Command use single connection ${ip} ${port}
940 ... flows -s -f ${olt_of_id} | grep -v deviceId
941 ${flow_count}= Get Line Count ${flow}
942 Should Be Equal As Integers ${flow_count} 0 Flows have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000943 # Verify Meters are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700944 ${meter}= Execute ONOS CLI Command use single connection ${ip} ${port}
945 ... meters ${olt_of_id}
946 ${meter_count}= Get Line Count ${meter}
947 Should Be Equal As Integers ${meter_count} 0 Meters have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000948 # Verify AAA-Users are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700949 ${aaa}= Execute ONOS CLI Command use single connection ${ip} ${port}
950 ... aaa-users ${olt_of_id}
951 ${aaa_count}= Get Line Count ${aaa}
952 Should Be Equal As Integers ${aaa_count} 0 AAA Users have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000953 # Verify Dhcp-Allocations are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700954 ${dhcp}= Execute ONOS CLI Command use single connection ${ip} ${port}
955 ... dhcpl2relay-allocations ${olt_of_id}
956 ${dhcp_count}= Get Line Count ${dhcp}
957 Should Be Equal As Integers ${dhcp_count} 0 DHCP Allocations have not been removed from ONOS after cleanup
Hardik Windlassdd1a9a12021-02-23 15:34:50 +0000958
959Delete ONOS App
960 [Arguments] ${url} ${app_name}
961 [Documentation] This keyword deactivates and uninstalls the given ONOS App
962 ${rc}= Run And Return Rc curl --fail -sSL -X DELETE ${url}/onos/v1/applications/${app_name}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -0700963 Should Be Equal As Integers ${rc} 0 Can't delete ${app_name} from ONOS
Hardik Windlassdd1a9a12021-02-23 15:34:50 +0000964
965Verify ONOS App Active
966 [Arguments] ${url} ${app_name} ${app_version}=${EMPTY}
967 [Documentation] This keyword verifies that the given ONOS App status is Active
968 ${rc} ${output} Run And Return Rc And Output
969 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name} | jq -r .state
970 Should Be Equal As Integers ${rc} 0
971 Should Be Equal '${output}' 'ACTIVE'
972 ${rc1} ${output1} Run And Return Rc And Output
973 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name} | jq -r .version
974 Run Keyword If '${app_version}'!='${EMPTY}'
975 ... Run Keywords
Matteo Scandolo2769d2b2021-04-14 10:29:24 -0700976 ... Should Be Equal As Integers ${rc1} 0 Can't read app ${app_name} status from ONOS
Hardik Windlassdd1a9a12021-02-23 15:34:50 +0000977 ... AND Should Be Equal '${output1}' '${app_version}'
978
979Install And Activate ONOS App
980 [Arguments] ${url} ${app_oar_file}
981 [Documentation] This keyword installs and activates the given ONOS App
982 ${cmd}= Catenate SEPARATOR=
983 ... curl --fail -sSL -H Content-Type:application/octet-stream -
984 ... X POST ${url}/onos/v1/applications?activate=true --data-binary \@${app_oar_file}
985 ${rc} ${output} Run And Return Rc And Output ${cmd}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -0700986 Should Be Equal As Integers ${rc} 0 Can't load onos app ${app_oar_file} to ONOS"
Hardik Windlassdd1a9a12021-02-23 15:34:50 +0000987 Log ${output}
Hardik Windlassdc2610f2021-03-09 07:33:51 +0000988
989Get ONOS App Details
990 [Arguments] ${url} ${app_name}
991 [Documentation] Retrieves ONOS App Details
992 ${rc} ${output} Run And Return Rc And Output
993 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -0700994 Should Be Equal As Integers ${rc} 0 Can't read app ${app_name} details from ONOS
Hardik Windlassdc2610f2021-03-09 07:33:51 +0000995 [Return] ${output}
Hardik Windlass88075f92022-01-25 12:19:45 +0000996
997Verify UniTag Subscriber
998 [Documentation] Verifies the unitag subscriber is provisioned/un-provisioned
999 [Arguments] ${ip} ${port} ${dev_id} ${onu_port} ${stag} ${ctag} ${tpid} ${sub_added}=True
1000 ${cmd}= Catenate SEPARATOR=
1001 ... volt-programmed-subscribers ${dev_id} ${onu_port} | grep "ponCTag=${ctag}, ponSTag=${stag}" | grep technologyProfileId
1002 ... =${tpid} --color=none
1003 ${subscriber}= Execute ONOS CLI Command use single connection ${ip} ${port} ${cmd}
1004 Log ${subscriber}
1005 ${sub_count}= Get Line Count ${subscriber}
1006 Run Keyword If ${sub_added}
1007 ... Should Be Equal As Integers ${sub_count} 1 UniTag Subscriber Not Added
1008 ... ELSE
1009 ... Should Be Equal As Integers ${sub_count} 0 UniTag Subscriber Not Removed