blob: 52773ad3dfb8cc4b0b9b1f45cf0356bf126e48e7 [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
27*** Keywords ***
Matteo Scandolo62e73862020-07-31 11:28:40 -070028
29Open ONOS SSH Connection
30 [Documentation] Establishes an ssh connection to ONOS contoller
31 [Arguments] ${host} ${port} ${user}=karaf ${pass}=karaf
32 ${conn_id}= SSHLibrary.Open Connection ${host} port=${port} timeout=300s alias=ONOS_SSH
33 SSHLibrary.Login ${user} ${pass}
34 [Return] ${conn_id}
35
36Execute ONOS CLI Command on open connection
37 [Documentation] Execute ONOS CLI Command On an Open Connection
38 [Arguments] ${connection_alias} ${cmd}
39 SSHLibrary.Switch Connection ${connection_alias}
40 @{result_values} SSHLibrary.Execute Command ${cmd} return_rc=True
41 ... return_stderr=True return_stdout=True
42 ${output} Set Variable @{result_values}[0]
43 Log ${output}
44 Should Be Empty @{result_values}[1]
45 Should Be Equal As Integers @{result_values}[2] 0
46 [Return] ${output}
47
48Close ONOS SSH Connection
49 [Documentation] Close an SSH Connection
50 [Arguments] ${connection_alias}
51 SSHLibrary.Switch Connection ${connection_alias}
52 SSHLibrary.Close Connection
53
Kailash6f5acb62019-08-28 14:38:45 -070054Validate OLT Device in ONOS
Zack Williamsa8fe75a2020-01-10 14:25:27 -070055 # FIXME use volt-olts to check that the OLT is ONOS
Kailash6f5acb62019-08-28 14:38:45 -070056 [Arguments] ${serial_number}
Zack Williamsec53a1b2019-09-16 15:50:52 -070057 [Documentation] Checks if olt has been connected to ONOS
Kailash6f5acb62019-08-28 14:38:45 -070058 ${resp}= Get Request ONOS onos/v1/devices
59 ${jsondata}= To Json ${resp.content}
60 Should Not Be Empty ${jsondata['devices']}
61 ${length}= Get Length ${jsondata['devices']}
62 @{serial_numbers}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -070063 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -070064 FOR ${INDEX} IN RANGE 0 ${length}
65 ${value}= Get From List ${jsondata['devices']} ${INDEX}
66 ${of_id}= Get From Dictionary ${value} id
67 ${sn}= Get From Dictionary ${value} serial
Andy Bavierb63f6d22020-03-12 15:34:37 -070068 ${matched}= Set Variable If '${sn}' == '${serial_number}' True False
69 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -070070 END
Andy Bavierb63f6d22020-03-12 15:34:37 -070071 Should Be True ${matched} No match for ${serial_number} found
Kailash57210eb2019-08-30 13:27:19 -070072 [Return] ${of_id}
Kailash6f5acb62019-08-28 14:38:45 -070073
Suchitra Vemuri102912a2019-09-24 00:35:42 -070074Get ONU Port in ONOS
Zack Williamsec53a1b2019-09-16 15:50:52 -070075 [Arguments] ${onu_serial_number} ${olt_of_id}
Suchitra Vemuri102912a2019-09-24 00:35:42 -070076 [Documentation] Retrieves ONU port for the ONU in ONOS
Suchitra Vemuria50c1c12019-09-30 19:54:26 -070077 ${onu_serial_number}= Catenate SEPARATOR=- ${onu_serial_number} 1
Suchitra Vemuri102912a2019-09-24 00:35:42 -070078 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
79 ${jsondata}= To Json ${resp.content}
80 Should Not Be Empty ${jsondata['ports']}
81 ${length}= Get Length ${jsondata['ports']}
82 @{ports}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -070083 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -070084 FOR ${INDEX} IN RANGE 0 ${length}
85 ${value}= Get From List ${jsondata['ports']} ${INDEX}
86 ${annotations}= Get From Dictionary ${value} annotations
87 ${onu_port}= Get From Dictionary ${value} port
88 ${portName}= Get From Dictionary ${annotations} portName
Andy Bavierb63f6d22020-03-12 15:34:37 -070089 ${matched}= Set Variable If '${portName}' == '${onu_serial_number}' True False
90 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -070091 END
Andy Bavierb63f6d22020-03-12 15:34:37 -070092 Should Be True ${matched} No match for ${onu_serial_number} found
Suchitra Vemuri102912a2019-09-24 00:35:42 -070093 [Return] ${onu_port}
94
Hardik Windlassfb5eace2020-03-26 14:49:01 +053095Get NNI Port in ONOS
96 [Arguments] ${olt_of_id}
97 [Documentation] Retrieves NNI port for the OLT in ONOS
98 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
99 ${jsondata}= To Json ${resp.content}
100 Should Not Be Empty ${jsondata['ports']}
101 ${length}= Get Length ${jsondata['ports']}
102 @{ports}= Create List
103 ${matched}= Set Variable False
104 FOR ${INDEX} IN RANGE 0 ${length}
105 ${value}= Get From List ${jsondata['ports']} ${INDEX}
106 ${annotations}= Get From Dictionary ${value} annotations
107 ${nni_port}= Get From Dictionary ${value} port
108 ${nniPortName}= Catenate SEPARATOR= nni- ${nni_port}
109 ${portName}= Get From Dictionary ${annotations} portName
110 ${matched}= Set Variable If '${portName}' == '${nniPortName}' True False
111 Exit For Loop If ${matched}
112 END
113 Should Be True ${matched} No match for NNI found for ${olt_of_id}
114 [Return] ${nni_port}
115
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700116Get FabricSwitch in ONOS
117 [Documentation] Returns of_id of the Fabric Switch in ONOS
118 ${resp}= Get Request ONOS onos/v1/devices
119 ${jsondata}= To Json ${resp.content}
120 Should Not Be Empty ${jsondata['devices']}
121 ${length}= Get Length ${jsondata['devices']}
Andy Bavierb63f6d22020-03-12 15:34:37 -0700122 ${matched}= Set Variable False
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700123 FOR ${INDEX} IN RANGE 0 ${length}
124 ${value}= Get From List ${jsondata['devices']} ${INDEX}
125 ${of_id}= Get From Dictionary ${value} id
126 ${type}= Get From Dictionary ${value} type
Andy Bavierb63f6d22020-03-12 15:34:37 -0700127 ${matched}= Set Variable If '${type}' == "SWITCH" True False
128 Exit For Loop If ${matched}
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700129 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700130 Should Be True ${matched} No fabric switch found
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700131 [Return] ${of_id}
132
Hardik Windlass21807632020-04-14 16:24:55 +0530133Verify Subscriber Access Flows Added for ONU
134 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${c_tag} ${s_tag}
135 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
136 # Verify upstream table=0 flow
137 ${upstream_flow_0_cmd}= Catenate SEPARATOR=
138 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:0 |
139 ... grep VLAN_ID:${c_tag} | grep transition=TABLE:1
140 ${upstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
141 ... ${upstream_flow_0_cmd}
142 Should Not Be Empty ${upstream_flow_0_added}
143 # Verify upstream table=1 flow
144 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
145 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
146 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
147 ${upstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
148 ... ${flow_vlan_push_cmd}
149 Should Not Be Empty ${upstream_flow_1_added}
150 # Verify downstream table=0 flow
151 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
152 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
153 ... grep VLAN_POP | grep transition=TABLE:1
154 ${downstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
155 ... ${flow_vlan_pop_cmd}
156 Should Not Be Empty ${downstream_flow_0_added}
157 # Verify downstream table=1 flow
158 ${downstream_flow_1_cmd}= Catenate SEPARATOR=
159 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${c_tag} |
160 ... grep VLAN_ID:0 | grep OUTPUT:${onu_port}
161 ${downstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
162 ... ${downstream_flow_1_cmd}
163 Should Not Be Empty ${downstream_flow_1_added}
164 # Verify ipv4 dhcp upstream flow
165 ${upstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200166 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:ipv4 |
167 ... grep IP_PROTO:17 | grep UDP_SRC:68 | grep UDP_DST:67 | grep VLAN_VID:${c_tag} |
168 ... grep OUTPUT:CONTROLLER
Hardik Windlass21807632020-04-14 16:24:55 +0530169 ${upstream_flow_ipv4_added}= Execute ONOS CLI Command ${ip} ${port}
170 ... ${upstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200171 Should Not Be Empty ${upstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530172 # Verify ipv4 dhcp downstream flow
173 # Note: This flow will be one per nni per olt
174 ${downstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200175 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep ETH_TYPE:ipv4 |
176 ... grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 | grep OUTPUT:CONTROLLER
Hardik Windlass21807632020-04-14 16:24:55 +0530177 ${downstream_flow_ipv4_added}= Execute ONOS CLI Command ${ip} ${port}
178 ... ${downstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200179 Should Not Be Empty ${downstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530180
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530181Verify Subscriber Access Flows Added for ONU DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530182 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530183 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
184 # Verify upstream table=0 flow
185 ${upstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530186 ... 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 +0530187 Should Not Be Empty ${upstream_flow_0_added}
188 # Verify upstream table=1 flow
189 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530190 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:Any |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530191 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
192 ${upstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
193 ... ${flow_vlan_push_cmd}
194 Should Not Be Empty ${upstream_flow_1_added}
195 # Verify downstream table=0 flow
196 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530197 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530198 ... grep VLAN_POP | grep transition=TABLE:1
199 ${downstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
200 ... ${flow_vlan_pop_cmd}
201 Should Not Be Empty ${downstream_flow_0_added}
202 # Verify downstream table=1 flow
203 ${downstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530204 ... 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 +0530205 Should Not Be Empty ${downstream_flow_1_added}
206
207Verify Subscriber Access Flows Added Count DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530208 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530209 [Documentation] Matches for total number of subscriber access flows added for all onus
210 ${access_flows_added}= Execute ONOS CLI Command ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530211 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep -v ETH_TYPE:lldp | wc -l
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530212 Should Be Equal As Integers ${access_flows_added} ${expected_flows}
213
Hardik Windlass480f3e22020-04-02 20:14:14 +0530214Verify Device Flows Removed
215 [Arguments] ${ip} ${port} ${olt_of_id}
216 [Documentation] Verifies all flows are removed from the device
217 ${device_flows}= Execute ONOS CLI Command ${ip} ${port}
218 ... flows -s -f ${olt_of_id} | grep -v deviceId | wc -l
219 Should Be Equal As Integers ${device_flows} 0
220
Kailash6f5acb62019-08-28 14:38:45 -0700221Verify Eapol Flows Added
Andy Bavierb0c06232019-08-29 12:58:53 -0700222 [Arguments] ${ip} ${port} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700223 [Documentation] Matches for number of eapol flows based on number of onus
Gilles Depatie675a2062019-10-22 12:44:42 -0400224 ${eapol_flows_added}= Execute ONOS CLI Command ${ip} ${port}
225 ... flows -s -f ADDED | grep eapol | grep IN_PORT | wc -l
Andy Bavierb0c06232019-08-29 12:58:53 -0700226 Should Contain ${eapol_flows_added} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700227
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800228Verify No Pending Flows For ONU
229 [Arguments] ${ip} ${port} ${onu_port}
230 [Documentation] Verifies that there are no flows "PENDING" state for the ONU in ONOS
231 ${pending_flows}= Execute ONOS CLI Command ${ip} ${port}
232 ... flows -s | grep IN_PORT:${onu_port} | grep PENDING
233 Should Be Empty ${pending_flows}
234
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700235Verify Eapol Flows Added For ONU
236 [Arguments] ${ip} ${port} ${onu_port}
237 [Documentation] Verifies if the Eapol Flows are added in ONOS for the ONU
Gilles Depatie675a2062019-10-22 12:44:42 -0400238 ${eapol_flows_added}= Execute ONOS CLI Command ${ip} ${port}
239 ... flows -s -f ADDED | grep eapol | grep IN_PORT:${onu_port}
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700240 Should Not Be Empty ${eapol_flows_added}
241
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800242Verify ONU Port Is Enabled
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700243 [Arguments] ${ip} ${port} ${onu_name}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800244 [Documentation] Verifies if the ONU port is enabled in ONOS
245 ${onu_port_enabled}= Execute ONOS CLI Command ${ip} ${port}
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700246 ... ports -e | grep portName=${onu_name}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800247 Log ${onu_port_enabled}
248 Should Not Be Empty ${onu_port_enabled}
249
Hardik Windlass63d5e002020-03-06 21:07:09 +0530250Verify ONU Port Is Disabled
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700251 [Arguments] ${ip} ${port} ${onu_name}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530252 [Documentation] Verifies if the ONU port is disabled in ONOS
253 ${onu_port_disabled}= Execute ONOS CLI Command ${ip} ${port}
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700254 ... ports -e | grep portName=${onu_name}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530255 Log ${onu_port_disabled}
256 Should Be Empty ${onu_port_disabled}
257
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700258Verify ONU in AAA-Users
259 [Arguments] ${ip} ${port} ${onu_port}
260 [Documentation] Verifies that the specified onu_port exists in aaa-users output
261 ${aaa_users}= Execute ONOS CLI Command ${ip} ${port} aaa-users | grep AUTHORIZED | grep ${onu_port}
262 Should Not Be Empty ${aaa_users} ONU port ${onu_port} not found in aaa-users
263
Matteo Scandolo142e6272020-04-29 17:36:59 -0700264Assert Number of AAA-Users
Matteo Scandolo62e73862020-07-31 11:28:40 -0700265 [Arguments] ${onos_ssh_connection} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700266 [Documentation] Matches for number of aaa-users authorized based on number of onus
Matteo Scandolo62e73862020-07-31 11:28:40 -0700267 ${aaa_users}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
268 ... aaa-users | grep AUTHORIZED | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700269 Should Be Equal As Integers ${aaa_users} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700270
271Validate DHCP Allocations
Matteo Scandolo62e73862020-07-31 11:28:40 -0700272 [Arguments] ${onos_ssh_connection} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700273 [Documentation] Matches for number of dhcpacks based on number of onus
Matteo Scandolo62e73862020-07-31 11:28:40 -0700274 ${allocations}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
275 ... dhcpl2relay-allocations | grep DHCPACK | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700276 Should Be Equal As Integers ${allocations} ${expected_onus}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700277
278Validate Subscriber DHCP Allocation
279 [Arguments] ${ip} ${port} ${onu_port}
280 [Documentation] Verifies that the specified subscriber is found in DHCP allocations
281 ##TODO: Enhance the keyword to include DHCP allocated address is not 0.0.0.0
Gilles Depatie675a2062019-10-22 12:44:42 -0400282 ${allocations}= Execute ONOS CLI Command ${ip} ${port}
283 ... dhcpl2relay-allocations | grep DHCPACK | grep ${onu_port}
284 Should Not Be Empty ${allocations} ONU port ${onu_port} not found in dhcpl2relay-allocations
David Bainbridgef81cd642019-11-20 00:14:47 +0000285
286Device Is Available In ONOS
287 [Arguments] ${url} ${dpid}
288 [Documentation] Validates the device exists and it available in ONOS
289 ${rc} ${json} Run And Return Rc And Output curl --fail -sSL ${url}/onos/v1/devices/${dpid}
290 Should Be Equal As Integers 0 ${rc}
291 ${rc} ${value} Run And Return Rc And Output echo '${json}' | jq -r .available
292 Should Be Equal As Integers 0 ${rc}
293 Should Be Equal 'true' '${value}'
294
295Remove All Devices From ONOS
296 [Arguments] ${url}
297 [Documentation] Executes the device-remove command on each device in ONOS
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000298 ${rc} ${output} Run And Return Rc And Output
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700299 ... curl --fail -sSL ${url}/onos/v1/devices | jq -r '.devices[].id'
David Bainbridgef81cd642019-11-20 00:14:47 +0000300 Should Be Equal As Integers ${rc} 0
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000301 @{dpids} Split String ${output}
David Bainbridgef81cd642019-11-20 00:14:47 +0000302 ${count}= Get length ${dpids}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700303 FOR ${dpid} IN @{dpids}
304 ${rc}= Run Keyword If '${dpid}' != ''
305 ... Run And Return Rc curl -XDELETE --fail -sSL ${url}/onos/v1/devices/${dpid}
306 Run Keyword If '${dpid}' != ''
307 ... Should Be Equal As Integers ${rc} 0
308 END
Matteo Scandolo142e6272020-04-29 17:36:59 -0700309
310Assert Ports in ONOS
Matteo Scandolo62e73862020-07-31 11:28:40 -0700311 [Arguments] ${onos_ssh_connection} ${count} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700312 [Documentation] Check that a certain number of ports are enabled in ONOS
Matteo Scandolo62e73862020-07-31 11:28:40 -0700313 ${ports}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700314 ... ports -e | grep ${filter} | wc -l
315 Should Be Equal As Integers ${ports} ${count}
316
317Wait for Ports in ONOS
Matteo Scandolo62e73862020-07-31 11:28:40 -0700318 [Arguments] ${onos_ssh_connection} ${count} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700319 [Documentation] Waits untill a certain number of ports are enabled in ONOS
Matteo Scandolo62e73862020-07-31 11:28:40 -0700320 Wait Until Keyword Succeeds 10m 5s Assert Ports in ONOS
321 ... ${onos_ssh_connection} ${count} ${filter}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700322
323Wait for AAA Authentication
Matteo Scandolo62e73862020-07-31 11:28:40 -0700324 [Arguments] ${onos_ssh_connection} ${count}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700325 [Documentation] Waits untill a certain number of subscribers are authenticated in ONOS
Matteo Scandolo62e73862020-07-31 11:28:40 -0700326 Wait Until Keyword Succeeds 10m 5s Assert Number of AAA-Users ${onos_ssh_connection} ${count}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700327
328Wait for DHCP Ack
Matteo Scandolo62e73862020-07-31 11:28:40 -0700329 [Arguments] ${onos_ssh_connection} ${count}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700330 [Documentation] Waits untill a certain number of subscribers have received a DHCP_ACK
Matteo Scandolo62e73862020-07-31 11:28:40 -0700331 Wait Until Keyword Succeeds 10m 5s Validate DHCP Allocations ${onos_ssh_connection} ${count}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700332
333Provision subscriber
334 [Documentation] Calls volt-add-subscriber-access in ONOS
335 [Arguments] ${onos_ip} ${onos_port} ${of_id} ${onu_port}
336 Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
337 ... volt-add-subscriber-access ${of_id} ${onu_port}
338
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700339Provision subscriber REST
340 [Documentation] Uses the rest APIs to provision a subscriber
341 [Arguments] ${onos_ip} ${onos_port} ${of_id} ${onu_port}
342 ${resp}= Post Request ONOS
343 ... /onos/olt/oltapp/${of_id}/${onu_port}
344 Should Be Equal As Strings ${resp.status_code} 200
345
346
Matteo Scandolo142e6272020-04-29 17:36:59 -0700347List Enabled UNI Ports
348 [Documentation] List all the UNI Ports, the only way we have is to filter out the one called NNI
349 ... Creates a list of dictionaries
Matteo Scandolo62e73862020-07-31 11:28:40 -0700350 [Arguments] ${onos_ssh_connection} ${of_id}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700351 [Return] [{'port': '16', 'of_id': 'of:00000a0a0a0a0a00'}, {'port': '32', 'of_id': 'of:00000a0a0a0a0a00'}]
352 ${result}= Create List
Matteo Scandolo62e73862020-07-31 11:28:40 -0700353 ${out}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700354 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000355 @{unis}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700356 FOR ${uni} IN @{unis}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000357 ${matches} = Get Regexp Matches ${uni} .*port=([0-9]+),.* 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700358 &{portDict} Create Dictionary of_id=${of_id} port=${matches[0]}
359 Append To List ${result} ${portDict}
360 END
361 Log ${result}
362 Return From Keyword ${result}
363
364Provision all subscribers on device
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700365 [Documentation] Provisions a subscriber in ONOS for all the enabled UNI ports on a particular device
Matteo Scandolo62e73862020-07-31 11:28:40 -0700366 [Arguments] ${onos_ssh_connection} ${onos_ip} ${onos_rest_port} ${of_id}
367 ${unis}= List Enabled UNI Ports ${onos_ssh_connection} ${of_id}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700368 ${onos_auth}= Create List karaf karaf
369 Create Session ONOS http://${onos_ip}:${onos_rest_port} auth=${onos_auth}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700370 FOR ${uni} IN @{unis}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700371 Provision Subscriber REST ${onos_ip} ${onos_rest_port} ${uni['of_id']} ${uni['port']}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700372 END
373
374List OLTs
375 [Documentation] Returns a list of OLTs known to ONOS
Matteo Scandolo62e73862020-07-31 11:28:40 -0700376 [Arguments] ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700377 [Return] ['of:00000a0a0a0a0a00', 'of:00000a0a0a0a0a01']
378 ${result}= Create List
Matteo Scandolo62e73862020-07-31 11:28:40 -0700379 ${out}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700380 ... volt-olts
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000381 @{olts}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700382 FOR ${olt} IN @{olts}
383 Log ${olt}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000384 ${matches} = Get Regexp Matches ${olt} ^OLT (.+)$ 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700385 # there may be some logs mixed with the output so only append if we have a match
386 ${matches_length}= Get Length ${matches}
387 Run Keyword If ${matches_length}==1
388 ... Append To List ${result} ${matches[0]}
389 END
390 Return From Keyword ${result}
391
392Count ADDED flows
393 [Documentation] Count the flows in ADDED state in ONOS
Matteo Scandolo62e73862020-07-31 11:28:40 -0700394 [Arguments] ${onos_ssh_connection} ${targetFlows}
395 ${flows}= Execute ONOS CLI Command on open connection ${onos_ssh_connection}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700396 ... flows -s | grep ADDED | wc -l
397 Should Be Equal As Integers ${targetFlows} ${flows}
398
399Wait for all flows to in ADDED state
400 [Documentation] Waits until the flows have been provisioned
Matteo Scandolo62e73862020-07-31 11:28:40 -0700401 [Arguments] ${onos_ssh_connection} ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200402 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700403 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200404 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700405 Wait Until Keyword Succeeds 10m 5s Count ADDED flows
Matteo Scandolo62e73862020-07-31 11:28:40 -0700406 ... ${onos_ssh_connection} ${targetFlows}
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000407
408Get Bandwidth Details
409 [Arguments] ${bandwidth_profile_name}
410 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
411 ... returns the limiting bandwidth
412 ${bandwidth_profile_values}= Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
413 ... bandwidthprofile ${bandwidth_profile_name}
414 @{bandwidth_profile_array}= Split String ${bandwidth_profile_values} ,
415 @{parameter_value_pair}= Split String ${bandwidth_profile_array[1]} =
416 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
417 ${value}= Set Variable ${parameter_value_pair[1]}
418 ${cir_value} Run Keyword If '${bandwidthparameter}' == ' committedInformationRate'
419 ... Set Variable ${value}
420 @{parameter_value_pair}= Split String ${bandwidth_profile_array[2]} =
421 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
422 ${value}= Set Variable ${parameter_value_pair[1]}
423 ${cbs_value} Run Keyword If '${bandwidthparameter}' == ' committedBurstSize' Set Variable ${value}
424 @{parameter_value_pair}= Split String ${bandwidth_profile_array[3]} =
425 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
426 ${value}= Set Variable ${parameter_value_pair[1]}
427 ${eir_value} Run Keyword If '${bandwidthparameter}' == ' exceededInformationRate' Set Variable ${value}
428 @{parameter_value_pair}= Split String ${bandwidth_profile_array[4]} =
429 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
430 ${value}= Set Variable ${parameter_value_pair[1]}
431 ${ebs_value} Run Keyword If '${bandwidthparameter}' == ' exceededBurstSize' Set Variable ${value}
432 ${limiting_BW}= Evaluate ${cir_value}+${eir_value}
433 [Return] ${limiting_BW}