blob: 9ba04c43d35304d883052ca6b402c0897b458a7e [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 ***
Kailash6f5acb62019-08-28 14:38:45 -070028Validate OLT Device in ONOS
Zack Williamsa8fe75a2020-01-10 14:25:27 -070029 # FIXME use volt-olts to check that the OLT is ONOS
Kailash6f5acb62019-08-28 14:38:45 -070030 [Arguments] ${serial_number}
Zack Williamsec53a1b2019-09-16 15:50:52 -070031 [Documentation] Checks if olt has been connected to ONOS
Kailash6f5acb62019-08-28 14:38:45 -070032 ${resp}= Get Request ONOS onos/v1/devices
33 ${jsondata}= To Json ${resp.content}
34 Should Not Be Empty ${jsondata['devices']}
35 ${length}= Get Length ${jsondata['devices']}
36 @{serial_numbers}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -070037 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -070038 FOR ${INDEX} IN RANGE 0 ${length}
39 ${value}= Get From List ${jsondata['devices']} ${INDEX}
40 ${of_id}= Get From Dictionary ${value} id
41 ${sn}= Get From Dictionary ${value} serial
Andy Bavierb63f6d22020-03-12 15:34:37 -070042 ${matched}= Set Variable If '${sn}' == '${serial_number}' True False
43 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -070044 END
Andy Bavierb63f6d22020-03-12 15:34:37 -070045 Should Be True ${matched} No match for ${serial_number} found
Kailash57210eb2019-08-30 13:27:19 -070046 [Return] ${of_id}
Kailash6f5acb62019-08-28 14:38:45 -070047
Suchitra Vemuri102912a2019-09-24 00:35:42 -070048Get ONU Port in ONOS
Zack Williamsec53a1b2019-09-16 15:50:52 -070049 [Arguments] ${onu_serial_number} ${olt_of_id}
Suchitra Vemuri102912a2019-09-24 00:35:42 -070050 [Documentation] Retrieves ONU port for the ONU in ONOS
Suchitra Vemuria50c1c12019-09-30 19:54:26 -070051 ${onu_serial_number}= Catenate SEPARATOR=- ${onu_serial_number} 1
Suchitra Vemuri102912a2019-09-24 00:35:42 -070052 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
53 ${jsondata}= To Json ${resp.content}
54 Should Not Be Empty ${jsondata['ports']}
55 ${length}= Get Length ${jsondata['ports']}
56 @{ports}= Create List
Andy Bavierb63f6d22020-03-12 15:34:37 -070057 ${matched}= Set Variable False
Zack Williamsec53a1b2019-09-16 15:50:52 -070058 FOR ${INDEX} IN RANGE 0 ${length}
59 ${value}= Get From List ${jsondata['ports']} ${INDEX}
60 ${annotations}= Get From Dictionary ${value} annotations
61 ${onu_port}= Get From Dictionary ${value} port
62 ${portName}= Get From Dictionary ${annotations} portName
Andy Bavierb63f6d22020-03-12 15:34:37 -070063 ${matched}= Set Variable If '${portName}' == '${onu_serial_number}' True False
64 Exit For Loop If ${matched}
Zack Williamsec53a1b2019-09-16 15:50:52 -070065 END
Andy Bavierb63f6d22020-03-12 15:34:37 -070066 Should Be True ${matched} No match for ${onu_serial_number} found
Suchitra Vemuri102912a2019-09-24 00:35:42 -070067 [Return] ${onu_port}
68
Hardik Windlassfb5eace2020-03-26 14:49:01 +053069Get NNI Port in ONOS
70 [Arguments] ${olt_of_id}
71 [Documentation] Retrieves NNI port for the OLT in ONOS
72 ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports
73 ${jsondata}= To Json ${resp.content}
74 Should Not Be Empty ${jsondata['ports']}
75 ${length}= Get Length ${jsondata['ports']}
76 @{ports}= Create List
77 ${matched}= Set Variable False
78 FOR ${INDEX} IN RANGE 0 ${length}
79 ${value}= Get From List ${jsondata['ports']} ${INDEX}
80 ${annotations}= Get From Dictionary ${value} annotations
81 ${nni_port}= Get From Dictionary ${value} port
82 ${nniPortName}= Catenate SEPARATOR= nni- ${nni_port}
83 ${portName}= Get From Dictionary ${annotations} portName
84 ${matched}= Set Variable If '${portName}' == '${nniPortName}' True False
85 Exit For Loop If ${matched}
86 END
87 Should Be True ${matched} No match for NNI found for ${olt_of_id}
88 [Return] ${nni_port}
89
Suchitra Vemuri532f67a2019-09-25 11:50:42 -070090Get FabricSwitch in ONOS
91 [Documentation] Returns of_id of the Fabric Switch in ONOS
92 ${resp}= Get Request ONOS onos/v1/devices
93 ${jsondata}= To Json ${resp.content}
94 Should Not Be Empty ${jsondata['devices']}
95 ${length}= Get Length ${jsondata['devices']}
Andy Bavierb63f6d22020-03-12 15:34:37 -070096 ${matched}= Set Variable False
Suchitra Vemuri532f67a2019-09-25 11:50:42 -070097 FOR ${INDEX} IN RANGE 0 ${length}
98 ${value}= Get From List ${jsondata['devices']} ${INDEX}
99 ${of_id}= Get From Dictionary ${value} id
100 ${type}= Get From Dictionary ${value} type
Andy Bavierb63f6d22020-03-12 15:34:37 -0700101 ${matched}= Set Variable If '${type}' == "SWITCH" True False
102 Exit For Loop If ${matched}
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700103 END
Andy Bavierb63f6d22020-03-12 15:34:37 -0700104 Should Be True ${matched} No fabric switch found
Suchitra Vemuri532f67a2019-09-25 11:50:42 -0700105 [Return] ${of_id}
106
Hardik Windlass21807632020-04-14 16:24:55 +0530107Verify Subscriber Access Flows Added for ONU
108 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${c_tag} ${s_tag}
109 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
110 # Verify upstream table=0 flow
111 ${upstream_flow_0_cmd}= Catenate SEPARATOR=
112 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:0 |
113 ... grep VLAN_ID:${c_tag} | grep transition=TABLE:1
114 ${upstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
115 ... ${upstream_flow_0_cmd}
116 Should Not Be Empty ${upstream_flow_0_added}
117 # Verify upstream table=1 flow
118 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
119 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:${c_tag} |
120 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
121 ${upstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
122 ... ${flow_vlan_push_cmd}
123 Should Not Be Empty ${upstream_flow_1_added}
124 # Verify downstream table=0 flow
125 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
126 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
127 ... grep VLAN_POP | grep transition=TABLE:1
128 ${downstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
129 ... ${flow_vlan_pop_cmd}
130 Should Not Be Empty ${downstream_flow_0_added}
131 # Verify downstream table=1 flow
132 ${downstream_flow_1_cmd}= Catenate SEPARATOR=
133 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${c_tag} |
134 ... grep VLAN_ID:0 | grep OUTPUT:${onu_port}
135 ${downstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
136 ... ${downstream_flow_1_cmd}
137 Should Not Be Empty ${downstream_flow_1_added}
138 # Verify ipv4 dhcp upstream flow
139 ${upstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200140 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep ETH_TYPE:ipv4 |
141 ... grep IP_PROTO:17 | grep UDP_SRC:68 | grep UDP_DST:67 | grep VLAN_VID:${c_tag} |
142 ... grep OUTPUT:CONTROLLER
Hardik Windlass21807632020-04-14 16:24:55 +0530143 ${upstream_flow_ipv4_added}= Execute ONOS CLI Command ${ip} ${port}
144 ... ${upstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200145 Should Not Be Empty ${upstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530146 # Verify ipv4 dhcp downstream flow
147 # Note: This flow will be one per nni per olt
148 ${downstream_flow_ipv4_cmd}= Catenate SEPARATOR=
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200149 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep ETH_TYPE:ipv4 |
150 ... grep IP_PROTO:17 | grep UDP_SRC:67 | grep UDP_DST:68 | grep OUTPUT:CONTROLLER
Hardik Windlass21807632020-04-14 16:24:55 +0530151 ${downstream_flow_ipv4_added}= Execute ONOS CLI Command ${ip} ${port}
152 ... ${downstream_flow_ipv4_cmd}
Andrea Campanella5e9051c2020-04-30 14:38:35 +0200153 Should Not Be Empty ${downstream_flow_ipv4_added}
Hardik Windlass21807632020-04-14 16:24:55 +0530154
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530155Verify Subscriber Access Flows Added for ONU DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530156 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530157 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
158 # Verify upstream table=0 flow
159 ${upstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530160 ... 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 +0530161 Should Not Be Empty ${upstream_flow_0_added}
162 # Verify upstream table=1 flow
163 ${flow_vlan_push_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530164 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${onu_port} | grep VLAN_VID:Any |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530165 ... grep VLAN_PUSH | grep VLAN_ID:${s_tag} | grep OUTPUT:${nni_port}
166 ${upstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
167 ... ${flow_vlan_push_cmd}
168 Should Not Be Empty ${upstream_flow_1_added}
169 # Verify downstream table=0 flow
170 ${flow_vlan_pop_cmd}= Catenate SEPARATOR=
Hardik Windlass25e11702020-03-30 20:05:19 +0530171 ... flows -s ADDED ${olt_of_id} | grep IN_PORT:${nni_port} | grep VLAN_VID:${s_tag} |
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530172 ... grep VLAN_POP | grep transition=TABLE:1
173 ${downstream_flow_0_added}= Execute ONOS CLI Command ${ip} ${port}
174 ... ${flow_vlan_pop_cmd}
175 Should Not Be Empty ${downstream_flow_0_added}
176 # Verify downstream table=1 flow
177 ${downstream_flow_1_added}= Execute ONOS CLI Command ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530178 ... 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 +0530179 Should Not Be Empty ${downstream_flow_1_added}
180
181Verify Subscriber Access Flows Added Count DT
Hardik Windlass25e11702020-03-30 20:05:19 +0530182 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530183 [Documentation] Matches for total number of subscriber access flows added for all onus
184 ${access_flows_added}= Execute ONOS CLI Command ${ip} ${port}
Hardik Windlass25e11702020-03-30 20:05:19 +0530185 ... flows -s ADDED ${olt_of_id} | grep -v deviceId | grep -v ETH_TYPE:lldp | wc -l
Hardik Windlassfb5eace2020-03-26 14:49:01 +0530186 Should Be Equal As Integers ${access_flows_added} ${expected_flows}
187
Hardik Windlass480f3e22020-04-02 20:14:14 +0530188Verify Device Flows Removed
189 [Arguments] ${ip} ${port} ${olt_of_id}
190 [Documentation] Verifies all flows are removed from the device
191 ${device_flows}= Execute ONOS CLI Command ${ip} ${port}
192 ... flows -s -f ${olt_of_id} | grep -v deviceId | wc -l
193 Should Be Equal As Integers ${device_flows} 0
194
Kailash6f5acb62019-08-28 14:38:45 -0700195Verify Eapol Flows Added
Andy Bavierb0c06232019-08-29 12:58:53 -0700196 [Arguments] ${ip} ${port} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700197 [Documentation] Matches for number of eapol flows based on number of onus
Gilles Depatie675a2062019-10-22 12:44:42 -0400198 ${eapol_flows_added}= Execute ONOS CLI Command ${ip} ${port}
199 ... flows -s -f ADDED | grep eapol | grep IN_PORT | wc -l
Andy Bavierb0c06232019-08-29 12:58:53 -0700200 Should Contain ${eapol_flows_added} ${expected_flows}
Kailash6f5acb62019-08-28 14:38:45 -0700201
Suchitra Vemuri9da44302020-03-04 14:24:49 -0800202Verify No Pending Flows For ONU
203 [Arguments] ${ip} ${port} ${onu_port}
204 [Documentation] Verifies that there are no flows "PENDING" state for the ONU in ONOS
205 ${pending_flows}= Execute ONOS CLI Command ${ip} ${port}
206 ... flows -s | grep IN_PORT:${onu_port} | grep PENDING
207 Should Be Empty ${pending_flows}
208
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700209Verify Eapol Flows Added For ONU
210 [Arguments] ${ip} ${port} ${onu_port}
211 [Documentation] Verifies if the Eapol Flows are added in ONOS for the ONU
Gilles Depatie675a2062019-10-22 12:44:42 -0400212 ${eapol_flows_added}= Execute ONOS CLI Command ${ip} ${port}
213 ... flows -s -f ADDED | grep eapol | grep IN_PORT:${onu_port}
Suchitra Vemuri3dd2f832019-10-18 13:14:54 -0700214 Should Not Be Empty ${eapol_flows_added}
215
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800216Verify ONU Port Is Enabled
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700217 [Arguments] ${ip} ${port} ${onu_name}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800218 [Documentation] Verifies if the ONU port is enabled in ONOS
219 ${onu_port_enabled}= Execute ONOS CLI Command ${ip} ${port}
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700220 ... ports -e | grep portName=${onu_name}
Suchitra Vemuri8078b972020-02-06 19:07:41 -0800221 Log ${onu_port_enabled}
222 Should Not Be Empty ${onu_port_enabled}
223
Hardik Windlass63d5e002020-03-06 21:07:09 +0530224Verify ONU Port Is Disabled
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700225 [Arguments] ${ip} ${port} ${onu_name}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530226 [Documentation] Verifies if the ONU port is disabled in ONOS
227 ${onu_port_disabled}= Execute ONOS CLI Command ${ip} ${port}
Suchitra Vemuri760bdd32020-06-17 12:34:48 -0700228 ... ports -e | grep portName=${onu_name}
Hardik Windlass63d5e002020-03-06 21:07:09 +0530229 Log ${onu_port_disabled}
230 Should Be Empty ${onu_port_disabled}
231
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700232Verify ONU in AAA-Users
233 [Arguments] ${ip} ${port} ${onu_port}
234 [Documentation] Verifies that the specified onu_port exists in aaa-users output
235 ${aaa_users}= Execute ONOS CLI Command ${ip} ${port} aaa-users | grep AUTHORIZED | grep ${onu_port}
236 Should Not Be Empty ${aaa_users} ONU port ${onu_port} not found in aaa-users
237
Matteo Scandolo142e6272020-04-29 17:36:59 -0700238Assert Number of AAA-Users
Kailash2b963f02019-08-28 22:46:33 -0700239 [Arguments] ${ip} ${port} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700240 [Documentation] Matches for number of aaa-users authorized based on number of onus
Kailash30c418f2019-09-11 13:50:10 -0700241 ${aaa_users}= Execute ONOS CLI Command ${ip} ${port} aaa-users | grep AUTHORIZED | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700242 Should Be Equal As Integers ${aaa_users} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700243
244Validate DHCP Allocations
Kailash2b963f02019-08-28 22:46:33 -0700245 [Arguments] ${ip} ${port} ${expected_onus}
Kailash6f5acb62019-08-28 14:38:45 -0700246 [Documentation] Matches for number of dhcpacks based on number of onus
Kailash30c418f2019-09-11 13:50:10 -0700247 ${allocations}= Execute ONOS CLI Command ${ip} ${port} dhcpl2relay-allocations | grep DHCPACK | wc -l
Matteo Scandolo142e6272020-04-29 17:36:59 -0700248 Should Be Equal As Integers ${allocations} ${expected_onus}
Suchitra Vemuri8a9c3782019-10-23 12:43:01 -0700249
250Validate Subscriber DHCP Allocation
251 [Arguments] ${ip} ${port} ${onu_port}
252 [Documentation] Verifies that the specified subscriber is found in DHCP allocations
253 ##TODO: Enhance the keyword to include DHCP allocated address is not 0.0.0.0
Gilles Depatie675a2062019-10-22 12:44:42 -0400254 ${allocations}= Execute ONOS CLI Command ${ip} ${port}
255 ... dhcpl2relay-allocations | grep DHCPACK | grep ${onu_port}
256 Should Not Be Empty ${allocations} ONU port ${onu_port} not found in dhcpl2relay-allocations
David Bainbridgef81cd642019-11-20 00:14:47 +0000257
258Device Is Available In ONOS
259 [Arguments] ${url} ${dpid}
260 [Documentation] Validates the device exists and it available in ONOS
261 ${rc} ${json} Run And Return Rc And Output curl --fail -sSL ${url}/onos/v1/devices/${dpid}
262 Should Be Equal As Integers 0 ${rc}
263 ${rc} ${value} Run And Return Rc And Output echo '${json}' | jq -r .available
264 Should Be Equal As Integers 0 ${rc}
265 Should Be Equal 'true' '${value}'
266
267Remove All Devices From ONOS
268 [Arguments] ${url}
269 [Documentation] Executes the device-remove command on each device in ONOS
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000270 ${rc} ${output} Run And Return Rc And Output
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700271 ... curl --fail -sSL ${url}/onos/v1/devices | jq -r '.devices[].id'
David Bainbridgef81cd642019-11-20 00:14:47 +0000272 Should Be Equal As Integers ${rc} 0
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000273 @{dpids} Split String ${output}
David Bainbridgef81cd642019-11-20 00:14:47 +0000274 ${count}= Get length ${dpids}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700275 FOR ${dpid} IN @{dpids}
276 ${rc}= Run Keyword If '${dpid}' != ''
277 ... Run And Return Rc curl -XDELETE --fail -sSL ${url}/onos/v1/devices/${dpid}
278 Run Keyword If '${dpid}' != ''
279 ... Should Be Equal As Integers ${rc} 0
280 END
Matteo Scandolo142e6272020-04-29 17:36:59 -0700281
282Assert Ports in ONOS
283 [Arguments] ${ip} ${port} ${count} ${filter}
284 [Documentation] Check that a certain number of ports are enabled in ONOS
285 ${ports}= Execute ONOS CLI Command ${ip} ${port}
286 ... ports -e | grep ${filter} | wc -l
287 Should Be Equal As Integers ${ports} ${count}
288
289Wait for Ports in ONOS
290 [Arguments] ${ip} ${port} ${count} ${filter}
291 [Documentation] Waits untill a certain number of ports are enabled in ONOS
292 Wait Until Keyword Succeeds 10m 5s Assert Ports in ONOS ${ip} ${port} ${count} ${filter}
293
294Wait for AAA Authentication
295 [Arguments] ${ip} ${port} ${count}
296 [Documentation] Waits untill a certain number of subscribers are authenticated in ONOS
297 Wait Until Keyword Succeeds 10m 5s Assert Number of AAA-Users ${ip} ${port} ${count}
298
299Wait for DHCP Ack
300 [Arguments] ${ip} ${port} ${count}
301 [Documentation] Waits untill a certain number of subscribers have received a DHCP_ACK
302 Wait Until Keyword Succeeds 10m 5s Validate DHCP Allocations ${ip} ${port} ${count}
303
304Provision subscriber
305 [Documentation] Calls volt-add-subscriber-access in ONOS
306 [Arguments] ${onos_ip} ${onos_port} ${of_id} ${onu_port}
307 Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
308 ... volt-add-subscriber-access ${of_id} ${onu_port}
309
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700310Provision subscriber REST
311 [Documentation] Uses the rest APIs to provision a subscriber
312 [Arguments] ${onos_ip} ${onos_port} ${of_id} ${onu_port}
313 ${resp}= Post Request ONOS
314 ... /onos/olt/oltapp/${of_id}/${onu_port}
315 Should Be Equal As Strings ${resp.status_code} 200
316
317
Matteo Scandolo142e6272020-04-29 17:36:59 -0700318List Enabled UNI Ports
319 [Documentation] List all the UNI Ports, the only way we have is to filter out the one called NNI
320 ... Creates a list of dictionaries
321 [Arguments] ${onos_ip} ${onos_port} ${of_id}
322 [Return] [{'port': '16', 'of_id': 'of:00000a0a0a0a0a00'}, {'port': '32', 'of_id': 'of:00000a0a0a0a0a00'}]
323 ${result}= Create List
324 ${out}= Execute ONOS CLI Command ${onos_ip} ${onos_port}
325 ... ports -e ${of_id} | grep -v SWITCH | grep -v nni
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000326 @{unis}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700327 FOR ${uni} IN @{unis}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000328 ${matches} = Get Regexp Matches ${uni} .*port=([0-9]+),.* 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700329 &{portDict} Create Dictionary of_id=${of_id} port=${matches[0]}
330 Append To List ${result} ${portDict}
331 END
332 Log ${result}
333 Return From Keyword ${result}
334
335Provision all subscribers on device
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700336 [Documentation] Provisions a subscriber in ONOS for all the enabled UNI ports on a particular device
337 [Arguments] ${onos_ip} ${onos_ssh_port} ${onos_rest_port} ${of_id}
338 ${unis}= List Enabled UNI Ports ${onos_ip} ${onos_ssh_port} ${of_id}
339 ${onos_auth}= Create List karaf karaf
340 Create Session ONOS http://${onos_ip}:${onos_rest_port} auth=${onos_auth}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700341 FOR ${uni} IN @{unis}
Matteo Scandolo96dbe432020-05-28 10:51:57 -0700342 Provision Subscriber REST ${onos_ip} ${onos_rest_port} ${uni['of_id']} ${uni['port']}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700343 END
344
345List OLTs
346 [Documentation] Returns a list of OLTs known to ONOS
347 [Arguments] ${onos_ip} ${onos_port}
348 [Return] ['of:00000a0a0a0a0a00', 'of:00000a0a0a0a0a01']
349 ${result}= Create List
350 ${out}= Execute ONOS CLI Command ${onos_ip} ${onos_port}
351 ... volt-olts
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000352 @{olts}= Split To Lines ${out}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700353 FOR ${olt} IN @{olts}
354 Log ${olt}
TorstenThiemebccd3ae2020-02-20 12:56:44 +0000355 ${matches} = Get Regexp Matches ${olt} ^OLT (.+)$ 1
Matteo Scandolo142e6272020-04-29 17:36:59 -0700356 # there may be some logs mixed with the output so only append if we have a match
357 ${matches_length}= Get Length ${matches}
358 Run Keyword If ${matches_length}==1
359 ... Append To List ${result} ${matches[0]}
360 END
361 Return From Keyword ${result}
362
363Count ADDED flows
364 [Documentation] Count the flows in ADDED state in ONOS
365 [Arguments] ${onos_ip} ${onos_port} ${targetFlows}
366 ${flows}= Execute ONOS CLI Command ${onos_ip} ${onos_port}
367 ... flows -s | grep ADDED | wc -l
368 Should Be Equal As Integers ${targetFlows} ${flows}
369
370Wait for all flows to in ADDED state
371 [Documentation] Waits until the flows have been provisioned
372 [Arguments] ${onos_ip} ${onos_port} ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200373 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700374 ${targetFlows}= Calculate flows by workflow ${workflow} ${uni_count} ${olt_count} ${provisioned}
Andrea Campanella70cf0a72020-05-27 10:55:15 +0200375 ... ${withEapol} ${withDhcp} ${withIgmp} ${withLldp}
Matteo Scandolo142e6272020-04-29 17:36:59 -0700376 Wait Until Keyword Succeeds 10m 5s Count ADDED flows
377 ... ${onos_ip} ${onos_port} ${targetFlows}
Gayathri.Selvan92d16862020-03-19 14:47:58 +0000378
379Get Bandwidth Details
380 [Arguments] ${bandwidth_profile_name}
381 [Documentation] Collects the bandwidth profile details for the given bandwidth profile and
382 ... returns the limiting bandwidth
383 ${bandwidth_profile_values}= Execute ONOS CLI Command ${ONOS_SSH_IP} ${ONOS_SSH_PORT}
384 ... bandwidthprofile ${bandwidth_profile_name}
385 @{bandwidth_profile_array}= Split String ${bandwidth_profile_values} ,
386 @{parameter_value_pair}= Split String ${bandwidth_profile_array[1]} =
387 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
388 ${value}= Set Variable ${parameter_value_pair[1]}
389 ${cir_value} Run Keyword If '${bandwidthparameter}' == ' committedInformationRate'
390 ... Set Variable ${value}
391 @{parameter_value_pair}= Split String ${bandwidth_profile_array[2]} =
392 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
393 ${value}= Set Variable ${parameter_value_pair[1]}
394 ${cbs_value} Run Keyword If '${bandwidthparameter}' == ' committedBurstSize' Set Variable ${value}
395 @{parameter_value_pair}= Split String ${bandwidth_profile_array[3]} =
396 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
397 ${value}= Set Variable ${parameter_value_pair[1]}
398 ${eir_value} Run Keyword If '${bandwidthparameter}' == ' exceededInformationRate' Set Variable ${value}
399 @{parameter_value_pair}= Split String ${bandwidth_profile_array[4]} =
400 ${bandwidthparameter}= Set Variable ${parameter_value_pair[0]}
401 ${value}= Set Variable ${parameter_value_pair[1]}
402 ${ebs_value} Run Keyword If '${bandwidthparameter}' == ' exceededBurstSize' Set Variable ${value}
403 ${limiting_BW}= Evaluate ${cir_value}+${eir_value}
404 [Return] ${limiting_BW}