blob: bdf39c90069a09bd184d6c0e6a1e7fdfd4fad83b [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
30${ssh_read_timeout} 15s
31${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
79 ${PassOrFail} ${Written}= Run Keyword And Ignore Error Write ${cmd}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000080 Run Keyword If '${PassOrFail}'=='FAIL' and ${do_reconnect} Reconnect ONOS SSH Connection ${connection_list_id}
TorstenThieme1d1413b2022-02-04 12:41:01 +000081 ${Written}= Run Keyword If '${PassOrFail}'=='FAIL' Write ${cmd} ELSE Set Variable ${Written}
82 Log pass_write: ${Written}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000083 ${PassOrFail} ${output}= Run Keyword And Ignore Error Read Until Prompt strip_prompt=True
TorstenThieme1d1413b2022-02-04 12:41:01 +000084 Log Result_values: ${output}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000085 ${output_length}= Get Length ${output}
86 # remove regexp-prompt if available
87 ${output}= Remove String Using Regexp ${output} ${regexp_prompt}
88 ${output_after}= Get Length ${output}
89 Run Keyword If '${PassOrFail}'=='FAIL' and ${output_length}== ${output_after} FAIL SSH access failed for '${cmd}'!
90 ${prompt_exist} Run Keyword If '${PassOrFail}'=='FAIL' Should Match Regexp ${output} ${regexp_prompt}
TorstenThieme1d1413b2022-02-04 12:41:01 +000091 # we do not use strip of escape sequences integrated in ssh lib, we do it by ourself to have it under control
92 ${output}= Remove String Using Regexp ${output} \\x1b[>=]{0,1}(?:\\[[0-?]*(?:[hlm])[~]{0,1})*
93 # remove the endless spaces and two carrige returns at the end of output
94 ${output}= Remove String Using Regexp ${output} \\s*\\r \\r
95 # now we have the plain output text
96 Log Stripped Result_values: ${output}
TorstenThieme4e2168e2021-06-22 14:01:47 +000097 [Return] ${output}
98
99Get Conn List Id
100 [Documentation] Looks up for an Open Connection with passed host and port in conection list
101 ... First match connection will be used.
102 [Arguments] ${host} ${port}
103 ${connection_list_id}= Set Variable ${EMPTY}
104 ${match}= Set Variable False
105 ${length}= Get Length ${connection_list}
106 FOR ${INDEX} IN RANGE 0 ${length}
107 #${Item}= Get From List ${connection_list} ${INDEX}
108 ${conndata}= Get Connection ${connection_list[${INDEX}].conn_id}
109 ${match}= Set Variable If '${conndata.host}'=='${host}' and '${conndata.port}'=='${port}' True False
110 ${connection_list_id}= Set Variable If ${match} ${INDEX} ${EMPTY}
111 Exit For Loop If ${match}
112 END
113 [Return] ${connection_list_id}
114
TorstenThiemeb198c482020-12-14 19:45:23 +0000115Reconnect ONOS SSH Connection
116 [Documentation] Reconnect an SSH Connection
117 [Arguments] ${connection_list_id}
118 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
119 ${user}= Get From Dictionary ${connection_entry} user
120 ${pass}= Get From Dictionary ${connection_entry} pass
121 ${oldconndata}= Get Connection ${connection_entry.conn_id}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000122 ${match}= Set Variable If
123 ... "${oldconndata.host}"=="${connection_entry.host}" and "${oldconndata.port}"=="${connection_entry.port}"
124 ... True False
125 Run Keyword If ${match} SSHLibrary.Switch Connection ${connection_entry.conn_id}
126 Run Keyword If ${match} Run Keyword And Ignore Error SSHLibrary.Close Connection
127 ${conn_id}= SSHLibrary.Open Connection ${connection_entry.host} port=${connection_entry.port}
TorstenThieme2ddb6e82022-02-08 14:44:24 +0000128 ... timeout=${ssh_read_timeout} alias=${alias}
TorstenThieme36a38a82022-02-09 15:51:30 +0000129 SSHLibrary.Login username=${user} password=${pass} keep_alive_interval=${keep_alive_interval}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000130 # set excepted prompt and terminal width to suppress unwanted line feeds
TorstenThieme2ddb6e82022-02-08 14:44:24 +0000131 SSHLibrary.Set Client Configuration prompt=${ssh_prompt} width=${ssh_width}
TorstenThiemeb198c482020-12-14 19:45:23 +0000132 ${conn_list_entry}= Create Dictionary conn_id=${conn_id} user=${user} pass=${pass}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000133 ... host=${connection_entry.host} port=${connection_entry.port} alias=${alias}
TorstenThiemeb198c482020-12-14 19:45:23 +0000134 Set List Value ${connection_list} ${connection_list_id} ${conn_list_entry}
135 Set Global Variable ${connection_list}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000136 # disable highlighting to suppress control sequences
TorstenThieme2ddb6e82022-02-08 14:44:24 +0000137 ${output}= Execute Single ONOS CLI Command ${conn_id} ${disable_highlighter} do_reconnect=False
TorstenThiemeb198c482020-12-14 19:45:23 +0000138
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700139Close ONOS SSH Connection
140 [Documentation] Close an SSH Connection
TorstenThiemeb198c482020-12-14 19:45:23 +0000141 [Arguments] ${connection_list_id}
142 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
143 ${connection_alias}= Get From Dictionary ${connection_entry} conn_id
144 ${oldconndata}= Get Connection ${connection_entry.conn_id}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700145 SSHLibrary.Switch Connection ${connection_alias}
TorstenThiemebcf14612021-01-27 10:19:18 +0000146 Run Keyword And Ignore Error SSHLibrary.Close Connection
TorstenThiemeb198c482020-12-14 19:45:23 +0000147 Remove From List ${connection_list} ${connection_list_id}
148 Set Global Variable ${connection_list}
149
150Close All ONOS SSH Connections
151 [Documentation] Close all SSH Connection and clear connection list.
152 SSHLibrary.Close All Connections
153 @{connection_list} Create List
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700154
Kailash6f5acb62019-08-28 14:38:45 -0700155Validate OLT Device in ONOS
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700156 # FIXME use volt-olts to check that the OLT is ONOS
Kailash6f5acb62019-08-28 14:38:45 -0700157 [Arguments] ${serial_number}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700158 [Documentation] Checks if olt has been connected to ONOS
Kailash6f5acb62019-08-28 14:38:45 -0700159 ${resp}= Get Request ONOS onos/v1/devices
160 ${jsondata}= To Json ${resp.content}
161 Should Not Be Empty ${jsondata['devices']}
162 ${length}= Get Length ${jsondata['devices']}
163 @{serial_numbers}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -0700164 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700165 FOR ${INDEX} IN RANGE 0 ${length}
166 ${value}= Get From List ${jsondata['devices']} ${INDEX}
167 ${of_id}= Get From Dictionary ${value} id
168 ${sn}= Get From Dictionary ${value} serial
Andy Bavierb63f6d22020-03-12 15:34:37 -0700169 ${matched}= Set Variable If '${sn}' == '${serial_number}' True False
170 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700171 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700172 Should Be True ${matched} No match for ${serial_number} found
Kailash57210eb2019-08-30 13:27:19 -0700173 [Return] ${of_id}
Kailash6f5acb62019-08-28 14:38:45 -0700174
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700175Get ONU Port in ONOS
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000176 [Arguments] ${onu_serial_number} ${olt_of_id} ${onu_uni_id}=1
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700177 [Documentation] Retrieves ONU port for the ONU in ONOS
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000178 ${onu_serial_number}= Catenate SEPARATOR=- ${onu_serial_number} ${onu_uni_id}
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700179 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
180 ${jsondata}= To Json ${resp.content}
181 Should Not Be Empty ${jsondata['ports']}
182 ${length}= Get Length ${jsondata['ports']}
183 @{ports}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -0700184 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700185 FOR ${INDEX} IN RANGE 0 ${length}
186 ${value}= Get From List ${jsondata['ports']} ${INDEX}
187 ${annotations}= Get From Dictionary ${value} annotations
188 ${onu_port}= Get From Dictionary ${value} port
189 ${portName}= Get From Dictionary ${annotations} portName
Andy Bavierb63f6d22020-03-12 15:34:37 -0700190 ${matched}= Set Variable If '${portName}' == '${onu_serial_number}' True False
191 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700192 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700193 Should Be True ${matched} No match for ${onu_serial_number} found
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700194 [Return] ${onu_port}
195
TorstenThieme9b25aab2021-12-16 15:59:45 +0000196Get Onu Ports in ONOS For ALL UNI per ONU
197 [Documentation] Retrieves ONU port(s) for the ONU in ONOS for all UNI-IDs, list of ports will return!
198 [Arguments] ${onu_serial_number} ${olt_of_id}
199 @{uni_id_list}= Create List
200 @{port_list}= Create List
201 FOR ${I} IN RANGE 0 ${num_all_onus}
202 ${src}= Set Variable ${hosts.src[${I}]}
203 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
204 ${uni_id}= Set Variable ${src['uni_id']}
205 # make sure all actions do only once per uni_id
206 ${id}= Get Index From List ${uni_id_list} ${uni_id}
207 Continue For Loop If -1 != ${id}
208 Append To List ${uni_id_list} ${uni_id}
209 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${onu_serial_number}
210 ... ${olt_of_id} ${uni_id}
211 Append To List ${port_list} ${onu_port}
212 END
213 [return] ${port_list}
214
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530215Get NNI Port in ONOS
216 [Arguments] ${olt_of_id}
217 [Documentation] Retrieves NNI port for the OLT in ONOS
218 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
219 ${jsondata}= To Json ${resp.content}
220 Should Not Be Empty ${jsondata['ports']}
221 ${length}= Get Length ${jsondata['ports']}
222 @{ports}= Create List
223 ${matched}= Set Variable False
224 FOR ${INDEX} IN RANGE 0 ${length}
225 ${value}= Get From List ${jsondata['ports']} ${INDEX}
226 ${annotations}= Get From Dictionary ${value} annotations
227 ${nni_port}= Get From Dictionary ${value} port
228 ${nniPortName}= Catenate SEPARATOR= nni- ${nni_port}
229 ${portName}= Get From Dictionary ${annotations} portName
230 ${matched}= Set Variable If '${portName}' == '${nniPortName}' True False
231 Exit For Loop If ${matched}
232 END
233 Should Be True ${matched} No match for NNI found for ${olt_of_id}
234 [Return] ${nni_port}
235
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700236Get FabricSwitch in ONOS
237 [Documentation] Returns of_id of the Fabric Switch in ONOS
238 ${resp}= Get Request ONOS onos/v1/devices
239 ${jsondata}= To Json ${resp.content}
240 Should Not Be Empty ${jsondata['devices']}
241 ${length}= Get Length ${jsondata['devices']}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700242 ${matched}= Set Variable False
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700243 FOR ${INDEX} IN RANGE 0 ${length}
244 ${value}= Get From List ${jsondata['devices']} ${INDEX}
245 ${of_id}= Get From Dictionary ${value} id
246 ${type}= Get From Dictionary ${value} type
Andy Bavierb63f6d22020-03-12 15:34:37 -0700247 ${matched}= Set Variable If '${type}' == "SWITCH" True False
248 Exit For Loop If ${matched}
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700249 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700250 Should Be True ${matched} No fabric switch found
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700251 [Return] ${of_id}
252
Andrea Campanella4c404632020-08-26 14:41:36 +0200253Get Master Instace in ONOS
254 [Arguments] ${of_id}
255 [Documentation] Returns nodeId of the Master instace for a giver device in ONOS
256 ${resp}= Get Request ONOS onos/v1/mastership/${of_id}/master
257 ${jsondata}= To Json ${resp.content}
258 Should Not Be Empty ${jsondata['nodeId']}
259 ${master_node}= Get From Dictionary ${jsondata} nodeId
260 [Return] ${master_node}
261
Matteo Scandolo7bdbe2d2021-11-29 15:48:25 -0800262Verify LLDP Flow Added
263 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
264 [Documentation] Matches for total number of LLDP flows added for one OLT
265 ${lldp_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
266 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep ETH_TYPE:lldp | grep -v ETH_TYPE:arp
267 ${lldp_flows_added_count}= Get Line Count ${lldp_flows_added}
268 Should Be Equal As Integers ${lldp_flows_added_count} ${expected_flows}
269
Hardik Windlass21807632020-04-14 16:24:55 +0530270Verify Subscriber Access Flows Added for ONU
271 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${c_tag} ${s_tag}
272 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
273 # Verify upstream table=0 flow
274 ${upstream_flow_0_cmd}= Catenate SEPARATOR=
275 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:0 |
276 ... grep VLAN_ID:${c_tag} | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000277 ${upstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530278 ... ${upstream_flow_0_cmd}
279 Should Not Be Empty ${upstream_flow_0_added}
280 # Verify upstream table=1 flow
281 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
282 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
283 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000284 ${upstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530285 ... ${flow_vlan_push_cmd}
286 Should Not Be Empty ${upstream_flow_1_added}
287 # Verify downstream table=0 flow
288 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
289 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
290 ... grep VLAN_POP | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000291 ${downstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530292 ... ${flow_vlan_pop_cmd}
293 Should Not Be Empty ${downstream_flow_0_added}
294 # Verify downstream table=1 flow
295 ${downstream_flow_1_cmd}= Catenate SEPARATOR=
296 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${c_tag} |
297 ... grep VLAN_ID:0 | grep OUTPUT:${onu_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000298 ${downstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530299 ... ${downstream_flow_1_cmd}
300 Should Not Be Empty ${downstream_flow_1_added}
301 # Verify ipv4 dhcp upstream flow
302 ${upstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200303 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:ipv4 |
Andrea Campanella08678e12020-09-18 17:40:22 +0200304 ... grep IP_PROTO:17 | grep UDP_SRC:68 | grep UDP_DST:67 | grep VLAN_ID:${c_tag} |
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200305 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000306 ${upstream_flow_ipv4_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530307 ... ${upstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200308 Should Not Be Empty ${upstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530309 # Verify ipv4 dhcp downstream flow
310 # Note: This flow will be one per nni per olt
311 ${downstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200312 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep ETH_TYPE:ipv4 |
313 ... grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 | grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000314 ${downstream_flow_ipv4_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530315 ... ${downstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200316 Should Not Be Empty ${downstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530317
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530318Verify Subscriber Access Flows Added for ONU DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530319 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530320 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
321 # Verify upstream table=0 flow
TorstenThieme4e2168e2021-06-22 14:01:47 +0000322 ${upstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530323 ... 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 +0530324 Should Not Be Empty ${upstream_flow_0_added}
325 # Verify upstream table=1 flow
326 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530327 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:Any |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530328 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000329 ${upstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530330 ... ${flow_vlan_push_cmd}
331 Should Not Be Empty ${upstream_flow_1_added}
332 # Verify downstream table=0 flow
333 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530334 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530335 ... grep VLAN_POP | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000336 ${downstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530337 ... ${flow_vlan_pop_cmd}
338 Should Not Be Empty ${downstream_flow_0_added}
339 # Verify downstream table=1 flow
TorstenThieme4e2168e2021-06-22 14:01:47 +0000340 ${downstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530341 ... 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 +0530342 Should Not Be Empty ${downstream_flow_1_added}
343
344Verify Subscriber Access Flows Added Count DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530345 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530346 [Documentation] Matches for total number of subscriber access flows added for all onus
TorstenThieme4e2168e2021-06-22 14:01:47 +0000347 ${access_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700348 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep -v ETH_TYPE:lldp | grep -v ETH_TYPE:arp
349 ${access_flows_added_count}= Get Line Count ${access_flows_added}
350 Should Be Equal As Integers ${access_flows_added_count} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530351
Huseyin Ahmet AYDIN45922c82021-05-27 12:37:32 +0000352Verify Added Flow Count for OLT TT
353 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
354 [Documentation] Total number of added flows given OLT with subscriber flows
TorstenThieme4e2168e2021-06-22 14:01:47 +0000355 ${access_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700356 ... flows -s ADDED ${olt_of_id} | grep -v deviceId
357 ${access_flows_added_count}= Get Line Count ${access_flows_added}
358 Should Be Equal As Integers ${access_flows_added_count} ${expected_flows}
Huseyin Ahmet AYDIN45922c82021-05-27 12:37:32 +0000359
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000360Verify Default Downstream Flows are added in ONOS for OLT TT
361 [Arguments] ${ip} ${port} ${olt_of_id} ${nni_port}
362 [Documentation] Verifies if the Default Downstream Flows are added in ONOS for the OLT
363 # Verify lldp flow
364 ${downstream_flow_lldp_cmd}= Catenate SEPARATOR=
365 ... flows -s ADDED ${olt_of_id} | grep lldp |
366 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000367 ${downstream_flow_lldp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000368 ... ${downstream_flow_lldp_cmd}
369 Should Not Be Empty ${downstream_flow_lldp_added}
370 # Verify downstream dhcp flow
371 ${downstream_flow_dhcp_cmd}= Catenate SEPARATOR=
372 ... flows -s ADDED ${olt_of_id} | grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 |
373 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000374 ${downstream_flow_dhcp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000375 ... ${downstream_flow_dhcp_cmd}
376 Should Not Be Empty ${downstream_flow_dhcp_added}
377 # Verify downstream igmp flow
378 ${downstream_flow_igmp_cmd}= Catenate SEPARATOR=
379 ... flows -s ADDED ${olt_of_id} | grep IP_PROTO:2 |
380 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000381 ${downstream_flow_igmp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000382 ... ${downstream_flow_igmp_cmd}
383 Should Not Be Empty ${downstream_flow_igmp_added}
384
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530385Get Programmed Subscribers
386 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
387 [Documentation] Retrieves the subscriber details at a given location
388 ${sub_location}= Catenate SEPARATOR=/ ${olt_of_id} ${onu_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000389 ${programmed_sub}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530390 ... volt-programmed-subscribers | grep ${sub_location}
391 [Return] ${programmed_sub}
392
393Get Upstream and Downstream Bandwidth Profile Name
394 [Arguments] ${programmed_sub}
395 [Documentation] Retrieves the upstream and downstream bandwidth profile name
396 ... from the programmed subscriber
397 @{programmed_sub_array}= Split String ${programmed_sub} ,
398 # Get upstream bandwidth profile name for the subscriber
399 @{param_val_pair}= Split String ${programmed_sub_array[9]} =
400 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
401 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
402 ${us_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' upstreamBandwidthProfile'
403 ... Set Variable ${programmed_sub_val}
404 Log ${us_bw_profile}
405 # Get downstream bandwidth profile name for the subscriber
406 @{param_val_pair}= Split String ${programmed_sub_array[10]} =
407 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
408 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
409 ${ds_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' downstreamBandwidthProfile'
410 ... Set Variable ${programmed_sub_val}
411 Log ${ds_bw_profile}
412 [Return] ${us_bw_profile} ${ds_bw_profile}
413
414Get Bandwidth Profile Details
415 [Arguments] ${ip} ${port} ${bw_profile}
416 [Documentation] Retrieves the details of the given bandwidth profile
TorstenThieme4e2168e2021-06-22 14:01:47 +0000417 ${bw_profile_values}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530418 ... bandwidthprofile ${bw_profile}
419 @{bw_profile_array}= Split String ${bw_profile_values} ,
420 @{param_val_pair}= Split String ${bw_profile_array[1]} =
421 ${bw_param}= Set Variable ${param_val_pair[0]}
422 ${bw_val}= Set Variable ${param_val_pair[1]}
423 ${cir} Run Keyword If '${bw_param}' == ' committedInformationRate'
424 ... Set Variable ${bw_val}
425 @{param_val_pair}= Split String ${bw_profile_array[2]} =
426 ${bw_param}= Set Variable ${param_val_pair[0]}
427 ${bw_val}= Set Variable ${param_val_pair[1]}
428 ${cbs} Run Keyword If '${bw_param}' == ' committedBurstSize'
429 ... Set Variable ${bw_val}
430 @{param_val_pair}= Split String ${bw_profile_array[3]} =
431 ${bw_param}= Set Variable ${param_val_pair[0]}
432 ${bw_val}= Set Variable ${param_val_pair[1]}
433 ${eir} Run Keyword If '${bw_param}' == ' exceededInformationRate'
434 ... Set Variable ${bw_val}
435 @{param_val_pair}= Split String ${bw_profile_array[4]} =
436 ${bw_param}= Set Variable ${param_val_pair[0]}
437 ${bw_val}= Set Variable ${param_val_pair[1]}
438 ${ebs} Run Keyword If '${bw_param}' == ' exceededBurstSize'
439 ... Set Variable ${bw_val}
440 @{param_val_pair}= Split String ${bw_profile_array[5]} =
441 ${bw_param}= Set Variable ${param_val_pair[0]}
442 ${bw_val}= Set Variable ${param_val_pair[1]}
443 @{bw_val_air}= Split String ${bw_val} }
444 ${air} Run Keyword If '${bw_param}' == ' assuredInformationRate'
445 ... Set Variable ${bw_val_air[0]}
446 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
447
Hardik Windlassba5add42021-05-04 12:41:29 +0000448Get Bandwidth Profile Details Rest
449 [Arguments] ${bw_profile_id}
450 [Documentation] Retrieves the details of the given bandwidth profile using REST API
Girish Gowdracb8482a2021-05-27 09:06:13 -0700451 ${bw_profile_id}= Remove String ${bw_profile_id} ' "
Hardik Windlassba5add42021-05-04 12:41:29 +0000452 ${resp}= Get Request ONOS onos/sadis/bandwidthprofile/${bw_profile_id}
453 ${jsondata}= To Json ${resp.content}
454 Should Not Be Empty ${jsondata['entry']}
455 ${length}= Get Length ${jsondata['entry']}
456 ${matched}= Set Variable False
457 FOR ${INDEX} IN RANGE 0 ${length}
458 ${value}= Get From List ${jsondata['entry']} ${INDEX}
459 ${bw_id}= Get From Dictionary ${value} id
460 ${matched}= Set Variable If '${bw_id}' == '${bw_profile_id}' True False
461 ${eir}= Get From Dictionary ${value} eir
462 ${ebs}= Get From Dictionary ${value} ebs
463 ${cir}= Get From Dictionary ${value} cir
464 ${cbs}= Get From Dictionary ${value} cbs
465 ${air}= Get From Dictionary ${value} air
466 Exit For Loop If ${matched}
467 END
468 Should Be True ${matched} No bandwidth profile found for id: ${bw_profile_id}
469 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
470
Hardik Windlass841979a2021-05-25 05:30:27 +0000471Get Bandwidth Profile Details Ietf Rest
472 [Arguments] ${bw_profile_id}
473 [Documentation] Retrieves the details of the given Ietf standard based bandwidth profile using REST API
474 ${bw_profile_id}= Remove String ${bw_profile_id} ' "
475 ${resp}= Get Request ONOS onos/sadis/bandwidthprofile/${bw_profile_id}
476 ${jsondata}= To Json ${resp.content}
477 Should Not Be Empty ${jsondata['entry']}
478 ${length}= Get Length ${jsondata['entry']}
479 ${matched}= Set Variable False
480 FOR ${INDEX} IN RANGE 0 ${length}
481 ${value}= Get From List ${jsondata['entry']} ${INDEX}
482 ${bw_id}= Get From Dictionary ${value} id
483 ${matched}= Set Variable If '${bw_id}' == '${bw_profile_id}' True False
484 ${pir}= Get From Dictionary ${value} pir
485 ${pbs}= Get From Dictionary ${value} pbs
486 ${cir}= Get From Dictionary ${value} cir
487 ${cbs}= Get From Dictionary ${value} cbs
488 ${gir}= Get From Dictionary ${value} gir
489 Exit For Loop If ${matched}
490 END
491 Should Be True ${matched} No bandwidth profile found for id: ${bw_profile_id}
492 [Return] ${cir} ${cbs} ${pir} ${pbs} ${gir}
493
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700494Verify Meters in ONOS Ietf
495 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
496 [Documentation] Verifies the meters with BW Ietf format (currently, DT workflow uses this format)
497 # Get programmed subscriber
498 ${programmed_sub}= Get Programmed Subscribers ${ip} ${port}
499 ... ${olt_of_id} ${onu_port}
500 Log ${programmed_sub}
501 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
502 ... ${programmed_sub}
503 # Get upstream bandwidth profile details
504 ${us_cir} ${us_cbs} ${us_pir} ${us_pbs} ${us_gir} Get Bandwidth Profile Details Ietf Rest
505 ... ${us_bw_profile}
506 # Verify meter for upstream bandwidth profile
507 ${us_meter_cmd}= Run Keyword If ${us_gir} != 0 Catenate SEPARATOR=
508 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
509 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | grep "rate=${us_gir}, burst-size=0" | wc -l
510 ... ELSE Catenate SEPARATOR=
511 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
512 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000513 ${upstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700514 ... ${us_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700515 Should Be Equal As Integers ${upstream_meter_added} 1 Upstream meter is missing
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700516 # Get downstream bandwidth profile details
517 ${ds_cir} ${ds_cbs} ${ds_pir} ${ds_pbs} ${ds_gir} Get Bandwidth Profile Details Ietf Rest
518 ... ${ds_bw_profile}
519 # Verify meter for downstream bandwidth profile
520 ${ds_meter_cmd}= Run Keyword If ${ds_gir} != 0 Catenate SEPARATOR=
521 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
522 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | grep "rate=${ds_gir}, burst-size=0" | wc -l
523 ... ELSE Catenate SEPARATOR=
524 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
525 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000526 ${downstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700527 ... ${ds_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700528 Should Be Equal As Integers ${downstream_meter_added} 1 Downstream meter is missing
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700529
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530530Verify Meters in ONOS
531 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
532 [Documentation] Verifies the meters
533 # Get programmed subscriber
534 ${programmed_sub}= Get Programmed Subscribers ${ip} ${port}
535 ... ${olt_of_id} ${onu_port}
536 Log ${programmed_sub}
537 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
538 ... ${programmed_sub}
Matteo Scandolo2056ed72021-11-02 17:38:03 -0700539 # logging all meters to facilitate debug
540 ${all_meters}= Execute ONOS CLI Command use single connection ${ip} ${port} meters
541 Log ${all_meters}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530542 # Get upstream bandwidth profile details
543 ${us_cir} ${us_cbs} ${us_eir} ${us_ebs} ${us_air} Get Bandwidth Profile Details
544 ... ${ip} ${port} ${us_bw_profile}
545 Sleep 1s
Andrea Campanella2b367102021-05-04 19:33:46 +0200546 ${us_pbs}= Evaluate ${us_cbs}+${us_ebs}
547 ${us_pir}= Evaluate ${us_eir}+${us_cir}+${us_air}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530548 # Verify meter for upstream bandwidth profile
549 ${us_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530550 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200551 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | grep "rate=${us_air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000552 ${upstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530553 ... ${us_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700554 Should Be Equal As Integers ${upstream_meter_added} 1 Upstream meter is missing
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530555 Sleep 1s
556 # Get downstream bandwidth profile details
557 ${ds_cir} ${ds_cbs} ${ds_eir} ${ds_ebs} ${ds_air} Get Bandwidth Profile Details
558 ... ${ip} ${port} ${ds_bw_profile}
559 Sleep 1s
560 # Verify meter for downstream bandwidth profile
Andrea Campanella2b367102021-05-04 19:33:46 +0200561 ${ds_pbs}= Evaluate ${ds_cbs}+${ds_ebs}
562 ${ds_pir}= Evaluate ${ds_eir}+${ds_cir}+${ds_air}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530563 ${ds_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530564 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200565 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | grep "rate=${ds_air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000566 ${downstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530567 ... ${ds_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700568 Should Be Equal As Integers ${downstream_meter_added} 1 Downstream meter is missing
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530569
570Verify Default Meter Present in ONOS
571 [Arguments] ${ip} ${port} ${olt_of_id}
572 [Documentation] Verifies the single default meter entry is present
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530573 # Get default bandwidth profile details
574 ${cir} ${cbs} ${eir} ${ebs} ${air} Get Bandwidth Profile Details
575 ... ${ip} ${port} 'Default'
576 Sleep 1s
Andrea Campanella2b367102021-05-04 19:33:46 +0200577 ${pbs}= Evaluate ${cbs}+${ebs}
578 ${pir}= Evaluate ${eir}+${cir}+${air}
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530579 # Verify meter for default bandwidth profile
580 ${meter_cmd}= Catenate SEPARATOR=
581 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${cir}, burst-size=${cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200582 ... | grep "rate=${pir}, burst-size=${pbs}" | grep "rate=${air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000583 ${default_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530584 ... ${meter_cmd}
Matteo Scandolo2056ed72021-11-02 17:38:03 -0700585 # logging all meters to facilitate debug
586 ${all_meters}= Execute ONOS CLI Command use single connection ${ip} ${port} meters
587 Log ${all_meters}
588 # done logging all meters to facilitate debug
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700589 Should Be Equal As Integers ${default_meter_added} 1 Default Meter not present
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530590
Hardik Windlass480f3e22020-04-02 20:14:14 +0530591Verify Device Flows Removed
592 [Arguments] ${ip} ${port} ${olt_of_id}
593 [Documentation] Verifies all flows are removed from the device
TorstenThieme4e2168e2021-06-22 14:01:47 +0000594 ${device_flows}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700595 ... flows -s -f ${olt_of_id} | grep -v deviceId
596 ${flow_count}= Get Line Count ${device_flows}
597 Should Be Equal As Integers ${flow_count} 0 Flows not removed
Hardik Windlass480f3e22020-04-02 20:14:14 +0530598
Kailash6f5acb62019-08-28 14:38:45 -0700599Verify Eapol Flows Added
Andy Bavierb0c06232019-08-29 12:58:53 -0700600 [Arguments] ${ip} ${port} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700601 [Documentation] Matches for number of eapol flows based on number of onus
TorstenThieme4e2168e2021-06-22 14:01:47 +0000602 ${eapol_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Gilles Depatie675a2062019-10-22 12:44:42 -0400603 ... flows -s -f ADDED | grep eapol | grep IN_PORT | wc -l
Andy Bavierb0c06232019-08-29 12:58:53 -0700604 Should Contain ${eapol_flows_added} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700605
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800606Verify No Pending Flows For ONU
607 [Arguments] ${ip} ${port} ${onu_port}
608 [Documentation] Verifies that there are no flows "PENDING" state for the ONU in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000609 ${pending_flows}= Execute ONOS CLI Command use single connection ${ip} ${port}
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800610 ... flows -s | grep IN_PORT:${onu_port} | grep PENDING
611 Should Be Empty ${pending_flows}
612
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700613Verify Eapol Flows Added For ONU
Matteo Scandolo7e519fb2021-08-13 11:35:16 -0700614 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${c_tag}=4091
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700615 [Documentation] Verifies if the Eapol Flows are added in ONOS for the ONU
Matteo Scandolo7e519fb2021-08-13 11:35:16 -0700616 ${eapol_flow_cmd}= Catenate SEPARATOR=
617 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:eapol |
618 ... grep VLAN_ID:${c_tag} | grep OUTPUT:CONTROLLER
619 ${eapol_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port} ${eapol_flow_cmd}
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700620 Should Not Be Empty ${eapol_flows_added}
621
Hardik Windlass39015672021-07-05 05:48:08 +0000622Verify UNI Port Is Enabled
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000623 [Arguments] ${ip} ${port} ${onu_name} ${onu_uni_id}=1
Hardik Windlass39015672021-07-05 05:48:08 +0000624 [Documentation] Verifies if the ONU's UNI port is enabled in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000625 ${onu_port_enabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000626 ... ports -e | grep portName=${onu_name}-${onu_uni_id}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800627 Log ${onu_port_enabled}
628 Should Not Be Empty ${onu_port_enabled}
629
Hardik Windlass39015672021-07-05 05:48:08 +0000630Verify UNI Port Is Disabled
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000631 [Arguments] ${ip} ${port} ${onu_name} ${onu_uni_id}=1
Hardik Windlass39015672021-07-05 05:48:08 +0000632 [Documentation] Verifies if the ONU's UNI port is disabled in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000633 ${onu_port_disabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo02768532021-10-21 15:14:12 -0700634 ... ports | grep portName=${onu_name}-${onu_uni_id} | grep state=disabled
Hardik Windlass63d5e002020-03-06 21:07:09 +0530635 Log ${onu_port_disabled}
Matteo Scandolo02768532021-10-21 15:14:12 -0700636 Should Not Be Empty ${onu_port_disabled}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530637
TorstenThieme9b25aab2021-12-16 15:59:45 +0000638Wait For All UNI Ports Are Disabled per ONU
639 [Documentation] Verifies all UNI Ports of passed ONU are disabled
640 [Arguments] ${ip} ${port} ${onu_serial_number}
641 @{uni_id_list}= Create List
642 FOR ${I} IN RANGE 0 ${num_all_onus}
643 ${src}= Set Variable ${hosts.src[${I}]}
644 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
645 ${uni_id}= Set Variable ${src['uni_id']}
646 # make sure all actions do only once per uni_id
647 ${id}= Get Index From List ${uni_id_list} ${uni_id}
648 Continue For Loop If -1 != ${id}
649 Append To List ${uni_id_list} ${uni_id}
650 Wait Until Keyword Succeeds ${timeout} 2s
651 ... Verify UNI Port Is Disabled ${ip} ${port} ${onu_serial_number} ${uni_id}
652 END
653
654Wait For All UNI Ports Are Enabled per ONU
655 [Documentation] Verifies all UNI Ports of passed ONU are enabled
656 [Arguments] ${ip} ${port} ${onu_serial_number}
657 @{uni_id_list}= Create List
658 FOR ${I} IN RANGE 0 ${num_all_onus}
659 ${src}= Set Variable ${hosts.src[${I}]}
660 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
661 ${uni_id}= Set Variable ${src['uni_id']}
662 # make sure all actions do only once per uni_id
663 ${id}= Get Index From List ${uni_id_list} ${uni_id}
664 Continue For Loop If -1 != ${id}
665 Append To List ${uni_id_list} ${uni_id}
666 Wait Until Keyword Succeeds ${timeout} 2s
667 ... Verify UNI Port Is Enabled ${ip} ${port} ${onu_serial_number} ${uni_id}
668 END
669
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700670Verify ONU in AAA-Users
671 [Arguments] ${ip} ${port} ${onu_port}
672 [Documentation] Verifies that the specified onu_port exists in aaa-users output
TorstenThieme4e2168e2021-06-22 14:01:47 +0000673 ${aaa_users}= Execute ONOS CLI Command use single connection ${ip} ${port}
674 ... aaa-users | grep AUTHORIZED | grep ${onu_port}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700675 Should Not Be Empty ${aaa_users} ONU port ${onu_port} not found in aaa-users
676
Hardik Windlass513afd12021-02-03 15:19:46 +0000677Verify Empty Group in ONOS
678 [Documentation] Verifies zero group count on the device
TorstenThieme731a7592021-07-01 14:26:54 +0000679 [Arguments] ${ip} ${port} ${deviceId}
680 ${groups}= Execute ONOS CLI Command use single connection ${ip} ${port} groups | grep ${deviceId}
Hardik Windlass513afd12021-02-03 15:19:46 +0000681 @{groups_arr}= Split String ${groups} ,
682 @{group_count_arr}= Split String ${groups_arr[1]} =
683 ${group_count}= Set Variable ${group_count_arr[1]}
684 Should Be Equal As Integers ${group_count} 0
685
686Verify ONUs in Group Count in ONOS
687 [Documentation] Verifies there exists a group bucket list with certain entries/count
688 ... Note: Currently, this validates only if all ONUs of an OLT joined the same igmp group
TorstenThieme731a7592021-07-01 14:26:54 +0000689 [Arguments] ${ip} ${port} ${count} ${deviceId}
690 ${result}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolofd36e212021-03-02 11:36:10 -0800691 ... groups added ${deviceId} | grep bucket | wc -l
692 Should Be Equal As Integers ${result} ${count} Bucket list count for a group: Found=${result} Expected=${count}
Hardik Windlass513afd12021-02-03 15:19:46 +0000693
694Verify ONU in Group Bucket
695 [Documentation] Matches if ONU port in Group Bucket
696 [Arguments] ${group_bucket_values} ${onu_port}
697 ${len}= Get Length ${group_bucket_values}
698 ${matched}= Set Variable False
699 FOR ${INDEX} IN RANGE 0 ${len}
700 ${value_bucket}= Get From List ${group_bucket_values} ${INDEX}
701 ${treatment}= Get From Dictionary ${value_bucket} treatment
702 ${instructions}= Get From Dictionary ${treatment} instructions
703 ${instructions_val}= Get From List ${instructions} 0
704 ${port}= Get From Dictionary ${instructions_val} port
705 ${matched}= Set Variable If '${port}'=='${onu_port}' True False
706 Exit For Loop If ${matched}
707 END
708 [Return] ${matched}
709
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700710Verify ONU in Groups
711 [Arguments] ${ip_onos} ${port_onos} ${deviceId} ${onu_port} ${group_exist}=True
712 [Documentation] Verifies that the specified onu_port exists in groups output
TorstenThieme4e2168e2021-06-22 14:01:47 +0000713 ${result}= Execute ONOS CLI Command use single connection ${ip_onos} ${port_onos} groups -j
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700714 Log Groups: ${result}
715 ${groups}= To Json ${result}
716 ${length}= Get Length ${groups}
717 ${buckets}= Create List
718 ${matched}= Set Variable False
719 FOR ${INDEX} IN RANGE 0 ${length}
720 ${value}= Get From List ${groups} ${INDEX}
721 ${devId}= Get From Dictionary ${value} deviceId
722 ${bucket}= Get From Dictionary ${value} buckets
723 Run Keyword If '${devId}'=='${deviceId}'
724 ... Append To List ${buckets} ${bucket}
725 END
726 ${bucket_len}= Get Length ${buckets}
Hardik Windlass513afd12021-02-03 15:19:46 +0000727 FOR ${INDEX_1} IN RANGE 0 ${bucket_len}
728 ${value}= Get From List ${buckets} ${INDEX_1}
729 ${matched}= Verify ONU in Group Bucket ${value} ${onu_port}
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700730 Exit For Loop If ${matched}
731 END
732 Run Keyword If ${group_exist}
733 ... Should Be True ${matched} No match for ${deviceId} and ${onu_port} found in ONOS groups
734 ... ELSE
735 ... Should Be True '${matched}'=='False' Match for ${deviceId} and ${onu_port} found in ONOS groups
736
Matteo Scandolo142e6272020-04-29 17:36:59 -0700737Assert Number of AAA-Users
TorstenThieme731a7592021-07-01 14:26:54 +0000738 [Arguments] ${ip} ${port} ${expected_onus} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700739 [Documentation] Matches for number of aaa-users authorized based on number of onus
TorstenThieme731a7592021-07-01 14:26:54 +0000740 ${aaa_users}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800741 ... aaa-users | grep ${deviceId} | grep AUTHORIZED | wc -l
742 Log Found ${aaa_users} of ${expected_onus} expected authenticated users on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700743 Should Be Equal As Integers ${aaa_users} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700744
745Validate DHCP Allocations
TorstenThieme731a7592021-07-01 14:26:54 +0000746 [Arguments] ${ip} ${port} ${count} ${workflow} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700747 [Documentation] Matches for number of dhcpacks based on number of onus
TorstenThieme731a7592021-07-01 14:26:54 +0000748 ${allocations}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800749 ... dhcpl2relay-allocations | grep ${deviceId} | grep DHCPACK | wc -l
Matteo Scandoloda854b02020-09-01 16:20:51 -0700750 # if the workflow is TT we'll have 2 allocations for each ONU
751 ${ttAllocations}= Evaluate (${count} * 2)
752 ${count}= Set Variable If $workflow=='tt' ${ttAllocations} ${count}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800753 Log Found ${allocations} of ${count} expected DHCPACK on device ${deviceId}
Matteo Scandoloda854b02020-09-01 16:20:51 -0700754 Should Be Equal As Integers ${allocations} ${count}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700755
756Validate Subscriber DHCP Allocation
Suchitra Vemuri42819412020-10-01 17:45:43 -0700757 [Arguments] ${ip} ${port} ${onu_port} ${vlan}=''
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700758 [Documentation] Verifies that the specified subscriber is found in DHCP allocations
759 ##TODO: Enhance the keyword to include DHCP allocated address is not 0.0.0.0
TorstenThieme4e2168e2021-06-22 14:01:47 +0000760 ${allocations}= Execute ONOS CLI Command use single connection ${ip} ${port}
Suchitra Vemuri42819412020-10-01 17:45:43 -0700761 ... dhcpl2relay-allocations | grep DHCPACK | grep ${onu_port} | grep ${vlan}
Gilles Depatie675a2062019-10-22 12:44:42 -0400762 Should Not Be Empty ${allocations} ONU port ${onu_port} not found in dhcpl2relay-allocations
David Bainbridgef81cd642019-11-20 00:14:47 +0000763
764Device Is Available In ONOS
Matteo Scandolo3218d5b2021-05-26 11:50:10 -0700765 [Arguments] ${url} ${dpid} ${available}=true
766 [Documentation] Validates the device exists and it has the expected availability in ONOS
David Bainbridgef81cd642019-11-20 00:14:47 +0000767 ${rc} ${json} Run And Return Rc And Output curl --fail -sSL ${url}/onos/v1/devices/${dpid}
768 Should Be Equal As Integers 0 ${rc}
769 ${rc} ${value} Run And Return Rc And Output echo '${json}' | jq -r .available
770 Should Be Equal As Integers 0 ${rc}
Matteo Scandolo3218d5b2021-05-26 11:50:10 -0700771 Should Be Equal ${available} ${value}
David Bainbridgef81cd642019-11-20 00:14:47 +0000772
773Remove All Devices From ONOS
774 [Arguments] ${url}
775 [Documentation] Executes the device-remove command on each device in ONOS
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000776 ${rc} ${output} Run And Return Rc And Output
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700777 ... curl --fail -sSL ${url}/onos/v1/devices | jq -r '.devices[].id'
David Bainbridgef81cd642019-11-20 00:14:47 +0000778 Should Be Equal As Integers ${rc} 0
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000779 @{dpids} Split String ${output}
David Bainbridgef81cd642019-11-20 00:14:47 +0000780 ${count}= Get length ${dpids}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700781 FOR ${dpid} IN @{dpids}
782 ${rc}= Run Keyword If '${dpid}' != ''
783 ... Run And Return Rc curl -XDELETE --fail -sSL ${url}/onos/v1/devices/${dpid}
784 Run Keyword If '${dpid}' != ''
785 ... Should Be Equal As Integers ${rc} 0
786 END
Matteo Scandolo142e6272020-04-29 17:36:59 -0700787
TorstenThieme440b7c02020-12-18 15:42:57 +0000788Assert ONU Port Is Disabled
TorstenThieme731a7592021-07-01 14:26:54 +0000789 [Arguments] ${ip} ${port} ${deviceId} ${onu_port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000790 [Documentation] Verifies if the ONU port is disabled in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000791 ${onu_port_disabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000792 ... ports -d ${deviceId} | grep port=${onu_port}
793 Log ${onu_port_disabled}
794 Should Not Be Empty ${onu_port_disabled}
795
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700796Assert Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000797 [Arguments] ${ip} ${port} ${count}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700798 [Documentation] DEPRECATED use Assert Olt in ONOS
799 ... Check that a certain number of olts are known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000800 ${olts}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700801 ... volt-olts | wc -l
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700802 Log Found ${olts} of ${count} expected Olts
803 Should Be Equal As Integers ${olts} ${count}
804
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700805Assert Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000806 [Arguments] ${ip} ${port} ${deviceId}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700807 [Documentation] Check that a particular olt is known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000808 ${olts}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700809 ... volt-olts | grep ${deviceId} | wc -l
810 Should Be Equal As Integers ${olts} 1 "Device ${deviceId} is not recognized as an OLT"
811
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700812Wait for Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000813 [Arguments] ${ip} ${port} ${count} ${max_wait_time}=10m
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700814 [Documentation] DEPRECATED use Wait for Olt in ONOS
815 ... Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700816 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000817 ... ${ip} ${port} ${count}
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700818
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700819Wait for Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000820 [Arguments] ${ip} ${port} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700821 [Documentation] Waits until a particular deviceId is recognized by ONOS as an OLT
822 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000823 ... ${ip} ${port} ${deviceId}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700824
Matteo Scandolo142e6272020-04-29 17:36:59 -0700825Assert Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000826 [Arguments] ${ip} ${port} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700827 [Documentation] Check that a certain number of ports are enabled in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000828 ${ports}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800829 ... ports -e ${deviceId} | grep ${filter} | wc -l
830 Log Found ${ports} of ${count} expected ports on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700831 Should Be Equal As Integers ${ports} ${count}
832
833Wait for Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000834 [Arguments] ${ip} ${port} ${count} ${deviceId} ${filter} ${max_wait_time}=10m
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800835 [Documentation] Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
TorstenThiemed4f48962020-12-08 12:17:19 +0000836 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000837 ... ${ip} ${port} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700838
839Wait for AAA Authentication
TorstenThieme731a7592021-07-01 14:26:54 +0000840 [Arguments] ${ip} ${port} ${count} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700841 [Documentation] Waits untill a certain number of subscribers are authenticated in ONOS
TorstenThiemed4f48962020-12-08 12:17:19 +0000842 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Number of AAA-Users
TorstenThieme731a7592021-07-01 14:26:54 +0000843 ... ${ip} ${port} ${count} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700844
845Wait for DHCP Ack
TorstenThieme731a7592021-07-01 14:26:54 +0000846 [Arguments] ${ip} ${port} ${count} ${workflow} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700847 [Documentation] Waits untill a certain number of subscribers have received a DHCP_ACK
TorstenThiemed4f48962020-12-08 12:17:19 +0000848 Wait Until Keyword Succeeds ${max_wait_time} 5s Validate DHCP Allocations
TorstenThieme731a7592021-07-01 14:26:54 +0000849 ... ${ip} ${port} ${count} ${workflow} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700850
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700851Provision subscriber REST
852 [Documentation] Uses the rest APIs to provision a subscriber
TorstenThieme731a7592021-07-01 14:26:54 +0000853 [Arguments] ${of_id} ${onu_port}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700854 ${resp}= Post Request ONOS
855 ... /onos/olt/oltapp/${of_id}/${onu_port}
856 Should Be Equal As Strings ${resp.status_code} 200
857
Hardik Windlassea4caf72021-07-30 07:22:12 +0000858Count Enabled UNI Ports
859 [Documentation] Count all the UNI Ports on a Device
860 [Arguments] ${ip} ${port} ${of_id}
861 ${count}= Execute ONOS CLI Command use single connection ${ip} ${port}
862 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni | wc -l
863 Log ${count}
864 [Return] ${count}
865
Matteo Scandolo142e6272020-04-29 17:36:59 -0700866List Enabled UNI Ports
867 [Documentation] List all the UNI Ports, the only way we have is to filter out the one called NNI
868 ... Creates a list of dictionaries
TorstenThieme731a7592021-07-01 14:26:54 +0000869 [Arguments] ${ip} ${port} ${of_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700870 [Return] [{'port': '16', 'of_id': 'of:00000a0a0a0a0a00'}, {'port': '32', 'of_id': 'of:00000a0a0a0a0a00'}]
871 ${result}= Create List
TorstenThieme731a7592021-07-01 14:26:54 +0000872 ${out}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700873 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000874 @{unis}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700875 FOR ${uni} IN @{unis}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000876 ${matches} = Get Regexp Matches ${uni} .*port=([0-9]+),.* 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700877 &{portDict} Create Dictionary of_id=${of_id} port=${matches[0]}
878 Append To List ${result} ${portDict}
879 END
880 Log ${result}
881 Return From Keyword ${result}
882
883Provision all subscribers on device
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700884 [Documentation] Provisions a subscriber in ONOS for all the enabled UNI ports on a particular device
TorstenThieme731a7592021-07-01 14:26:54 +0000885 [Arguments] ${ip} ${port} ${onos_ip} ${onos_rest_port} ${of_id}
886 ${unis}= List Enabled UNI Ports ${ip} ${port} ${of_id}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700887 ${onos_auth}= Create List karaf karaf
888 Create Session ONOS http://${onos_ip}:${onos_rest_port} auth=${onos_auth}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700889 FOR ${uni} IN @{unis}
TorstenThieme731a7592021-07-01 14:26:54 +0000890 Provision Subscriber REST ${uni['of_id']} ${uni['port']}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700891 END
892
893List OLTs
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800894 # NOTE this method is not currently used but it can come useful in the future
895 [Documentation] Returns a list of all OLTs known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000896 [Arguments] ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700897 [Return] ['of:00000a0a0a0a0a00', 'of:00000a0a0a0a0a01']
898 ${result}= Create List
TorstenThieme731a7592021-07-01 14:26:54 +0000899 ${out}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700900 ... volt-olts
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000901 @{olts}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700902 FOR ${olt} IN @{olts}
903 Log ${olt}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000904 ${matches} = Get Regexp Matches ${olt} ^OLT (.+)$ 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700905 # there may be some logs mixed with the output so only append if we have a match
906 ${matches_length}= Get Length ${matches}
907 Run Keyword If ${matches_length}==1
908 ... Append To List ${result} ${matches[0]}
909 END
910 Return From Keyword ${result}
911
Matteo Scandolo75911092021-11-16 17:05:36 -0800912Count flows
913 [Documentation] Count flows in a particular ${state} in ONOS
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000914 ... Optionally for a certain onu-port.
915 [Arguments] ${ip} ${port} ${deviceId} ${state} ${onu_port}=${EMPTY}
916 ${cmd}= Catenate SEPARATOR= flows -s ${state} ${deviceId} | grep -v deviceId
917 ${cmd}= Run Keyword If "${onu_port}"!="${EMPTY}" Catenate SEPARATOR= ${cmd} | grep ${onu_port}
918 ... ELSE Set Variable ${cmd}
919 ${cmd}= Catenate SEPARATOR= ${cmd} | wc -l
920 ${flows}= Execute ONOS CLI Command use single connection ${ip} ${port} ${cmd}
921 [return] ${flows}
922
923Validate number of flows
924 [Documentation] Validates number of flows in a particular ${state} in ONOS
925 ... Optionally for a certain onu-port.
926 [Arguments] ${ip} ${port} ${targetFlows} ${deviceId} ${state} ${onu_port}=${EMPTY}
927 ${flows}= Count flows ${ip} ${port} ${deviceId} ${state} ${onu_port}
Matteo Scandolo75911092021-11-16 17:05:36 -0800928 Log Found ${state} ${flows} of ${targetFlows} expected flows on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700929 Should Be Equal As Integers ${targetFlows} ${flows}
930
931Wait for all flows to in ADDED state
932 [Documentation] Waits until the flows have been provisioned
TorstenThieme731a7592021-07-01 14:26:54 +0000933 [Arguments] ${ip} ${port} ${deviceId} ${workflow} ${uni_count} ${olt_count}
TorstenThiemeb198c482020-12-14 19:45:23 +0000934 ... ${provisioned} ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700935 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200936 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000937 Wait Until Keyword Succeeds 10m 5s Validate number of flows
Matteo Scandolo75911092021-11-16 17:05:36 -0800938 ... ${ip} ${port} ${targetFlows} ${deviceId} added
939
940Wait for all flows to be removed
941 [Documentation] Wait for all flows to be removed from a particular device
942 [Arguments] ${ip} ${port} ${deviceId}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000943 Wait Until Keyword Succeeds 10m 5s Validate number of flows
Matteo Scandolo75911092021-11-16 17:05:36 -0800944 ... ${ip} ${port} 0 ${deviceId} any
945
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000946
Girish Gowdrad769b412021-05-16 11:09:46 -0700947Get Limiting Bandwidth Details
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000948 [Arguments] ${bandwidth_profile_name}
949 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
950 ... returns the limiting bandwidth
Girish Gowdracb8482a2021-05-27 09:06:13 -0700951 ${cir} ${cbs} ${eir} ${ebs} ${air}= Get Bandwidth Profile Details Rest
952 ... ${bandwidth_profile_name}
Girish Gowdrad769b412021-05-16 11:09:46 -0700953 ${limiting_BW}= Evaluate ${eir}+${cir}+${air}
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000954 [Return] ${limiting_BW}
Hardik Windlasse8b99222021-01-25 10:03:14 +0000955
Emrehan UZUNd6f85892021-07-01 13:54:26 +0000956Get Limiting Bandwidth Details for Fixed and Committed
957 [Arguments] ${bandwidth_profile_name}
958 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
959 ... returns the limiting bandwidth for fixed and committed
960 ${cir} ${cbs} ${eir} ${ebs} ${air}= Get Bandwidth Profile Details Rest
961 ... ${bandwidth_profile_name}
962 ${limiting_BW}= Evaluate ${cir}+${air}
963 [Return] ${limiting_BW}
964
Hardik Windlasse8b99222021-01-25 10:03:14 +0000965Validate Deleted Device Cleanup In ONOS
966 [Arguments] ${ip} ${port} ${olt_serial_number}
967 [Documentation] The keyword verifies that ports, flows, meters, subscribers, dhcp are all cleared in ONOS
968 # Fetch OF Id for OLT
969 ${olt_of_id}= Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device in ONOS ${olt_serial_number}
Hardik Windlasse8b99222021-01-25 10:03:14 +0000970 # Verify Ports are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700971 ${ports}= Execute ONOS CLI Command use single connection ${ip} ${port}
972 ... ports ${olt_of_id} | grep -v ${olt_of_id}
973 ${port_count}= Get Line Count ${ports}
974 Should Be Equal As Integers ${port_count} 0 Ports have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000975 # Verify Subscribers are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700976 ${sub}= Execute ONOS CLI Command use single connection ${ip} ${port}
977 ... volt-programmed-subscribers | grep ${olt_of_id}
978 ${sub_count}= Get Line Count ${sub}
979 Should Be Equal As Integers ${sub_count} 0 Subscribers have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000980 # Verify Flows are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700981 ${flow}= Execute ONOS CLI Command use single connection ${ip} ${port}
982 ... flows -s -f ${olt_of_id} | grep -v deviceId
983 ${flow_count}= Get Line Count ${flow}
984 Should Be Equal As Integers ${flow_count} 0 Flows have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000985 # Verify Meters are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700986 ${meter}= Execute ONOS CLI Command use single connection ${ip} ${port}
987 ... meters ${olt_of_id}
988 ${meter_count}= Get Line Count ${meter}
989 Should Be Equal As Integers ${meter_count} 0 Meters have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000990 # Verify AAA-Users are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700991 ${aaa}= Execute ONOS CLI Command use single connection ${ip} ${port}
992 ... aaa-users ${olt_of_id}
993 ${aaa_count}= Get Line Count ${aaa}
994 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 +0000995 # Verify Dhcp-Allocations are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700996 ${dhcp}= Execute ONOS CLI Command use single connection ${ip} ${port}
997 ... dhcpl2relay-allocations ${olt_of_id}
998 ${dhcp_count}= Get Line Count ${dhcp}
999 Should Be Equal As Integers ${dhcp_count} 0 DHCP Allocations have not been removed from ONOS after cleanup
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001000
1001Delete ONOS App
1002 [Arguments] ${url} ${app_name}
1003 [Documentation] This keyword deactivates and uninstalls the given ONOS App
1004 ${rc}= Run And Return Rc curl --fail -sSL -X DELETE ${url}/onos/v1/applications/${app_name}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001005 Should Be Equal As Integers ${rc} 0 Can't delete ${app_name} from ONOS
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001006
1007Verify ONOS App Active
1008 [Arguments] ${url} ${app_name} ${app_version}=${EMPTY}
1009 [Documentation] This keyword verifies that the given ONOS App status is Active
1010 ${rc} ${output} Run And Return Rc And Output
1011 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name} | jq -r .state
1012 Should Be Equal As Integers ${rc} 0
1013 Should Be Equal '${output}' 'ACTIVE'
1014 ${rc1} ${output1} Run And Return Rc And Output
1015 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name} | jq -r .version
1016 Run Keyword If '${app_version}'!='${EMPTY}'
1017 ... Run Keywords
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001018 ... Should Be Equal As Integers ${rc1} 0 Can't read app ${app_name} status from ONOS
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001019 ... AND Should Be Equal '${output1}' '${app_version}'
1020
1021Install And Activate ONOS App
1022 [Arguments] ${url} ${app_oar_file}
1023 [Documentation] This keyword installs and activates the given ONOS App
1024 ${cmd}= Catenate SEPARATOR=
1025 ... curl --fail -sSL -H Content-Type:application/octet-stream -
1026 ... X POST ${url}/onos/v1/applications?activate=true --data-binary \@${app_oar_file}
1027 ${rc} ${output} Run And Return Rc And Output ${cmd}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001028 Should Be Equal As Integers ${rc} 0 Can't load onos app ${app_oar_file} to ONOS"
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001029 Log ${output}
Hardik Windlassdc2610f2021-03-09 07:33:51 +00001030
1031Get ONOS App Details
1032 [Arguments] ${url} ${app_name}
1033 [Documentation] Retrieves ONOS App Details
1034 ${rc} ${output} Run And Return Rc And Output
1035 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001036 Should Be Equal As Integers ${rc} 0 Can't read app ${app_name} details from ONOS
Hardik Windlassdc2610f2021-03-09 07:33:51 +00001037 [Return] ${output}
Hardik Windlass88075f92022-01-25 12:19:45 +00001038
1039Verify UniTag Subscriber
1040 [Documentation] Verifies the unitag subscriber is provisioned/un-provisioned
1041 [Arguments] ${ip} ${port} ${dev_id} ${onu_port} ${stag} ${ctag} ${tpid} ${sub_added}=True
1042 ${cmd}= Catenate SEPARATOR=
1043 ... volt-programmed-subscribers ${dev_id} ${onu_port} | grep "ponCTag=${ctag}, ponSTag=${stag}" | grep technologyProfileId
1044 ... =${tpid} --color=none
1045 ${subscriber}= Execute ONOS CLI Command use single connection ${ip} ${port} ${cmd}
1046 Log ${subscriber}
1047 ${sub_count}= Get Line Count ${subscriber}
1048 Run Keyword If ${sub_added}
1049 ... Should Be Equal As Integers ${sub_count} 1 UniTag Subscriber Not Added
1050 ... ELSE
1051 ... Should Be Equal As Integers ${sub_count} 0 UniTag Subscriber Not Removed