blob: b6a9cb9cb413097c4097786f18360be6b1eef02f [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}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000029${alias} ONOS_SSH
TorstenThieme1f58cac2022-02-10 15:58:38 +000030${ssh_read_timeout} 60s
TorstenThieme2ddb6e82022-02-08 14:44:24 +000031${ssh_prompt} karaf@root >
32${ssh_regexp_prompt} REGEXP:k.*a.*r.*a.*f.*@.*r.*o.*o.*t.* .*>.*
TorstenThieme5fef5a52022-05-12 12:12:31 +000033${regexp_prompt} (?ms)(.*)k(.*)a(.*)r(.*)a(.*)f(.*)@(.*)r(.*)o(.*)o(.*)t(.*) (.*)>(.*)
TorstenThieme2ddb6e82022-02-08 14:44:24 +000034${ssh_width} 400
35${disable_highlighter} setopt disable-highlighter
TorstenThieme36a38a82022-02-09 15:51:30 +000036# ${keep_alive_interval} is set to 0s means sending the keepalive packet is disabled!
37${keep_alive_interval} 0s
TorstenThiemeb198c482020-12-14 19:45:23 +000038
Kailash6f5acb62019-08-28 14:38:45 -070039*** Keywords ***
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070040
41Open ONOS SSH Connection
42 [Documentation] Establishes an ssh connection to ONOS contoller
43 [Arguments] ${host} ${port} ${user}=karaf ${pass}=karaf
TorstenThieme2ddb6e82022-02-08 14:44:24 +000044 ${conn_id}= SSHLibrary.Open Connection ${host} port=${port} timeout=${ssh_read_timeout} alias=${alias}
TorstenThieme36a38a82022-02-09 15:51:30 +000045 SSHLibrary.Login username=${user} password=${pass} keep_alive_interval=${keep_alive_interval}
TorstenThieme1d1413b2022-02-04 12:41:01 +000046 # set excepted prompt and terminal width to suppress unwanted line feeds
TorstenThieme2ddb6e82022-02-08 14:44:24 +000047 SSHLibrary.Set Client Configuration prompt=${ssh_prompt} width=${ssh_width}
TorstenThiemeb198c482020-12-14 19:45:23 +000048 ${conn_list_entry}= Create Dictionary conn_id=${conn_id} user=${user} pass=${pass}
TorstenThieme1d1413b2022-02-04 12:41:01 +000049 ... host=${host} port=${port} alias=${alias}
TorstenThiemeb198c482020-12-14 19:45:23 +000050 Append To List ${connection_list} ${conn_list_entry}
51 ${conn_list_id}= Get Index From List ${connection_list} ${conn_list_entry}
52 Set Global Variable ${connection_list}
TorstenThieme1d1413b2022-02-04 12:41:01 +000053 # disable highlighting to suppress control sequences
TorstenThieme2ddb6e82022-02-08 14:44:24 +000054 ${output}= Execute Single ONOS CLI Command ${conn_id} ${disable_highlighter} do_reconnect=False
TorstenThiemeb198c482020-12-14 19:45:23 +000055 [Return] ${conn_list_id}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070056
TorstenThieme4e2168e2021-06-22 14:01:47 +000057Execute ONOS CLI Command use single connection
58 [Documentation] Execute ONOS CLI Command use an Open Connection
59 ... In case no connection is open a connection will be opened
TorstenThieme1d1413b2022-02-04 12:41:01 +000060 ... Using Write and Read instead of Execute Command to keep connection alive.
TorstenThieme4e2168e2021-06-22 14:01:47 +000061 [Arguments] ${host} ${port} ${cmd}
62 ${connection_list_id}= Get Conn List Id ${host} ${port}
63 ${connection_list_id}= Run Keyword If "${connection_list_id}"=="${EMPTY}"
64 ... Open ONOS SSH Connection ${host} ${port}
65 ... ELSE Set Variable ${connection_list_id}
66 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000067 ${output}= Execute Single ONOS CLI Command ${connection_entry.conn_id} ${cmd}
TorstenThieme36a38a82022-02-09 15:51:30 +000068 ... connection_list_id=${connection_list_id}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000069 [Return] ${output}
70
71Execute Single ONOS CLI Command
72 [Documentation] Executes ONOS CLI Command on current connection
73 ... Using Write and Read instead of Execute Command to keep connection alive.
TorstenThieme36a38a82022-02-09 15:51:30 +000074 [Arguments] ${conn_id} ${cmd} ${do_reconnect}=True ${connection_list_id}=${EMPTY}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000075 Log Command: ${cmd}
76 SSHLibrary.Switch Connection ${conn_id}
77 # get connection settings, has no functional reason, only for info
TorstenThieme1d1413b2022-02-04 12:41:01 +000078 ${connection_info}= SSHLibrary.Get Connection
TorstenThiemeedc50672022-02-14 10:32:10 +000079 # write the command until it is mirrored
80 ${PassOrFail} ${Written}= Run Keyword And Ignore Error Write Until Expected Output ${cmd} expected=${cmd}
81 ... timeout=5s retry_interval=1s
TorstenThieme2ddb6e82022-02-08 14:44:24 +000082 Run Keyword If '${PassOrFail}'=='FAIL' and ${do_reconnect} Reconnect ONOS SSH Connection ${connection_list_id}
TorstenThiemeedc50672022-02-14 10:32:10 +000083 Run Keyword If '${PassOrFail}'=='FAIL' Write Until Expected Output ${cmd}${\n} expected=${cmd} timeout=5s
84 ... retry_interval=1s
85 # set up the comand - press enter key!
86 ${Written}= Write ${EMPTY}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000087 ${PassOrFail} ${output}= Run Keyword And Ignore Error Read Until Prompt strip_prompt=True
TorstenThieme1d1413b2022-02-04 12:41:01 +000088 Log Result_values: ${output}
TorstenThieme1f58cac2022-02-10 15:58:38 +000089 # remove error printout from ssh library in case of failure
90 ${output}= Run Keyword If '${PassOrFail}'=='FAIL' Fetch From Right ${output} Output:
91 ... ELSE Set Variable ${output}
92 ${output}= Run Keyword If '${PassOrFail}'=='FAIL' Get Substring ${output} 1
93 ... ELSE Set Variable ${output}
TorstenThieme5fef5a52022-05-12 12:12:31 +000094 ${match} ${grp1} ${grp2} ${grp3} ${grp4} ${grp5} ${grp6} ${grp7} ${grp8} ${grp9}
95 ... ${grp10} ${grp11} ${grp12} ${grp13}= Run Keyword If '${PassOrFail}'=='FAIL'
96 ... Should Match Regexp ${output} ${regexp_prompt} SSH access failed for '${cmd}'! False
97 ${output}= Run Keyword If '${PassOrFail}'=='FAIL' Catenate SEPARATOR= ${grp1} ${grp2} ${grp3}
98 ... ${grp4} ${grp5} ${grp6} ${grp7} ${grp8} ${grp9} ${grp10} ${grp11} ${grp12} ${grp13}
99 ... ELSE Set Variable ${output}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000100 # we do not use strip of escape sequences integrated in ssh lib, we do it by ourself to have it under control
101 ${output}= Remove String Using Regexp ${output} \\x1b[>=]{0,1}(?:\\[[0-?]*(?:[hlm])[~]{0,1})*
102 # remove the endless spaces and two carrige returns at the end of output
103 ${output}= Remove String Using Regexp ${output} \\s*\\r \\r
104 # now we have the plain output text
105 Log Stripped Result_values: ${output}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000106 [Return] ${output}
107
108Get Conn List Id
109 [Documentation] Looks up for an Open Connection with passed host and port in conection list
110 ... First match connection will be used.
111 [Arguments] ${host} ${port}
112 ${connection_list_id}= Set Variable ${EMPTY}
113 ${match}= Set Variable False
114 ${length}= Get Length ${connection_list}
115 FOR ${INDEX} IN RANGE 0 ${length}
116 #${Item}= Get From List ${connection_list} ${INDEX}
117 ${conndata}= Get Connection ${connection_list[${INDEX}].conn_id}
118 ${match}= Set Variable If '${conndata.host}'=='${host}' and '${conndata.port}'=='${port}' True False
119 ${connection_list_id}= Set Variable If ${match} ${INDEX} ${EMPTY}
120 Exit For Loop If ${match}
121 END
122 [Return] ${connection_list_id}
123
TorstenThiemeb198c482020-12-14 19:45:23 +0000124Reconnect ONOS SSH Connection
125 [Documentation] Reconnect an SSH Connection
126 [Arguments] ${connection_list_id}
127 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
128 ${user}= Get From Dictionary ${connection_entry} user
129 ${pass}= Get From Dictionary ${connection_entry} pass
130 ${oldconndata}= Get Connection ${connection_entry.conn_id}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000131 ${match}= Set Variable If
132 ... "${oldconndata.host}"=="${connection_entry.host}" and "${oldconndata.port}"=="${connection_entry.port}"
133 ... True False
134 Run Keyword If ${match} SSHLibrary.Switch Connection ${connection_entry.conn_id}
135 Run Keyword If ${match} Run Keyword And Ignore Error SSHLibrary.Close Connection
136 ${conn_id}= SSHLibrary.Open Connection ${connection_entry.host} port=${connection_entry.port}
TorstenThieme2ddb6e82022-02-08 14:44:24 +0000137 ... timeout=${ssh_read_timeout} alias=${alias}
TorstenThieme36a38a82022-02-09 15:51:30 +0000138 SSHLibrary.Login username=${user} password=${pass} keep_alive_interval=${keep_alive_interval}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000139 # set excepted prompt and terminal width to suppress unwanted line feeds
TorstenThieme2ddb6e82022-02-08 14:44:24 +0000140 SSHLibrary.Set Client Configuration prompt=${ssh_prompt} width=${ssh_width}
TorstenThiemeb198c482020-12-14 19:45:23 +0000141 ${conn_list_entry}= Create Dictionary conn_id=${conn_id} user=${user} pass=${pass}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000142 ... host=${connection_entry.host} port=${connection_entry.port} alias=${alias}
TorstenThiemeb198c482020-12-14 19:45:23 +0000143 Set List Value ${connection_list} ${connection_list_id} ${conn_list_entry}
144 Set Global Variable ${connection_list}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000145 # disable highlighting to suppress control sequences
TorstenThieme2ddb6e82022-02-08 14:44:24 +0000146 ${output}= Execute Single ONOS CLI Command ${conn_id} ${disable_highlighter} do_reconnect=False
TorstenThiemeb198c482020-12-14 19:45:23 +0000147
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700148Close ONOS SSH Connection
149 [Documentation] Close an SSH Connection
TorstenThiemeb198c482020-12-14 19:45:23 +0000150 [Arguments] ${connection_list_id}
151 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
152 ${connection_alias}= Get From Dictionary ${connection_entry} conn_id
153 ${oldconndata}= Get Connection ${connection_entry.conn_id}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700154 SSHLibrary.Switch Connection ${connection_alias}
TorstenThiemebcf14612021-01-27 10:19:18 +0000155 Run Keyword And Ignore Error SSHLibrary.Close Connection
TorstenThiemeb198c482020-12-14 19:45:23 +0000156 Remove From List ${connection_list} ${connection_list_id}
157 Set Global Variable ${connection_list}
158
159Close All ONOS SSH Connections
160 [Documentation] Close all SSH Connection and clear connection list.
161 SSHLibrary.Close All Connections
162 @{connection_list} Create List
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700163
Kailash6f5acb62019-08-28 14:38:45 -0700164Validate OLT Device in ONOS
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700165 # FIXME use volt-olts to check that the OLT is ONOS
Kailash6f5acb62019-08-28 14:38:45 -0700166 [Arguments] ${serial_number}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700167 [Documentation] Checks if olt has been connected to ONOS
Kailash6f5acb62019-08-28 14:38:45 -0700168 ${resp}= Get Request ONOS onos/v1/devices
169 ${jsondata}= To Json ${resp.content}
170 Should Not Be Empty ${jsondata['devices']}
171 ${length}= Get Length ${jsondata['devices']}
172 @{serial_numbers}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -0700173 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700174 FOR ${INDEX} IN RANGE 0 ${length}
175 ${value}= Get From List ${jsondata['devices']} ${INDEX}
176 ${of_id}= Get From Dictionary ${value} id
177 ${sn}= Get From Dictionary ${value} serial
Andy Bavierb63f6d22020-03-12 15:34:37 -0700178 ${matched}= Set Variable If '${sn}' == '${serial_number}' True False
179 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700180 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700181 Should Be True ${matched} No match for ${serial_number} found
Kailash57210eb2019-08-30 13:27:19 -0700182 [Return] ${of_id}
Kailash6f5acb62019-08-28 14:38:45 -0700183
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700184Get ONU Port in ONOS
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000185 [Arguments] ${onu_serial_number} ${olt_of_id} ${onu_uni_id}=1
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700186 [Documentation] Retrieves ONU port for the ONU in ONOS
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000187 ${onu_serial_number}= Catenate SEPARATOR=- ${onu_serial_number} ${onu_uni_id}
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700188 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
189 ${jsondata}= To Json ${resp.content}
190 Should Not Be Empty ${jsondata['ports']}
191 ${length}= Get Length ${jsondata['ports']}
192 @{ports}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -0700193 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700194 FOR ${INDEX} IN RANGE 0 ${length}
195 ${value}= Get From List ${jsondata['ports']} ${INDEX}
196 ${annotations}= Get From Dictionary ${value} annotations
197 ${onu_port}= Get From Dictionary ${value} port
198 ${portName}= Get From Dictionary ${annotations} portName
Andy Bavierb63f6d22020-03-12 15:34:37 -0700199 ${matched}= Set Variable If '${portName}' == '${onu_serial_number}' True False
200 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700201 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700202 Should Be True ${matched} No match for ${onu_serial_number} found
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700203 [Return] ${onu_port}
204
TorstenThieme9b25aab2021-12-16 15:59:45 +0000205Get Onu Ports in ONOS For ALL UNI per ONU
206 [Documentation] Retrieves ONU port(s) for the ONU in ONOS for all UNI-IDs, list of ports will return!
207 [Arguments] ${onu_serial_number} ${olt_of_id}
208 @{uni_id_list}= Create List
209 @{port_list}= Create List
210 FOR ${I} IN RANGE 0 ${num_all_onus}
211 ${src}= Set Variable ${hosts.src[${I}]}
212 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
213 ${uni_id}= Set Variable ${src['uni_id']}
214 # make sure all actions do only once per uni_id
215 ${id}= Get Index From List ${uni_id_list} ${uni_id}
216 Continue For Loop If -1 != ${id}
217 Append To List ${uni_id_list} ${uni_id}
218 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${onu_serial_number}
219 ... ${olt_of_id} ${uni_id}
220 Append To List ${port_list} ${onu_port}
221 END
222 [return] ${port_list}
223
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530224Get NNI Port in ONOS
225 [Arguments] ${olt_of_id}
226 [Documentation] Retrieves NNI port for the OLT in ONOS
227 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
228 ${jsondata}= To Json ${resp.content}
229 Should Not Be Empty ${jsondata['ports']}
230 ${length}= Get Length ${jsondata['ports']}
231 @{ports}= Create List
232 ${matched}= Set Variable False
233 FOR ${INDEX} IN RANGE 0 ${length}
234 ${value}= Get From List ${jsondata['ports']} ${INDEX}
235 ${annotations}= Get From Dictionary ${value} annotations
236 ${nni_port}= Get From Dictionary ${value} port
237 ${nniPortName}= Catenate SEPARATOR= nni- ${nni_port}
238 ${portName}= Get From Dictionary ${annotations} portName
239 ${matched}= Set Variable If '${portName}' == '${nniPortName}' True False
240 Exit For Loop If ${matched}
241 END
242 Should Be True ${matched} No match for NNI found for ${olt_of_id}
243 [Return] ${nni_port}
244
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700245Get FabricSwitch in ONOS
246 [Documentation] Returns of_id of the Fabric Switch in ONOS
247 ${resp}= Get Request ONOS onos/v1/devices
248 ${jsondata}= To Json ${resp.content}
249 Should Not Be Empty ${jsondata['devices']}
250 ${length}= Get Length ${jsondata['devices']}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700251 ${matched}= Set Variable False
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700252 FOR ${INDEX} IN RANGE 0 ${length}
253 ${value}= Get From List ${jsondata['devices']} ${INDEX}
254 ${of_id}= Get From Dictionary ${value} id
255 ${type}= Get From Dictionary ${value} type
Andy Bavierb63f6d22020-03-12 15:34:37 -0700256 ${matched}= Set Variable If '${type}' == "SWITCH" True False
257 Exit For Loop If ${matched}
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700258 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700259 Should Be True ${matched} No fabric switch found
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700260 [Return] ${of_id}
261
Andrea Campanella4c404632020-08-26 14:41:36 +0200262Get Master Instace in ONOS
263 [Arguments] ${of_id}
264 [Documentation] Returns nodeId of the Master instace for a giver device in ONOS
265 ${resp}= Get Request ONOS onos/v1/mastership/${of_id}/master
266 ${jsondata}= To Json ${resp.content}
267 Should Not Be Empty ${jsondata['nodeId']}
268 ${master_node}= Get From Dictionary ${jsondata} nodeId
269 [Return] ${master_node}
270
Matteo Scandolo7bdbe2d2021-11-29 15:48:25 -0800271Verify LLDP Flow Added
272 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
273 [Documentation] Matches for total number of LLDP flows added for one OLT
274 ${lldp_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
275 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep ETH_TYPE:lldp | grep -v ETH_TYPE:arp
276 ${lldp_flows_added_count}= Get Line Count ${lldp_flows_added}
277 Should Be Equal As Integers ${lldp_flows_added_count} ${expected_flows}
278
Hardik Windlass21807632020-04-14 16:24:55 +0530279Verify Subscriber Access Flows Added for ONU
280 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${c_tag} ${s_tag}
281 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
282 # Verify upstream table=0 flow
283 ${upstream_flow_0_cmd}= Catenate SEPARATOR=
284 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:0 |
285 ... grep VLAN_ID:${c_tag} | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000286 ${upstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530287 ... ${upstream_flow_0_cmd}
288 Should Not Be Empty ${upstream_flow_0_added}
289 # Verify upstream table=1 flow
290 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
291 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
292 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000293 ${upstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530294 ... ${flow_vlan_push_cmd}
295 Should Not Be Empty ${upstream_flow_1_added}
296 # Verify downstream table=0 flow
297 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
298 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
299 ... grep VLAN_POP | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000300 ${downstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530301 ... ${flow_vlan_pop_cmd}
302 Should Not Be Empty ${downstream_flow_0_added}
303 # Verify downstream table=1 flow
304 ${downstream_flow_1_cmd}= Catenate SEPARATOR=
305 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${c_tag} |
306 ... grep VLAN_ID:0 | grep OUTPUT:${onu_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000307 ${downstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530308 ... ${downstream_flow_1_cmd}
309 Should Not Be Empty ${downstream_flow_1_added}
310 # Verify ipv4 dhcp upstream flow
311 ${upstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200312 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:ipv4 |
Andrea Campanella08678e12020-09-18 17:40:22 +0200313 ... grep IP_PROTO:17 | grep UDP_SRC:68 | grep UDP_DST:67 | grep VLAN_ID:${c_tag} |
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200314 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000315 ${upstream_flow_ipv4_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530316 ... ${upstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200317 Should Not Be Empty ${upstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530318 # Verify ipv4 dhcp downstream flow
319 # Note: This flow will be one per nni per olt
320 ${downstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200321 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep ETH_TYPE:ipv4 |
322 ... grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 | grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000323 ${downstream_flow_ipv4_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530324 ... ${downstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200325 Should Not Be Empty ${downstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530326
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530327Verify Subscriber Access Flows Added for ONU DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530328 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530329 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
330 # Verify upstream table=0 flow
TorstenThieme4e2168e2021-06-22 14:01:47 +0000331 ${upstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530332 ... 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 +0530333 Should Not Be Empty ${upstream_flow_0_added}
334 # Verify upstream table=1 flow
335 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530336 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:Any |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530337 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000338 ${upstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530339 ... ${flow_vlan_push_cmd}
340 Should Not Be Empty ${upstream_flow_1_added}
341 # Verify downstream table=0 flow
342 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530343 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530344 ... grep VLAN_POP | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000345 ${downstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530346 ... ${flow_vlan_pop_cmd}
347 Should Not Be Empty ${downstream_flow_0_added}
348 # Verify downstream table=1 flow
TorstenThieme4e2168e2021-06-22 14:01:47 +0000349 ${downstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530350 ... 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 +0530351 Should Not Be Empty ${downstream_flow_1_added}
352
Hardik Windlassa7b34be2022-03-22 17:28:31 +0000353Verify Subscriber Access Flows Added for DT FTTB
354 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag} ${c_tag}
355 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
356 # Upstream
357 # ONU
358 ${us_flow_onu_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
359 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} | grep transition=TABLE:1
360 Should Not Be Empty ${us_flow_onu_added}
361 # OLT
362 ${us_flow_olt_cmd}= Catenate
363 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
364 ... grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
365 ${us_flow_olt_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
366 ... ${us_flow_olt_cmd}
367 Should Not Be Empty ${us_flow_olt_added}
368 # Downstream
369 # OLT
370 ${ds_flow_olt_cmd}= Catenate
371 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
372 ... grep VLAN_ID:${c_tag} | grep transition=TABLE:1
373 ${ds_flow_olt_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
374 ... ${ds_flow_olt_cmd}
375 Should Not Be Empty ${ds_flow_olt_added}
376 # ONU
377 ${ds_flow_onu_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
378 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${c_tag} | grep OUTPUT:${onu_port}
379 Should Not Be Empty ${ds_flow_onu_added}
380
381Verify DPU ANCP Flows Added for DT FTTB
382 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag} ${c_tag}
383 [Documentation] Verifies if the DPU ANCP Flows are added in ONOS for the ONU
384 # Upstream
385 # ONU
386 ${us_flow_onu_cmd}= Catenate
387 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
388 ... grep VLAN_ID:${s_tag} | grep transition=TABLE:1
389 ${us_flow_onu_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
390 ... ${us_flow_onu_cmd}
391 Should Not Be Empty ${us_flow_onu_added}
392 # OLT
393 ${us_flow_olt_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
394 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${s_tag} | grep OUTPUT:${nni_port}
395 Should Not Be Empty ${us_flow_olt_added}
396 # Downstream
397 # OLT
398 ${ds_flow_olt_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
399 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} | grep transition=TABLE:1
400 Should Not Be Empty ${ds_flow_olt_added}
401 # ONU
402 ${ds_flow_onu_cmd}= Catenate
403 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
404 ... grep VLAN_ID:${c_tag} | grep OUTPUT:${onu_port}
405 ${ds_flow_onu_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
406 ... ${ds_flow_onu_cmd}
407 Should Not Be Empty ${ds_flow_onu_added}
408
409Verify DPU MGMT Flows Added for DT FTTB
410 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag} ${c_tag}
411 [Documentation] Verifies if the DPU MGMT Flows are added in ONOS for the ONU
412 # Upstream
413 # ONU
414 ${us_flow_onu_cmd}= Catenate
415 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
416 ... grep VLAN_ID:${s_tag} | grep transition=TABLE:1
417 ${us_flow_onu_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
418 ... ${us_flow_onu_cmd}
419 Should Not Be Empty ${us_flow_onu_added}
420 # OLT
421 ${us_flow_olt_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
422 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${s_tag} | grep OUTPUT:${nni_port}
423 Should Not Be Empty ${us_flow_olt_added}
424 # Downstream
425 # OLT
426 ${ds_flow_olt_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
427 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} | grep transition=TABLE:1
428 Should Not Be Empty ${ds_flow_olt_added}
429 # ONU
430 ${ds_flow_onu_cmd}= Catenate
431 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
432 ... grep VLAN_ID:${c_tag} | grep OUTPUT:${onu_port}
433 ${ds_flow_onu_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
434 ... ${ds_flow_onu_cmd}
435 Should Not Be Empty ${ds_flow_onu_added}
436
437Verify ONOS Flows Added for DT FTTB
438 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${service}
439 [Documentation] Verifies if the Flows are added in ONOS for the ONU
440 ${num_services}= Get Length ${service}
441 FOR ${I} IN RANGE 0 ${num_services}
442 ${service_name}= Set Variable ${service[${I}]['name']}
443 ${stag}= Set Variable ${service[${I}]['s_tag']}
444 ${ctag}= Set Variable ${service[${I}]['c_tag']}
445 Run Keyword If '${service_name}' == 'FTTB_SUBSCRIBER_TRAFFIC'
446 ... Verify Subscriber Access Flows Added for DT FTTB ${ip} ${port}
447 ... ${olt_of_id} ${onu_port} ${nni_port} ${stag} ${ctag}
448 ... ELSE IF '${service_name}' == 'DPU_ANCP_TRAFFIC'
449 ... Verify DPU ANCP Flows Added for DT FTTB ${ip} ${port}
450 ... ${olt_of_id} ${onu_port} ${nni_port} ${stag} ${ctag}
451 ... ELSE IF '${service_name}' == 'DPU_MGMT_TRAFFIC'
452 ... Verify DPU MGMT Flows Added for DT FTTB ${ip} ${port}
453 ... ${olt_of_id} ${onu_port} ${nni_port} ${stag} ${ctag}
454 END
455
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530456Verify Subscriber Access Flows Added Count DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530457 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530458 [Documentation] Matches for total number of subscriber access flows added for all onus
TorstenThieme4e2168e2021-06-22 14:01:47 +0000459 ${access_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700460 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep -v ETH_TYPE:lldp | grep -v ETH_TYPE:arp
461 ${access_flows_added_count}= Get Line Count ${access_flows_added}
462 Should Be Equal As Integers ${access_flows_added_count} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530463
Huseyin Ahmet AYDIN45922c82021-05-27 12:37:32 +0000464Verify Added Flow Count for OLT TT
465 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
466 [Documentation] Total number of added flows given OLT with subscriber flows
TorstenThieme4e2168e2021-06-22 14:01:47 +0000467 ${access_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700468 ... flows -s ADDED ${olt_of_id} | grep -v deviceId
469 ${access_flows_added_count}= Get Line Count ${access_flows_added}
470 Should Be Equal As Integers ${access_flows_added_count} ${expected_flows}
Huseyin Ahmet AYDIN45922c82021-05-27 12:37:32 +0000471
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000472Verify Default Downstream Flows are added in ONOS for OLT TT
473 [Arguments] ${ip} ${port} ${olt_of_id} ${nni_port}
474 [Documentation] Verifies if the Default Downstream Flows are added in ONOS for the OLT
475 # Verify lldp flow
476 ${downstream_flow_lldp_cmd}= Catenate SEPARATOR=
477 ... flows -s ADDED ${olt_of_id} | grep lldp |
478 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000479 ${downstream_flow_lldp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000480 ... ${downstream_flow_lldp_cmd}
481 Should Not Be Empty ${downstream_flow_lldp_added}
482 # Verify downstream dhcp flow
483 ${downstream_flow_dhcp_cmd}= Catenate SEPARATOR=
484 ... flows -s ADDED ${olt_of_id} | grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 |
485 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000486 ${downstream_flow_dhcp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000487 ... ${downstream_flow_dhcp_cmd}
488 Should Not Be Empty ${downstream_flow_dhcp_added}
489 # Verify downstream igmp flow
490 ${downstream_flow_igmp_cmd}= Catenate SEPARATOR=
491 ... flows -s ADDED ${olt_of_id} | grep IP_PROTO:2 |
492 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000493 ${downstream_flow_igmp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000494 ... ${downstream_flow_igmp_cmd}
495 Should Not Be Empty ${downstream_flow_igmp_added}
496
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530497Get Programmed Subscribers
Hardik Windlassa7b34be2022-03-22 17:28:31 +0000498 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${filter}=${EMPTY}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530499 [Documentation] Retrieves the subscriber details at a given location
Hardik Windlassa7b34be2022-03-22 17:28:31 +0000500 ${cmd}= Set Variable If '${filter}' == '${EMPTY}'
501 ... volt-programmed-subscribers ${olt_of_id} ${onu_port}
502 ... volt-programmed-subscribers ${olt_of_id} ${onu_port} | grep ${filter} --color=none
503 ${programmed_sub}= Execute ONOS CLI Command use single connection ${ip} ${port} ${cmd}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530504 [Return] ${programmed_sub}
505
Hardik Windlassa7b34be2022-03-22 17:28:31 +0000506Verify Programmed Subscribers DT FTTB
507 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${service}
508 [Documentation] Verifies the subscriber is present at a given location
509 ${num_services}= Get Length ${service}
510 FOR ${I} IN RANGE 0 ${num_services}
511 ${service_name}= Set Variable ${service[${I}]['name']}
512 ${programmed_subscriber}= Get Programmed Subscribers ${ip} ${port} ${olt_of_id} ${onu_port}
513 ... ${service_name}
514 Log ${programmed_subscriber}
515 Should Not Be Empty ${programmed_subscriber}
516 END
517
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530518Get Upstream and Downstream Bandwidth Profile Name
519 [Arguments] ${programmed_sub}
520 [Documentation] Retrieves the upstream and downstream bandwidth profile name
521 ... from the programmed subscriber
522 @{programmed_sub_array}= Split String ${programmed_sub} ,
523 # Get upstream bandwidth profile name for the subscriber
524 @{param_val_pair}= Split String ${programmed_sub_array[9]} =
525 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
526 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
527 ${us_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' upstreamBandwidthProfile'
528 ... Set Variable ${programmed_sub_val}
529 Log ${us_bw_profile}
530 # Get downstream bandwidth profile name for the subscriber
531 @{param_val_pair}= Split String ${programmed_sub_array[10]} =
532 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
533 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
534 ${ds_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' downstreamBandwidthProfile'
535 ... Set Variable ${programmed_sub_val}
536 Log ${ds_bw_profile}
537 [Return] ${us_bw_profile} ${ds_bw_profile}
538
539Get Bandwidth Profile Details
540 [Arguments] ${ip} ${port} ${bw_profile}
541 [Documentation] Retrieves the details of the given bandwidth profile
TorstenThieme4e2168e2021-06-22 14:01:47 +0000542 ${bw_profile_values}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530543 ... bandwidthprofile ${bw_profile}
544 @{bw_profile_array}= Split String ${bw_profile_values} ,
545 @{param_val_pair}= Split String ${bw_profile_array[1]} =
546 ${bw_param}= Set Variable ${param_val_pair[0]}
547 ${bw_val}= Set Variable ${param_val_pair[1]}
548 ${cir} Run Keyword If '${bw_param}' == ' committedInformationRate'
549 ... Set Variable ${bw_val}
550 @{param_val_pair}= Split String ${bw_profile_array[2]} =
551 ${bw_param}= Set Variable ${param_val_pair[0]}
552 ${bw_val}= Set Variable ${param_val_pair[1]}
553 ${cbs} Run Keyword If '${bw_param}' == ' committedBurstSize'
554 ... Set Variable ${bw_val}
555 @{param_val_pair}= Split String ${bw_profile_array[3]} =
556 ${bw_param}= Set Variable ${param_val_pair[0]}
557 ${bw_val}= Set Variable ${param_val_pair[1]}
558 ${eir} Run Keyword If '${bw_param}' == ' exceededInformationRate'
559 ... Set Variable ${bw_val}
560 @{param_val_pair}= Split String ${bw_profile_array[4]} =
561 ${bw_param}= Set Variable ${param_val_pair[0]}
562 ${bw_val}= Set Variable ${param_val_pair[1]}
563 ${ebs} Run Keyword If '${bw_param}' == ' exceededBurstSize'
564 ... Set Variable ${bw_val}
565 @{param_val_pair}= Split String ${bw_profile_array[5]} =
566 ${bw_param}= Set Variable ${param_val_pair[0]}
567 ${bw_val}= Set Variable ${param_val_pair[1]}
568 @{bw_val_air}= Split String ${bw_val} }
569 ${air} Run Keyword If '${bw_param}' == ' assuredInformationRate'
570 ... Set Variable ${bw_val_air[0]}
571 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
572
Hardik Windlassba5add42021-05-04 12:41:29 +0000573Get Bandwidth Profile Details Rest
574 [Arguments] ${bw_profile_id}
575 [Documentation] Retrieves the details of the given bandwidth profile using REST API
Girish Gowdracb8482a2021-05-27 09:06:13 -0700576 ${bw_profile_id}= Remove String ${bw_profile_id} ' "
Hardik Windlassba5add42021-05-04 12:41:29 +0000577 ${resp}= Get Request ONOS onos/sadis/bandwidthprofile/${bw_profile_id}
578 ${jsondata}= To Json ${resp.content}
579 Should Not Be Empty ${jsondata['entry']}
580 ${length}= Get Length ${jsondata['entry']}
581 ${matched}= Set Variable False
582 FOR ${INDEX} IN RANGE 0 ${length}
583 ${value}= Get From List ${jsondata['entry']} ${INDEX}
584 ${bw_id}= Get From Dictionary ${value} id
585 ${matched}= Set Variable If '${bw_id}' == '${bw_profile_id}' True False
586 ${eir}= Get From Dictionary ${value} eir
587 ${ebs}= Get From Dictionary ${value} ebs
588 ${cir}= Get From Dictionary ${value} cir
589 ${cbs}= Get From Dictionary ${value} cbs
590 ${air}= Get From Dictionary ${value} air
591 Exit For Loop If ${matched}
592 END
593 Should Be True ${matched} No bandwidth profile found for id: ${bw_profile_id}
594 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
595
Hardik Windlass841979a2021-05-25 05:30:27 +0000596Get Bandwidth Profile Details Ietf Rest
597 [Arguments] ${bw_profile_id}
598 [Documentation] Retrieves the details of the given Ietf standard based bandwidth profile using REST API
599 ${bw_profile_id}= Remove String ${bw_profile_id} ' "
600 ${resp}= Get Request ONOS onos/sadis/bandwidthprofile/${bw_profile_id}
601 ${jsondata}= To Json ${resp.content}
602 Should Not Be Empty ${jsondata['entry']}
603 ${length}= Get Length ${jsondata['entry']}
604 ${matched}= Set Variable False
605 FOR ${INDEX} IN RANGE 0 ${length}
606 ${value}= Get From List ${jsondata['entry']} ${INDEX}
607 ${bw_id}= Get From Dictionary ${value} id
608 ${matched}= Set Variable If '${bw_id}' == '${bw_profile_id}' True False
609 ${pir}= Get From Dictionary ${value} pir
610 ${pbs}= Get From Dictionary ${value} pbs
611 ${cir}= Get From Dictionary ${value} cir
612 ${cbs}= Get From Dictionary ${value} cbs
613 ${gir}= Get From Dictionary ${value} gir
614 Exit For Loop If ${matched}
615 END
616 Should Be True ${matched} No bandwidth profile found for id: ${bw_profile_id}
617 [Return] ${cir} ${cbs} ${pir} ${pbs} ${gir}
618
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700619Verify Meters in ONOS Ietf
Hardik Windlassa7b34be2022-03-22 17:28:31 +0000620 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${filter}=${EMPTY}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700621 [Documentation] Verifies the meters with BW Ietf format (currently, DT workflow uses this format)
622 # Get programmed subscriber
623 ${programmed_sub}= Get Programmed Subscribers ${ip} ${port}
Hardik Windlassa7b34be2022-03-22 17:28:31 +0000624 ... ${olt_of_id} ${onu_port} ${filter}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700625 Log ${programmed_sub}
626 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
627 ... ${programmed_sub}
628 # Get upstream bandwidth profile details
629 ${us_cir} ${us_cbs} ${us_pir} ${us_pbs} ${us_gir} Get Bandwidth Profile Details Ietf Rest
630 ... ${us_bw_profile}
631 # Verify meter for upstream bandwidth profile
632 ${us_meter_cmd}= Run Keyword If ${us_gir} != 0 Catenate SEPARATOR=
633 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
634 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | grep "rate=${us_gir}, burst-size=0" | wc -l
635 ... ELSE Catenate SEPARATOR=
636 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
637 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000638 ${upstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700639 ... ${us_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700640 Should Be Equal As Integers ${upstream_meter_added} 1 Upstream meter is missing
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700641 # Get downstream bandwidth profile details
642 ${ds_cir} ${ds_cbs} ${ds_pir} ${ds_pbs} ${ds_gir} Get Bandwidth Profile Details Ietf Rest
643 ... ${ds_bw_profile}
644 # Verify meter for downstream bandwidth profile
645 ${ds_meter_cmd}= Run Keyword If ${ds_gir} != 0 Catenate SEPARATOR=
646 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
647 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | grep "rate=${ds_gir}, burst-size=0" | wc -l
648 ... ELSE Catenate SEPARATOR=
649 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
650 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000651 ${downstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700652 ... ${ds_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700653 Should Be Equal As Integers ${downstream_meter_added} 1 Downstream meter is missing
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700654
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530655Verify Meters in ONOS
656 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
657 [Documentation] Verifies the meters
658 # Get programmed subscriber
659 ${programmed_sub}= Get Programmed Subscribers ${ip} ${port}
660 ... ${olt_of_id} ${onu_port}
661 Log ${programmed_sub}
662 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
663 ... ${programmed_sub}
Matteo Scandolo2056ed72021-11-02 17:38:03 -0700664 # logging all meters to facilitate debug
665 ${all_meters}= Execute ONOS CLI Command use single connection ${ip} ${port} meters
666 Log ${all_meters}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530667 # Get upstream bandwidth profile details
668 ${us_cir} ${us_cbs} ${us_eir} ${us_ebs} ${us_air} Get Bandwidth Profile Details
669 ... ${ip} ${port} ${us_bw_profile}
670 Sleep 1s
Andrea Campanella2b367102021-05-04 19:33:46 +0200671 ${us_pbs}= Evaluate ${us_cbs}+${us_ebs}
672 ${us_pir}= Evaluate ${us_eir}+${us_cir}+${us_air}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530673 # Verify meter for upstream bandwidth profile
674 ${us_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530675 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200676 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | grep "rate=${us_air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000677 ${upstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530678 ... ${us_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700679 Should Be Equal As Integers ${upstream_meter_added} 1 Upstream meter is missing
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530680 Sleep 1s
681 # Get downstream bandwidth profile details
682 ${ds_cir} ${ds_cbs} ${ds_eir} ${ds_ebs} ${ds_air} Get Bandwidth Profile Details
683 ... ${ip} ${port} ${ds_bw_profile}
684 Sleep 1s
685 # Verify meter for downstream bandwidth profile
Andrea Campanella2b367102021-05-04 19:33:46 +0200686 ${ds_pbs}= Evaluate ${ds_cbs}+${ds_ebs}
687 ${ds_pir}= Evaluate ${ds_eir}+${ds_cir}+${ds_air}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530688 ${ds_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530689 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200690 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | grep "rate=${ds_air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000691 ${downstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530692 ... ${ds_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700693 Should Be Equal As Integers ${downstream_meter_added} 1 Downstream meter is missing
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530694
695Verify Default Meter Present in ONOS
696 [Arguments] ${ip} ${port} ${olt_of_id}
697 [Documentation] Verifies the single default meter entry is present
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530698 # Get default bandwidth profile details
699 ${cir} ${cbs} ${eir} ${ebs} ${air} Get Bandwidth Profile Details
700 ... ${ip} ${port} 'Default'
701 Sleep 1s
Andrea Campanella2b367102021-05-04 19:33:46 +0200702 ${pbs}= Evaluate ${cbs}+${ebs}
703 ${pir}= Evaluate ${eir}+${cir}+${air}
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530704 # Verify meter for default bandwidth profile
705 ${meter_cmd}= Catenate SEPARATOR=
706 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${cir}, burst-size=${cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200707 ... | grep "rate=${pir}, burst-size=${pbs}" | grep "rate=${air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000708 ${default_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530709 ... ${meter_cmd}
Matteo Scandolo2056ed72021-11-02 17:38:03 -0700710 # logging all meters to facilitate debug
711 ${all_meters}= Execute ONOS CLI Command use single connection ${ip} ${port} meters
712 Log ${all_meters}
713 # done logging all meters to facilitate debug
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700714 Should Be Equal As Integers ${default_meter_added} 1 Default Meter not present
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530715
Hardik Windlass480f3e22020-04-02 20:14:14 +0530716Verify Device Flows Removed
717 [Arguments] ${ip} ${port} ${olt_of_id}
718 [Documentation] Verifies all flows are removed from the device
TorstenThieme4e2168e2021-06-22 14:01:47 +0000719 ${device_flows}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700720 ... flows -s -f ${olt_of_id} | grep -v deviceId
721 ${flow_count}= Get Line Count ${device_flows}
722 Should Be Equal As Integers ${flow_count} 0 Flows not removed
Hardik Windlass480f3e22020-04-02 20:14:14 +0530723
Kailash6f5acb62019-08-28 14:38:45 -0700724Verify Eapol Flows Added
Andy Bavierb0c06232019-08-29 12:58:53 -0700725 [Arguments] ${ip} ${port} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700726 [Documentation] Matches for number of eapol flows based on number of onus
TorstenThieme4e2168e2021-06-22 14:01:47 +0000727 ${eapol_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Gilles Depatie675a2062019-10-22 12:44:42 -0400728 ... flows -s -f ADDED | grep eapol | grep IN_PORT | wc -l
Andy Bavierb0c06232019-08-29 12:58:53 -0700729 Should Contain ${eapol_flows_added} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700730
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800731Verify No Pending Flows For ONU
732 [Arguments] ${ip} ${port} ${onu_port}
733 [Documentation] Verifies that there are no flows "PENDING" state for the ONU in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000734 ${pending_flows}= Execute ONOS CLI Command use single connection ${ip} ${port}
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800735 ... flows -s | grep IN_PORT:${onu_port} | grep PENDING
736 Should Be Empty ${pending_flows}
737
TorstenThieme1e207df2022-05-17 10:31:34 +0000738Verify Pending Flows For ONU
739 [Arguments] ${ip} ${port} ${onu_port}
740 [Documentation] Verifies that there are flows "PENDING" state for the ONU in ONOS
741 ${pending_flows}= Execute ONOS CLI Command use single connection ${ip} ${port}
742 ... flows -s | grep IN_PORT:${onu_port} | grep PENDING
743 Should Not Be Empty ${pending_flows}
744
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700745Verify Eapol Flows Added For ONU
Matteo Scandolo7e519fb2021-08-13 11:35:16 -0700746 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${c_tag}=4091
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700747 [Documentation] Verifies if the Eapol Flows are added in ONOS for the ONU
Matteo Scandolo7e519fb2021-08-13 11:35:16 -0700748 ${eapol_flow_cmd}= Catenate SEPARATOR=
749 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:eapol |
750 ... grep VLAN_ID:${c_tag} | grep OUTPUT:CONTROLLER
751 ${eapol_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port} ${eapol_flow_cmd}
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700752 Should Not Be Empty ${eapol_flows_added}
753
Hardik Windlass39015672021-07-05 05:48:08 +0000754Verify UNI Port Is Enabled
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000755 [Arguments] ${ip} ${port} ${onu_name} ${onu_uni_id}=1
Hardik Windlass39015672021-07-05 05:48:08 +0000756 [Documentation] Verifies if the ONU's UNI port is enabled in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000757 ${onu_port_enabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000758 ... ports -e | grep portName=${onu_name}-${onu_uni_id}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800759 Log ${onu_port_enabled}
760 Should Not Be Empty ${onu_port_enabled}
761
Hardik Windlass39015672021-07-05 05:48:08 +0000762Verify UNI Port Is Disabled
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000763 [Arguments] ${ip} ${port} ${onu_name} ${onu_uni_id}=1
Hardik Windlass39015672021-07-05 05:48:08 +0000764 [Documentation] Verifies if the ONU's UNI port is disabled in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000765 ${onu_port_disabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo02768532021-10-21 15:14:12 -0700766 ... ports | grep portName=${onu_name}-${onu_uni_id} | grep state=disabled
Hardik Windlass63d5e002020-03-06 21:07:09 +0530767 Log ${onu_port_disabled}
Matteo Scandolo02768532021-10-21 15:14:12 -0700768 Should Not Be Empty ${onu_port_disabled}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530769
TorstenThieme9b25aab2021-12-16 15:59:45 +0000770Wait For All UNI Ports Are Disabled per ONU
771 [Documentation] Verifies all UNI Ports of passed ONU are disabled
772 [Arguments] ${ip} ${port} ${onu_serial_number}
773 @{uni_id_list}= Create List
774 FOR ${I} IN RANGE 0 ${num_all_onus}
775 ${src}= Set Variable ${hosts.src[${I}]}
776 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
777 ${uni_id}= Set Variable ${src['uni_id']}
778 # make sure all actions do only once per uni_id
779 ${id}= Get Index From List ${uni_id_list} ${uni_id}
780 Continue For Loop If -1 != ${id}
781 Append To List ${uni_id_list} ${uni_id}
782 Wait Until Keyword Succeeds ${timeout} 2s
783 ... Verify UNI Port Is Disabled ${ip} ${port} ${onu_serial_number} ${uni_id}
784 END
785
786Wait For All UNI Ports Are Enabled per ONU
787 [Documentation] Verifies all UNI Ports of passed ONU are enabled
788 [Arguments] ${ip} ${port} ${onu_serial_number}
789 @{uni_id_list}= Create List
790 FOR ${I} IN RANGE 0 ${num_all_onus}
791 ${src}= Set Variable ${hosts.src[${I}]}
792 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
793 ${uni_id}= Set Variable ${src['uni_id']}
794 # make sure all actions do only once per uni_id
795 ${id}= Get Index From List ${uni_id_list} ${uni_id}
796 Continue For Loop If -1 != ${id}
797 Append To List ${uni_id_list} ${uni_id}
798 Wait Until Keyword Succeeds ${timeout} 2s
799 ... Verify UNI Port Is Enabled ${ip} ${port} ${onu_serial_number} ${uni_id}
800 END
801
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700802Verify ONU in AAA-Users
803 [Arguments] ${ip} ${port} ${onu_port}
804 [Documentation] Verifies that the specified onu_port exists in aaa-users output
TorstenThieme4e2168e2021-06-22 14:01:47 +0000805 ${aaa_users}= Execute ONOS CLI Command use single connection ${ip} ${port}
806 ... aaa-users | grep AUTHORIZED | grep ${onu_port}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700807 Should Not Be Empty ${aaa_users} ONU port ${onu_port} not found in aaa-users
808
Hardik Windlass513afd12021-02-03 15:19:46 +0000809Verify Empty Group in ONOS
810 [Documentation] Verifies zero group count on the device
TorstenThieme731a7592021-07-01 14:26:54 +0000811 [Arguments] ${ip} ${port} ${deviceId}
812 ${groups}= Execute ONOS CLI Command use single connection ${ip} ${port} groups | grep ${deviceId}
Hardik Windlass513afd12021-02-03 15:19:46 +0000813 @{groups_arr}= Split String ${groups} ,
814 @{group_count_arr}= Split String ${groups_arr[1]} =
815 ${group_count}= Set Variable ${group_count_arr[1]}
816 Should Be Equal As Integers ${group_count} 0
817
818Verify ONUs in Group Count in ONOS
819 [Documentation] Verifies there exists a group bucket list with certain entries/count
820 ... Note: Currently, this validates only if all ONUs of an OLT joined the same igmp group
TorstenThieme731a7592021-07-01 14:26:54 +0000821 [Arguments] ${ip} ${port} ${count} ${deviceId}
822 ${result}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolofd36e212021-03-02 11:36:10 -0800823 ... groups added ${deviceId} | grep bucket | wc -l
824 Should Be Equal As Integers ${result} ${count} Bucket list count for a group: Found=${result} Expected=${count}
Hardik Windlass513afd12021-02-03 15:19:46 +0000825
826Verify ONU in Group Bucket
827 [Documentation] Matches if ONU port in Group Bucket
828 [Arguments] ${group_bucket_values} ${onu_port}
829 ${len}= Get Length ${group_bucket_values}
830 ${matched}= Set Variable False
831 FOR ${INDEX} IN RANGE 0 ${len}
832 ${value_bucket}= Get From List ${group_bucket_values} ${INDEX}
833 ${treatment}= Get From Dictionary ${value_bucket} treatment
834 ${instructions}= Get From Dictionary ${treatment} instructions
835 ${instructions_val}= Get From List ${instructions} 0
836 ${port}= Get From Dictionary ${instructions_val} port
837 ${matched}= Set Variable If '${port}'=='${onu_port}' True False
838 Exit For Loop If ${matched}
839 END
840 [Return] ${matched}
841
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700842Verify ONU in Groups
843 [Arguments] ${ip_onos} ${port_onos} ${deviceId} ${onu_port} ${group_exist}=True
844 [Documentation] Verifies that the specified onu_port exists in groups output
TorstenThieme4e2168e2021-06-22 14:01:47 +0000845 ${result}= Execute ONOS CLI Command use single connection ${ip_onos} ${port_onos} groups -j
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700846 Log Groups: ${result}
847 ${groups}= To Json ${result}
848 ${length}= Get Length ${groups}
849 ${buckets}= Create List
850 ${matched}= Set Variable False
851 FOR ${INDEX} IN RANGE 0 ${length}
852 ${value}= Get From List ${groups} ${INDEX}
853 ${devId}= Get From Dictionary ${value} deviceId
854 ${bucket}= Get From Dictionary ${value} buckets
855 Run Keyword If '${devId}'=='${deviceId}'
856 ... Append To List ${buckets} ${bucket}
857 END
858 ${bucket_len}= Get Length ${buckets}
Hardik Windlass513afd12021-02-03 15:19:46 +0000859 FOR ${INDEX_1} IN RANGE 0 ${bucket_len}
860 ${value}= Get From List ${buckets} ${INDEX_1}
861 ${matched}= Verify ONU in Group Bucket ${value} ${onu_port}
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700862 Exit For Loop If ${matched}
863 END
864 Run Keyword If ${group_exist}
865 ... Should Be True ${matched} No match for ${deviceId} and ${onu_port} found in ONOS groups
866 ... ELSE
867 ... Should Be True '${matched}'=='False' Match for ${deviceId} and ${onu_port} found in ONOS groups
868
Matteo Scandolo142e6272020-04-29 17:36:59 -0700869Assert Number of AAA-Users
TorstenThieme731a7592021-07-01 14:26:54 +0000870 [Arguments] ${ip} ${port} ${expected_onus} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700871 [Documentation] Matches for number of aaa-users authorized based on number of onus
TorstenThieme731a7592021-07-01 14:26:54 +0000872 ${aaa_users}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800873 ... aaa-users | grep ${deviceId} | grep AUTHORIZED | wc -l
874 Log Found ${aaa_users} of ${expected_onus} expected authenticated users on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700875 Should Be Equal As Integers ${aaa_users} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700876
877Validate DHCP Allocations
TorstenThieme731a7592021-07-01 14:26:54 +0000878 [Arguments] ${ip} ${port} ${count} ${workflow} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700879 [Documentation] Matches for number of dhcpacks based on number of onus
TorstenThieme731a7592021-07-01 14:26:54 +0000880 ${allocations}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800881 ... dhcpl2relay-allocations | grep ${deviceId} | grep DHCPACK | wc -l
Matteo Scandoloda854b02020-09-01 16:20:51 -0700882 # if the workflow is TT we'll have 2 allocations for each ONU
883 ${ttAllocations}= Evaluate (${count} * 2)
884 ${count}= Set Variable If $workflow=='tt' ${ttAllocations} ${count}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800885 Log Found ${allocations} of ${count} expected DHCPACK on device ${deviceId}
Matteo Scandoloda854b02020-09-01 16:20:51 -0700886 Should Be Equal As Integers ${allocations} ${count}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700887
888Validate Subscriber DHCP Allocation
Suchitra Vemuri42819412020-10-01 17:45:43 -0700889 [Arguments] ${ip} ${port} ${onu_port} ${vlan}=''
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700890 [Documentation] Verifies that the specified subscriber is found in DHCP allocations
891 ##TODO: Enhance the keyword to include DHCP allocated address is not 0.0.0.0
TorstenThieme4e2168e2021-06-22 14:01:47 +0000892 ${allocations}= Execute ONOS CLI Command use single connection ${ip} ${port}
Suchitra Vemuri42819412020-10-01 17:45:43 -0700893 ... dhcpl2relay-allocations | grep DHCPACK | grep ${onu_port} | grep ${vlan}
Gilles Depatie675a2062019-10-22 12:44:42 -0400894 Should Not Be Empty ${allocations} ONU port ${onu_port} not found in dhcpl2relay-allocations
David Bainbridgef81cd642019-11-20 00:14:47 +0000895
Hardik Windlassc609eb02022-02-22 11:28:37 +0000896Validate Mac Learner Mapping in ONOS
897 [Arguments] ${ip} ${port} ${dev_id} ${onu_port} ${vlan}
898 [Documentation] Verifies the MAC mapping for the client
899 ${mac}= Execute ONOS CLI Command use single connection ${ip} ${port}
900 ... mac-learner-get-mapping ${dev_id} ${onu_port} ${vlan} | grep -v INFO
901 Should Not Be Empty ${mac}
902 ... No client mac-mapping found with vlan-id: ${vlan} that uses port: ${onu_port} of device: ${dev_id}
903
David Bainbridgef81cd642019-11-20 00:14:47 +0000904Device Is Available In ONOS
Matteo Scandolo3218d5b2021-05-26 11:50:10 -0700905 [Arguments] ${url} ${dpid} ${available}=true
906 [Documentation] Validates the device exists and it has the expected availability in ONOS
David Bainbridgef81cd642019-11-20 00:14:47 +0000907 ${rc} ${json} Run And Return Rc And Output curl --fail -sSL ${url}/onos/v1/devices/${dpid}
908 Should Be Equal As Integers 0 ${rc}
909 ${rc} ${value} Run And Return Rc And Output echo '${json}' | jq -r .available
910 Should Be Equal As Integers 0 ${rc}
Matteo Scandolo3218d5b2021-05-26 11:50:10 -0700911 Should Be Equal ${available} ${value}
David Bainbridgef81cd642019-11-20 00:14:47 +0000912
913Remove All Devices From ONOS
914 [Arguments] ${url}
915 [Documentation] Executes the device-remove command on each device in ONOS
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000916 ${rc} ${output} Run And Return Rc And Output
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700917 ... curl --fail -sSL ${url}/onos/v1/devices | jq -r '.devices[].id'
David Bainbridgef81cd642019-11-20 00:14:47 +0000918 Should Be Equal As Integers ${rc} 0
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000919 @{dpids} Split String ${output}
David Bainbridgef81cd642019-11-20 00:14:47 +0000920 ${count}= Get length ${dpids}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700921 FOR ${dpid} IN @{dpids}
922 ${rc}= Run Keyword If '${dpid}' != ''
923 ... Run And Return Rc curl -XDELETE --fail -sSL ${url}/onos/v1/devices/${dpid}
924 Run Keyword If '${dpid}' != ''
925 ... Should Be Equal As Integers ${rc} 0
926 END
Matteo Scandolo142e6272020-04-29 17:36:59 -0700927
TorstenThieme440b7c02020-12-18 15:42:57 +0000928Assert ONU Port Is Disabled
TorstenThieme731a7592021-07-01 14:26:54 +0000929 [Arguments] ${ip} ${port} ${deviceId} ${onu_port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000930 [Documentation] Verifies if the ONU port is disabled in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000931 ${onu_port_disabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000932 ... ports -d ${deviceId} | grep port=${onu_port}
933 Log ${onu_port_disabled}
934 Should Not Be Empty ${onu_port_disabled}
935
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700936Assert Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000937 [Arguments] ${ip} ${port} ${count}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700938 [Documentation] DEPRECATED use Assert Olt in ONOS
939 ... Check that a certain number of olts are known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000940 ${olts}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700941 ... volt-olts | wc -l
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700942 Log Found ${olts} of ${count} expected Olts
943 Should Be Equal As Integers ${olts} ${count}
944
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700945Assert Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000946 [Arguments] ${ip} ${port} ${deviceId}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700947 [Documentation] Check that a particular olt is known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000948 ${olts}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700949 ... volt-olts | grep ${deviceId} | wc -l
950 Should Be Equal As Integers ${olts} 1 "Device ${deviceId} is not recognized as an OLT"
951
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700952Wait for Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000953 [Arguments] ${ip} ${port} ${count} ${max_wait_time}=10m
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700954 [Documentation] DEPRECATED use Wait for Olt in ONOS
955 ... Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700956 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000957 ... ${ip} ${port} ${count}
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700958
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700959Wait for Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000960 [Arguments] ${ip} ${port} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700961 [Documentation] Waits until a particular deviceId is recognized by ONOS as an OLT
962 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000963 ... ${ip} ${port} ${deviceId}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700964
Matteo Scandolo142e6272020-04-29 17:36:59 -0700965Assert Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000966 [Arguments] ${ip} ${port} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700967 [Documentation] Check that a certain number of ports are enabled in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000968 ${ports}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800969 ... ports -e ${deviceId} | grep ${filter} | wc -l
970 Log Found ${ports} of ${count} expected ports on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700971 Should Be Equal As Integers ${ports} ${count}
972
973Wait for Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000974 [Arguments] ${ip} ${port} ${count} ${deviceId} ${filter} ${max_wait_time}=10m
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800975 [Documentation] Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
TorstenThiemed4f48962020-12-08 12:17:19 +0000976 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000977 ... ${ip} ${port} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700978
979Wait for AAA Authentication
TorstenThieme731a7592021-07-01 14:26:54 +0000980 [Arguments] ${ip} ${port} ${count} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700981 [Documentation] Waits untill a certain number of subscribers are authenticated in ONOS
TorstenThiemed4f48962020-12-08 12:17:19 +0000982 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Number of AAA-Users
TorstenThieme731a7592021-07-01 14:26:54 +0000983 ... ${ip} ${port} ${count} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700984
985Wait for DHCP Ack
TorstenThieme731a7592021-07-01 14:26:54 +0000986 [Arguments] ${ip} ${port} ${count} ${workflow} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700987 [Documentation] Waits untill a certain number of subscribers have received a DHCP_ACK
TorstenThiemed4f48962020-12-08 12:17:19 +0000988 Wait Until Keyword Succeeds ${max_wait_time} 5s Validate DHCP Allocations
TorstenThieme731a7592021-07-01 14:26:54 +0000989 ... ${ip} ${port} ${count} ${workflow} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700990
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700991Provision subscriber REST
992 [Documentation] Uses the rest APIs to provision a subscriber
TorstenThieme731a7592021-07-01 14:26:54 +0000993 [Arguments] ${of_id} ${onu_port}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700994 ${resp}= Post Request ONOS
995 ... /onos/olt/oltapp/${of_id}/${onu_port}
996 Should Be Equal As Strings ${resp.status_code} 200
997
Hardik Windlassea4caf72021-07-30 07:22:12 +0000998Count Enabled UNI Ports
999 [Documentation] Count all the UNI Ports on a Device
1000 [Arguments] ${ip} ${port} ${of_id}
1001 ${count}= Execute ONOS CLI Command use single connection ${ip} ${port}
1002 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni | wc -l
1003 Log ${count}
1004 [Return] ${count}
1005
Matteo Scandolo142e6272020-04-29 17:36:59 -07001006List Enabled UNI Ports
1007 [Documentation] List all the UNI Ports, the only way we have is to filter out the one called NNI
1008 ... Creates a list of dictionaries
TorstenThieme731a7592021-07-01 14:26:54 +00001009 [Arguments] ${ip} ${port} ${of_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001010 [Return] [{'port': '16', 'of_id': 'of:00000a0a0a0a0a00'}, {'port': '32', 'of_id': 'of:00000a0a0a0a0a00'}]
1011 ${result}= Create List
TorstenThieme731a7592021-07-01 14:26:54 +00001012 ${out}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001013 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni
TorstenThiemebccd3ae2020-02-20 12:56:44 +00001014 @{unis}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001015 FOR ${uni} IN @{unis}
TorstenThiemebccd3ae2020-02-20 12:56:44 +00001016 ${matches} = Get Regexp Matches ${uni} .*port=([0-9]+),.* 1
Matteo Scandolo142e6272020-04-29 17:36:59 -07001017 &{portDict} Create Dictionary of_id=${of_id} port=${matches[0]}
1018 Append To List ${result} ${portDict}
1019 END
1020 Log ${result}
1021 Return From Keyword ${result}
1022
1023Provision all subscribers on device
Matteo Scandolo96dbe432020-05-28 10:51:57 -07001024 [Documentation] Provisions a subscriber in ONOS for all the enabled UNI ports on a particular device
TorstenThieme731a7592021-07-01 14:26:54 +00001025 [Arguments] ${ip} ${port} ${onos_ip} ${onos_rest_port} ${of_id}
1026 ${unis}= List Enabled UNI Ports ${ip} ${port} ${of_id}
Matteo Scandolo96dbe432020-05-28 10:51:57 -07001027 ${onos_auth}= Create List karaf karaf
1028 Create Session ONOS http://${onos_ip}:${onos_rest_port} auth=${onos_auth}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001029 FOR ${uni} IN @{unis}
TorstenThieme731a7592021-07-01 14:26:54 +00001030 Provision Subscriber REST ${uni['of_id']} ${uni['port']}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001031 END
1032
1033List OLTs
Matteo Scandolo50be75c2020-11-12 11:14:12 -08001034 # NOTE this method is not currently used but it can come useful in the future
1035 [Documentation] Returns a list of all OLTs known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +00001036 [Arguments] ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001037 [Return] ['of:00000a0a0a0a0a00', 'of:00000a0a0a0a0a01']
1038 ${result}= Create List
TorstenThieme731a7592021-07-01 14:26:54 +00001039 ${out}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001040 ... volt-olts
TorstenThiemebccd3ae2020-02-20 12:56:44 +00001041 @{olts}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001042 FOR ${olt} IN @{olts}
1043 Log ${olt}
TorstenThiemebccd3ae2020-02-20 12:56:44 +00001044 ${matches} = Get Regexp Matches ${olt} ^OLT (.+)$ 1
Matteo Scandolo142e6272020-04-29 17:36:59 -07001045 # there may be some logs mixed with the output so only append if we have a match
1046 ${matches_length}= Get Length ${matches}
1047 Run Keyword If ${matches_length}==1
1048 ... Append To List ${result} ${matches[0]}
1049 END
1050 Return From Keyword ${result}
1051
Matteo Scandolo75911092021-11-16 17:05:36 -08001052Count flows
1053 [Documentation] Count flows in a particular ${state} in ONOS
TorstenThiemef7cd2be2021-12-06 14:30:11 +00001054 ... Optionally for a certain onu-port.
1055 [Arguments] ${ip} ${port} ${deviceId} ${state} ${onu_port}=${EMPTY}
1056 ${cmd}= Catenate SEPARATOR= flows -s ${state} ${deviceId} | grep -v deviceId
1057 ${cmd}= Run Keyword If "${onu_port}"!="${EMPTY}" Catenate SEPARATOR= ${cmd} | grep ${onu_port}
1058 ... ELSE Set Variable ${cmd}
1059 ${cmd}= Catenate SEPARATOR= ${cmd} | wc -l
1060 ${flows}= Execute ONOS CLI Command use single connection ${ip} ${port} ${cmd}
1061 [return] ${flows}
1062
1063Validate number of flows
1064 [Documentation] Validates number of flows in a particular ${state} in ONOS
1065 ... Optionally for a certain onu-port.
1066 [Arguments] ${ip} ${port} ${targetFlows} ${deviceId} ${state} ${onu_port}=${EMPTY}
1067 ${flows}= Count flows ${ip} ${port} ${deviceId} ${state} ${onu_port}
Matteo Scandolo75911092021-11-16 17:05:36 -08001068 Log Found ${state} ${flows} of ${targetFlows} expected flows on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001069 Should Be Equal As Integers ${targetFlows} ${flows}
1070
1071Wait for all flows to in ADDED state
1072 [Documentation] Waits until the flows have been provisioned
TorstenThieme731a7592021-07-01 14:26:54 +00001073 [Arguments] ${ip} ${port} ${deviceId} ${workflow} ${uni_count} ${olt_count}
TorstenThiemeb198c482020-12-14 19:45:23 +00001074 ... ${provisioned} ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001075 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +02001076 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
TorstenThiemef7cd2be2021-12-06 14:30:11 +00001077 Wait Until Keyword Succeeds 10m 5s Validate number of flows
Matteo Scandolo75911092021-11-16 17:05:36 -08001078 ... ${ip} ${port} ${targetFlows} ${deviceId} added
1079
1080Wait for all flows to be removed
1081 [Documentation] Wait for all flows to be removed from a particular device
1082 [Arguments] ${ip} ${port} ${deviceId}
TorstenThiemef7cd2be2021-12-06 14:30:11 +00001083 Wait Until Keyword Succeeds 10m 5s Validate number of flows
Matteo Scandolo75911092021-11-16 17:05:36 -08001084 ... ${ip} ${port} 0 ${deviceId} any
1085
TorstenThieme700ccbf2022-02-11 10:24:05 +00001086Check All Flows Removed
1087 [Documentation] Checks all flows removed per OLT
1088 FOR ${I} IN RANGE 0 ${num_olts}
1089 ${olt_serial_number}= Set Variable ${list_olts}[${I}][sn]
1090 ${onu_port_list}= Get ONU Ports per OLT ${olt_serial_number}
1091 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS ${olt_serial_number}
1092 Check All Flows Removed per OLT ${of_id} ${onu_port_list}
1093 END
1094
1095Check All Flows Removed per OLT
1096 [Documentation] Checks all flows removed per OLT, in case of flow remove, not after delete device!
1097 ... Attention: For ATT there must be the eapol flow still available!
1098 [Arguments] ${of_id} ${onu_port_list}
1099 ${expected_flows_onu}= Set Variable If "${workflow}"=="ATT" 1 0
1100 FOR ${onu_port} IN @{onu_port_list}
1101 Wait Until Keyword Succeeds ${timeout} 2s Validate number of flows ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
1102 ... ${expected_flows_onu} ${of_id} any ${onu_port}
1103 END
1104
1105Get ONU Ports per OLT
1106 [Documentation] Collects all ONU ports per OLT
1107 [Arguments] ${olt}
1108 ${onu_port_list} Create List
1109 FOR ${I} IN RANGE 0 ${num_all_onus}
1110 ${src}= Set Variable ${hosts.src[${I}]}
1111 Continue For Loop If "${olt}"!="${src['olt']}"
1112 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS ${src['olt']}
1113 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']}
1114 ... ${of_id} ${src['uni_id']}
1115 ${port_id}= Get Index From List ${onu_port_list} ${onu_port}
1116 Continue For Loop If -1 != ${port_id}
1117 Append To List ${onu_port_list} ${onu_port}
1118 END
1119 [return] ${onu_port_list}
Gayathri.Selvan92d16862020-03-19 14:47:58 +00001120
Girish Gowdrad769b412021-05-16 11:09:46 -07001121Get Limiting Bandwidth Details
Gayathri.Selvan92d16862020-03-19 14:47:58 +00001122 [Arguments] ${bandwidth_profile_name}
1123 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
1124 ... returns the limiting bandwidth
Girish Gowdracb8482a2021-05-27 09:06:13 -07001125 ${cir} ${cbs} ${eir} ${ebs} ${air}= Get Bandwidth Profile Details Rest
1126 ... ${bandwidth_profile_name}
Girish Gowdrad769b412021-05-16 11:09:46 -07001127 ${limiting_BW}= Evaluate ${eir}+${cir}+${air}
Gayathri.Selvan92d16862020-03-19 14:47:58 +00001128 [Return] ${limiting_BW}
Hardik Windlasse8b99222021-01-25 10:03:14 +00001129
Emrehan UZUNd6f85892021-07-01 13:54:26 +00001130Get Limiting Bandwidth Details for Fixed and Committed
1131 [Arguments] ${bandwidth_profile_name}
1132 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
1133 ... returns the limiting bandwidth for fixed and committed
1134 ${cir} ${cbs} ${eir} ${ebs} ${air}= Get Bandwidth Profile Details Rest
1135 ... ${bandwidth_profile_name}
1136 ${limiting_BW}= Evaluate ${cir}+${air}
1137 [Return] ${limiting_BW}
1138
Hardik Windlasse8b99222021-01-25 10:03:14 +00001139Validate Deleted Device Cleanup In ONOS
Hardik Windlassc609eb02022-02-22 11:28:37 +00001140 [Arguments] ${ip} ${port} ${olt_serial_number} ${maclearning_enabled}=False
Hardik Windlasse8b99222021-01-25 10:03:14 +00001141 [Documentation] The keyword verifies that ports, flows, meters, subscribers, dhcp are all cleared in ONOS
1142 # Fetch OF Id for OLT
1143 ${olt_of_id}= Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device in ONOS ${olt_serial_number}
Hardik Windlasse8b99222021-01-25 10:03:14 +00001144 # Verify Ports are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -07001145 ${ports}= Execute ONOS CLI Command use single connection ${ip} ${port}
1146 ... ports ${olt_of_id} | grep -v ${olt_of_id}
1147 ${port_count}= Get Line Count ${ports}
1148 Should Be Equal As Integers ${port_count} 0 Ports have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +00001149 # Verify Subscribers are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -07001150 ${sub}= Execute ONOS CLI Command use single connection ${ip} ${port}
1151 ... volt-programmed-subscribers | grep ${olt_of_id}
1152 ${sub_count}= Get Line Count ${sub}
1153 Should Be Equal As Integers ${sub_count} 0 Subscribers have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +00001154 # Verify Flows are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -07001155 ${flow}= Execute ONOS CLI Command use single connection ${ip} ${port}
1156 ... flows -s -f ${olt_of_id} | grep -v deviceId
1157 ${flow_count}= Get Line Count ${flow}
1158 Should Be Equal As Integers ${flow_count} 0 Flows have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +00001159 # Verify Meters are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -07001160 ${meter}= Execute ONOS CLI Command use single connection ${ip} ${port}
1161 ... meters ${olt_of_id}
1162 ${meter_count}= Get Line Count ${meter}
1163 Should Be Equal As Integers ${meter_count} 0 Meters have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +00001164 # Verify AAA-Users are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -07001165 ${aaa}= Execute ONOS CLI Command use single connection ${ip} ${port}
1166 ... aaa-users ${olt_of_id}
1167 ${aaa_count}= Get Line Count ${aaa}
1168 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 +00001169 # Verify Dhcp-Allocations are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -07001170 ${dhcp}= Execute ONOS CLI Command use single connection ${ip} ${port}
1171 ... dhcpl2relay-allocations ${olt_of_id}
1172 ${dhcp_count}= Get Line Count ${dhcp}
1173 Should Be Equal As Integers ${dhcp_count} 0 DHCP Allocations have not been removed from ONOS after cleanup
Hardik Windlassc609eb02022-02-22 11:28:37 +00001174 # Verify MAC Learner Mappings are Removed
1175 ${mac}= Run Keyword If ${maclearning_enabled} Execute ONOS CLI Command use single connection ${ip} ${port}
1176 ... mac-learner-get-mapping | grep -v INFO
1177 ${mac_count}= Run Keyword If ${maclearning_enabled} Get Line Count ${mac}
1178 ... ELSE Set Variable 0
1179 Should Be Equal As Integers ${mac_count} 0 Client MAC Learner Mappings have not been removed from ONOS after cleanup
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001180
1181Delete ONOS App
1182 [Arguments] ${url} ${app_name}
1183 [Documentation] This keyword deactivates and uninstalls the given ONOS App
1184 ${rc}= Run And Return Rc curl --fail -sSL -X DELETE ${url}/onos/v1/applications/${app_name}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001185 Should Be Equal As Integers ${rc} 0 Can't delete ${app_name} from ONOS
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001186
1187Verify ONOS App Active
1188 [Arguments] ${url} ${app_name} ${app_version}=${EMPTY}
1189 [Documentation] This keyword verifies that the given ONOS App status is Active
1190 ${rc} ${output} Run And Return Rc And Output
1191 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name} | jq -r .state
1192 Should Be Equal As Integers ${rc} 0
1193 Should Be Equal '${output}' 'ACTIVE'
1194 ${rc1} ${output1} Run And Return Rc And Output
1195 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name} | jq -r .version
1196 Run Keyword If '${app_version}'!='${EMPTY}'
1197 ... Run Keywords
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001198 ... Should Be Equal As Integers ${rc1} 0 Can't read app ${app_name} status from ONOS
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001199 ... AND Should Be Equal '${output1}' '${app_version}'
1200
1201Install And Activate ONOS App
1202 [Arguments] ${url} ${app_oar_file}
1203 [Documentation] This keyword installs and activates the given ONOS App
1204 ${cmd}= Catenate SEPARATOR=
1205 ... curl --fail -sSL -H Content-Type:application/octet-stream -
1206 ... X POST ${url}/onos/v1/applications?activate=true --data-binary \@${app_oar_file}
1207 ${rc} ${output} Run And Return Rc And Output ${cmd}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001208 Should Be Equal As Integers ${rc} 0 Can't load onos app ${app_oar_file} to ONOS"
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001209 Log ${output}
Hardik Windlassdc2610f2021-03-09 07:33:51 +00001210
1211Get ONOS App Details
1212 [Arguments] ${url} ${app_name}
1213 [Documentation] Retrieves ONOS App Details
1214 ${rc} ${output} Run And Return Rc And Output
1215 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001216 Should Be Equal As Integers ${rc} 0 Can't read app ${app_name} details from ONOS
Hardik Windlassdc2610f2021-03-09 07:33:51 +00001217 [Return] ${output}
Hardik Windlass88075f92022-01-25 12:19:45 +00001218
1219Verify UniTag Subscriber
1220 [Documentation] Verifies the unitag subscriber is provisioned/un-provisioned
1221 [Arguments] ${ip} ${port} ${dev_id} ${onu_port} ${stag} ${ctag} ${tpid} ${sub_added}=True
1222 ${cmd}= Catenate SEPARATOR=
1223 ... volt-programmed-subscribers ${dev_id} ${onu_port} | grep "ponCTag=${ctag}, ponSTag=${stag}" | grep technologyProfileId
1224 ... =${tpid} --color=none
1225 ${subscriber}= Execute ONOS CLI Command use single connection ${ip} ${port} ${cmd}
1226 Log ${subscriber}
1227 ${sub_count}= Get Line Count ${subscriber}
1228 Run Keyword If ${sub_added}
1229 ... Should Be Equal As Integers ${sub_count} 1 UniTag Subscriber Not Added
1230 ... ELSE
1231 ... Should Be Equal As Integers ${sub_count} 0 UniTag Subscriber Not Removed