blob: 74c9d312d51aba4441d5f73038a5762da318706f [file] [log] [blame]
Joey Armstrong9fadcbe2024-01-17 19:00:37 -05001# Copyright 2017-2024 Open Networking Foundation (ONF) and the ONF Contributors
bharat raj58488b32023-05-11 22:46:18 +05302#
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.
14# vgc common functions
15
16*** Settings ***
17Documentation Library for various utilities
18Library SSHLibrary
19Library String
20Library DateTime
21Library Process
22Library Collections
23Library RequestsLibrary
24Library OperatingSystem
25
26*** Variables ***
27@{connection_list}
28${alias} VGC_SSH
29${ssh_read_timeout} 60s
30${ssh_prompt} karaf@root >
31${ssh_regexp_prompt} REGEXP:k.*a.*r.*a.*f.*@.*r.*o.*o.*t.* .*>.*
32${regexp_prompt} (?ms)(.*)k(.*)a(.*)r(.*)a(.*)f(.*)@(.*)r(.*)o(.*)o(.*)t(.*) (.*)>(.*)
33${ssh_width} 400
34${disable_highlighter} setopt disable-highlighter
35# ${keep_alive_interval} is set to 0s means sending the keepalive packet is disabled!
36${keep_alive_interval} 0s
37${INFRA_DT_NAMESPACE} infra
38
39
40*** Keywords ***
41Create VGC Session
42 [Documentation] Creates a VGC session
43 Create Session VGC http://${VGC_REST_IP}:${VGC_REST_PORT}/vgc/v1
44
45Validate OLT Device in VGC
46 # FIXME use volt-olts to check that the OLT is VGC
47 [Arguments] ${serial_number}
48 [Documentation] Checks if olt has been connected to VGC
49 Create VGC Session
50 ${resp}= Get Request VGC devices
51 Log ${resp}
52 ${jsondata}= To Json ${resp.content}
Cristina de Franciscoc4cfd7e2023-10-09 10:55:08 +020053 Should Not Be Empty ${jsondata['devices']} No devices data found in VGC
bharat raj58488b32023-05-11 22:46:18 +053054 ${length}= Get Length ${jsondata['devices']}
55 @{serial_numbers}= Create List
56 ${matched}= Set Variable False
57 FOR ${INDEX} IN RANGE 0 ${length}
58 ${value}= Get From List ${jsondata['devices']} ${INDEX}
59 ${of_id}= Get From Dictionary ${value} id
60 ${sn}= Get From Dictionary ${value} serial
61 ${matched}= Set Variable If '${sn}' == '${serial_number}' True False
62 Exit For Loop If ${matched}
63 END
64 Should Be True ${matched} No match for ${serial_number} found
65 [Return] ${of_id}
66
67
68
69Validate Deleted Device Cleanup In VGC
70 [Arguments] ${ip} ${port} ${olt_serial_number} ${olt_of_id} ${maclearning_enabled}=False
71 [Documentation] The keyword verifies that ports, flows, meters, subscribers, dhcp are all cleared in VGC
72 # Verify Ports are Removed
73 ${ports}= Get Request VGC devices/ports
74 ${port_json_resp}= To Json ${ports.content}
75 Should Not Contain ${port_json_resp} ${olt_of_id} Ports have not been removed from VGC after cleanup
76 # Verify Subscribers are Removed
77 ${sub}= Get Request VGC programmed-subscribers
78 ${sub_json_resp}= To Json ${sub.content}
79 Should Not Contain ${sub_json_resp} ${olt_of_id} Subscriber have not been removed from VGC after cleanup
80 # Verify Flows are Removed
81 ${flows}= Get Request VGC flows
82 ${flow_json_resp}= To Json ${flows.content}
83 Should Not Contain ${flow_json_resp} ${olt_of_id} Flows have not been removed from VGC after cleanup
84 # Verify Meters are Removed
85 ${meter}= Get Request VGC meters
86 ${meter_json_resp}= To Json ${meter.content}
87 Should Not Contain ${meter_json_resp} ${olt_of_id} Meter have not been removed from VGC after cleanup
88 # Verify AAA-Users are Removed
89 # ${aaa}= Execute ONOS CLI Command use single connection ${ip} ${port}
90 #... aaa-users ${olt_of_id}
91 # ${aaa_count}= Get Line Count ${aaa}
92 #Should Be Equal As Integers ${aaa_count} 0 AAA Users have not been removed from ONOS after cleanup
93 # Verify Dhcp-Allocations are Removed
94 ${dhcp}= Get Request VGC allocations/${olt_of_id}
95 ${dhcp_json_resp}= To Json ${dhcp.content}
96 ${dhcp_count} = Get Length ${dhcp_json_resp}
97 #Should Be Equal ${dhcp_json_resp} ${None} DHCP Allocations have not been removed from VGC after cleanup
98 Should Be Equal As Integers ${dhcp_count} 0 DHCP Allocations have not been removed from VGC after cleanup
99 # Verify MAC Learner Mappings are Removed
100 # ${mac}= Run Keyword If ${maclearning_enabled} Execute ONOS CLI Command use single connection ${ip} ${port}
101 # ... mac-learner-get-mapping | grep -v INFO
102 # ${mac_count}= Run Keyword If ${maclearning_enabled} Get Line Count ${mac}
103 # ... ELSE Set Variable 0
104 # Should Be Equal As Integers ${mac_count} 0 Client MAC Learner Mappings have not been removed from ONOS after cleanup
105
106
107Get NNI Port in VGC
108 [Arguments] ${olt_of_id}
109 [Documentation] Retrieves NNI port for the OLT in VGC
110 ${resp}= Get Request VGC devices/${olt_of_id}/ports
111 ${jsondata}= To Json ${resp.content}
Cristina de Franciscoc4cfd7e2023-10-09 10:55:08 +0200112 Should Not Be Empty ${jsondata['ports']} No ports data found for OLT ${olt_of_id} in VGC
bharat raj58488b32023-05-11 22:46:18 +0530113 ${length}= Get Length ${jsondata['ports']}
114 @{ports}= Create List
115 ${matched}= Set Variable False
116 FOR ${INDEX} IN RANGE 0 ${length}
117 ${value}= Get From List ${jsondata['ports']} ${INDEX}
118 ${annotations}= Get From Dictionary ${value} annotations
119 ${nni_port}= Get From Dictionary ${value} port
120 ${nniPortName}= Catenate SEPARATOR= nni- ${nni_port}
121 ${portName}= Get From Dictionary ${annotations} portName
122 ${matched}= Set Variable If '${portName}' == '${nniPortName}' True False
123 Exit For Loop If ${matched}
124 END
125 Should Be True ${matched} No match for NNI found for ${olt_of_id}
126 [Return] ${nni_port}
127
128
129
130Get ONU Port in VGC
131 [Arguments] ${onu_serial_number} ${olt_of_id} ${onu_uni_id}=1
132 [Documentation] Retrieves ONU port for the ONU in VGC
133 ${onu_serial_number}= Catenate SEPARATOR=- ${onu_serial_number} ${onu_uni_id}
134 ${resp}= Get Request VGC devices/${olt_of_id}/ports
135 ${jsondata}= To Json ${resp.content}
Cristina de Franciscoc4cfd7e2023-10-09 10:55:08 +0200136 Should Not Be Empty ${jsondata['ports']} No ports data found for OLT ${olt_of_id} in VGC
bharat raj58488b32023-05-11 22:46:18 +0530137 ${length}= Get Length ${jsondata['ports']}
138 @{ports}= Create List
139 ${matched}= Set Variable False
140 FOR ${INDEX} IN RANGE 0 ${length}
141 ${value}= Get From List ${jsondata['ports']} ${INDEX}
142 ${annotations}= Get From Dictionary ${value} annotations
143 ${onu_port}= Get From Dictionary ${value} port
144 ${portName}= Get From Dictionary ${annotations} portName
145 ${matched}= Set Variable If '${portName}' == '${onu_serial_number}' True False
146 Exit For Loop If ${matched}
147 END
148 Should Be True ${matched} No match for ${onu_serial_number} found
149 [Return] ${onu_port}
150
151
152
153Verify UNI Port Is Enabled
154 [Arguments] ${onu_name} ${onu_uni_id}=1
155 [Documentation] Verifies if the ONU's UNI port is enabled in VGC
156 ${onu_serial_number}= Catenate SEPARATOR=- ${onu_name} ${onu_uni_id}
157 ${resp}= Get Request VGC devices/ports
158 ${jsondata}= To Json ${resp.content}
Cristina de Franciscoc4cfd7e2023-10-09 10:55:08 +0200159 Should Not Be Empty ${jsondata['ports']} No devices ports data in VGC
bharat raj58488b32023-05-11 22:46:18 +0530160 ${length}= Get Length ${jsondata['ports']}
161 @{ports}= Create List
162 ${matched}= Set Variable False
163 FOR ${INDEX} IN RANGE 0 ${length}
164 ${value}= Get From List ${jsondata['ports']} ${INDEX}
165 ${annotations}= Get From Dictionary ${value} annotations
166 ${onu_port}= Get From Dictionary ${value} port
167 ${portName}= Get From Dictionary ${annotations} portName
168 ${portstatus}= Get From Dictionary ${value} isEnabled
169 ${matched}= Set Variable If '${portName}' == '${onu_serial_number}' True False
170 Exit For Loop If ${matched}
171 END
172 Should Be True ${matched} No match for ${onu_serial_number} found
173 Should be Equal ${portstatus} ${True}
174
175
176Verify UNI Port Is Disabled
177 [Arguments] ${ip} ${port} ${onu_name} ${onu_uni_id}=1
178 [Documentation] Verifies if the ONU's UNI port is enabled in VGC
179 ${onu_serial_number}= Catenate SEPARATOR=- ${onu_name} ${onu_uni_id}
180 ${resp}= Get Request VGC devices/ports
181 ${jsondata}= To Json ${resp.content}
Cristina de Franciscoc4cfd7e2023-10-09 10:55:08 +0200182 Should Not Be Empty ${jsondata['ports']} No devices ports data in VGC
bharat raj58488b32023-05-11 22:46:18 +0530183 ${length}= Get Length ${jsondata['ports']}
184 @{ports}= Create List
185 ${matched}= Set Variable False
186 FOR ${INDEX} IN RANGE 0 ${length}
187 ${value}= Get From List ${jsondata['ports']} ${INDEX}
188 ${annotations}= Get From Dictionary ${value} annotations
189 ${onu_port}= Get From Dictionary ${value} port
190 ${portName}= Get From Dictionary ${annotations} portName
191 ${portstatus}= Get From Dictionary ${value} isEnabled
192 ${matched}= Set Variable If '${portName}' == '${onu_serial_number}' True False
193 Exit For Loop If ${matched}
194 END
195 Should Be True ${matched} No match for ${onu_serial_number} found
196 Should be Equal ${portstatus} ${False}
197
198Close All VGC SSH Connections
199 [Documentation] Close all VGC Connection and clear connection list.
200 SSHLibrary.Close All Connections
201 @{connection_list} Create List
202
203
204
205Verify Subscriber Access Flows Added For ONU DT in VGC
206 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${nni_port} ${s_tag}
207 [Documentation] Verifies if the Subscriber Access Flows are added in VGC for the ONU
208 # Get all flows from VGC
209 ${resp}= Get Request VGC flows/${olt_of_id}
210 ${jsondata}= To Json ${resp.content}
Cristina de Franciscoc4cfd7e2023-10-09 10:55:08 +0200211 Should Not Be Empty ${jsondata['flows']} No flows data found for OLT ${olt_of_id} in VGC
bharat raj58488b32023-05-11 22:46:18 +0530212 # Verify upstream table=0 flow
213 ${length}= Get Length ${jsondata['flows']}
214 @{flows}= Create List
215 ${matched}= Set Variable False
216 FOR ${INDEX} IN RANGE 0 ${length}
217 ${flow}= Get From List ${jsondata['flows']} ${INDEX}
218 ${tableid}= Get Table Id From Flow ${flow}
219 ${inport}= Get In Port From Flow ${flow}
220 ${vlanvid}= Get Vlan VId From Flow ${flow}
221 ${outport}= Get Out Port From Flow ${flow}
222 ${matched}= Set Variable If
223 ... '${tableid}' == '0' and '${inport}' == '${onu_port}' and '${vlanvid}' == '4096' and '${outport}' == '1'
224 ... True False
225 Exit For Loop If ${matched}
226 END
227 Should Be True ${matched} No match for upstream table 0 flow found
228 # Verify upstream table=1 flow
229 ${matched1}= Set Variable False
230 FOR ${INDEX} IN RANGE 0 ${length}
231 ${flow}= Get From List ${jsondata['flows']} ${INDEX}
232 ${inport}= Get In Port From Flow ${flow}
233 ${vlanvid}= Get Vlan VId From Flow ${flow}
234 ${outport}= Get Out Port From Flow ${flow}
235 ${subtype}= Get Subtype From Flow ${flow}
236 ${vlanid}= Get Vlan Id From Flow ${flow}
237 ${res1}= Evaluate '${inport}' == '${onu_port}'
238 ${res2}= Evaluate '${vlanvid}' == '4096' and '${outport}' == '${nni_port}'
239 ${res3}= Evaluate '${subtype}' == 'VLAN_PUSH' and '${vlanid}' == '${s_tag}'
240 ${matched1}= Set Variable If ${res1} and ${res2} and ${res3} True False
241 Exit For Loop If ${matched1}
242 END
243 Should Be True ${matched1} No match for upstream table 1 flow found
244 # Verify downstream table=0 flow
245 ${matched2}= Set Variable False
246 FOR ${INDEX} IN RANGE 0 ${length}
247 ${flow}= Get From List ${jsondata['flows']} ${INDEX}
248 ${inport}= Get In Port From Flow ${flow}
249 ${vlanvid}= Get Vlan VId From Flow ${flow}
250 ${outport}= Get Out Port From Flow ${flow}
251 ${subtype}= Get Subtype From Flow ${flow}
252 ${res1}= Evaluate '${inport}' == '${nni_port}'
253 ${res2}= Evaluate '${vlanvid}' == '${s_tag}' and '${outport}' == '1'
254 ${res3}= Evaluate '${subtype}' == 'VLAN_POP'
255 ${matched2}= Set Variable If ${res1} and ${res2} and ${res3} True False
256 Exit For Loop If ${matched2}
257 END
258 Should Be True ${matched2} No match for downstream table 0 flow found
259 # Verify downstream table=1 flow
260 ${matched3}= Set Variable False
261 FOR ${INDEX} IN RANGE 0 ${length}
262 ${flow}= Get From List ${jsondata['flows']} ${INDEX}
263 ${inport}= Get In Port From Flow ${flow}
264 ${vlanvid}= Get Vlan VId From Flow ${flow}
265 ${outport}= Get Out Port From Flow ${flow}
266 ${matched3}= Set Variable If
267 ... '${inport}' == '${nni_port}' and '${vlanvid}' == '4096' and '${outport}' == '${onu_port}'
268 ... True False
269 Exit For Loop If ${matched3}
270 END
271 Should Be True ${matched3} "No match for downstream table 1 flow found"
272
273Verify Subscriber Access Flows Added for DT FTTB
274 [Arguments] ${olt_of_id} ${onu_port} ${nni_port} ${s_tag} ${c_tag}
275 [Documentation] Verifies if the Subscriber Access Flows are added in ONOS for the ONU
276 # Get all flows from VGC
277 ${resp}= Get Request VGC flows/${olt_of_id}
278 ${jsondata}= To Json ${resp.content}
Cristina de Franciscoc4cfd7e2023-10-09 10:55:08 +0200279 Should Not Be Empty ${jsondata['flows']} No ports data found for OLT ${olt_of_id} in VGC
bharat raj58488b32023-05-11 22:46:18 +0530280 # Upstream
281 # ONU
282 ${length}= Get Length ${jsondata['flows']}
283 @{flows}= Create List
284 ${matched}= Set Variable False
285 FOR ${INDEX} IN RANGE 0 ${length}
286 ${flow}= Get From List ${jsondata['flows']} ${INDEX}
287 ${tableid}= Get Table Id From Flow ${flow}
288 ${inport}= Get In Port From Flow ${flow}
289 ${vlanvid}= Get Vlan VId From Flow ${flow}
290 ${outport}= Get Out Port From Flow ${flow}
291 ${matched}= Set Variable If
292 ... '${inport}' == '${onu_port}' and '${vlanvid}' == '${c_tag}' and '${outport}' == '1'
293 ... True False
294 Exit For Loop If ${matched}
295 END
296 Should Be True ${matched} No match for upstream ONU flow found
297 # OLT
298 ${matched1}= Set Variable False
299 FOR ${INDEX} IN RANGE 0 ${length}
300 ${flow}= Get From List ${jsondata['flows']} ${INDEX}
301 ${inport}= Get In Port From Flow ${flow}
302 ${vlanvid}= Get Vlan VId From Flow ${flow}
303 ${outport}= Get Out Port From Flow ${flow}
304 ${vlanid}= Get Vlan Id From Flow For Fttb ${flow}
305 ${res1}= Evaluate '${inport}' == '${onu_port}'
306 ${res2}= Evaluate '${vlanvid}' == '${c_tag}' and '${vlanid}' == '${s_tag}'
307 ${res3}= Evaluate '${outport}' == '${nni_port}'
308 ${matched1}= Set Variable If ${res1} and ${res2} and ${res3} True False
309 Exit For Loop If ${matched1}
310 END
311 Should Be True ${matched1} No match for upstream OLT found
312 # Downstream
313 # OLT
314 ${matched2}= Set Variable False
315 FOR ${INDEX} IN RANGE 0 ${length}
316 ${flow}= Get From List ${jsondata['flows']} ${INDEX}
317 ${inport}= Get In Port From Flow ${flow}
318 ${vlanvid}= Get Vlan VId From Flow ${flow}
319 ${outport}= Get Out Port From Flow ${flow}
320 ${vlanid}= Get Vlan Id From Flow For Fttb ${flow}
321 ${res1}= Evaluate '${inport}' == '${nni_port}'
322 ${res2}= Evaluate '${vlanvid}' == '${s_tag}' and '${vlanid}' == '${c_tag}'
323 ${res3}= Evaluate '${outport}' == '1'
324 ${matched2}= Set Variable If ${res1} and ${res2} and ${res3} True False
325 Exit For Loop If ${matched2}
326 END
327 Should Be True ${matched2} No match for downstream OLT found
328 # ONU
329 ${matched3}= Set Variable False
330 FOR ${INDEX} IN RANGE 0 ${length}
331 ${flow}= Get From List ${jsondata['flows']} ${INDEX}
332 ${inport}= Get In Port From Flow ${flow}
333 ${vlanvid}= Get Vlan VId From Flow ${flow}
334 ${tableid}= Get Table Id From Flow ${flow}
335 ${outport}= Get Out Port From Flow ${flow}
336 ${vlanid}= Get Vlan Id From Flow For Fttb ${flow}
337 ${res1}= Evaluate '${inport}' == '${nni_port}'
338 ${res2}= Evaluate '${vlanvid}' == '${c_tag}' and '${outport}' == '${onu_port}'
339 ${matched3}= Set Variable If ${res1} and ${res2} True False
340 Exit For Loop If ${matched3}
341 END
342 Should Be True ${matched3} No match for downstream ONU found
343
344Verify DPU MGMT Flows Added for DT FTTB
345 [Arguments] ${olt_of_id} ${onu_port} ${nni_port} ${s_tag} ${c_tag}
346 [Documentation] Verifies if the DPU MGMT Flows are added in VGC for the ONU
347 # Get all flows from VGC
348 ${resp}= Get Request VGC flows/${olt_of_id}
349 ${jsondata}= To Json ${resp.content}
Cristina de Franciscoc4cfd7e2023-10-09 10:55:08 +0200350 Should Not Be Empty ${jsondata['flows']} No ports data found for OLT ${olt_of_id} in VGC
bharat raj58488b32023-05-11 22:46:18 +0530351 # Upstream
352 # ONU
353 ${length}= Get Length ${jsondata['flows']}
354 @{flows}= Create List
355 ${matched}= Set Variable False
356 FOR ${INDEX} IN RANGE 0 ${length}
357 ${flow}= Get From List ${jsondata['flows']} ${INDEX}
358 ${tableid}= Get Table Id From Flow ${flow}
359 ${inport}= Get In Port From Flow ${flow}
360 ${vlanvid}= Get Vlan VId From Flow ${flow}
361 ${vlanid}= Get Vlan Id From Flow For Fttb ${flow}
362 ${outport}= Get Out Port From Flow ${flow}
363 ${res1}= Evaluate '${inport}' == '${onu_port}'
364 ${res2}= Evaluate '${vlanvid}' == '${c_tag}' and '${vlanid}' == '${s_tag}'
365 ${res3}= Evaluate '${outport}' == '1'
366 ${matched}= Set Variable If ${res1} and ${res2} and ${res3} True False
367 Exit For Loop If ${matched}
368 END
369 Should Be True ${matched} No match for upstream ONU flow found
370 # OLT
371 ${matched1}= Set Variable False
372 FOR ${INDEX} IN RANGE 0 ${length}
373 ${flow}= Get From List ${jsondata['flows']} ${INDEX}
374 ${inport}= Get In Port From Flow ${flow}
375 ${vlanvid}= Get Vlan VId From Flow ${flow}
376 ${outport}= Get Out Port From Flow ${flow}
377 ${vlanid}= Get Vlan Id From Flow For Fttb ${flow}
378 ${matched1}= Set Variable If
379 ... '${inport}' == '${onu_port}' and '${vlanvid}' == '${s_tag}' and '${outport}' == '${nni_port}'
380 ... True False
381 ${matched1}= Set Variable If ${res1} and ${res2} and ${res3} True False
382 Log To Console "bbb",'${inport}' == '${onu_port}' '${vlanvid}' == '${s_tag}' '${outport}' == '${nni_port}'
383 Exit For Loop If ${matched1}
384 END
385 Should Be True ${matched1} No match for upstream OLT found
386 # Downstream
387 # OLT
388 ${matched2}= Set Variable False
389 FOR ${INDEX} IN RANGE 0 ${length}
390 ${flow}= Get From List ${jsondata['flows']} ${INDEX}
391 ${inport}= Get In Port From Flow ${flow}
392 ${vlanvid}= Get Vlan VId From Flow ${flow}
393 ${outport}= Get Out Port From Flow ${flow}
394 ${vlanid}= Get Vlan Id From Flow For Fttb ${flow}
395 ${matched3}= Set Variable If
396 ... '${inport}' == '${nni_port}' and '${vlanvid}' == '${s_tag}' and '${outport}' == '1'
397 ... True False
398 Exit For Loop If ${matched3}
399 END
400 Should Be True ${matched3} No match for downstream OLT found
401 # ONU
402 ${matched4}= Set Variable False
403 FOR ${INDEX} IN RANGE 0 ${length}
404 ${flow}= Get From List ${jsondata['flows']} ${INDEX}
405 ${inport}= Get In Port From Flow ${flow}
406 ${vlanvid}= Get Vlan VId From Flow ${flow}
407 ${tableid}= Get Table Id From Flow ${flow}
408 ${outport}= Get Out Port From Flow ${flow}
409 ${vlanid}= Get Vlan Id From Flow For Fttb ${flow}
410 ${res1}= Evaluate '${inport}' == '${nni_port}'
411 ${res2}= Evaluate '${vlanvid}' == '${s_tag}' and '${vlanid}' == '${c_tag}'
412 ${res3}= Evaluate '${outport}' == '${onu_port}'
413 ${matched4}= Set Variable If ${res1} and ${res2} and ${res3} True False
414 Exit For Loop If ${matched4}
415 END
416 Should Be True ${matched4} No match for downstream ONU found
417
418Verify VGC Flows Added for DT FTTB
419 [Arguments] ${olt_of_id} ${onu_port} ${nni_port} ${service}
420 [Documentation] Verifies if the Flows are added in ONOS for the ONU
421 ${num_services}= Get Length ${service}
422 FOR ${I} IN RANGE 0 ${num_services}
423 ${service_name}= Set Variable ${service[${I}]['name']}
424 ${stag}= Set Variable ${service[${I}]['s_tag']}
425 ${ctag}= Set Variable ${service[${I}]['c_tag']}
rbodapatfe5bb152025-03-17 11:34:42 +0530426 Run Keyword If '${service_name}' == 'FTTB_SUBSCRIBER_TRAFFIC' Run Keywords
427 Verify Subscriber Access Flows Added for DT FTTB ${olt_of_id} ${onu_port} ${nni_port} ${stag} ${ctag}
428 Verify DPU MGMT Flows Added for DT FTTB ${olt_of_id} ${onu_port} ${nni_port} ${stag} ${ctag }
bharat raj58488b32023-05-11 22:46:18 +0530429 END
430
431
432Add Subscriber Details
433 [Documentation] Adds a particular subscriber
434 [Arguments] ${of_id} ${onu_port}
435 ${resp}= Post Request VGC services/${of_id}/${onu_port}
436 Log ${resp}
437 Should Be Equal As Strings ${resp.status_code} 200
438
439Remove Subscriber Access
440 [Documentation] Removes a particular subscriber
441 [Arguments] ${of_id} ${onu_port}
442 ${resp}= Delete Request VGC services/${of_id}/${onu_port}
443 Log ${resp}
444 Should Be Equal As Strings ${resp.status_code} 200
445
446Send File To VGC
447 [Documentation] Send the content of the file to VGC to selected section of configuration
448 ... using Post Request
449 [Arguments] ${CONFIG_FILE} #${section}=${EMPTY}
450 ${Headers}= Create Dictionary Content-Type application/json
451 ${File_Data}= OperatingSystem.Get File ${CONFIG_FILE}
452 Log ${Headers}
453 Log ${File_Data}
454 ${resp}= Post Request VGC
Akash Soni35cafc32023-12-20 12:48:08 +0530455 ... network-configurations headers=${Headers} data=${File_Data}
bharat raj58488b32023-05-11 22:46:18 +0530456 Should Be Equal As Strings ${resp.status_code} 200
457
458Verify No Pending Flows For ONU
459 [Arguments] ${ip} ${port} ${onu_port}
460 [Documentation] Verifies that there are no flows "PENDING" state for the ONU in VGC
461 ${resp}= Get Request VGC flows/pending
462 ${jsondata}= To Json ${resp.content}
463 ${length}= Get Length ${jsondata['flows']}
464 ${matched}= Set Variable False
465 FOR ${INDEX} IN RANGE 0 ${length}
466 ${flow}= Get From List ${jsondata['flows']} ${INDEX}
467 ${inport}= Get In Port From Flow ${flow}
468 ${matched}= Run Keyword If '${inport}' == '${onu_port}' Set Variable ${TRUE}
469 Exit For Loop If ${matched}
470 END
471 Should Be Equal ${matched} False No match for pending flow found
472
473Get Pending Flow Count
474 [Documentation] Get the count for flows "PENDING" state for the ONU in VGC
475 ${resp}= Get Request VGC flows/pending
476 ${jsondata}= To Json ${resp.content}
477 ${length}= Get Length ${jsondata['flows']}
478 [Return] ${length}
479
480Get In Port From Flow
481 [Documentation] Fetches the port Record for IN_PORT
482 [Arguments] ${flow}
483 ${selector}= Get From Dictionary ${flow} selector
484 ${len}= Get Length ${selector['criteria']}
485 ${matched}= Set Variable False
486 FOR ${INDEX} IN RANGE 0 ${len}
487 ${criteria}= Get From List ${selector['criteria']} ${INDEX}
488 ${type}= Get From Dictionary ${criteria} type
489 ${port}= Run Keyword If '${type}' == 'IN_PORT' Get From Dictionary ${criteria} port
490 ${matched}= Set Variable If '${type}' == 'IN_PORT' True False
491 Exit For Loop If ${matched}
492 END
493 [Return] ${port}
494
495
496
497Get Vlan VId From Flow
498 [Documentation] Fetches the vlan Id
499 [Arguments] ${flow}
500 ${selector}= Get From Dictionary ${flow} selector
501 ${len}= Get Length ${selector['criteria']}
502 ${matched}= Set Variable False
503 ${vlanid}= Set Variable
504 FOR ${INDEX} IN RANGE 0 ${len}
505 ${criteria}= Get From List ${selector['criteria']} ${INDEX}
506 ${type}= Get From Dictionary ${criteria} type
507 ${vlanid}= Run Keyword If '${type}' == 'VLAN_VID' Get From Dictionary ${criteria} vlanId
508 ${matched}= Set Variable If '${type}' == 'VLAN_VID' True False
509 Exit For Loop If ${matched}
510 END
511 [Return] ${vlanid}
512
513
514Get Out Port From Flow
515 [Documentation] Fetches the port for OUTPUT
516 [Arguments] ${flow}
517 ${treatment}= Get From Dictionary ${flow} treatment
518 ${len}= Get Length ${treatment['instructions']}
519 ${matched}= Set Variable False
520 FOR ${INDEX} IN RANGE 0 ${len}
521 ${instructions}= Get From List ${treatment['instructions']} ${INDEX}
522 ${type}= Get From Dictionary ${instructions} type
523 ${outport}= Run Keyword If '${type}' == 'OUTPUT' Get From Dictionary ${instructions} port
524 ${matched}= Set Variable If '${type}' == 'OUTPUT' True False
525 Exit For Loop If ${matched}
526 END
527 [Return] ${outport}
528
529
530Get Subtype From Flow
531 [Documentation] Fetches the L2MODIFICATION subtype
532 [Arguments] ${flow}
533 ${treatment}= Get From Dictionary ${flow} treatment
534 ${len}= Get Length ${treatment['instructions']}
535 ${matched}= Set Variable False
536 FOR ${INDEX} IN RANGE 0 ${len}
537 ${instructions}= Get From List ${treatment['instructions']} ${INDEX}
538 ${type}= Get From Dictionary ${instructions} type
539 ${subtype}= Run Keyword If '${type}' == 'L2MODIFICATION' Get From Dictionary ${instructions} subtype
540 ${matched}= Set Variable If '${type}' == 'L2MODIFICATION' True False
541 Exit For Loop If ${matched}
542 END
543 [Return] ${subtype}
544
545Get Vlan Id From Flow For Fttb
546 [Documentation] Fetch the VLAN id for L2MODIFICATION
547 [Arguments] ${flow}
548 ${treatment}= Get From Dictionary ${flow} treatment
549 ${len}= Get Length ${treatment['instructions']}
550 ${matched}= Set Variable False
551 FOR ${INDEX} IN RANGE 0 ${len}
552 ${instructions}= Get From List ${treatment['instructions']} ${INDEX}
553 ${type}= Get From Dictionary ${instructions} type
554 ${subtype}= Run Keyword If '${type}' == 'L2MODIFICATION' Get From Dictionary ${instructions} subtype
555 ${vlanId}= Run Keyword If '${type}' == 'L2MODIFICATION' and '${subtype}' == 'VLAN_SET'
556 ... Get From Dictionary ${instructions} vlanId
557 ${matched}= Set Variable If '${type}' == 'L2MODIFICATION' and '${subtype}' == 'VLAN_SET' True False
558 Exit For Loop If ${matched}
559 END
560 [Return] ${vlanId}
561
562Get Table Id From Flow
563 [Documentation] Fetch the TableId
564 [Arguments] ${flow}
565 ${tableid}= Get From Dictionary ${flow} tableId
566 [Return] ${tableid}
567
568Get Vlan Id From Flow
569 [Documentation] Fetch the VLAN id for L2MODIFICATION
570 [Arguments] ${flow}
571 ${treatment}= Get From Dictionary ${flow} treatment
572 ${len}= Get Length ${treatment['instructions']}
573 ${matched}= Set Variable False
574 FOR ${INDEX} IN RANGE 0 ${len}
575 ${instructions}= Get From List ${treatment['instructions']} ${INDEX}
576 ${type}= Get From Dictionary ${instructions} type
577 ${subtype}= Run Keyword If '${type}' == 'L2MODIFICATION' Get From Dictionary ${instructions} subtype
578 ${vlanId}= Run Keyword If '${type}' == 'L2MODIFICATION' and '${subtype}' == 'VLAN_ID'
579 ... Get From Dictionary ${instructions} vlanId
580 ${matched}= Set Variable If '${type}' == 'L2MODIFICATION' and '${subtype}' == 'VLAN_ID' True False
581 Exit For Loop If ${matched}
582 END
583 [Return] ${vlanId}
584
585Get Subscribers for a Particular Service
586 [Documentation] Filters the subscriber for a particular service
587 [Arguments] ${olt_of_id} ${subscriber_json} ${filter}
588 ${subscribers_info}= Get From Dictionary ${subscriber_json} subscribers
589 ${num_subscribers}= Get Length ${subscribers_info}
590 ${subscriber_list} Create List
591 Return From Keyword If '${filter}' == '${EMPTY}' ${subscribers_info}
592 FOR ${INDEX} IN RANGE 0 ${num_subscribers}
593 ${subscriber}= Get From List ${subscribers_info} ${INDEX}
594 ${res1}= Evaluate '${olt_of_id}' == '${subscriber["location"]}'
595 ${tag_subscriber_info}= Get From Dictionary ${subscriber} tagInfo
596 ${ServiceName}= Get From Dictionary ${tag_subscriber_info} serviceName
597 ${res2}= Evaluate '${filter}' == '${ServiceName}'
598 Run Keyword If ${res1} and ${res2}
599 ... Append To List ${subscriber_list} ${subscriber}
600 ${matched}= Set Variable If ${res1} and ${res2} True False
601 Exit For Loop If ${matched}
602 END
603 Should Be True ${matched} No matching subscriber for OLT
604 [Return] ${subscriber_list}
605
606Get Programmed Subscribers
607 [Arguments] ${olt_of_id} ${onu_port} ${filter}=${EMPTY}
608 [Documentation] Retrieves the subscriber details at a given location
609 ${programmed_sub}= Get Request VGC programmed-subscribers
610 ${programmed_sub_json_resp}= To Json ${programmed_sub.content}
611 ${filtered_subscriber_list}= Get Subscribers for a Particular Service ${olt_of_id} ${programmed_sub_json_resp}
612 ... ${filter}
613 [Return] ${filtered_subscriber_list}
614
615Verify Programmed Subscribers DT FTTB
616 [Arguments] ${olt_of_id} ${onu_port} ${service}
617 [Documentation] Verifies the subscriber is present at a given location
618 ${num_services}= Get Length ${service}
619 FOR ${I} IN RANGE 0 ${num_services}
620 ${service_name}= Set Variable ${service[${I}]['name']}
621 ${programmed_subscriber}= Get Programmed Subscribers ${olt_of_id} ${onu_port}
622 ... ${service_name}
623 Log ${programmed_subscriber}
Cristina de Franciscoc4cfd7e2023-10-09 10:55:08 +0200624 Should Not Be Empty ${programmed_subscriber} No programmed subscribers found for ${service_name}
bharat raj58488b32023-05-11 22:46:18 +0530625 END
626
627Verify Meters in VGC Ietf
628 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${filter}=${EMPTY}
629 [Documentation] Verifies the meters with BW Ietf format (currently, DT workflow uses this format)
630 ${programmed_sub_json_resp}= Get Programmed Subscribers ${olt_of_id} ${onu_port}
631 ... ${filter}
632 Log ${programmed_sub_json_resp}
633 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
634 ... ${programmed_sub_json_resp}
635 # Get upstream bandwidth profile details
636 ${us_cir} ${us_cbs} ${us_pir} ${us_pbs} ${us_gir} Get Bandwidth Profile Details Ietf Rest
637 ... ${us_bw_profile}
638 # Verify meter for upstream bandwidth profile
639 ${meter}= Get Request VGC meters
640 ${meter_json_resp}= To Json ${meter.content}
641 Log ${meter_json_resp}
642 ${rate} ${burst_size} Get Meter Param In Details
643 ... ${meter_json_resp} 1
644 Log ${rate}
645 Log ${burst_size}
646 # for cir & cbs
647 ${matched}= Set Variable If '${rate}' == '${us_cir}' and '${burst_size}' == '${us_cbs}' True False
648 Should Be True ${matched}
649 ${res1}= Evaluate '${rate}' == '${us_cir}' and '${burst_size}' == '${us_cbs}'
650 #for pir & pbs
651 ${rate} ${burst_size} Get Meter Param In Details
652 ... ${meter_json_resp} 2
653 ${matched}= Set Variable If '${rate}' == '${us_pir}' and '${burst_size}' == '${us_pbs}' True False
654 Should Be True ${matched}
655 ${res2}= Evaluate '${rate}' == '${us_pir}' and '${burst_size}' == '${us_pbs}'
656 #for gir
657 Run Keyword if ${us_gir} != 0 Validate Guarenteed Information Rate ${us_gir} ${meter_json_resp}
658 # Get downstream bandwidth profile details
659 ${ds_cir} ${ds_cbs} ${ds_pir} ${ds_pbs} ${ds_gir} Get Bandwidth Profile Details Ietf Rest
660 ... ${ds_bw_profile}
661 # Verify meter for downstream bandwidth profile
662 ${meter}= Get Request VGC meters
663 ${meter_json_resp}= To Json ${meter.content}
664 Log ${meter_json_resp}
665 ${rate} ${burst_size} Get Meter Param In Details
666 ... ${meter_json_resp} 1
667 Log ${rate}
668 Log ${burst_size}
669 # for cir & cbs
670 ${matched}= Set Variable If '${rate}' == '${ds_cir}' and '${burst_size}' == '${ds_cbs}' True False
671 Should Be True ${matched}
672 #for pir & pbs
673 ${rate} ${burst_size} Get Meter Param In Details
674 ... ${meter_json_resp} 2
675 ${matched}= Set Variable If '${rate}' == '${ds_pir}' and '${burst_size}' == '${ds_pbs}' True False
676 Should Be True ${matched}
677 #for gir
678 Run Keyword If ${ds_gir} != 0
679 ... Validate Guarenteed Information Rate ${ds_gir} ${meter_json_resp}
680
681Validate Guarenteed Information Rate
682 [Documentation] Validate gir for both upstream and downstream meters
683 [Arguments] ${gir} ${meter_json_resp}
684 ${rate} ${burst_size} Get Meter Param In Details
685 ... ${meter_json_resp} 3
686 ${matched}= Set Variable If '${rate}' == '${gir}' and '${burst_size}' == '0' True False
687 Should Be True ${matched}
688 [Return] ${matched}
689
690Get Bandwidth Profile Details Ietf Rest
691 [Arguments] ${bw_profile_id}
692 [Documentation] Retrieves the details of the given Ietf standard based bandwidth profile using REST API
693 ${bw_profile_id}= Remove String ${bw_profile_id} ' "
694 ${resp}= Get Request VGC profiles/${bw_profile_id}
695 Log ${resp}
696 ${jsondata}= To Json ${resp.content}
Cristina de Franciscoc4cfd7e2023-10-09 10:55:08 +0200697 Should Not Be Empty ${jsondata} Could not find data for bandwidth profile ${bw_profile_id} in VGC
bharat raj58488b32023-05-11 22:46:18 +0530698 ${matched}= Set Variable False
699 ${bw_id}= Get From Dictionary ${jsondata} id
700 ${matched}= Set Variable If '${bw_id}' == '${bw_profile_id}' True False
701 ${pir}= Get From Dictionary ${jsondata} pir
702 ${pbs}= Get From Dictionary ${jsondata} pbs
703 ${cir}= Get From Dictionary ${jsondata} cir
704 ${cbs}= Get From Dictionary ${jsondata} cbs
705 ${gir}= Get From Dictionary ${jsondata} gir
706 Should Be True ${matched} No bandwidth profile found for id: ${bw_profile_id}
707 [Return] ${cir} ${cbs} ${pir} ${pbs} ${gir}
708
709
710Get Upstream and Downstream Bandwidth Profile Name
711 [Arguments] ${programmed_sub}
712 [Documentation] Retrieves the upstream and downstream bandwidth profile name
713 ... from the programmed subscriber
714 ${length}= Get Length ${programmed_sub}
715 ${matched}= Set Variable False
716 FOR ${INDEX} IN RANGE 0 ${length}
717 ${value}= Get From List ${programmed_sub} ${INDEX}
718 ${tagInfo_id}= Get From Dictionary ${value} tagInfo
719 Log ${tagInfo_id}
720 ${us_bw_profile}= Get From Dictionary ${tagInfo_id} upstreamBandwidthProfile
721 Log ${us_bw_profile}
722 ${ds_bw_profile}= Get From Dictionary ${tagInfo_id} downstreamBandwidthProfile
723 Log ${ds_bw_profile}
724 END
725 [Return] ${us_bw_profile} ${ds_bw_profile}
726
727Verify Subscriber Access Flows Added Count DT
728 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
729 [Documentation] Matches for total number of subscriber access flows added for all onus
730 ${resp}= Get Request VGC flows/${olt_of_id}
731 ${jsondata}= To Json ${resp.content}
732 ${access_flows_added_count}= Get Length ${jsondata['flows']}
733 Should Be Equal As Integers ${access_flows_added_count} ${expected_flows}
734
735Get Meter Param In Details
736 [Arguments] ${meter_json} ${length}
737 [Documentation] Retrieves the meter rate state burst-size
738 ${metername}= Get From Dictionary ${meter_json} meters
739 Log ${metername}
740 ${value}= Get From List ${metername} 0
741 ${bands_info}= Get From Dictionary ${value} bands
742 Log ${bands_info}
743 FOR ${INDEX} IN RANGE 0 ${length}
744 ${value}= Get From List ${bands_info} ${INDEX}
745 ${burst_size}= Get From Dictionary ${value} burstSize
746 ${rate}= Get From Dictionary ${value} rate
747 END
748 [Return] ${rate} ${burst_size}
749
750Delete Subscribers And BW Profile In VGC
751 [Documentation] Delete Subscribers and bw profile In VGC
752 Create VGC Session
753 ${resp}= Get Request VGC programmed-subscribers
754 Log ${resp}
755 ${jsondata}= To Json ${resp.content}
756 ${length}= Get Length ${jsondata['subscribers']}
757 @{serial_numbers}= Create List
758 FOR ${INDEX} IN RANGE 0 ${length}
759 ${value}= Get From List ${jsondata['subscribers']} ${INDEX}
760 ${taginfo}= Get From Dictionary ${value} tagInfo
761 ${service_id}= Get From Dictionary ${taginfo} serviceName
762 ${upstream_bw_id}= Get From Dictionary ${taginfo} upstreamBandwidthProfile
763 ${downstream_bw_id}= Get From Dictionary ${taginfo} downstreamBandwidthProfile
764 Delete Request VGC subscribers/${service_id}
765 Delete Request VGC profiles/${upstream_bw_id}
766 Delete Request VGC profiles/${downstream_bw_id}
767 END
768
769Deactivate Subscribers In VGC
770 [Documentation] Deactivate Subscribers In VGC
771 Create VGC Session
772 ${resp}= Get Request VGC devices/ports
773 Log ${resp}
774 ${jsondata}= To Json ${resp.content}
775 ${length}= Get Length ${jsondata['ports']}
776 FOR ${INDEX} IN RANGE 0 ${length}
777 ${value}= Get From List ${jsondata['ports']} ${INDEX}
778 ${annotations}= Get From Dictionary ${value} annotations
779 ${portname}= Get From Dictionary ${annotations} portName
780 Delete Request VGC services/${portname}
781 END
782
783Verify Device Flows Removed
784 [Arguments] ${ip} ${port} ${olt_of_id}
785 [Documentation] Verifies all flows are removed from the device
786 ${resp}= Get Request VGC flows/${olt_of_id}
787 ${jsondata}= To Json ${resp.content}
788 ${flow_count}= Get Length ${jsondata['flows']}
789 Should Be Equal As Integers ${flow_count} 0 Flows not removed
790
791Device Is Available In VGC
Akash Soni35cafc32023-12-20 12:48:08 +0530792 [Arguments] ${olt_of_id} ${available}=True
bharat raj58488b32023-05-11 22:46:18 +0530793 [Documentation] Validates the device exists and it has the expected availability in VGC
794 ${resp}= Get Request VGC devices
795 ${jsondata}= To Json ${resp.content}
Cristina de Franciscoc4cfd7e2023-10-09 10:55:08 +0200796 Should Not Be Empty ${jsondata['devices']} No devices data found in VGC
bharat raj58488b32023-05-11 22:46:18 +0530797 ${length}= Get Length ${jsondata['devices']}
798 ${matched}= Set Variable False
799 FOR ${INDEX} IN RANGE 0 ${length}
800 ${value}= Get From List ${jsondata['devices']} ${INDEX}
801 ${of_id}= Get From Dictionary ${value} id
802 ${availability}= Get From Dictionary ${value} available
803 Log ${olt_of_id}
804 Log ${of_id}
Akash Soni35cafc32023-12-20 12:48:08 +0530805 ${matched}= Set Variable If '${of_id}' == '${olt_of_id}' and '${availability}' True False
bharat raj58488b32023-05-11 22:46:18 +0530806 Exit For Loop If ${matched}
807 END
808 Should Be True ${matched} No match for '${olt_of_id}' found
bharat raj58488b32023-05-11 22:46:18 +0530809