blob: cecfc19c7a012005edd5f2beac27c5bfa8325a82 [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.* .*>.*
33${regexp_prompt} k.*a.*r.*a.*f.*@.*r.*o.*o.*t.* .*>.*
34${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}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000094 ${output_length}= Get Length ${output}
95 # remove regexp-prompt if available
96 ${output}= Remove String Using Regexp ${output} ${regexp_prompt}
97 ${output_after}= Get Length ${output}
98 Run Keyword If '${PassOrFail}'=='FAIL' and ${output_length}== ${output_after} FAIL SSH access failed for '${cmd}'!
TorstenThieme1d1413b2022-02-04 12:41:01 +000099 # we do not use strip of escape sequences integrated in ssh lib, we do it by ourself to have it under control
100 ${output}= Remove String Using Regexp ${output} \\x1b[>=]{0,1}(?:\\[[0-?]*(?:[hlm])[~]{0,1})*
101 # remove the endless spaces and two carrige returns at the end of output
102 ${output}= Remove String Using Regexp ${output} \\s*\\r \\r
103 # now we have the plain output text
104 Log Stripped Result_values: ${output}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000105 [Return] ${output}
106
107Get Conn List Id
108 [Documentation] Looks up for an Open Connection with passed host and port in conection list
109 ... First match connection will be used.
110 [Arguments] ${host} ${port}
111 ${connection_list_id}= Set Variable ${EMPTY}
112 ${match}= Set Variable False
113 ${length}= Get Length ${connection_list}
114 FOR ${INDEX} IN RANGE 0 ${length}
115 #${Item}= Get From List ${connection_list} ${INDEX}
116 ${conndata}= Get Connection ${connection_list[${INDEX}].conn_id}
117 ${match}= Set Variable If '${conndata.host}'=='${host}' and '${conndata.port}'=='${port}' True False
118 ${connection_list_id}= Set Variable If ${match} ${INDEX} ${EMPTY}
119 Exit For Loop If ${match}
120 END
121 [Return] ${connection_list_id}
122
TorstenThiemeb198c482020-12-14 19:45:23 +0000123Reconnect ONOS SSH Connection
124 [Documentation] Reconnect an SSH Connection
125 [Arguments] ${connection_list_id}
126 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
127 ${user}= Get From Dictionary ${connection_entry} user
128 ${pass}= Get From Dictionary ${connection_entry} pass
129 ${oldconndata}= Get Connection ${connection_entry.conn_id}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000130 ${match}= Set Variable If
131 ... "${oldconndata.host}"=="${connection_entry.host}" and "${oldconndata.port}"=="${connection_entry.port}"
132 ... True False
133 Run Keyword If ${match} SSHLibrary.Switch Connection ${connection_entry.conn_id}
134 Run Keyword If ${match} Run Keyword And Ignore Error SSHLibrary.Close Connection
135 ${conn_id}= SSHLibrary.Open Connection ${connection_entry.host} port=${connection_entry.port}
TorstenThieme2ddb6e82022-02-08 14:44:24 +0000136 ... timeout=${ssh_read_timeout} alias=${alias}
TorstenThieme36a38a82022-02-09 15:51:30 +0000137 SSHLibrary.Login username=${user} password=${pass} keep_alive_interval=${keep_alive_interval}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000138 # set excepted prompt and terminal width to suppress unwanted line feeds
TorstenThieme2ddb6e82022-02-08 14:44:24 +0000139 SSHLibrary.Set Client Configuration prompt=${ssh_prompt} width=${ssh_width}
TorstenThiemeb198c482020-12-14 19:45:23 +0000140 ${conn_list_entry}= Create Dictionary conn_id=${conn_id} user=${user} pass=${pass}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000141 ... host=${connection_entry.host} port=${connection_entry.port} alias=${alias}
TorstenThiemeb198c482020-12-14 19:45:23 +0000142 Set List Value ${connection_list} ${connection_list_id} ${conn_list_entry}
143 Set Global Variable ${connection_list}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000144 # disable highlighting to suppress control sequences
TorstenThieme2ddb6e82022-02-08 14:44:24 +0000145 ${output}= Execute Single ONOS CLI Command ${conn_id} ${disable_highlighter} do_reconnect=False
TorstenThiemeb198c482020-12-14 19:45:23 +0000146
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700147Close ONOS SSH Connection
148 [Documentation] Close an SSH Connection
TorstenThiemeb198c482020-12-14 19:45:23 +0000149 [Arguments] ${connection_list_id}
150 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
151 ${connection_alias}= Get From Dictionary ${connection_entry} conn_id
152 ${oldconndata}= Get Connection ${connection_entry.conn_id}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700153 SSHLibrary.Switch Connection ${connection_alias}
TorstenThiemebcf14612021-01-27 10:19:18 +0000154 Run Keyword And Ignore Error SSHLibrary.Close Connection
TorstenThiemeb198c482020-12-14 19:45:23 +0000155 Remove From List ${connection_list} ${connection_list_id}
156 Set Global Variable ${connection_list}
157
158Close All ONOS SSH Connections
159 [Documentation] Close all SSH Connection and clear connection list.
160 SSHLibrary.Close All Connections
161 @{connection_list} Create List
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700162
Kailash6f5acb62019-08-28 14:38:45 -0700163Validate OLT Device in ONOS
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700164 # FIXME use volt-olts to check that the OLT is ONOS
Kailash6f5acb62019-08-28 14:38:45 -0700165 [Arguments] ${serial_number}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700166 [Documentation] Checks if olt has been connected to ONOS
Kailash6f5acb62019-08-28 14:38:45 -0700167 ${resp}= Get Request ONOS onos/v1/devices
168 ${jsondata}= To Json ${resp.content}
169 Should Not Be Empty ${jsondata['devices']}
170 ${length}= Get Length ${jsondata['devices']}
171 @{serial_numbers}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -0700172 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700173 FOR ${INDEX} IN RANGE 0 ${length}
174 ${value}= Get From List ${jsondata['devices']} ${INDEX}
175 ${of_id}= Get From Dictionary ${value} id
176 ${sn}= Get From Dictionary ${value} serial
Andy Bavierb63f6d22020-03-12 15:34:37 -0700177 ${matched}= Set Variable If '${sn}' == '${serial_number}' True False
178 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700179 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700180 Should Be True ${matched} No match for ${serial_number} found
Kailash57210eb2019-08-30 13:27:19 -0700181 [Return] ${of_id}
Kailash6f5acb62019-08-28 14:38:45 -0700182
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700183Get ONU Port in ONOS
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000184 [Arguments] ${onu_serial_number} ${olt_of_id} ${onu_uni_id}=1
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700185 [Documentation] Retrieves ONU port for the ONU in ONOS
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000186 ${onu_serial_number}= Catenate SEPARATOR=- ${onu_serial_number} ${onu_uni_id}
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700187 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
188 ${jsondata}= To Json ${resp.content}
189 Should Not Be Empty ${jsondata['ports']}
190 ${length}= Get Length ${jsondata['ports']}
191 @{ports}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -0700192 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700193 FOR ${INDEX} IN RANGE 0 ${length}
194 ${value}= Get From List ${jsondata['ports']} ${INDEX}
195 ${annotations}= Get From Dictionary ${value} annotations
196 ${onu_port}= Get From Dictionary ${value} port
197 ${portName}= Get From Dictionary ${annotations} portName
Andy Bavierb63f6d22020-03-12 15:34:37 -0700198 ${matched}= Set Variable If '${portName}' == '${onu_serial_number}' True False
199 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700200 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700201 Should Be True ${matched} No match for ${onu_serial_number} found
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700202 [Return] ${onu_port}
203
TorstenThieme9b25aab2021-12-16 15:59:45 +0000204Get Onu Ports in ONOS For ALL UNI per ONU
205 [Documentation] Retrieves ONU port(s) for the ONU in ONOS for all UNI-IDs, list of ports will return!
206 [Arguments] ${onu_serial_number} ${olt_of_id}
207 @{uni_id_list}= Create List
208 @{port_list}= Create List
209 FOR ${I} IN RANGE 0 ${num_all_onus}
210 ${src}= Set Variable ${hosts.src[${I}]}
211 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
212 ${uni_id}= Set Variable ${src['uni_id']}
213 # make sure all actions do only once per uni_id
214 ${id}= Get Index From List ${uni_id_list} ${uni_id}
215 Continue For Loop If -1 != ${id}
216 Append To List ${uni_id_list} ${uni_id}
217 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${onu_serial_number}
218 ... ${olt_of_id} ${uni_id}
219 Append To List ${port_list} ${onu_port}
220 END
221 [return] ${port_list}
222
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530223Get NNI Port in ONOS
224 [Arguments] ${olt_of_id}
225 [Documentation] Retrieves NNI port for the OLT in ONOS
226 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
227 ${jsondata}= To Json ${resp.content}
228 Should Not Be Empty ${jsondata['ports']}
229 ${length}= Get Length ${jsondata['ports']}
230 @{ports}= Create List
231 ${matched}= Set Variable False
232 FOR ${INDEX} IN RANGE 0 ${length}
233 ${value}= Get From List ${jsondata['ports']} ${INDEX}
234 ${annotations}= Get From Dictionary ${value} annotations
235 ${nni_port}= Get From Dictionary ${value} port
236 ${nniPortName}= Catenate SEPARATOR= nni- ${nni_port}
237 ${portName}= Get From Dictionary ${annotations} portName
238 ${matched}= Set Variable If '${portName}' == '${nniPortName}' True False
239 Exit For Loop If ${matched}
240 END
241 Should Be True ${matched} No match for NNI found for ${olt_of_id}
242 [Return] ${nni_port}
243
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700244Get FabricSwitch in ONOS
245 [Documentation] Returns of_id of the Fabric Switch in ONOS
246 ${resp}= Get Request ONOS onos/v1/devices
247 ${jsondata}= To Json ${resp.content}
248 Should Not Be Empty ${jsondata['devices']}
249 ${length}= Get Length ${jsondata['devices']}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700250 ${matched}= Set Variable False
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700251 FOR ${INDEX} IN RANGE 0 ${length}
252 ${value}= Get From List ${jsondata['devices']} ${INDEX}
253 ${of_id}= Get From Dictionary ${value} id
254 ${type}= Get From Dictionary ${value} type
Andy Bavierb63f6d22020-03-12 15:34:37 -0700255 ${matched}= Set Variable If '${type}' == "SWITCH" True False
256 Exit For Loop If ${matched}
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700257 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700258 Should Be True ${matched} No fabric switch found
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700259 [Return] ${of_id}
260
Andrea Campanella4c404632020-08-26 14:41:36 +0200261Get Master Instace in ONOS
262 [Arguments] ${of_id}
263 [Documentation] Returns nodeId of the Master instace for a giver device in ONOS
264 ${resp}= Get Request ONOS onos/v1/mastership/${of_id}/master
265 ${jsondata}= To Json ${resp.content}
266 Should Not Be Empty ${jsondata['nodeId']}
267 ${master_node}= Get From Dictionary ${jsondata} nodeId
268 [Return] ${master_node}
269
Matteo Scandolo7bdbe2d2021-11-29 15:48:25 -0800270Verify LLDP Flow Added
271 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
272 [Documentation] Matches for total number of LLDP flows added for one OLT
273 ${lldp_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
274 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep ETH_TYPE:lldp | grep -v ETH_TYPE:arp
275 ${lldp_flows_added_count}= Get Line Count ${lldp_flows_added}
276 Should Be Equal As Integers ${lldp_flows_added_count} ${expected_flows}
277
Hardik Windlass21807632020-04-14 16:24:55 +0530278Verify Subscriber Access Flows Added for ONU
279 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${c_tag} ${s_tag}
280 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
281 # Verify upstream table=0 flow
282 ${upstream_flow_0_cmd}= Catenate SEPARATOR=
283 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:0 |
284 ... grep VLAN_ID:${c_tag} | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000285 ${upstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530286 ... ${upstream_flow_0_cmd}
287 Should Not Be Empty ${upstream_flow_0_added}
288 # Verify upstream table=1 flow
289 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
290 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
291 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000292 ${upstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530293 ... ${flow_vlan_push_cmd}
294 Should Not Be Empty ${upstream_flow_1_added}
295 # Verify downstream table=0 flow
296 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
297 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
298 ... grep VLAN_POP | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000299 ${downstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530300 ... ${flow_vlan_pop_cmd}
301 Should Not Be Empty ${downstream_flow_0_added}
302 # Verify downstream table=1 flow
303 ${downstream_flow_1_cmd}= Catenate SEPARATOR=
304 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${c_tag} |
305 ... grep VLAN_ID:0 | grep OUTPUT:${onu_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000306 ${downstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530307 ... ${downstream_flow_1_cmd}
308 Should Not Be Empty ${downstream_flow_1_added}
309 # Verify ipv4 dhcp upstream flow
310 ${upstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200311 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:ipv4 |
Andrea Campanella08678e12020-09-18 17:40:22 +0200312 ... grep IP_PROTO:17 | grep UDP_SRC:68 | grep UDP_DST:67 | grep VLAN_ID:${c_tag} |
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200313 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000314 ${upstream_flow_ipv4_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530315 ... ${upstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200316 Should Not Be Empty ${upstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530317 # Verify ipv4 dhcp downstream flow
318 # Note: This flow will be one per nni per olt
319 ${downstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200320 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep ETH_TYPE:ipv4 |
321 ... grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 | grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000322 ${downstream_flow_ipv4_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530323 ... ${downstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200324 Should Not Be Empty ${downstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530325
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530326Verify Subscriber Access Flows Added for ONU DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530327 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530328 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
329 # Verify upstream table=0 flow
TorstenThieme4e2168e2021-06-22 14:01:47 +0000330 ${upstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530331 ... 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 +0530332 Should Not Be Empty ${upstream_flow_0_added}
333 # Verify upstream table=1 flow
334 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530335 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:Any |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530336 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000337 ${upstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530338 ... ${flow_vlan_push_cmd}
339 Should Not Be Empty ${upstream_flow_1_added}
340 # Verify downstream table=0 flow
341 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530342 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530343 ... grep VLAN_POP | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000344 ${downstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530345 ... ${flow_vlan_pop_cmd}
346 Should Not Be Empty ${downstream_flow_0_added}
347 # Verify downstream table=1 flow
TorstenThieme4e2168e2021-06-22 14:01:47 +0000348 ${downstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530349 ... 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 +0530350 Should Not Be Empty ${downstream_flow_1_added}
351
Hardik Windlassa7b34be2022-03-22 17:28:31 +0000352Verify Subscriber Access Flows Added for DT FTTB
353 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag} ${c_tag}
354 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
355 # Upstream
356 # ONU
357 ${us_flow_onu_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
358 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} | grep transition=TABLE:1
359 Should Not Be Empty ${us_flow_onu_added}
360 # OLT
361 ${us_flow_olt_cmd}= Catenate
362 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
363 ... grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
364 ${us_flow_olt_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
365 ... ${us_flow_olt_cmd}
366 Should Not Be Empty ${us_flow_olt_added}
367 # Downstream
368 # OLT
369 ${ds_flow_olt_cmd}= Catenate
370 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
371 ... grep VLAN_ID:${c_tag} | grep transition=TABLE:1
372 ${ds_flow_olt_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
373 ... ${ds_flow_olt_cmd}
374 Should Not Be Empty ${ds_flow_olt_added}
375 # ONU
376 ${ds_flow_onu_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
377 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${c_tag} | grep OUTPUT:${onu_port}
378 Should Not Be Empty ${ds_flow_onu_added}
379
380Verify DPU ANCP Flows Added for DT FTTB
381 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag} ${c_tag}
382 [Documentation] Verifies if the DPU ANCP Flows are added in ONOS for the ONU
383 # Upstream
384 # ONU
385 ${us_flow_onu_cmd}= Catenate
386 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
387 ... grep VLAN_ID:${s_tag} | grep transition=TABLE:1
388 ${us_flow_onu_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
389 ... ${us_flow_onu_cmd}
390 Should Not Be Empty ${us_flow_onu_added}
391 # OLT
392 ${us_flow_olt_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
393 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${s_tag} | grep OUTPUT:${nni_port}
394 Should Not Be Empty ${us_flow_olt_added}
395 # Downstream
396 # OLT
397 ${ds_flow_olt_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
398 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} | grep transition=TABLE:1
399 Should Not Be Empty ${ds_flow_olt_added}
400 # ONU
401 ${ds_flow_onu_cmd}= Catenate
402 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
403 ... grep VLAN_ID:${c_tag} | grep OUTPUT:${onu_port}
404 ${ds_flow_onu_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
405 ... ${ds_flow_onu_cmd}
406 Should Not Be Empty ${ds_flow_onu_added}
407
408Verify DPU MGMT Flows Added for DT FTTB
409 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag} ${c_tag}
410 [Documentation] Verifies if the DPU MGMT Flows are added in ONOS for the ONU
411 # Upstream
412 # ONU
413 ${us_flow_onu_cmd}= Catenate
414 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
415 ... grep VLAN_ID:${s_tag} | grep transition=TABLE:1
416 ${us_flow_onu_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
417 ... ${us_flow_onu_cmd}
418 Should Not Be Empty ${us_flow_onu_added}
419 # OLT
420 ${us_flow_olt_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
421 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${s_tag} | grep OUTPUT:${nni_port}
422 Should Not Be Empty ${us_flow_olt_added}
423 # Downstream
424 # OLT
425 ${ds_flow_olt_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
426 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} | grep transition=TABLE:1
427 Should Not Be Empty ${ds_flow_olt_added}
428 # ONU
429 ${ds_flow_onu_cmd}= Catenate
430 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
431 ... grep VLAN_ID:${c_tag} | grep OUTPUT:${onu_port}
432 ${ds_flow_onu_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
433 ... ${ds_flow_onu_cmd}
434 Should Not Be Empty ${ds_flow_onu_added}
435
436Verify ONOS Flows Added for DT FTTB
437 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${service}
438 [Documentation] Verifies if the Flows are added in ONOS for the ONU
439 ${num_services}= Get Length ${service}
440 FOR ${I} IN RANGE 0 ${num_services}
441 ${service_name}= Set Variable ${service[${I}]['name']}
442 ${stag}= Set Variable ${service[${I}]['s_tag']}
443 ${ctag}= Set Variable ${service[${I}]['c_tag']}
444 Run Keyword If '${service_name}' == 'FTTB_SUBSCRIBER_TRAFFIC'
445 ... Verify Subscriber Access Flows Added for DT FTTB ${ip} ${port}
446 ... ${olt_of_id} ${onu_port} ${nni_port} ${stag} ${ctag}
447 ... ELSE IF '${service_name}' == 'DPU_ANCP_TRAFFIC'
448 ... Verify DPU ANCP Flows Added for DT FTTB ${ip} ${port}
449 ... ${olt_of_id} ${onu_port} ${nni_port} ${stag} ${ctag}
450 ... ELSE IF '${service_name}' == 'DPU_MGMT_TRAFFIC'
451 ... Verify DPU MGMT Flows Added for DT FTTB ${ip} ${port}
452 ... ${olt_of_id} ${onu_port} ${nni_port} ${stag} ${ctag}
453 END
454
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530455Verify Subscriber Access Flows Added Count DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530456 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530457 [Documentation] Matches for total number of subscriber access flows added for all onus
TorstenThieme4e2168e2021-06-22 14:01:47 +0000458 ${access_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700459 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep -v ETH_TYPE:lldp | grep -v ETH_TYPE:arp
460 ${access_flows_added_count}= Get Line Count ${access_flows_added}
461 Should Be Equal As Integers ${access_flows_added_count} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530462
Huseyin Ahmet AYDIN45922c82021-05-27 12:37:32 +0000463Verify Added Flow Count for OLT TT
464 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
465 [Documentation] Total number of added flows given OLT with subscriber flows
TorstenThieme4e2168e2021-06-22 14:01:47 +0000466 ${access_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700467 ... flows -s ADDED ${olt_of_id} | grep -v deviceId
468 ${access_flows_added_count}= Get Line Count ${access_flows_added}
469 Should Be Equal As Integers ${access_flows_added_count} ${expected_flows}
Huseyin Ahmet AYDIN45922c82021-05-27 12:37:32 +0000470
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000471Verify Default Downstream Flows are added in ONOS for OLT TT
472 [Arguments] ${ip} ${port} ${olt_of_id} ${nni_port}
473 [Documentation] Verifies if the Default Downstream Flows are added in ONOS for the OLT
474 # Verify lldp flow
475 ${downstream_flow_lldp_cmd}= Catenate SEPARATOR=
476 ... flows -s ADDED ${olt_of_id} | grep lldp |
477 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000478 ${downstream_flow_lldp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000479 ... ${downstream_flow_lldp_cmd}
480 Should Not Be Empty ${downstream_flow_lldp_added}
481 # Verify downstream dhcp flow
482 ${downstream_flow_dhcp_cmd}= Catenate SEPARATOR=
483 ... flows -s ADDED ${olt_of_id} | grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 |
484 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000485 ${downstream_flow_dhcp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000486 ... ${downstream_flow_dhcp_cmd}
487 Should Not Be Empty ${downstream_flow_dhcp_added}
488 # Verify downstream igmp flow
489 ${downstream_flow_igmp_cmd}= Catenate SEPARATOR=
490 ... flows -s ADDED ${olt_of_id} | grep IP_PROTO:2 |
491 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000492 ${downstream_flow_igmp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000493 ... ${downstream_flow_igmp_cmd}
494 Should Not Be Empty ${downstream_flow_igmp_added}
495
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530496Get Programmed Subscribers
Hardik Windlassa7b34be2022-03-22 17:28:31 +0000497 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${filter}=${EMPTY}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530498 [Documentation] Retrieves the subscriber details at a given location
Hardik Windlassa7b34be2022-03-22 17:28:31 +0000499 ${cmd}= Set Variable If '${filter}' == '${EMPTY}'
500 ... volt-programmed-subscribers ${olt_of_id} ${onu_port}
501 ... volt-programmed-subscribers ${olt_of_id} ${onu_port} | grep ${filter} --color=none
502 ${programmed_sub}= Execute ONOS CLI Command use single connection ${ip} ${port} ${cmd}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530503 [Return] ${programmed_sub}
504
Hardik Windlassa7b34be2022-03-22 17:28:31 +0000505Verify Programmed Subscribers DT FTTB
506 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${service}
507 [Documentation] Verifies the subscriber is present at a given location
508 ${num_services}= Get Length ${service}
509 FOR ${I} IN RANGE 0 ${num_services}
510 ${service_name}= Set Variable ${service[${I}]['name']}
511 ${programmed_subscriber}= Get Programmed Subscribers ${ip} ${port} ${olt_of_id} ${onu_port}
512 ... ${service_name}
513 Log ${programmed_subscriber}
514 Should Not Be Empty ${programmed_subscriber}
515 END
516
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530517Get Upstream and Downstream Bandwidth Profile Name
518 [Arguments] ${programmed_sub}
519 [Documentation] Retrieves the upstream and downstream bandwidth profile name
520 ... from the programmed subscriber
521 @{programmed_sub_array}= Split String ${programmed_sub} ,
522 # Get upstream bandwidth profile name for the subscriber
523 @{param_val_pair}= Split String ${programmed_sub_array[9]} =
524 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
525 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
526 ${us_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' upstreamBandwidthProfile'
527 ... Set Variable ${programmed_sub_val}
528 Log ${us_bw_profile}
529 # Get downstream bandwidth profile name for the subscriber
530 @{param_val_pair}= Split String ${programmed_sub_array[10]} =
531 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
532 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
533 ${ds_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' downstreamBandwidthProfile'
534 ... Set Variable ${programmed_sub_val}
535 Log ${ds_bw_profile}
536 [Return] ${us_bw_profile} ${ds_bw_profile}
537
538Get Bandwidth Profile Details
539 [Arguments] ${ip} ${port} ${bw_profile}
540 [Documentation] Retrieves the details of the given bandwidth profile
TorstenThieme4e2168e2021-06-22 14:01:47 +0000541 ${bw_profile_values}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530542 ... bandwidthprofile ${bw_profile}
543 @{bw_profile_array}= Split String ${bw_profile_values} ,
544 @{param_val_pair}= Split String ${bw_profile_array[1]} =
545 ${bw_param}= Set Variable ${param_val_pair[0]}
546 ${bw_val}= Set Variable ${param_val_pair[1]}
547 ${cir} Run Keyword If '${bw_param}' == ' committedInformationRate'
548 ... Set Variable ${bw_val}
549 @{param_val_pair}= Split String ${bw_profile_array[2]} =
550 ${bw_param}= Set Variable ${param_val_pair[0]}
551 ${bw_val}= Set Variable ${param_val_pair[1]}
552 ${cbs} Run Keyword If '${bw_param}' == ' committedBurstSize'
553 ... Set Variable ${bw_val}
554 @{param_val_pair}= Split String ${bw_profile_array[3]} =
555 ${bw_param}= Set Variable ${param_val_pair[0]}
556 ${bw_val}= Set Variable ${param_val_pair[1]}
557 ${eir} Run Keyword If '${bw_param}' == ' exceededInformationRate'
558 ... Set Variable ${bw_val}
559 @{param_val_pair}= Split String ${bw_profile_array[4]} =
560 ${bw_param}= Set Variable ${param_val_pair[0]}
561 ${bw_val}= Set Variable ${param_val_pair[1]}
562 ${ebs} Run Keyword If '${bw_param}' == ' exceededBurstSize'
563 ... Set Variable ${bw_val}
564 @{param_val_pair}= Split String ${bw_profile_array[5]} =
565 ${bw_param}= Set Variable ${param_val_pair[0]}
566 ${bw_val}= Set Variable ${param_val_pair[1]}
567 @{bw_val_air}= Split String ${bw_val} }
568 ${air} Run Keyword If '${bw_param}' == ' assuredInformationRate'
569 ... Set Variable ${bw_val_air[0]}
570 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
571
Hardik Windlassba5add42021-05-04 12:41:29 +0000572Get Bandwidth Profile Details Rest
573 [Arguments] ${bw_profile_id}
574 [Documentation] Retrieves the details of the given bandwidth profile using REST API
Girish Gowdracb8482a2021-05-27 09:06:13 -0700575 ${bw_profile_id}= Remove String ${bw_profile_id} ' "
Hardik Windlassba5add42021-05-04 12:41:29 +0000576 ${resp}= Get Request ONOS onos/sadis/bandwidthprofile/${bw_profile_id}
577 ${jsondata}= To Json ${resp.content}
578 Should Not Be Empty ${jsondata['entry']}
579 ${length}= Get Length ${jsondata['entry']}
580 ${matched}= Set Variable False
581 FOR ${INDEX} IN RANGE 0 ${length}
582 ${value}= Get From List ${jsondata['entry']} ${INDEX}
583 ${bw_id}= Get From Dictionary ${value} id
584 ${matched}= Set Variable If '${bw_id}' == '${bw_profile_id}' True False
585 ${eir}= Get From Dictionary ${value} eir
586 ${ebs}= Get From Dictionary ${value} ebs
587 ${cir}= Get From Dictionary ${value} cir
588 ${cbs}= Get From Dictionary ${value} cbs
589 ${air}= Get From Dictionary ${value} air
590 Exit For Loop If ${matched}
591 END
592 Should Be True ${matched} No bandwidth profile found for id: ${bw_profile_id}
593 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
594
Hardik Windlass841979a2021-05-25 05:30:27 +0000595Get Bandwidth Profile Details Ietf Rest
596 [Arguments] ${bw_profile_id}
597 [Documentation] Retrieves the details of the given Ietf standard based bandwidth profile using REST API
598 ${bw_profile_id}= Remove String ${bw_profile_id} ' "
599 ${resp}= Get Request ONOS onos/sadis/bandwidthprofile/${bw_profile_id}
600 ${jsondata}= To Json ${resp.content}
601 Should Not Be Empty ${jsondata['entry']}
602 ${length}= Get Length ${jsondata['entry']}
603 ${matched}= Set Variable False
604 FOR ${INDEX} IN RANGE 0 ${length}
605 ${value}= Get From List ${jsondata['entry']} ${INDEX}
606 ${bw_id}= Get From Dictionary ${value} id
607 ${matched}= Set Variable If '${bw_id}' == '${bw_profile_id}' True False
608 ${pir}= Get From Dictionary ${value} pir
609 ${pbs}= Get From Dictionary ${value} pbs
610 ${cir}= Get From Dictionary ${value} cir
611 ${cbs}= Get From Dictionary ${value} cbs
612 ${gir}= Get From Dictionary ${value} gir
613 Exit For Loop If ${matched}
614 END
615 Should Be True ${matched} No bandwidth profile found for id: ${bw_profile_id}
616 [Return] ${cir} ${cbs} ${pir} ${pbs} ${gir}
617
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700618Verify Meters in ONOS Ietf
Hardik Windlassa7b34be2022-03-22 17:28:31 +0000619 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${filter}=${EMPTY}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700620 [Documentation] Verifies the meters with BW Ietf format (currently, DT workflow uses this format)
621 # Get programmed subscriber
622 ${programmed_sub}= Get Programmed Subscribers ${ip} ${port}
Hardik Windlassa7b34be2022-03-22 17:28:31 +0000623 ... ${olt_of_id} ${onu_port} ${filter}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700624 Log ${programmed_sub}
625 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
626 ... ${programmed_sub}
627 # Get upstream bandwidth profile details
628 ${us_cir} ${us_cbs} ${us_pir} ${us_pbs} ${us_gir} Get Bandwidth Profile Details Ietf Rest
629 ... ${us_bw_profile}
630 # Verify meter for upstream bandwidth profile
631 ${us_meter_cmd}= Run Keyword If ${us_gir} != 0 Catenate SEPARATOR=
632 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
633 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | grep "rate=${us_gir}, burst-size=0" | wc -l
634 ... ELSE Catenate SEPARATOR=
635 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
636 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000637 ${upstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700638 ... ${us_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700639 Should Be Equal As Integers ${upstream_meter_added} 1 Upstream meter is missing
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700640 # Get downstream bandwidth profile details
641 ${ds_cir} ${ds_cbs} ${ds_pir} ${ds_pbs} ${ds_gir} Get Bandwidth Profile Details Ietf Rest
642 ... ${ds_bw_profile}
643 # Verify meter for downstream bandwidth profile
644 ${ds_meter_cmd}= Run Keyword If ${ds_gir} != 0 Catenate SEPARATOR=
645 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
646 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | grep "rate=${ds_gir}, burst-size=0" | wc -l
647 ... ELSE Catenate SEPARATOR=
648 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
649 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000650 ${downstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700651 ... ${ds_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700652 Should Be Equal As Integers ${downstream_meter_added} 1 Downstream meter is missing
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700653
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530654Verify Meters in ONOS
655 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
656 [Documentation] Verifies the meters
657 # Get programmed subscriber
658 ${programmed_sub}= Get Programmed Subscribers ${ip} ${port}
659 ... ${olt_of_id} ${onu_port}
660 Log ${programmed_sub}
661 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
662 ... ${programmed_sub}
Matteo Scandolo2056ed72021-11-02 17:38:03 -0700663 # logging all meters to facilitate debug
664 ${all_meters}= Execute ONOS CLI Command use single connection ${ip} ${port} meters
665 Log ${all_meters}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530666 # Get upstream bandwidth profile details
667 ${us_cir} ${us_cbs} ${us_eir} ${us_ebs} ${us_air} Get Bandwidth Profile Details
668 ... ${ip} ${port} ${us_bw_profile}
669 Sleep 1s
Andrea Campanella2b367102021-05-04 19:33:46 +0200670 ${us_pbs}= Evaluate ${us_cbs}+${us_ebs}
671 ${us_pir}= Evaluate ${us_eir}+${us_cir}+${us_air}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530672 # Verify meter for upstream bandwidth profile
673 ${us_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530674 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200675 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | grep "rate=${us_air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000676 ${upstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530677 ... ${us_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700678 Should Be Equal As Integers ${upstream_meter_added} 1 Upstream meter is missing
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530679 Sleep 1s
680 # Get downstream bandwidth profile details
681 ${ds_cir} ${ds_cbs} ${ds_eir} ${ds_ebs} ${ds_air} Get Bandwidth Profile Details
682 ... ${ip} ${port} ${ds_bw_profile}
683 Sleep 1s
684 # Verify meter for downstream bandwidth profile
Andrea Campanella2b367102021-05-04 19:33:46 +0200685 ${ds_pbs}= Evaluate ${ds_cbs}+${ds_ebs}
686 ${ds_pir}= Evaluate ${ds_eir}+${ds_cir}+${ds_air}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530687 ${ds_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530688 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200689 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | grep "rate=${ds_air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000690 ${downstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530691 ... ${ds_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700692 Should Be Equal As Integers ${downstream_meter_added} 1 Downstream meter is missing
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530693
694Verify Default Meter Present in ONOS
695 [Arguments] ${ip} ${port} ${olt_of_id}
696 [Documentation] Verifies the single default meter entry is present
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530697 # Get default bandwidth profile details
698 ${cir} ${cbs} ${eir} ${ebs} ${air} Get Bandwidth Profile Details
699 ... ${ip} ${port} 'Default'
700 Sleep 1s
Andrea Campanella2b367102021-05-04 19:33:46 +0200701 ${pbs}= Evaluate ${cbs}+${ebs}
702 ${pir}= Evaluate ${eir}+${cir}+${air}
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530703 # Verify meter for default bandwidth profile
704 ${meter_cmd}= Catenate SEPARATOR=
705 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${cir}, burst-size=${cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200706 ... | grep "rate=${pir}, burst-size=${pbs}" | grep "rate=${air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000707 ${default_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530708 ... ${meter_cmd}
Matteo Scandolo2056ed72021-11-02 17:38:03 -0700709 # logging all meters to facilitate debug
710 ${all_meters}= Execute ONOS CLI Command use single connection ${ip} ${port} meters
711 Log ${all_meters}
712 # done logging all meters to facilitate debug
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700713 Should Be Equal As Integers ${default_meter_added} 1 Default Meter not present
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530714
Hardik Windlass480f3e22020-04-02 20:14:14 +0530715Verify Device Flows Removed
716 [Arguments] ${ip} ${port} ${olt_of_id}
717 [Documentation] Verifies all flows are removed from the device
TorstenThieme4e2168e2021-06-22 14:01:47 +0000718 ${device_flows}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700719 ... flows -s -f ${olt_of_id} | grep -v deviceId
720 ${flow_count}= Get Line Count ${device_flows}
721 Should Be Equal As Integers ${flow_count} 0 Flows not removed
Hardik Windlass480f3e22020-04-02 20:14:14 +0530722
Kailash6f5acb62019-08-28 14:38:45 -0700723Verify Eapol Flows Added
Andy Bavierb0c06232019-08-29 12:58:53 -0700724 [Arguments] ${ip} ${port} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700725 [Documentation] Matches for number of eapol flows based on number of onus
TorstenThieme4e2168e2021-06-22 14:01:47 +0000726 ${eapol_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Gilles Depatie675a2062019-10-22 12:44:42 -0400727 ... flows -s -f ADDED | grep eapol | grep IN_PORT | wc -l
Andy Bavierb0c06232019-08-29 12:58:53 -0700728 Should Contain ${eapol_flows_added} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700729
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800730Verify No Pending Flows For ONU
731 [Arguments] ${ip} ${port} ${onu_port}
732 [Documentation] Verifies that there are no flows "PENDING" state for the ONU in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000733 ${pending_flows}= Execute ONOS CLI Command use single connection ${ip} ${port}
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800734 ... flows -s | grep IN_PORT:${onu_port} | grep PENDING
735 Should Be Empty ${pending_flows}
736
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700737Verify Eapol Flows Added For ONU
Matteo Scandolo7e519fb2021-08-13 11:35:16 -0700738 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${c_tag}=4091
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700739 [Documentation] Verifies if the Eapol Flows are added in ONOS for the ONU
Matteo Scandolo7e519fb2021-08-13 11:35:16 -0700740 ${eapol_flow_cmd}= Catenate SEPARATOR=
741 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:eapol |
742 ... grep VLAN_ID:${c_tag} | grep OUTPUT:CONTROLLER
743 ${eapol_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port} ${eapol_flow_cmd}
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700744 Should Not Be Empty ${eapol_flows_added}
745
Hardik Windlass39015672021-07-05 05:48:08 +0000746Verify UNI Port Is Enabled
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000747 [Arguments] ${ip} ${port} ${onu_name} ${onu_uni_id}=1
Hardik Windlass39015672021-07-05 05:48:08 +0000748 [Documentation] Verifies if the ONU's UNI port is enabled in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000749 ${onu_port_enabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000750 ... ports -e | grep portName=${onu_name}-${onu_uni_id}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800751 Log ${onu_port_enabled}
752 Should Not Be Empty ${onu_port_enabled}
753
Hardik Windlass39015672021-07-05 05:48:08 +0000754Verify UNI Port Is Disabled
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 disabled in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000757 ${onu_port_disabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo02768532021-10-21 15:14:12 -0700758 ... ports | grep portName=${onu_name}-${onu_uni_id} | grep state=disabled
Hardik Windlass63d5e002020-03-06 21:07:09 +0530759 Log ${onu_port_disabled}
Matteo Scandolo02768532021-10-21 15:14:12 -0700760 Should Not Be Empty ${onu_port_disabled}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530761
TorstenThieme9b25aab2021-12-16 15:59:45 +0000762Wait For All UNI Ports Are Disabled per ONU
763 [Documentation] Verifies all UNI Ports of passed ONU are disabled
764 [Arguments] ${ip} ${port} ${onu_serial_number}
765 @{uni_id_list}= Create List
766 FOR ${I} IN RANGE 0 ${num_all_onus}
767 ${src}= Set Variable ${hosts.src[${I}]}
768 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
769 ${uni_id}= Set Variable ${src['uni_id']}
770 # make sure all actions do only once per uni_id
771 ${id}= Get Index From List ${uni_id_list} ${uni_id}
772 Continue For Loop If -1 != ${id}
773 Append To List ${uni_id_list} ${uni_id}
774 Wait Until Keyword Succeeds ${timeout} 2s
775 ... Verify UNI Port Is Disabled ${ip} ${port} ${onu_serial_number} ${uni_id}
776 END
777
778Wait For All UNI Ports Are Enabled per ONU
779 [Documentation] Verifies all UNI Ports of passed ONU are enabled
780 [Arguments] ${ip} ${port} ${onu_serial_number}
781 @{uni_id_list}= Create List
782 FOR ${I} IN RANGE 0 ${num_all_onus}
783 ${src}= Set Variable ${hosts.src[${I}]}
784 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
785 ${uni_id}= Set Variable ${src['uni_id']}
786 # make sure all actions do only once per uni_id
787 ${id}= Get Index From List ${uni_id_list} ${uni_id}
788 Continue For Loop If -1 != ${id}
789 Append To List ${uni_id_list} ${uni_id}
790 Wait Until Keyword Succeeds ${timeout} 2s
791 ... Verify UNI Port Is Enabled ${ip} ${port} ${onu_serial_number} ${uni_id}
792 END
793
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700794Verify ONU in AAA-Users
795 [Arguments] ${ip} ${port} ${onu_port}
796 [Documentation] Verifies that the specified onu_port exists in aaa-users output
TorstenThieme4e2168e2021-06-22 14:01:47 +0000797 ${aaa_users}= Execute ONOS CLI Command use single connection ${ip} ${port}
798 ... aaa-users | grep AUTHORIZED | grep ${onu_port}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700799 Should Not Be Empty ${aaa_users} ONU port ${onu_port} not found in aaa-users
800
Hardik Windlass513afd12021-02-03 15:19:46 +0000801Verify Empty Group in ONOS
802 [Documentation] Verifies zero group count on the device
TorstenThieme731a7592021-07-01 14:26:54 +0000803 [Arguments] ${ip} ${port} ${deviceId}
804 ${groups}= Execute ONOS CLI Command use single connection ${ip} ${port} groups | grep ${deviceId}
Hardik Windlass513afd12021-02-03 15:19:46 +0000805 @{groups_arr}= Split String ${groups} ,
806 @{group_count_arr}= Split String ${groups_arr[1]} =
807 ${group_count}= Set Variable ${group_count_arr[1]}
808 Should Be Equal As Integers ${group_count} 0
809
810Verify ONUs in Group Count in ONOS
811 [Documentation] Verifies there exists a group bucket list with certain entries/count
812 ... Note: Currently, this validates only if all ONUs of an OLT joined the same igmp group
TorstenThieme731a7592021-07-01 14:26:54 +0000813 [Arguments] ${ip} ${port} ${count} ${deviceId}
814 ${result}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolofd36e212021-03-02 11:36:10 -0800815 ... groups added ${deviceId} | grep bucket | wc -l
816 Should Be Equal As Integers ${result} ${count} Bucket list count for a group: Found=${result} Expected=${count}
Hardik Windlass513afd12021-02-03 15:19:46 +0000817
818Verify ONU in Group Bucket
819 [Documentation] Matches if ONU port in Group Bucket
820 [Arguments] ${group_bucket_values} ${onu_port}
821 ${len}= Get Length ${group_bucket_values}
822 ${matched}= Set Variable False
823 FOR ${INDEX} IN RANGE 0 ${len}
824 ${value_bucket}= Get From List ${group_bucket_values} ${INDEX}
825 ${treatment}= Get From Dictionary ${value_bucket} treatment
826 ${instructions}= Get From Dictionary ${treatment} instructions
827 ${instructions_val}= Get From List ${instructions} 0
828 ${port}= Get From Dictionary ${instructions_val} port
829 ${matched}= Set Variable If '${port}'=='${onu_port}' True False
830 Exit For Loop If ${matched}
831 END
832 [Return] ${matched}
833
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700834Verify ONU in Groups
835 [Arguments] ${ip_onos} ${port_onos} ${deviceId} ${onu_port} ${group_exist}=True
836 [Documentation] Verifies that the specified onu_port exists in groups output
TorstenThieme4e2168e2021-06-22 14:01:47 +0000837 ${result}= Execute ONOS CLI Command use single connection ${ip_onos} ${port_onos} groups -j
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700838 Log Groups: ${result}
839 ${groups}= To Json ${result}
840 ${length}= Get Length ${groups}
841 ${buckets}= Create List
842 ${matched}= Set Variable False
843 FOR ${INDEX} IN RANGE 0 ${length}
844 ${value}= Get From List ${groups} ${INDEX}
845 ${devId}= Get From Dictionary ${value} deviceId
846 ${bucket}= Get From Dictionary ${value} buckets
847 Run Keyword If '${devId}'=='${deviceId}'
848 ... Append To List ${buckets} ${bucket}
849 END
850 ${bucket_len}= Get Length ${buckets}
Hardik Windlass513afd12021-02-03 15:19:46 +0000851 FOR ${INDEX_1} IN RANGE 0 ${bucket_len}
852 ${value}= Get From List ${buckets} ${INDEX_1}
853 ${matched}= Verify ONU in Group Bucket ${value} ${onu_port}
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700854 Exit For Loop If ${matched}
855 END
856 Run Keyword If ${group_exist}
857 ... Should Be True ${matched} No match for ${deviceId} and ${onu_port} found in ONOS groups
858 ... ELSE
859 ... Should Be True '${matched}'=='False' Match for ${deviceId} and ${onu_port} found in ONOS groups
860
Matteo Scandolo142e6272020-04-29 17:36:59 -0700861Assert Number of AAA-Users
TorstenThieme731a7592021-07-01 14:26:54 +0000862 [Arguments] ${ip} ${port} ${expected_onus} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700863 [Documentation] Matches for number of aaa-users authorized based on number of onus
TorstenThieme731a7592021-07-01 14:26:54 +0000864 ${aaa_users}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800865 ... aaa-users | grep ${deviceId} | grep AUTHORIZED | wc -l
866 Log Found ${aaa_users} of ${expected_onus} expected authenticated users on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700867 Should Be Equal As Integers ${aaa_users} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700868
869Validate DHCP Allocations
TorstenThieme731a7592021-07-01 14:26:54 +0000870 [Arguments] ${ip} ${port} ${count} ${workflow} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700871 [Documentation] Matches for number of dhcpacks based on number of onus
TorstenThieme731a7592021-07-01 14:26:54 +0000872 ${allocations}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800873 ... dhcpl2relay-allocations | grep ${deviceId} | grep DHCPACK | wc -l
Matteo Scandoloda854b02020-09-01 16:20:51 -0700874 # if the workflow is TT we'll have 2 allocations for each ONU
875 ${ttAllocations}= Evaluate (${count} * 2)
876 ${count}= Set Variable If $workflow=='tt' ${ttAllocations} ${count}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800877 Log Found ${allocations} of ${count} expected DHCPACK on device ${deviceId}
Matteo Scandoloda854b02020-09-01 16:20:51 -0700878 Should Be Equal As Integers ${allocations} ${count}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700879
880Validate Subscriber DHCP Allocation
Suchitra Vemuri42819412020-10-01 17:45:43 -0700881 [Arguments] ${ip} ${port} ${onu_port} ${vlan}=''
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700882 [Documentation] Verifies that the specified subscriber is found in DHCP allocations
883 ##TODO: Enhance the keyword to include DHCP allocated address is not 0.0.0.0
TorstenThieme4e2168e2021-06-22 14:01:47 +0000884 ${allocations}= Execute ONOS CLI Command use single connection ${ip} ${port}
Suchitra Vemuri42819412020-10-01 17:45:43 -0700885 ... dhcpl2relay-allocations | grep DHCPACK | grep ${onu_port} | grep ${vlan}
Gilles Depatie675a2062019-10-22 12:44:42 -0400886 Should Not Be Empty ${allocations} ONU port ${onu_port} not found in dhcpl2relay-allocations
David Bainbridgef81cd642019-11-20 00:14:47 +0000887
Hardik Windlassc609eb02022-02-22 11:28:37 +0000888Validate Mac Learner Mapping in ONOS
889 [Arguments] ${ip} ${port} ${dev_id} ${onu_port} ${vlan}
890 [Documentation] Verifies the MAC mapping for the client
891 ${mac}= Execute ONOS CLI Command use single connection ${ip} ${port}
892 ... mac-learner-get-mapping ${dev_id} ${onu_port} ${vlan} | grep -v INFO
893 Should Not Be Empty ${mac}
894 ... No client mac-mapping found with vlan-id: ${vlan} that uses port: ${onu_port} of device: ${dev_id}
895
David Bainbridgef81cd642019-11-20 00:14:47 +0000896Device Is Available In ONOS
Matteo Scandolo3218d5b2021-05-26 11:50:10 -0700897 [Arguments] ${url} ${dpid} ${available}=true
898 [Documentation] Validates the device exists and it has the expected availability in ONOS
David Bainbridgef81cd642019-11-20 00:14:47 +0000899 ${rc} ${json} Run And Return Rc And Output curl --fail -sSL ${url}/onos/v1/devices/${dpid}
900 Should Be Equal As Integers 0 ${rc}
901 ${rc} ${value} Run And Return Rc And Output echo '${json}' | jq -r .available
902 Should Be Equal As Integers 0 ${rc}
Matteo Scandolo3218d5b2021-05-26 11:50:10 -0700903 Should Be Equal ${available} ${value}
David Bainbridgef81cd642019-11-20 00:14:47 +0000904
905Remove All Devices From ONOS
906 [Arguments] ${url}
907 [Documentation] Executes the device-remove command on each device in ONOS
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000908 ${rc} ${output} Run And Return Rc And Output
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700909 ... curl --fail -sSL ${url}/onos/v1/devices | jq -r '.devices[].id'
David Bainbridgef81cd642019-11-20 00:14:47 +0000910 Should Be Equal As Integers ${rc} 0
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000911 @{dpids} Split String ${output}
David Bainbridgef81cd642019-11-20 00:14:47 +0000912 ${count}= Get length ${dpids}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700913 FOR ${dpid} IN @{dpids}
914 ${rc}= Run Keyword If '${dpid}' != ''
915 ... Run And Return Rc curl -XDELETE --fail -sSL ${url}/onos/v1/devices/${dpid}
916 Run Keyword If '${dpid}' != ''
917 ... Should Be Equal As Integers ${rc} 0
918 END
Matteo Scandolo142e6272020-04-29 17:36:59 -0700919
TorstenThieme440b7c02020-12-18 15:42:57 +0000920Assert ONU Port Is Disabled
TorstenThieme731a7592021-07-01 14:26:54 +0000921 [Arguments] ${ip} ${port} ${deviceId} ${onu_port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000922 [Documentation] Verifies if the ONU port is disabled in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000923 ${onu_port_disabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000924 ... ports -d ${deviceId} | grep port=${onu_port}
925 Log ${onu_port_disabled}
926 Should Not Be Empty ${onu_port_disabled}
927
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700928Assert Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000929 [Arguments] ${ip} ${port} ${count}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700930 [Documentation] DEPRECATED use Assert Olt in ONOS
931 ... Check that a certain number of olts are known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000932 ${olts}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700933 ... volt-olts | wc -l
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700934 Log Found ${olts} of ${count} expected Olts
935 Should Be Equal As Integers ${olts} ${count}
936
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700937Assert Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000938 [Arguments] ${ip} ${port} ${deviceId}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700939 [Documentation] Check that a particular olt is 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 | grep ${deviceId} | wc -l
942 Should Be Equal As Integers ${olts} 1 "Device ${deviceId} is not recognized as an OLT"
943
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700944Wait for Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000945 [Arguments] ${ip} ${port} ${count} ${max_wait_time}=10m
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700946 [Documentation] DEPRECATED use Wait for Olt in ONOS
947 ... Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700948 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000949 ... ${ip} ${port} ${count}
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700950
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700951Wait for Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000952 [Arguments] ${ip} ${port} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700953 [Documentation] Waits until a particular deviceId is recognized by ONOS as an OLT
954 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000955 ... ${ip} ${port} ${deviceId}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700956
Matteo Scandolo142e6272020-04-29 17:36:59 -0700957Assert Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000958 [Arguments] ${ip} ${port} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700959 [Documentation] Check that a certain number of ports are enabled in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000960 ${ports}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800961 ... ports -e ${deviceId} | grep ${filter} | wc -l
962 Log Found ${ports} of ${count} expected ports on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700963 Should Be Equal As Integers ${ports} ${count}
964
965Wait for Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000966 [Arguments] ${ip} ${port} ${count} ${deviceId} ${filter} ${max_wait_time}=10m
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800967 [Documentation] Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
TorstenThiemed4f48962020-12-08 12:17:19 +0000968 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000969 ... ${ip} ${port} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700970
971Wait for AAA Authentication
TorstenThieme731a7592021-07-01 14:26:54 +0000972 [Arguments] ${ip} ${port} ${count} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700973 [Documentation] Waits untill a certain number of subscribers are authenticated in ONOS
TorstenThiemed4f48962020-12-08 12:17:19 +0000974 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Number of AAA-Users
TorstenThieme731a7592021-07-01 14:26:54 +0000975 ... ${ip} ${port} ${count} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700976
977Wait for DHCP Ack
TorstenThieme731a7592021-07-01 14:26:54 +0000978 [Arguments] ${ip} ${port} ${count} ${workflow} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700979 [Documentation] Waits untill a certain number of subscribers have received a DHCP_ACK
TorstenThiemed4f48962020-12-08 12:17:19 +0000980 Wait Until Keyword Succeeds ${max_wait_time} 5s Validate DHCP Allocations
TorstenThieme731a7592021-07-01 14:26:54 +0000981 ... ${ip} ${port} ${count} ${workflow} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700982
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700983Provision subscriber REST
984 [Documentation] Uses the rest APIs to provision a subscriber
TorstenThieme731a7592021-07-01 14:26:54 +0000985 [Arguments] ${of_id} ${onu_port}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700986 ${resp}= Post Request ONOS
987 ... /onos/olt/oltapp/${of_id}/${onu_port}
988 Should Be Equal As Strings ${resp.status_code} 200
989
Hardik Windlassea4caf72021-07-30 07:22:12 +0000990Count Enabled UNI Ports
991 [Documentation] Count all the UNI Ports on a Device
992 [Arguments] ${ip} ${port} ${of_id}
993 ${count}= Execute ONOS CLI Command use single connection ${ip} ${port}
994 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni | wc -l
995 Log ${count}
996 [Return] ${count}
997
Matteo Scandolo142e6272020-04-29 17:36:59 -0700998List Enabled UNI Ports
999 [Documentation] List all the UNI Ports, the only way we have is to filter out the one called NNI
1000 ... Creates a list of dictionaries
TorstenThieme731a7592021-07-01 14:26:54 +00001001 [Arguments] ${ip} ${port} ${of_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001002 [Return] [{'port': '16', 'of_id': 'of:00000a0a0a0a0a00'}, {'port': '32', 'of_id': 'of:00000a0a0a0a0a00'}]
1003 ${result}= Create List
TorstenThieme731a7592021-07-01 14:26:54 +00001004 ${out}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001005 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni
TorstenThiemebccd3ae2020-02-20 12:56:44 +00001006 @{unis}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001007 FOR ${uni} IN @{unis}
TorstenThiemebccd3ae2020-02-20 12:56:44 +00001008 ${matches} = Get Regexp Matches ${uni} .*port=([0-9]+),.* 1
Matteo Scandolo142e6272020-04-29 17:36:59 -07001009 &{portDict} Create Dictionary of_id=${of_id} port=${matches[0]}
1010 Append To List ${result} ${portDict}
1011 END
1012 Log ${result}
1013 Return From Keyword ${result}
1014
1015Provision all subscribers on device
Matteo Scandolo96dbe432020-05-28 10:51:57 -07001016 [Documentation] Provisions a subscriber in ONOS for all the enabled UNI ports on a particular device
TorstenThieme731a7592021-07-01 14:26:54 +00001017 [Arguments] ${ip} ${port} ${onos_ip} ${onos_rest_port} ${of_id}
1018 ${unis}= List Enabled UNI Ports ${ip} ${port} ${of_id}
Matteo Scandolo96dbe432020-05-28 10:51:57 -07001019 ${onos_auth}= Create List karaf karaf
1020 Create Session ONOS http://${onos_ip}:${onos_rest_port} auth=${onos_auth}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001021 FOR ${uni} IN @{unis}
TorstenThieme731a7592021-07-01 14:26:54 +00001022 Provision Subscriber REST ${uni['of_id']} ${uni['port']}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001023 END
1024
1025List OLTs
Matteo Scandolo50be75c2020-11-12 11:14:12 -08001026 # NOTE this method is not currently used but it can come useful in the future
1027 [Documentation] Returns a list of all OLTs known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +00001028 [Arguments] ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001029 [Return] ['of:00000a0a0a0a0a00', 'of:00000a0a0a0a0a01']
1030 ${result}= Create List
TorstenThieme731a7592021-07-01 14:26:54 +00001031 ${out}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001032 ... volt-olts
TorstenThiemebccd3ae2020-02-20 12:56:44 +00001033 @{olts}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001034 FOR ${olt} IN @{olts}
1035 Log ${olt}
TorstenThiemebccd3ae2020-02-20 12:56:44 +00001036 ${matches} = Get Regexp Matches ${olt} ^OLT (.+)$ 1
Matteo Scandolo142e6272020-04-29 17:36:59 -07001037 # there may be some logs mixed with the output so only append if we have a match
1038 ${matches_length}= Get Length ${matches}
1039 Run Keyword If ${matches_length}==1
1040 ... Append To List ${result} ${matches[0]}
1041 END
1042 Return From Keyword ${result}
1043
Matteo Scandolo75911092021-11-16 17:05:36 -08001044Count flows
1045 [Documentation] Count flows in a particular ${state} in ONOS
TorstenThiemef7cd2be2021-12-06 14:30:11 +00001046 ... Optionally for a certain onu-port.
1047 [Arguments] ${ip} ${port} ${deviceId} ${state} ${onu_port}=${EMPTY}
1048 ${cmd}= Catenate SEPARATOR= flows -s ${state} ${deviceId} | grep -v deviceId
1049 ${cmd}= Run Keyword If "${onu_port}"!="${EMPTY}" Catenate SEPARATOR= ${cmd} | grep ${onu_port}
1050 ... ELSE Set Variable ${cmd}
1051 ${cmd}= Catenate SEPARATOR= ${cmd} | wc -l
1052 ${flows}= Execute ONOS CLI Command use single connection ${ip} ${port} ${cmd}
1053 [return] ${flows}
1054
1055Validate number of flows
1056 [Documentation] Validates number of flows in a particular ${state} in ONOS
1057 ... Optionally for a certain onu-port.
1058 [Arguments] ${ip} ${port} ${targetFlows} ${deviceId} ${state} ${onu_port}=${EMPTY}
1059 ${flows}= Count flows ${ip} ${port} ${deviceId} ${state} ${onu_port}
Matteo Scandolo75911092021-11-16 17:05:36 -08001060 Log Found ${state} ${flows} of ${targetFlows} expected flows on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001061 Should Be Equal As Integers ${targetFlows} ${flows}
1062
1063Wait for all flows to in ADDED state
1064 [Documentation] Waits until the flows have been provisioned
TorstenThieme731a7592021-07-01 14:26:54 +00001065 [Arguments] ${ip} ${port} ${deviceId} ${workflow} ${uni_count} ${olt_count}
TorstenThiemeb198c482020-12-14 19:45:23 +00001066 ... ${provisioned} ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -07001067 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +02001068 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
TorstenThiemef7cd2be2021-12-06 14:30:11 +00001069 Wait Until Keyword Succeeds 10m 5s Validate number of flows
Matteo Scandolo75911092021-11-16 17:05:36 -08001070 ... ${ip} ${port} ${targetFlows} ${deviceId} added
1071
1072Wait for all flows to be removed
1073 [Documentation] Wait for all flows to be removed from a particular device
1074 [Arguments] ${ip} ${port} ${deviceId}
TorstenThiemef7cd2be2021-12-06 14:30:11 +00001075 Wait Until Keyword Succeeds 10m 5s Validate number of flows
Matteo Scandolo75911092021-11-16 17:05:36 -08001076 ... ${ip} ${port} 0 ${deviceId} any
1077
TorstenThieme700ccbf2022-02-11 10:24:05 +00001078Check All Flows Removed
1079 [Documentation] Checks all flows removed per OLT
1080 FOR ${I} IN RANGE 0 ${num_olts}
1081 ${olt_serial_number}= Set Variable ${list_olts}[${I}][sn]
1082 ${onu_port_list}= Get ONU Ports per OLT ${olt_serial_number}
1083 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS ${olt_serial_number}
1084 Check All Flows Removed per OLT ${of_id} ${onu_port_list}
1085 END
1086
1087Check All Flows Removed per OLT
1088 [Documentation] Checks all flows removed per OLT, in case of flow remove, not after delete device!
1089 ... Attention: For ATT there must be the eapol flow still available!
1090 [Arguments] ${of_id} ${onu_port_list}
1091 ${expected_flows_onu}= Set Variable If "${workflow}"=="ATT" 1 0
1092 FOR ${onu_port} IN @{onu_port_list}
1093 Wait Until Keyword Succeeds ${timeout} 2s Validate number of flows ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
1094 ... ${expected_flows_onu} ${of_id} any ${onu_port}
1095 END
1096
1097Get ONU Ports per OLT
1098 [Documentation] Collects all ONU ports per OLT
1099 [Arguments] ${olt}
1100 ${onu_port_list} Create List
1101 FOR ${I} IN RANGE 0 ${num_all_onus}
1102 ${src}= Set Variable ${hosts.src[${I}]}
1103 Continue For Loop If "${olt}"!="${src['olt']}"
1104 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS ${src['olt']}
1105 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']}
1106 ... ${of_id} ${src['uni_id']}
1107 ${port_id}= Get Index From List ${onu_port_list} ${onu_port}
1108 Continue For Loop If -1 != ${port_id}
1109 Append To List ${onu_port_list} ${onu_port}
1110 END
1111 [return] ${onu_port_list}
Gayathri.Selvan92d16862020-03-19 14:47:58 +00001112
Girish Gowdrad769b412021-05-16 11:09:46 -07001113Get Limiting Bandwidth Details
Gayathri.Selvan92d16862020-03-19 14:47:58 +00001114 [Arguments] ${bandwidth_profile_name}
1115 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
1116 ... returns the limiting bandwidth
Girish Gowdracb8482a2021-05-27 09:06:13 -07001117 ${cir} ${cbs} ${eir} ${ebs} ${air}= Get Bandwidth Profile Details Rest
1118 ... ${bandwidth_profile_name}
Girish Gowdrad769b412021-05-16 11:09:46 -07001119 ${limiting_BW}= Evaluate ${eir}+${cir}+${air}
Gayathri.Selvan92d16862020-03-19 14:47:58 +00001120 [Return] ${limiting_BW}
Hardik Windlasse8b99222021-01-25 10:03:14 +00001121
Emrehan UZUNd6f85892021-07-01 13:54:26 +00001122Get Limiting Bandwidth Details for Fixed and Committed
1123 [Arguments] ${bandwidth_profile_name}
1124 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
1125 ... returns the limiting bandwidth for fixed and committed
1126 ${cir} ${cbs} ${eir} ${ebs} ${air}= Get Bandwidth Profile Details Rest
1127 ... ${bandwidth_profile_name}
1128 ${limiting_BW}= Evaluate ${cir}+${air}
1129 [Return] ${limiting_BW}
1130
Hardik Windlasse8b99222021-01-25 10:03:14 +00001131Validate Deleted Device Cleanup In ONOS
Hardik Windlassc609eb02022-02-22 11:28:37 +00001132 [Arguments] ${ip} ${port} ${olt_serial_number} ${maclearning_enabled}=False
Hardik Windlasse8b99222021-01-25 10:03:14 +00001133 [Documentation] The keyword verifies that ports, flows, meters, subscribers, dhcp are all cleared in ONOS
1134 # Fetch OF Id for OLT
1135 ${olt_of_id}= Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device in ONOS ${olt_serial_number}
Hardik Windlasse8b99222021-01-25 10:03:14 +00001136 # Verify Ports are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -07001137 ${ports}= Execute ONOS CLI Command use single connection ${ip} ${port}
1138 ... ports ${olt_of_id} | grep -v ${olt_of_id}
1139 ${port_count}= Get Line Count ${ports}
1140 Should Be Equal As Integers ${port_count} 0 Ports have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +00001141 # Verify Subscribers are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -07001142 ${sub}= Execute ONOS CLI Command use single connection ${ip} ${port}
1143 ... volt-programmed-subscribers | grep ${olt_of_id}
1144 ${sub_count}= Get Line Count ${sub}
1145 Should Be Equal As Integers ${sub_count} 0 Subscribers have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +00001146 # Verify Flows are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -07001147 ${flow}= Execute ONOS CLI Command use single connection ${ip} ${port}
1148 ... flows -s -f ${olt_of_id} | grep -v deviceId
1149 ${flow_count}= Get Line Count ${flow}
1150 Should Be Equal As Integers ${flow_count} 0 Flows have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +00001151 # Verify Meters are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -07001152 ${meter}= Execute ONOS CLI Command use single connection ${ip} ${port}
1153 ... meters ${olt_of_id}
1154 ${meter_count}= Get Line Count ${meter}
1155 Should Be Equal As Integers ${meter_count} 0 Meters have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +00001156 # Verify AAA-Users are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -07001157 ${aaa}= Execute ONOS CLI Command use single connection ${ip} ${port}
1158 ... aaa-users ${olt_of_id}
1159 ${aaa_count}= Get Line Count ${aaa}
1160 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 +00001161 # Verify Dhcp-Allocations are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -07001162 ${dhcp}= Execute ONOS CLI Command use single connection ${ip} ${port}
1163 ... dhcpl2relay-allocations ${olt_of_id}
1164 ${dhcp_count}= Get Line Count ${dhcp}
1165 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 +00001166 # Verify MAC Learner Mappings are Removed
1167 ${mac}= Run Keyword If ${maclearning_enabled} Execute ONOS CLI Command use single connection ${ip} ${port}
1168 ... mac-learner-get-mapping | grep -v INFO
1169 ${mac_count}= Run Keyword If ${maclearning_enabled} Get Line Count ${mac}
1170 ... ELSE Set Variable 0
1171 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 +00001172
1173Delete ONOS App
1174 [Arguments] ${url} ${app_name}
1175 [Documentation] This keyword deactivates and uninstalls the given ONOS App
1176 ${rc}= Run And Return Rc curl --fail -sSL -X DELETE ${url}/onos/v1/applications/${app_name}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001177 Should Be Equal As Integers ${rc} 0 Can't delete ${app_name} from ONOS
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001178
1179Verify ONOS App Active
1180 [Arguments] ${url} ${app_name} ${app_version}=${EMPTY}
1181 [Documentation] This keyword verifies that the given ONOS App status is Active
1182 ${rc} ${output} Run And Return Rc And Output
1183 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name} | jq -r .state
1184 Should Be Equal As Integers ${rc} 0
1185 Should Be Equal '${output}' 'ACTIVE'
1186 ${rc1} ${output1} Run And Return Rc And Output
1187 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name} | jq -r .version
1188 Run Keyword If '${app_version}'!='${EMPTY}'
1189 ... Run Keywords
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001190 ... Should Be Equal As Integers ${rc1} 0 Can't read app ${app_name} status from ONOS
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001191 ... AND Should Be Equal '${output1}' '${app_version}'
1192
1193Install And Activate ONOS App
1194 [Arguments] ${url} ${app_oar_file}
1195 [Documentation] This keyword installs and activates the given ONOS App
1196 ${cmd}= Catenate SEPARATOR=
1197 ... curl --fail -sSL -H Content-Type:application/octet-stream -
1198 ... X POST ${url}/onos/v1/applications?activate=true --data-binary \@${app_oar_file}
1199 ${rc} ${output} Run And Return Rc And Output ${cmd}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001200 Should Be Equal As Integers ${rc} 0 Can't load onos app ${app_oar_file} to ONOS"
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001201 Log ${output}
Hardik Windlassdc2610f2021-03-09 07:33:51 +00001202
1203Get ONOS App Details
1204 [Arguments] ${url} ${app_name}
1205 [Documentation] Retrieves ONOS App Details
1206 ${rc} ${output} Run And Return Rc And Output
1207 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001208 Should Be Equal As Integers ${rc} 0 Can't read app ${app_name} details from ONOS
Hardik Windlassdc2610f2021-03-09 07:33:51 +00001209 [Return] ${output}
Hardik Windlass88075f92022-01-25 12:19:45 +00001210
1211Verify UniTag Subscriber
1212 [Documentation] Verifies the unitag subscriber is provisioned/un-provisioned
1213 [Arguments] ${ip} ${port} ${dev_id} ${onu_port} ${stag} ${ctag} ${tpid} ${sub_added}=True
1214 ${cmd}= Catenate SEPARATOR=
1215 ... volt-programmed-subscribers ${dev_id} ${onu_port} | grep "ponCTag=${ctag}, ponSTag=${stag}" | grep technologyProfileId
1216 ... =${tpid} --color=none
1217 ${subscriber}= Execute ONOS CLI Command use single connection ${ip} ${port} ${cmd}
1218 Log ${subscriber}
1219 ${sub_count}= Get Line Count ${subscriber}
1220 Run Keyword If ${sub_added}
1221 ... Should Be Equal As Integers ${sub_count} 1 UniTag Subscriber Not Added
1222 ... ELSE
1223 ... Should Be Equal As Integers ${sub_count} 0 UniTag Subscriber Not Removed