blob: bd006dcf3cc45c454f3146f7f12219e0a35cb83e [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
TorstenThiemeb198c482020-12-14 19:45:23 +000036
Kailash6f5acb62019-08-28 14:38:45 -070037*** Keywords ***
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070038
39Open ONOS SSH Connection
40 [Documentation] Establishes an ssh connection to ONOS contoller
41 [Arguments] ${host} ${port} ${user}=karaf ${pass}=karaf
TorstenThieme2ddb6e82022-02-08 14:44:24 +000042 ${conn_id}= SSHLibrary.Open Connection ${host} port=${port} timeout=${ssh_read_timeout} alias=${alias}
TorstenThieme1d1413b2022-02-04 12:41:01 +000043 SSHLibrary.Login username=${user} password=${pass} keep_alive_interval=30s
44 # set excepted prompt and terminal width to suppress unwanted line feeds
TorstenThieme2ddb6e82022-02-08 14:44:24 +000045 SSHLibrary.Set Client Configuration prompt=${ssh_prompt} width=${ssh_width}
TorstenThiemeb198c482020-12-14 19:45:23 +000046 ${conn_list_entry}= Create Dictionary conn_id=${conn_id} user=${user} pass=${pass}
TorstenThieme1d1413b2022-02-04 12:41:01 +000047 ... host=${host} port=${port} alias=${alias}
TorstenThiemeb198c482020-12-14 19:45:23 +000048 Append To List ${connection_list} ${conn_list_entry}
49 ${conn_list_id}= Get Index From List ${connection_list} ${conn_list_entry}
50 Set Global Variable ${connection_list}
TorstenThieme1d1413b2022-02-04 12:41:01 +000051 # disable highlighting to suppress control sequences
TorstenThieme2ddb6e82022-02-08 14:44:24 +000052 ${output}= Execute Single ONOS CLI Command ${conn_id} ${disable_highlighter} do_reconnect=False
TorstenThiemeb198c482020-12-14 19:45:23 +000053 [Return] ${conn_list_id}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -070054
TorstenThieme4e2168e2021-06-22 14:01:47 +000055Execute ONOS CLI Command use single connection
56 [Documentation] Execute ONOS CLI Command use an Open Connection
57 ... In case no connection is open a connection will be opened
TorstenThieme1d1413b2022-02-04 12:41:01 +000058 ... Using Write and Read instead of Execute Command to keep connection alive.
TorstenThieme4e2168e2021-06-22 14:01:47 +000059 [Arguments] ${host} ${port} ${cmd}
60 ${connection_list_id}= Get Conn List Id ${host} ${port}
61 ${connection_list_id}= Run Keyword If "${connection_list_id}"=="${EMPTY}"
62 ... Open ONOS SSH Connection ${host} ${port}
63 ... ELSE Set Variable ${connection_list_id}
64 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000065 Log Command: ${cmd}
66 ${output}= Execute Single ONOS CLI Command ${connection_entry.conn_id} ${cmd}
67 [Return] ${output}
68
69Execute Single ONOS CLI Command
70 [Documentation] Executes ONOS CLI Command on current connection
71 ... Using Write and Read instead of Execute Command to keep connection alive.
72 [Arguments] ${conn_id} ${cmd} ${do_reconnect}=True
73 Log Command: ${cmd}
74 SSHLibrary.Switch Connection ${conn_id}
75 # get connection settings, has no functional reason, only for info
TorstenThieme1d1413b2022-02-04 12:41:01 +000076 ${connection_info}= SSHLibrary.Get Connection
77 ${PassOrFail} ${Written}= Run Keyword And Ignore Error Write ${cmd}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000078 Run Keyword If '${PassOrFail}'=='FAIL' and ${do_reconnect} Reconnect ONOS SSH Connection ${connection_list_id}
TorstenThieme1d1413b2022-02-04 12:41:01 +000079 ${Written}= Run Keyword If '${PassOrFail}'=='FAIL' Write ${cmd} ELSE Set Variable ${Written}
80 Log pass_write: ${Written}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000081 ${PassOrFail} ${output}= Run Keyword And Ignore Error Read Until Prompt strip_prompt=True
TorstenThieme1d1413b2022-02-04 12:41:01 +000082 Log Result_values: ${output}
TorstenThieme2ddb6e82022-02-08 14:44:24 +000083 ${output_length}= Get Length ${output}
84 # remove regexp-prompt if available
85 ${output}= Remove String Using Regexp ${output} ${regexp_prompt}
86 ${output_after}= Get Length ${output}
87 Run Keyword If '${PassOrFail}'=='FAIL' and ${output_length}== ${output_after} FAIL SSH access failed for '${cmd}'!
88 ${prompt_exist} Run Keyword If '${PassOrFail}'=='FAIL' Should Match Regexp ${output} ${regexp_prompt}
TorstenThieme1d1413b2022-02-04 12:41:01 +000089 # we do not use strip of escape sequences integrated in ssh lib, we do it by ourself to have it under control
90 ${output}= Remove String Using Regexp ${output} \\x1b[>=]{0,1}(?:\\[[0-?]*(?:[hlm])[~]{0,1})*
91 # remove the endless spaces and two carrige returns at the end of output
92 ${output}= Remove String Using Regexp ${output} \\s*\\r \\r
93 # now we have the plain output text
94 Log Stripped Result_values: ${output}
TorstenThieme4e2168e2021-06-22 14:01:47 +000095 [Return] ${output}
96
97Get Conn List Id
98 [Documentation] Looks up for an Open Connection with passed host and port in conection list
99 ... First match connection will be used.
100 [Arguments] ${host} ${port}
101 ${connection_list_id}= Set Variable ${EMPTY}
102 ${match}= Set Variable False
103 ${length}= Get Length ${connection_list}
104 FOR ${INDEX} IN RANGE 0 ${length}
105 #${Item}= Get From List ${connection_list} ${INDEX}
106 ${conndata}= Get Connection ${connection_list[${INDEX}].conn_id}
107 ${match}= Set Variable If '${conndata.host}'=='${host}' and '${conndata.port}'=='${port}' True False
108 ${connection_list_id}= Set Variable If ${match} ${INDEX} ${EMPTY}
109 Exit For Loop If ${match}
110 END
111 [Return] ${connection_list_id}
112
TorstenThiemeb198c482020-12-14 19:45:23 +0000113Reconnect ONOS SSH Connection
114 [Documentation] Reconnect an SSH Connection
115 [Arguments] ${connection_list_id}
116 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
117 ${user}= Get From Dictionary ${connection_entry} user
118 ${pass}= Get From Dictionary ${connection_entry} pass
119 ${oldconndata}= Get Connection ${connection_entry.conn_id}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000120 ${match}= Set Variable If
121 ... "${oldconndata.host}"=="${connection_entry.host}" and "${oldconndata.port}"=="${connection_entry.port}"
122 ... True False
123 Run Keyword If ${match} SSHLibrary.Switch Connection ${connection_entry.conn_id}
124 Run Keyword If ${match} Run Keyword And Ignore Error SSHLibrary.Close Connection
125 ${conn_id}= SSHLibrary.Open Connection ${connection_entry.host} port=${connection_entry.port}
TorstenThieme2ddb6e82022-02-08 14:44:24 +0000126 ... timeout=${ssh_read_timeout} alias=${alias}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000127 SSHLibrary.Login username=${user} password=${pass} keep_alive_interval=30s
128 # set excepted prompt and terminal width to suppress unwanted line feeds
TorstenThieme2ddb6e82022-02-08 14:44:24 +0000129 SSHLibrary.Set Client Configuration prompt=${ssh_prompt} width=${ssh_width}
TorstenThiemeb198c482020-12-14 19:45:23 +0000130 ${conn_list_entry}= Create Dictionary conn_id=${conn_id} user=${user} pass=${pass}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000131 ... host=${connection_entry.host} port=${connection_entry.port} alias=${alias}
TorstenThiemeb198c482020-12-14 19:45:23 +0000132 Set List Value ${connection_list} ${connection_list_id} ${conn_list_entry}
133 Set Global Variable ${connection_list}
TorstenThieme1d1413b2022-02-04 12:41:01 +0000134 # disable highlighting to suppress control sequences
TorstenThieme2ddb6e82022-02-08 14:44:24 +0000135 ${output}= Execute Single ONOS CLI Command ${conn_id} ${disable_highlighter} do_reconnect=False
TorstenThiemeb198c482020-12-14 19:45:23 +0000136
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700137Close ONOS SSH Connection
138 [Documentation] Close an SSH Connection
TorstenThiemeb198c482020-12-14 19:45:23 +0000139 [Arguments] ${connection_list_id}
140 ${connection_entry}= Get From List ${connection_list} ${connection_list_id}
141 ${connection_alias}= Get From Dictionary ${connection_entry} conn_id
142 ${oldconndata}= Get Connection ${connection_entry.conn_id}
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700143 SSHLibrary.Switch Connection ${connection_alias}
TorstenThiemebcf14612021-01-27 10:19:18 +0000144 Run Keyword And Ignore Error SSHLibrary.Close Connection
TorstenThiemeb198c482020-12-14 19:45:23 +0000145 Remove From List ${connection_list} ${connection_list_id}
146 Set Global Variable ${connection_list}
147
148Close All ONOS SSH Connections
149 [Documentation] Close all SSH Connection and clear connection list.
150 SSHLibrary.Close All Connections
151 @{connection_list} Create List
Matteo Scandolo37bca8d2020-07-31 11:28:40 -0700152
Kailash6f5acb62019-08-28 14:38:45 -0700153Validate OLT Device in ONOS
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700154 # FIXME use volt-olts to check that the OLT is ONOS
Kailash6f5acb62019-08-28 14:38:45 -0700155 [Arguments] ${serial_number}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700156 [Documentation] Checks if olt has been connected to ONOS
Kailash6f5acb62019-08-28 14:38:45 -0700157 ${resp}= Get Request ONOS onos/v1/devices
158 ${jsondata}= To Json ${resp.content}
159 Should Not Be Empty ${jsondata['devices']}
160 ${length}= Get Length ${jsondata['devices']}
161 @{serial_numbers}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -0700162 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700163 FOR ${INDEX} IN RANGE 0 ${length}
164 ${value}= Get From List ${jsondata['devices']} ${INDEX}
165 ${of_id}= Get From Dictionary ${value} id
166 ${sn}= Get From Dictionary ${value} serial
Andy Bavierb63f6d22020-03-12 15:34:37 -0700167 ${matched}= Set Variable If '${sn}' == '${serial_number}' True False
168 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700169 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700170 Should Be True ${matched} No match for ${serial_number} found
Kailash57210eb2019-08-30 13:27:19 -0700171 [Return] ${of_id}
Kailash6f5acb62019-08-28 14:38:45 -0700172
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700173Get ONU Port in ONOS
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000174 [Arguments] ${onu_serial_number} ${olt_of_id} ${onu_uni_id}=1
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700175 [Documentation] Retrieves ONU port for the ONU in ONOS
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000176 ${onu_serial_number}= Catenate SEPARATOR=- ${onu_serial_number} ${onu_uni_id}
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700177 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
178 ${jsondata}= To Json ${resp.content}
179 Should Not Be Empty ${jsondata['ports']}
180 ${length}= Get Length ${jsondata['ports']}
181 @{ports}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -0700182 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -0700183 FOR ${INDEX} IN RANGE 0 ${length}
184 ${value}= Get From List ${jsondata['ports']} ${INDEX}
185 ${annotations}= Get From Dictionary ${value} annotations
186 ${onu_port}= Get From Dictionary ${value} port
187 ${portName}= Get From Dictionary ${annotations} portName
Andy Bavierb63f6d22020-03-12 15:34:37 -0700188 ${matched}= Set Variable If '${portName}' == '${onu_serial_number}' True False
189 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700190 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700191 Should Be True ${matched} No match for ${onu_serial_number} found
Suchitra Vemuri102912a2019-09-24 00:35:42 -0700192 [Return] ${onu_port}
193
TorstenThieme9b25aab2021-12-16 15:59:45 +0000194Get Onu Ports in ONOS For ALL UNI per ONU
195 [Documentation] Retrieves ONU port(s) for the ONU in ONOS for all UNI-IDs, list of ports will return!
196 [Arguments] ${onu_serial_number} ${olt_of_id}
197 @{uni_id_list}= Create List
198 @{port_list}= Create List
199 FOR ${I} IN RANGE 0 ${num_all_onus}
200 ${src}= Set Variable ${hosts.src[${I}]}
201 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
202 ${uni_id}= Set Variable ${src['uni_id']}
203 # make sure all actions do only once per uni_id
204 ${id}= Get Index From List ${uni_id_list} ${uni_id}
205 Continue For Loop If -1 != ${id}
206 Append To List ${uni_id_list} ${uni_id}
207 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${onu_serial_number}
208 ... ${olt_of_id} ${uni_id}
209 Append To List ${port_list} ${onu_port}
210 END
211 [return] ${port_list}
212
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530213Get NNI Port in ONOS
214 [Arguments] ${olt_of_id}
215 [Documentation] Retrieves NNI port for the OLT in ONOS
216 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
217 ${jsondata}= To Json ${resp.content}
218 Should Not Be Empty ${jsondata['ports']}
219 ${length}= Get Length ${jsondata['ports']}
220 @{ports}= Create List
221 ${matched}= Set Variable False
222 FOR ${INDEX} IN RANGE 0 ${length}
223 ${value}= Get From List ${jsondata['ports']} ${INDEX}
224 ${annotations}= Get From Dictionary ${value} annotations
225 ${nni_port}= Get From Dictionary ${value} port
226 ${nniPortName}= Catenate SEPARATOR= nni- ${nni_port}
227 ${portName}= Get From Dictionary ${annotations} portName
228 ${matched}= Set Variable If '${portName}' == '${nniPortName}' True False
229 Exit For Loop If ${matched}
230 END
231 Should Be True ${matched} No match for NNI found for ${olt_of_id}
232 [Return] ${nni_port}
233
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700234Get FabricSwitch in ONOS
235 [Documentation] Returns of_id of the Fabric Switch in ONOS
236 ${resp}= Get Request ONOS onos/v1/devices
237 ${jsondata}= To Json ${resp.content}
238 Should Not Be Empty ${jsondata['devices']}
239 ${length}= Get Length ${jsondata['devices']}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700240 ${matched}= Set Variable False
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700241 FOR ${INDEX} IN RANGE 0 ${length}
242 ${value}= Get From List ${jsondata['devices']} ${INDEX}
243 ${of_id}= Get From Dictionary ${value} id
244 ${type}= Get From Dictionary ${value} type
Andy Bavierb63f6d22020-03-12 15:34:37 -0700245 ${matched}= Set Variable If '${type}' == "SWITCH" True False
246 Exit For Loop If ${matched}
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700247 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700248 Should Be True ${matched} No fabric switch found
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700249 [Return] ${of_id}
250
Andrea Campanella4c404632020-08-26 14:41:36 +0200251Get Master Instace in ONOS
252 [Arguments] ${of_id}
253 [Documentation] Returns nodeId of the Master instace for a giver device in ONOS
254 ${resp}= Get Request ONOS onos/v1/mastership/${of_id}/master
255 ${jsondata}= To Json ${resp.content}
256 Should Not Be Empty ${jsondata['nodeId']}
257 ${master_node}= Get From Dictionary ${jsondata} nodeId
258 [Return] ${master_node}
259
Matteo Scandolo7bdbe2d2021-11-29 15:48:25 -0800260Verify LLDP Flow Added
261 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
262 [Documentation] Matches for total number of LLDP flows added for one OLT
263 ${lldp_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
264 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep ETH_TYPE:lldp | grep -v ETH_TYPE:arp
265 ${lldp_flows_added_count}= Get Line Count ${lldp_flows_added}
266 Should Be Equal As Integers ${lldp_flows_added_count} ${expected_flows}
267
Hardik Windlass21807632020-04-14 16:24:55 +0530268Verify Subscriber Access Flows Added for ONU
269 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${c_tag} ${s_tag}
270 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
271 # Verify upstream table=0 flow
272 ${upstream_flow_0_cmd}= Catenate SEPARATOR=
273 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:0 |
274 ... grep VLAN_ID:${c_tag} | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000275 ${upstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530276 ... ${upstream_flow_0_cmd}
277 Should Not Be Empty ${upstream_flow_0_added}
278 # Verify upstream table=1 flow
279 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
280 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
281 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000282 ${upstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530283 ... ${flow_vlan_push_cmd}
284 Should Not Be Empty ${upstream_flow_1_added}
285 # Verify downstream table=0 flow
286 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
287 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
288 ... grep VLAN_POP | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000289 ${downstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530290 ... ${flow_vlan_pop_cmd}
291 Should Not Be Empty ${downstream_flow_0_added}
292 # Verify downstream table=1 flow
293 ${downstream_flow_1_cmd}= Catenate SEPARATOR=
294 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${c_tag} |
295 ... grep VLAN_ID:0 | grep OUTPUT:${onu_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000296 ${downstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530297 ... ${downstream_flow_1_cmd}
298 Should Not Be Empty ${downstream_flow_1_added}
299 # Verify ipv4 dhcp upstream flow
300 ${upstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200301 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:ipv4 |
Andrea Campanella08678e12020-09-18 17:40:22 +0200302 ... grep IP_PROTO:17 | grep UDP_SRC:68 | grep UDP_DST:67 | grep VLAN_ID:${c_tag} |
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200303 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000304 ${upstream_flow_ipv4_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530305 ... ${upstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200306 Should Not Be Empty ${upstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530307 # Verify ipv4 dhcp downstream flow
308 # Note: This flow will be one per nni per olt
309 ${downstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200310 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep ETH_TYPE:ipv4 |
311 ... grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 | grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000312 ${downstream_flow_ipv4_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass21807632020-04-14 16:24:55 +0530313 ... ${downstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200314 Should Not Be Empty ${downstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530315
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530316Verify Subscriber Access Flows Added for ONU DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530317 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530318 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
319 # Verify upstream table=0 flow
TorstenThieme4e2168e2021-06-22 14:01:47 +0000320 ${upstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530321 ... 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 +0530322 Should Not Be Empty ${upstream_flow_0_added}
323 # Verify upstream table=1 flow
324 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530325 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:Any |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530326 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000327 ${upstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530328 ... ${flow_vlan_push_cmd}
329 Should Not Be Empty ${upstream_flow_1_added}
330 # Verify downstream table=0 flow
331 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530332 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530333 ... grep VLAN_POP | grep transition=TABLE:1
TorstenThieme4e2168e2021-06-22 14:01:47 +0000334 ${downstream_flow_0_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530335 ... ${flow_vlan_pop_cmd}
336 Should Not Be Empty ${downstream_flow_0_added}
337 # Verify downstream table=1 flow
TorstenThieme4e2168e2021-06-22 14:01:47 +0000338 ${downstream_flow_1_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530339 ... 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 +0530340 Should Not Be Empty ${downstream_flow_1_added}
341
342Verify Subscriber Access Flows Added Count DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530343 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530344 [Documentation] Matches for total number of subscriber access flows added for all onus
TorstenThieme4e2168e2021-06-22 14:01:47 +0000345 ${access_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700346 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep -v ETH_TYPE:lldp | grep -v ETH_TYPE:arp
347 ${access_flows_added_count}= Get Line Count ${access_flows_added}
348 Should Be Equal As Integers ${access_flows_added_count} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530349
Huseyin Ahmet AYDIN45922c82021-05-27 12:37:32 +0000350Verify Added Flow Count for OLT TT
351 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
352 [Documentation] Total number of added flows given OLT with subscriber flows
TorstenThieme4e2168e2021-06-22 14:01:47 +0000353 ${access_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700354 ... flows -s ADDED ${olt_of_id} | grep -v deviceId
355 ${access_flows_added_count}= Get Line Count ${access_flows_added}
356 Should Be Equal As Integers ${access_flows_added_count} ${expected_flows}
Huseyin Ahmet AYDIN45922c82021-05-27 12:37:32 +0000357
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000358Verify Default Downstream Flows are added in ONOS for OLT TT
359 [Arguments] ${ip} ${port} ${olt_of_id} ${nni_port}
360 [Documentation] Verifies if the Default Downstream Flows are added in ONOS for the OLT
361 # Verify lldp flow
362 ${downstream_flow_lldp_cmd}= Catenate SEPARATOR=
363 ... flows -s ADDED ${olt_of_id} | grep lldp |
364 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000365 ${downstream_flow_lldp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000366 ... ${downstream_flow_lldp_cmd}
367 Should Not Be Empty ${downstream_flow_lldp_added}
368 # Verify downstream dhcp flow
369 ${downstream_flow_dhcp_cmd}= Catenate SEPARATOR=
370 ... flows -s ADDED ${olt_of_id} | grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 |
371 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000372 ${downstream_flow_dhcp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000373 ... ${downstream_flow_dhcp_cmd}
374 Should Not Be Empty ${downstream_flow_dhcp_added}
375 # Verify downstream igmp flow
376 ${downstream_flow_igmp_cmd}= Catenate SEPARATOR=
377 ... flows -s ADDED ${olt_of_id} | grep IP_PROTO:2 |
378 ... grep OUTPUT:CONTROLLER
TorstenThieme4e2168e2021-06-22 14:01:47 +0000379 ${downstream_flow_igmp_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Emrehan UZUN2884ed52021-05-04 15:36:31 +0000380 ... ${downstream_flow_igmp_cmd}
381 Should Not Be Empty ${downstream_flow_igmp_added}
382
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530383Get Programmed Subscribers
384 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
385 [Documentation] Retrieves the subscriber details at a given location
386 ${sub_location}= Catenate SEPARATOR=/ ${olt_of_id} ${onu_port}
TorstenThieme4e2168e2021-06-22 14:01:47 +0000387 ${programmed_sub}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530388 ... volt-programmed-subscribers | grep ${sub_location}
389 [Return] ${programmed_sub}
390
391Get Upstream and Downstream Bandwidth Profile Name
392 [Arguments] ${programmed_sub}
393 [Documentation] Retrieves the upstream and downstream bandwidth profile name
394 ... from the programmed subscriber
395 @{programmed_sub_array}= Split String ${programmed_sub} ,
396 # Get upstream bandwidth profile name for the subscriber
397 @{param_val_pair}= Split String ${programmed_sub_array[9]} =
398 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
399 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
400 ${us_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' upstreamBandwidthProfile'
401 ... Set Variable ${programmed_sub_val}
402 Log ${us_bw_profile}
403 # Get downstream bandwidth profile name for the subscriber
404 @{param_val_pair}= Split String ${programmed_sub_array[10]} =
405 ${programmed_sub_param}= Set Variable ${param_val_pair[0]}
406 ${programmed_sub_val}= Set Variable ${param_val_pair[1]}
407 ${ds_bw_profile}= Run Keyword If '${programmed_sub_param}' == ' downstreamBandwidthProfile'
408 ... Set Variable ${programmed_sub_val}
409 Log ${ds_bw_profile}
410 [Return] ${us_bw_profile} ${ds_bw_profile}
411
412Get Bandwidth Profile Details
413 [Arguments] ${ip} ${port} ${bw_profile}
414 [Documentation] Retrieves the details of the given bandwidth profile
TorstenThieme4e2168e2021-06-22 14:01:47 +0000415 ${bw_profile_values}= Execute ONOS CLI Command use single connection ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530416 ... bandwidthprofile ${bw_profile}
417 @{bw_profile_array}= Split String ${bw_profile_values} ,
418 @{param_val_pair}= Split String ${bw_profile_array[1]} =
419 ${bw_param}= Set Variable ${param_val_pair[0]}
420 ${bw_val}= Set Variable ${param_val_pair[1]}
421 ${cir} Run Keyword If '${bw_param}' == ' committedInformationRate'
422 ... Set Variable ${bw_val}
423 @{param_val_pair}= Split String ${bw_profile_array[2]} =
424 ${bw_param}= Set Variable ${param_val_pair[0]}
425 ${bw_val}= Set Variable ${param_val_pair[1]}
426 ${cbs} Run Keyword If '${bw_param}' == ' committedBurstSize'
427 ... Set Variable ${bw_val}
428 @{param_val_pair}= Split String ${bw_profile_array[3]} =
429 ${bw_param}= Set Variable ${param_val_pair[0]}
430 ${bw_val}= Set Variable ${param_val_pair[1]}
431 ${eir} Run Keyword If '${bw_param}' == ' exceededInformationRate'
432 ... Set Variable ${bw_val}
433 @{param_val_pair}= Split String ${bw_profile_array[4]} =
434 ${bw_param}= Set Variable ${param_val_pair[0]}
435 ${bw_val}= Set Variable ${param_val_pair[1]}
436 ${ebs} Run Keyword If '${bw_param}' == ' exceededBurstSize'
437 ... Set Variable ${bw_val}
438 @{param_val_pair}= Split String ${bw_profile_array[5]} =
439 ${bw_param}= Set Variable ${param_val_pair[0]}
440 ${bw_val}= Set Variable ${param_val_pair[1]}
441 @{bw_val_air}= Split String ${bw_val} }
442 ${air} Run Keyword If '${bw_param}' == ' assuredInformationRate'
443 ... Set Variable ${bw_val_air[0]}
444 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
445
Hardik Windlassba5add42021-05-04 12:41:29 +0000446Get Bandwidth Profile Details Rest
447 [Arguments] ${bw_profile_id}
448 [Documentation] Retrieves the details of the given bandwidth profile using REST API
Girish Gowdracb8482a2021-05-27 09:06:13 -0700449 ${bw_profile_id}= Remove String ${bw_profile_id} ' "
Hardik Windlassba5add42021-05-04 12:41:29 +0000450 ${resp}= Get Request ONOS onos/sadis/bandwidthprofile/${bw_profile_id}
451 ${jsondata}= To Json ${resp.content}
452 Should Not Be Empty ${jsondata['entry']}
453 ${length}= Get Length ${jsondata['entry']}
454 ${matched}= Set Variable False
455 FOR ${INDEX} IN RANGE 0 ${length}
456 ${value}= Get From List ${jsondata['entry']} ${INDEX}
457 ${bw_id}= Get From Dictionary ${value} id
458 ${matched}= Set Variable If '${bw_id}' == '${bw_profile_id}' True False
459 ${eir}= Get From Dictionary ${value} eir
460 ${ebs}= Get From Dictionary ${value} ebs
461 ${cir}= Get From Dictionary ${value} cir
462 ${cbs}= Get From Dictionary ${value} cbs
463 ${air}= Get From Dictionary ${value} air
464 Exit For Loop If ${matched}
465 END
466 Should Be True ${matched} No bandwidth profile found for id: ${bw_profile_id}
467 [Return] ${cir} ${cbs} ${eir} ${ebs} ${air}
468
Hardik Windlass841979a2021-05-25 05:30:27 +0000469Get Bandwidth Profile Details Ietf Rest
470 [Arguments] ${bw_profile_id}
471 [Documentation] Retrieves the details of the given Ietf standard based bandwidth profile using REST API
472 ${bw_profile_id}= Remove String ${bw_profile_id} ' "
473 ${resp}= Get Request ONOS onos/sadis/bandwidthprofile/${bw_profile_id}
474 ${jsondata}= To Json ${resp.content}
475 Should Not Be Empty ${jsondata['entry']}
476 ${length}= Get Length ${jsondata['entry']}
477 ${matched}= Set Variable False
478 FOR ${INDEX} IN RANGE 0 ${length}
479 ${value}= Get From List ${jsondata['entry']} ${INDEX}
480 ${bw_id}= Get From Dictionary ${value} id
481 ${matched}= Set Variable If '${bw_id}' == '${bw_profile_id}' True False
482 ${pir}= Get From Dictionary ${value} pir
483 ${pbs}= Get From Dictionary ${value} pbs
484 ${cir}= Get From Dictionary ${value} cir
485 ${cbs}= Get From Dictionary ${value} cbs
486 ${gir}= Get From Dictionary ${value} gir
487 Exit For Loop If ${matched}
488 END
489 Should Be True ${matched} No bandwidth profile found for id: ${bw_profile_id}
490 [Return] ${cir} ${cbs} ${pir} ${pbs} ${gir}
491
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700492Verify Meters in ONOS Ietf
493 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
494 [Documentation] Verifies the meters with BW Ietf format (currently, DT workflow uses this format)
495 # Get programmed subscriber
496 ${programmed_sub}= Get Programmed Subscribers ${ip} ${port}
497 ... ${olt_of_id} ${onu_port}
498 Log ${programmed_sub}
499 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
500 ... ${programmed_sub}
501 # Get upstream bandwidth profile details
502 ${us_cir} ${us_cbs} ${us_pir} ${us_pbs} ${us_gir} Get Bandwidth Profile Details Ietf Rest
503 ... ${us_bw_profile}
504 # Verify meter for upstream bandwidth profile
505 ${us_meter_cmd}= Run Keyword If ${us_gir} != 0 Catenate SEPARATOR=
506 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
507 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | grep "rate=${us_gir}, burst-size=0" | wc -l
508 ... ELSE Catenate SEPARATOR=
509 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
510 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000511 ${upstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700512 ... ${us_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700513 Should Be Equal As Integers ${upstream_meter_added} 1 Upstream meter is missing
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700514 # Get downstream bandwidth profile details
515 ${ds_cir} ${ds_cbs} ${ds_pir} ${ds_pbs} ${ds_gir} Get Bandwidth Profile Details Ietf Rest
516 ... ${ds_bw_profile}
517 # Verify meter for downstream bandwidth profile
518 ${ds_meter_cmd}= Run Keyword If ${ds_gir} != 0 Catenate SEPARATOR=
519 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
520 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | grep "rate=${ds_gir}, burst-size=0" | wc -l
521 ... ELSE Catenate SEPARATOR=
522 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
523 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000524 ${downstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700525 ... ${ds_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700526 Should Be Equal As Integers ${downstream_meter_added} 1 Downstream meter is missing
Girish Gowdra21ec25d2021-05-24 10:07:01 -0700527
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530528Verify Meters in ONOS
529 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port}
530 [Documentation] Verifies the meters
531 # Get programmed subscriber
532 ${programmed_sub}= Get Programmed Subscribers ${ip} ${port}
533 ... ${olt_of_id} ${onu_port}
534 Log ${programmed_sub}
535 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
536 ... ${programmed_sub}
Matteo Scandolo2056ed72021-11-02 17:38:03 -0700537 # logging all meters to facilitate debug
538 ${all_meters}= Execute ONOS CLI Command use single connection ${ip} ${port} meters
539 Log ${all_meters}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530540 # Get upstream bandwidth profile details
541 ${us_cir} ${us_cbs} ${us_eir} ${us_ebs} ${us_air} Get Bandwidth Profile Details
542 ... ${ip} ${port} ${us_bw_profile}
543 Sleep 1s
Andrea Campanella2b367102021-05-04 19:33:46 +0200544 ${us_pbs}= Evaluate ${us_cbs}+${us_ebs}
545 ${us_pir}= Evaluate ${us_eir}+${us_cir}+${us_air}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530546 # Verify meter for upstream bandwidth profile
547 ${us_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530548 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${us_cir}, burst-size=${us_cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200549 ... | grep "rate=${us_pir}, burst-size=${us_pbs}" | grep "rate=${us_air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000550 ${upstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530551 ... ${us_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700552 Should Be Equal As Integers ${upstream_meter_added} 1 Upstream meter is missing
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530553 Sleep 1s
554 # Get downstream bandwidth profile details
555 ${ds_cir} ${ds_cbs} ${ds_eir} ${ds_ebs} ${ds_air} Get Bandwidth Profile Details
556 ... ${ip} ${port} ${ds_bw_profile}
557 Sleep 1s
558 # Verify meter for downstream bandwidth profile
Andrea Campanella2b367102021-05-04 19:33:46 +0200559 ${ds_pbs}= Evaluate ${ds_cbs}+${ds_ebs}
560 ${ds_pir}= Evaluate ${ds_eir}+${ds_cir}+${ds_air}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530561 ${ds_meter_cmd}= Catenate SEPARATOR=
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530562 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${ds_cir}, burst-size=${ds_cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200563 ... | grep "rate=${ds_pir}, burst-size=${ds_pbs}" | grep "rate=${ds_air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000564 ${downstream_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530565 ... ${ds_meter_cmd}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700566 Should Be Equal As Integers ${downstream_meter_added} 1 Downstream meter is missing
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530567
568Verify Default Meter Present in ONOS
569 [Arguments] ${ip} ${port} ${olt_of_id}
570 [Documentation] Verifies the single default meter entry is present
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530571 # Get default bandwidth profile details
572 ${cir} ${cbs} ${eir} ${ebs} ${air} Get Bandwidth Profile Details
573 ... ${ip} ${port} 'Default'
574 Sleep 1s
Andrea Campanella2b367102021-05-04 19:33:46 +0200575 ${pbs}= Evaluate ${cbs}+${ebs}
576 ${pir}= Evaluate ${eir}+${cir}+${air}
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530577 # Verify meter for default bandwidth profile
578 ${meter_cmd}= Catenate SEPARATOR=
579 ... meters ${olt_of_id} | grep state=ADDED | grep "rate=${cir}, burst-size=${cbs}"
Andrea Campanella2b367102021-05-04 19:33:46 +0200580 ... | grep "rate=${pir}, burst-size=${pbs}" | grep "rate=${air}, burst-size=0" | wc -l
TorstenThieme4e2168e2021-06-22 14:01:47 +0000581 ${default_meter_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlasse380bdb2020-07-30 19:09:25 +0530582 ... ${meter_cmd}
Matteo Scandolo2056ed72021-11-02 17:38:03 -0700583 # logging all meters to facilitate debug
584 ${all_meters}= Execute ONOS CLI Command use single connection ${ip} ${port} meters
585 Log ${all_meters}
586 # done logging all meters to facilitate debug
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700587 Should Be Equal As Integers ${default_meter_added} 1 Default Meter not present
Hardik Windlass2a9b1592020-07-23 18:28:13 +0530588
Hardik Windlass480f3e22020-04-02 20:14:14 +0530589Verify Device Flows Removed
590 [Arguments] ${ip} ${port} ${olt_of_id}
591 [Documentation] Verifies all flows are removed from the device
TorstenThieme4e2168e2021-06-22 14:01:47 +0000592 ${device_flows}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700593 ... flows -s -f ${olt_of_id} | grep -v deviceId
594 ${flow_count}= Get Line Count ${device_flows}
595 Should Be Equal As Integers ${flow_count} 0 Flows not removed
Hardik Windlass480f3e22020-04-02 20:14:14 +0530596
Kailash6f5acb62019-08-28 14:38:45 -0700597Verify Eapol Flows Added
Andy Bavierb0c06232019-08-29 12:58:53 -0700598 [Arguments] ${ip} ${port} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700599 [Documentation] Matches for number of eapol flows based on number of onus
TorstenThieme4e2168e2021-06-22 14:01:47 +0000600 ${eapol_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port}
Gilles Depatie675a2062019-10-22 12:44:42 -0400601 ... flows -s -f ADDED | grep eapol | grep IN_PORT | wc -l
Andy Bavierb0c06232019-08-29 12:58:53 -0700602 Should Contain ${eapol_flows_added} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700603
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800604Verify No Pending Flows For ONU
605 [Arguments] ${ip} ${port} ${onu_port}
606 [Documentation] Verifies that there are no flows "PENDING" state for the ONU in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000607 ${pending_flows}= Execute ONOS CLI Command use single connection ${ip} ${port}
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800608 ... flows -s | grep IN_PORT:${onu_port} | grep PENDING
609 Should Be Empty ${pending_flows}
610
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700611Verify Eapol Flows Added For ONU
Matteo Scandolo7e519fb2021-08-13 11:35:16 -0700612 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${c_tag}=4091
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700613 [Documentation] Verifies if the Eapol Flows are added in ONOS for the ONU
Matteo Scandolo7e519fb2021-08-13 11:35:16 -0700614 ${eapol_flow_cmd}= Catenate SEPARATOR=
615 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:eapol |
616 ... grep VLAN_ID:${c_tag} | grep OUTPUT:CONTROLLER
617 ${eapol_flows_added}= Execute ONOS CLI Command use single connection ${ip} ${port} ${eapol_flow_cmd}
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700618 Should Not Be Empty ${eapol_flows_added}
619
Hardik Windlass39015672021-07-05 05:48:08 +0000620Verify UNI Port Is Enabled
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000621 [Arguments] ${ip} ${port} ${onu_name} ${onu_uni_id}=1
Hardik Windlass39015672021-07-05 05:48:08 +0000622 [Documentation] Verifies if the ONU's UNI port is enabled in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000623 ${onu_port_enabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000624 ... ports -e | grep portName=${onu_name}-${onu_uni_id}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800625 Log ${onu_port_enabled}
626 Should Not Be Empty ${onu_port_enabled}
627
Hardik Windlass39015672021-07-05 05:48:08 +0000628Verify UNI Port Is Disabled
Hardik Windlass1ed2eee2021-06-25 09:51:03 +0000629 [Arguments] ${ip} ${port} ${onu_name} ${onu_uni_id}=1
Hardik Windlass39015672021-07-05 05:48:08 +0000630 [Documentation] Verifies if the ONU's UNI port is disabled in ONOS
TorstenThieme4e2168e2021-06-22 14:01:47 +0000631 ${onu_port_disabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo02768532021-10-21 15:14:12 -0700632 ... ports | grep portName=${onu_name}-${onu_uni_id} | grep state=disabled
Hardik Windlass63d5e002020-03-06 21:07:09 +0530633 Log ${onu_port_disabled}
Matteo Scandolo02768532021-10-21 15:14:12 -0700634 Should Not Be Empty ${onu_port_disabled}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530635
TorstenThieme9b25aab2021-12-16 15:59:45 +0000636Wait For All UNI Ports Are Disabled per ONU
637 [Documentation] Verifies all UNI Ports of passed ONU are disabled
638 [Arguments] ${ip} ${port} ${onu_serial_number}
639 @{uni_id_list}= Create List
640 FOR ${I} IN RANGE 0 ${num_all_onus}
641 ${src}= Set Variable ${hosts.src[${I}]}
642 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
643 ${uni_id}= Set Variable ${src['uni_id']}
644 # make sure all actions do only once per uni_id
645 ${id}= Get Index From List ${uni_id_list} ${uni_id}
646 Continue For Loop If -1 != ${id}
647 Append To List ${uni_id_list} ${uni_id}
648 Wait Until Keyword Succeeds ${timeout} 2s
649 ... Verify UNI Port Is Disabled ${ip} ${port} ${onu_serial_number} ${uni_id}
650 END
651
652Wait For All UNI Ports Are Enabled per ONU
653 [Documentation] Verifies all UNI Ports of passed ONU are enabled
654 [Arguments] ${ip} ${port} ${onu_serial_number}
655 @{uni_id_list}= Create List
656 FOR ${I} IN RANGE 0 ${num_all_onus}
657 ${src}= Set Variable ${hosts.src[${I}]}
658 Continue For Loop If "${src['onu']}" != "${onu_serial_number}"
659 ${uni_id}= Set Variable ${src['uni_id']}
660 # make sure all actions do only once per uni_id
661 ${id}= Get Index From List ${uni_id_list} ${uni_id}
662 Continue For Loop If -1 != ${id}
663 Append To List ${uni_id_list} ${uni_id}
664 Wait Until Keyword Succeeds ${timeout} 2s
665 ... Verify UNI Port Is Enabled ${ip} ${port} ${onu_serial_number} ${uni_id}
666 END
667
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700668Verify ONU in AAA-Users
669 [Arguments] ${ip} ${port} ${onu_port}
670 [Documentation] Verifies that the specified onu_port exists in aaa-users output
TorstenThieme4e2168e2021-06-22 14:01:47 +0000671 ${aaa_users}= Execute ONOS CLI Command use single connection ${ip} ${port}
672 ... aaa-users | grep AUTHORIZED | grep ${onu_port}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700673 Should Not Be Empty ${aaa_users} ONU port ${onu_port} not found in aaa-users
674
Hardik Windlass513afd12021-02-03 15:19:46 +0000675Verify Empty Group in ONOS
676 [Documentation] Verifies zero group count on the device
TorstenThieme731a7592021-07-01 14:26:54 +0000677 [Arguments] ${ip} ${port} ${deviceId}
678 ${groups}= Execute ONOS CLI Command use single connection ${ip} ${port} groups | grep ${deviceId}
Hardik Windlass513afd12021-02-03 15:19:46 +0000679 @{groups_arr}= Split String ${groups} ,
680 @{group_count_arr}= Split String ${groups_arr[1]} =
681 ${group_count}= Set Variable ${group_count_arr[1]}
682 Should Be Equal As Integers ${group_count} 0
683
684Verify ONUs in Group Count in ONOS
685 [Documentation] Verifies there exists a group bucket list with certain entries/count
686 ... Note: Currently, this validates only if all ONUs of an OLT joined the same igmp group
TorstenThieme731a7592021-07-01 14:26:54 +0000687 [Arguments] ${ip} ${port} ${count} ${deviceId}
688 ${result}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolofd36e212021-03-02 11:36:10 -0800689 ... groups added ${deviceId} | grep bucket | wc -l
690 Should Be Equal As Integers ${result} ${count} Bucket list count for a group: Found=${result} Expected=${count}
Hardik Windlass513afd12021-02-03 15:19:46 +0000691
692Verify ONU in Group Bucket
693 [Documentation] Matches if ONU port in Group Bucket
694 [Arguments] ${group_bucket_values} ${onu_port}
695 ${len}= Get Length ${group_bucket_values}
696 ${matched}= Set Variable False
697 FOR ${INDEX} IN RANGE 0 ${len}
698 ${value_bucket}= Get From List ${group_bucket_values} ${INDEX}
699 ${treatment}= Get From Dictionary ${value_bucket} treatment
700 ${instructions}= Get From Dictionary ${treatment} instructions
701 ${instructions_val}= Get From List ${instructions} 0
702 ${port}= Get From Dictionary ${instructions_val} port
703 ${matched}= Set Variable If '${port}'=='${onu_port}' True False
704 Exit For Loop If ${matched}
705 END
706 [Return] ${matched}
707
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700708Verify ONU in Groups
709 [Arguments] ${ip_onos} ${port_onos} ${deviceId} ${onu_port} ${group_exist}=True
710 [Documentation] Verifies that the specified onu_port exists in groups output
TorstenThieme4e2168e2021-06-22 14:01:47 +0000711 ${result}= Execute ONOS CLI Command use single connection ${ip_onos} ${port_onos} groups -j
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700712 Log Groups: ${result}
713 ${groups}= To Json ${result}
714 ${length}= Get Length ${groups}
715 ${buckets}= Create List
716 ${matched}= Set Variable False
717 FOR ${INDEX} IN RANGE 0 ${length}
718 ${value}= Get From List ${groups} ${INDEX}
719 ${devId}= Get From Dictionary ${value} deviceId
720 ${bucket}= Get From Dictionary ${value} buckets
721 Run Keyword If '${devId}'=='${deviceId}'
722 ... Append To List ${buckets} ${bucket}
723 END
724 ${bucket_len}= Get Length ${buckets}
Hardik Windlass513afd12021-02-03 15:19:46 +0000725 FOR ${INDEX_1} IN RANGE 0 ${bucket_len}
726 ${value}= Get From List ${buckets} ${INDEX_1}
727 ${matched}= Verify ONU in Group Bucket ${value} ${onu_port}
Matteo Scandoloa80b4732020-09-04 13:51:10 -0700728 Exit For Loop If ${matched}
729 END
730 Run Keyword If ${group_exist}
731 ... Should Be True ${matched} No match for ${deviceId} and ${onu_port} found in ONOS groups
732 ... ELSE
733 ... Should Be True '${matched}'=='False' Match for ${deviceId} and ${onu_port} found in ONOS groups
734
Matteo Scandolo142e6272020-04-29 17:36:59 -0700735Assert Number of AAA-Users
TorstenThieme731a7592021-07-01 14:26:54 +0000736 [Arguments] ${ip} ${port} ${expected_onus} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700737 [Documentation] Matches for number of aaa-users authorized based on number of onus
TorstenThieme731a7592021-07-01 14:26:54 +0000738 ${aaa_users}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800739 ... aaa-users | grep ${deviceId} | grep AUTHORIZED | wc -l
740 Log Found ${aaa_users} of ${expected_onus} expected authenticated users on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700741 Should Be Equal As Integers ${aaa_users} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700742
743Validate DHCP Allocations
TorstenThieme731a7592021-07-01 14:26:54 +0000744 [Arguments] ${ip} ${port} ${count} ${workflow} ${deviceId}
Kailash6f5acb62019-08-28 14:38:45 -0700745 [Documentation] Matches for number of dhcpacks based on number of onus
TorstenThieme731a7592021-07-01 14:26:54 +0000746 ${allocations}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800747 ... dhcpl2relay-allocations | grep ${deviceId} | grep DHCPACK | wc -l
Matteo Scandoloda854b02020-09-01 16:20:51 -0700748 # if the workflow is TT we'll have 2 allocations for each ONU
749 ${ttAllocations}= Evaluate (${count} * 2)
750 ${count}= Set Variable If $workflow=='tt' ${ttAllocations} ${count}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800751 Log Found ${allocations} of ${count} expected DHCPACK on device ${deviceId}
Matteo Scandoloda854b02020-09-01 16:20:51 -0700752 Should Be Equal As Integers ${allocations} ${count}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700753
754Validate Subscriber DHCP Allocation
Suchitra Vemuri42819412020-10-01 17:45:43 -0700755 [Arguments] ${ip} ${port} ${onu_port} ${vlan}=''
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700756 [Documentation] Verifies that the specified subscriber is found in DHCP allocations
757 ##TODO: Enhance the keyword to include DHCP allocated address is not 0.0.0.0
TorstenThieme4e2168e2021-06-22 14:01:47 +0000758 ${allocations}= Execute ONOS CLI Command use single connection ${ip} ${port}
Suchitra Vemuri42819412020-10-01 17:45:43 -0700759 ... dhcpl2relay-allocations | grep DHCPACK | grep ${onu_port} | grep ${vlan}
Gilles Depatie675a2062019-10-22 12:44:42 -0400760 Should Not Be Empty ${allocations} ONU port ${onu_port} not found in dhcpl2relay-allocations
David Bainbridgef81cd642019-11-20 00:14:47 +0000761
762Device Is Available In ONOS
Matteo Scandolo3218d5b2021-05-26 11:50:10 -0700763 [Arguments] ${url} ${dpid} ${available}=true
764 [Documentation] Validates the device exists and it has the expected availability in ONOS
David Bainbridgef81cd642019-11-20 00:14:47 +0000765 ${rc} ${json} Run And Return Rc And Output curl --fail -sSL ${url}/onos/v1/devices/${dpid}
766 Should Be Equal As Integers 0 ${rc}
767 ${rc} ${value} Run And Return Rc And Output echo '${json}' | jq -r .available
768 Should Be Equal As Integers 0 ${rc}
Matteo Scandolo3218d5b2021-05-26 11:50:10 -0700769 Should Be Equal ${available} ${value}
David Bainbridgef81cd642019-11-20 00:14:47 +0000770
771Remove All Devices From ONOS
772 [Arguments] ${url}
773 [Documentation] Executes the device-remove command on each device in ONOS
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000774 ${rc} ${output} Run And Return Rc And Output
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700775 ... curl --fail -sSL ${url}/onos/v1/devices | jq -r '.devices[].id'
David Bainbridgef81cd642019-11-20 00:14:47 +0000776 Should Be Equal As Integers ${rc} 0
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000777 @{dpids} Split String ${output}
David Bainbridgef81cd642019-11-20 00:14:47 +0000778 ${count}= Get length ${dpids}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700779 FOR ${dpid} IN @{dpids}
780 ${rc}= Run Keyword If '${dpid}' != ''
781 ... Run And Return Rc curl -XDELETE --fail -sSL ${url}/onos/v1/devices/${dpid}
782 Run Keyword If '${dpid}' != ''
783 ... Should Be Equal As Integers ${rc} 0
784 END
Matteo Scandolo142e6272020-04-29 17:36:59 -0700785
TorstenThieme440b7c02020-12-18 15:42:57 +0000786Assert ONU Port Is Disabled
TorstenThieme731a7592021-07-01 14:26:54 +0000787 [Arguments] ${ip} ${port} ${deviceId} ${onu_port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000788 [Documentation] Verifies if the ONU port is disabled in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000789 ${onu_port_disabled}= Execute ONOS CLI Command use single connection ${ip} ${port}
TorstenThieme440b7c02020-12-18 15:42:57 +0000790 ... ports -d ${deviceId} | grep port=${onu_port}
791 Log ${onu_port_disabled}
792 Should Not Be Empty ${onu_port_disabled}
793
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700794Assert Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000795 [Arguments] ${ip} ${port} ${count}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700796 [Documentation] DEPRECATED use Assert Olt in ONOS
797 ... Check that a certain number of olts are known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000798 ${olts}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700799 ... volt-olts | wc -l
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700800 Log Found ${olts} of ${count} expected Olts
801 Should Be Equal As Integers ${olts} ${count}
802
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700803Assert Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000804 [Arguments] ${ip} ${port} ${deviceId}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700805 [Documentation] Check that a particular olt is known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000806 ${olts}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700807 ... volt-olts | grep ${deviceId} | wc -l
808 Should Be Equal As Integers ${olts} 1 "Device ${deviceId} is not recognized as an OLT"
809
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700810Wait for Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000811 [Arguments] ${ip} ${port} ${count} ${max_wait_time}=10m
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700812 [Documentation] DEPRECATED use Wait for Olt in ONOS
813 ... Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700814 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Olts in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000815 ... ${ip} ${port} ${count}
Matteo Scandolo7d1a80d2021-04-09 14:30:43 -0700816
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700817Wait for Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000818 [Arguments] ${ip} ${port} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700819 [Documentation] Waits until a particular deviceId is recognized by ONOS as an OLT
820 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Olt in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000821 ... ${ip} ${port} ${deviceId}
Matteo Scandolo520f77e2021-06-01 16:14:47 -0700822
Matteo Scandolo142e6272020-04-29 17:36:59 -0700823Assert Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000824 [Arguments] ${ip} ${port} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700825 [Documentation] Check that a certain number of ports are enabled in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000826 ${ports}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800827 ... ports -e ${deviceId} | grep ${filter} | wc -l
828 Log Found ${ports} of ${count} expected ports on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700829 Should Be Equal As Integers ${ports} ${count}
830
831Wait for Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000832 [Arguments] ${ip} ${port} ${count} ${deviceId} ${filter} ${max_wait_time}=10m
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800833 [Documentation] Waits untill a certain number of ports are enabled in ONOS for a particular deviceId
TorstenThiemed4f48962020-12-08 12:17:19 +0000834 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Ports in ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000835 ... ${ip} ${port} ${count} ${deviceId} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700836
837Wait for AAA Authentication
TorstenThieme731a7592021-07-01 14:26:54 +0000838 [Arguments] ${ip} ${port} ${count} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700839 [Documentation] Waits untill a certain number of subscribers are authenticated in ONOS
TorstenThiemed4f48962020-12-08 12:17:19 +0000840 Wait Until Keyword Succeeds ${max_wait_time} 5s Assert Number of AAA-Users
TorstenThieme731a7592021-07-01 14:26:54 +0000841 ... ${ip} ${port} ${count} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700842
843Wait for DHCP Ack
TorstenThieme731a7592021-07-01 14:26:54 +0000844 [Arguments] ${ip} ${port} ${count} ${workflow} ${deviceId} ${max_wait_time}=10m
Matteo Scandolo142e6272020-04-29 17:36:59 -0700845 [Documentation] Waits untill a certain number of subscribers have received a DHCP_ACK
TorstenThiemed4f48962020-12-08 12:17:19 +0000846 Wait Until Keyword Succeeds ${max_wait_time} 5s Validate DHCP Allocations
TorstenThieme731a7592021-07-01 14:26:54 +0000847 ... ${ip} ${port} ${count} ${workflow} ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700848
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700849Provision subscriber REST
850 [Documentation] Uses the rest APIs to provision a subscriber
TorstenThieme731a7592021-07-01 14:26:54 +0000851 [Arguments] ${of_id} ${onu_port}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700852 ${resp}= Post Request ONOS
853 ... /onos/olt/oltapp/${of_id}/${onu_port}
854 Should Be Equal As Strings ${resp.status_code} 200
855
Hardik Windlassea4caf72021-07-30 07:22:12 +0000856Count Enabled UNI Ports
857 [Documentation] Count all the UNI Ports on a Device
858 [Arguments] ${ip} ${port} ${of_id}
859 ${count}= Execute ONOS CLI Command use single connection ${ip} ${port}
860 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni | wc -l
861 Log ${count}
862 [Return] ${count}
863
Matteo Scandolo142e6272020-04-29 17:36:59 -0700864List Enabled UNI Ports
865 [Documentation] List all the UNI Ports, the only way we have is to filter out the one called NNI
866 ... Creates a list of dictionaries
TorstenThieme731a7592021-07-01 14:26:54 +0000867 [Arguments] ${ip} ${port} ${of_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700868 [Return] [{'port': '16', 'of_id': 'of:00000a0a0a0a0a00'}, {'port': '32', 'of_id': 'of:00000a0a0a0a0a00'}]
869 ${result}= Create List
TorstenThieme731a7592021-07-01 14:26:54 +0000870 ${out}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700871 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000872 @{unis}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700873 FOR ${uni} IN @{unis}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000874 ${matches} = Get Regexp Matches ${uni} .*port=([0-9]+),.* 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700875 &{portDict} Create Dictionary of_id=${of_id} port=${matches[0]}
876 Append To List ${result} ${portDict}
877 END
878 Log ${result}
879 Return From Keyword ${result}
880
881Provision all subscribers on device
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700882 [Documentation] Provisions a subscriber in ONOS for all the enabled UNI ports on a particular device
TorstenThieme731a7592021-07-01 14:26:54 +0000883 [Arguments] ${ip} ${port} ${onos_ip} ${onos_rest_port} ${of_id}
884 ${unis}= List Enabled UNI Ports ${ip} ${port} ${of_id}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700885 ${onos_auth}= Create List karaf karaf
886 Create Session ONOS http://${onos_ip}:${onos_rest_port} auth=${onos_auth}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700887 FOR ${uni} IN @{unis}
TorstenThieme731a7592021-07-01 14:26:54 +0000888 Provision Subscriber REST ${uni['of_id']} ${uni['port']}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700889 END
890
891List OLTs
Matteo Scandolo50be75c2020-11-12 11:14:12 -0800892 # NOTE this method is not currently used but it can come useful in the future
893 [Documentation] Returns a list of all OLTs known to ONOS
TorstenThieme731a7592021-07-01 14:26:54 +0000894 [Arguments] ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700895 [Return] ['of:00000a0a0a0a0a00', 'of:00000a0a0a0a0a01']
896 ${result}= Create List
TorstenThieme731a7592021-07-01 14:26:54 +0000897 ${out}= Execute ONOS CLI Command use single connection ${ip} ${port}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700898 ... volt-olts
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000899 @{olts}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700900 FOR ${olt} IN @{olts}
901 Log ${olt}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000902 ${matches} = Get Regexp Matches ${olt} ^OLT (.+)$ 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700903 # there may be some logs mixed with the output so only append if we have a match
904 ${matches_length}= Get Length ${matches}
905 Run Keyword If ${matches_length}==1
906 ... Append To List ${result} ${matches[0]}
907 END
908 Return From Keyword ${result}
909
Matteo Scandolo75911092021-11-16 17:05:36 -0800910Count flows
911 [Documentation] Count flows in a particular ${state} in ONOS
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000912 ... Optionally for a certain onu-port.
913 [Arguments] ${ip} ${port} ${deviceId} ${state} ${onu_port}=${EMPTY}
914 ${cmd}= Catenate SEPARATOR= flows -s ${state} ${deviceId} | grep -v deviceId
915 ${cmd}= Run Keyword If "${onu_port}"!="${EMPTY}" Catenate SEPARATOR= ${cmd} | grep ${onu_port}
916 ... ELSE Set Variable ${cmd}
917 ${cmd}= Catenate SEPARATOR= ${cmd} | wc -l
918 ${flows}= Execute ONOS CLI Command use single connection ${ip} ${port} ${cmd}
919 [return] ${flows}
920
921Validate number of flows
922 [Documentation] Validates number of flows in a particular ${state} in ONOS
923 ... Optionally for a certain onu-port.
924 [Arguments] ${ip} ${port} ${targetFlows} ${deviceId} ${state} ${onu_port}=${EMPTY}
925 ${flows}= Count flows ${ip} ${port} ${deviceId} ${state} ${onu_port}
Matteo Scandolo75911092021-11-16 17:05:36 -0800926 Log Found ${state} ${flows} of ${targetFlows} expected flows on device ${deviceId}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700927 Should Be Equal As Integers ${targetFlows} ${flows}
928
929Wait for all flows to in ADDED state
930 [Documentation] Waits until the flows have been provisioned
TorstenThieme731a7592021-07-01 14:26:54 +0000931 [Arguments] ${ip} ${port} ${deviceId} ${workflow} ${uni_count} ${olt_count}
TorstenThiemeb198c482020-12-14 19:45:23 +0000932 ... ${provisioned} ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700933 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200934 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000935 Wait Until Keyword Succeeds 10m 5s Validate number of flows
Matteo Scandolo75911092021-11-16 17:05:36 -0800936 ... ${ip} ${port} ${targetFlows} ${deviceId} added
937
938Wait for all flows to be removed
939 [Documentation] Wait for all flows to be removed from a particular device
940 [Arguments] ${ip} ${port} ${deviceId}
TorstenThiemef7cd2be2021-12-06 14:30:11 +0000941 Wait Until Keyword Succeeds 10m 5s Validate number of flows
Matteo Scandolo75911092021-11-16 17:05:36 -0800942 ... ${ip} ${port} 0 ${deviceId} any
943
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000944
Girish Gowdrad769b412021-05-16 11:09:46 -0700945Get Limiting Bandwidth Details
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000946 [Arguments] ${bandwidth_profile_name}
947 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
948 ... returns the limiting bandwidth
Girish Gowdracb8482a2021-05-27 09:06:13 -0700949 ${cir} ${cbs} ${eir} ${ebs} ${air}= Get Bandwidth Profile Details Rest
950 ... ${bandwidth_profile_name}
Girish Gowdrad769b412021-05-16 11:09:46 -0700951 ${limiting_BW}= Evaluate ${eir}+${cir}+${air}
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000952 [Return] ${limiting_BW}
Hardik Windlasse8b99222021-01-25 10:03:14 +0000953
Emrehan UZUNd6f85892021-07-01 13:54:26 +0000954Get Limiting Bandwidth Details for Fixed and Committed
955 [Arguments] ${bandwidth_profile_name}
956 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
957 ... returns the limiting bandwidth for fixed and committed
958 ${cir} ${cbs} ${eir} ${ebs} ${air}= Get Bandwidth Profile Details Rest
959 ... ${bandwidth_profile_name}
960 ${limiting_BW}= Evaluate ${cir}+${air}
961 [Return] ${limiting_BW}
962
Hardik Windlasse8b99222021-01-25 10:03:14 +0000963Validate Deleted Device Cleanup In ONOS
964 [Arguments] ${ip} ${port} ${olt_serial_number}
965 [Documentation] The keyword verifies that ports, flows, meters, subscribers, dhcp are all cleared in ONOS
966 # Fetch OF Id for OLT
967 ${olt_of_id}= Wait Until Keyword Succeeds ${timeout} 5s Validate OLT Device in ONOS ${olt_serial_number}
Hardik Windlasse8b99222021-01-25 10:03:14 +0000968 # Verify Ports are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700969 ${ports}= Execute ONOS CLI Command use single connection ${ip} ${port}
970 ... ports ${olt_of_id} | grep -v ${olt_of_id}
971 ${port_count}= Get Line Count ${ports}
972 Should Be Equal As Integers ${port_count} 0 Ports have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000973 # Verify Subscribers are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700974 ${sub}= Execute ONOS CLI Command use single connection ${ip} ${port}
975 ... volt-programmed-subscribers | grep ${olt_of_id}
976 ${sub_count}= Get Line Count ${sub}
977 Should Be Equal As Integers ${sub_count} 0 Subscribers have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000978 # Verify Flows are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700979 ${flow}= Execute ONOS CLI Command use single connection ${ip} ${port}
980 ... flows -s -f ${olt_of_id} | grep -v deviceId
981 ${flow_count}= Get Line Count ${flow}
982 Should Be Equal As Integers ${flow_count} 0 Flows have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000983 # Verify Meters are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700984 ${meter}= Execute ONOS CLI Command use single connection ${ip} ${port}
985 ... meters ${olt_of_id}
986 ${meter_count}= Get Line Count ${meter}
987 Should Be Equal As Integers ${meter_count} 0 Meters have not been removed from ONOS after cleanup
Hardik Windlasse8b99222021-01-25 10:03:14 +0000988 # Verify AAA-Users are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700989 ${aaa}= Execute ONOS CLI Command use single connection ${ip} ${port}
990 ... aaa-users ${olt_of_id}
991 ${aaa_count}= Get Line Count ${aaa}
992 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 +0000993 # Verify Dhcp-Allocations are Removed
Matteo Scandolo45645bd2021-11-02 10:09:07 -0700994 ${dhcp}= Execute ONOS CLI Command use single connection ${ip} ${port}
995 ... dhcpl2relay-allocations ${olt_of_id}
996 ${dhcp_count}= Get Line Count ${dhcp}
997 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 +0000998
999Delete ONOS App
1000 [Arguments] ${url} ${app_name}
1001 [Documentation] This keyword deactivates and uninstalls the given ONOS App
1002 ${rc}= Run And Return Rc curl --fail -sSL -X DELETE ${url}/onos/v1/applications/${app_name}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001003 Should Be Equal As Integers ${rc} 0 Can't delete ${app_name} from ONOS
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001004
1005Verify ONOS App Active
1006 [Arguments] ${url} ${app_name} ${app_version}=${EMPTY}
1007 [Documentation] This keyword verifies that the given ONOS App status is Active
1008 ${rc} ${output} Run And Return Rc And Output
1009 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name} | jq -r .state
1010 Should Be Equal As Integers ${rc} 0
1011 Should Be Equal '${output}' 'ACTIVE'
1012 ${rc1} ${output1} Run And Return Rc And Output
1013 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name} | jq -r .version
1014 Run Keyword If '${app_version}'!='${EMPTY}'
1015 ... Run Keywords
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001016 ... Should Be Equal As Integers ${rc1} 0 Can't read app ${app_name} status from ONOS
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001017 ... AND Should Be Equal '${output1}' '${app_version}'
1018
1019Install And Activate ONOS App
1020 [Arguments] ${url} ${app_oar_file}
1021 [Documentation] This keyword installs and activates the given ONOS App
1022 ${cmd}= Catenate SEPARATOR=
1023 ... curl --fail -sSL -H Content-Type:application/octet-stream -
1024 ... X POST ${url}/onos/v1/applications?activate=true --data-binary \@${app_oar_file}
1025 ${rc} ${output} Run And Return Rc And Output ${cmd}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001026 Should Be Equal As Integers ${rc} 0 Can't load onos app ${app_oar_file} to ONOS"
Hardik Windlassdd1a9a12021-02-23 15:34:50 +00001027 Log ${output}
Hardik Windlassdc2610f2021-03-09 07:33:51 +00001028
1029Get ONOS App Details
1030 [Arguments] ${url} ${app_name}
1031 [Documentation] Retrieves ONOS App Details
1032 ${rc} ${output} Run And Return Rc And Output
1033 ... curl --fail -sSL ${url}/onos/v1/applications/${app_name}
Matteo Scandolo2769d2b2021-04-14 10:29:24 -07001034 Should Be Equal As Integers ${rc} 0 Can't read app ${app_name} details from ONOS
Hardik Windlassdc2610f2021-03-09 07:33:51 +00001035 [Return] ${output}
Hardik Windlass88075f92022-01-25 12:19:45 +00001036
1037Verify UniTag Subscriber
1038 [Documentation] Verifies the unitag subscriber is provisioned/un-provisioned
1039 [Arguments] ${ip} ${port} ${dev_id} ${onu_port} ${stag} ${ctag} ${tpid} ${sub_added}=True
1040 ${cmd}= Catenate SEPARATOR=
1041 ... volt-programmed-subscribers ${dev_id} ${onu_port} | grep "ponCTag=${ctag}, ponSTag=${stag}" | grep technologyProfileId
1042 ... =${tpid} --color=none
1043 ${subscriber}= Execute ONOS CLI Command use single connection ${ip} ${port} ${cmd}
1044 Log ${subscriber}
1045 ${sub_count}= Get Line Count ${subscriber}
1046 Run Keyword If ${sub_added}
1047 ... Should Be Equal As Integers ${sub_count} 1 UniTag Subscriber Not Added
1048 ... ELSE
1049 ... Should Be Equal As Integers ${sub_count} 0 UniTag Subscriber Not Removed