blob: fa98b93e2dc5ddb0a518b10a11a8974a49ced098 [file] [log] [blame]
bharat raj58488b32023-05-11 22:46:18 +05301# 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.
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']}
426 Run Keyword If '${service_name}' == 'FTTB_SUBSCRIBER_TRAFFIC'
427 ... Verify Subscriber Access Flows Added for DT FTTB ${olt_of_id}
428 ... ${onu_port} ${nni_port} ${stag} ${ctag}
429 ... Verify DPU MGMT Flows Added for DT FTTB ${olt_of_id}
430 ... ${onu_port} ${nni_port} ${stag} ${ctag}
431 END
432
433
434Add Subscriber Details
435 [Documentation] Adds a particular subscriber
436 [Arguments] ${of_id} ${onu_port}
437 ${resp}= Post Request VGC services/${of_id}/${onu_port}
438 Log ${resp}
439 Should Be Equal As Strings ${resp.status_code} 200
440
441Remove Subscriber Access
442 [Documentation] Removes a particular subscriber
443 [Arguments] ${of_id} ${onu_port}
444 ${resp}= Delete Request VGC services/${of_id}/${onu_port}
445 Log ${resp}
446 Should Be Equal As Strings ${resp.status_code} 200
447
448Send File To VGC
449 [Documentation] Send the content of the file to VGC to selected section of configuration
450 ... using Post Request
451 [Arguments] ${CONFIG_FILE} #${section}=${EMPTY}
452 ${Headers}= Create Dictionary Content-Type application/json
453 ${File_Data}= OperatingSystem.Get File ${CONFIG_FILE}
454 Log ${Headers}
455 Log ${File_Data}
456 ${resp}= Post Request VGC
457 ... network/configurations headers=${Headers} data=${File_Data}
458 Should Be Equal As Strings ${resp.status_code} 200
459
460Verify No Pending Flows For ONU
461 [Arguments] ${ip} ${port} ${onu_port}
462 [Documentation] Verifies that there are no flows "PENDING" state for the ONU in VGC
463 ${resp}= Get Request VGC flows/pending
464 ${jsondata}= To Json ${resp.content}
465 ${length}= Get Length ${jsondata['flows']}
466 ${matched}= Set Variable False
467 FOR ${INDEX} IN RANGE 0 ${length}
468 ${flow}= Get From List ${jsondata['flows']} ${INDEX}
469 ${inport}= Get In Port From Flow ${flow}
470 ${matched}= Run Keyword If '${inport}' == '${onu_port}' Set Variable ${TRUE}
471 Exit For Loop If ${matched}
472 END
473 Should Be Equal ${matched} False No match for pending flow found
474
475Get Pending Flow Count
476 [Documentation] Get the count for flows "PENDING" state for the ONU in VGC
477 ${resp}= Get Request VGC flows/pending
478 ${jsondata}= To Json ${resp.content}
479 ${length}= Get Length ${jsondata['flows']}
480 [Return] ${length}
481
482Get In Port From Flow
483 [Documentation] Fetches the port Record for IN_PORT
484 [Arguments] ${flow}
485 ${selector}= Get From Dictionary ${flow} selector
486 ${len}= Get Length ${selector['criteria']}
487 ${matched}= Set Variable False
488 FOR ${INDEX} IN RANGE 0 ${len}
489 ${criteria}= Get From List ${selector['criteria']} ${INDEX}
490 ${type}= Get From Dictionary ${criteria} type
491 ${port}= Run Keyword If '${type}' == 'IN_PORT' Get From Dictionary ${criteria} port
492 ${matched}= Set Variable If '${type}' == 'IN_PORT' True False
493 Exit For Loop If ${matched}
494 END
495 [Return] ${port}
496
497
498
499Get Vlan VId From Flow
500 [Documentation] Fetches the vlan Id
501 [Arguments] ${flow}
502 ${selector}= Get From Dictionary ${flow} selector
503 ${len}= Get Length ${selector['criteria']}
504 ${matched}= Set Variable False
505 ${vlanid}= Set Variable
506 FOR ${INDEX} IN RANGE 0 ${len}
507 ${criteria}= Get From List ${selector['criteria']} ${INDEX}
508 ${type}= Get From Dictionary ${criteria} type
509 ${vlanid}= Run Keyword If '${type}' == 'VLAN_VID' Get From Dictionary ${criteria} vlanId
510 ${matched}= Set Variable If '${type}' == 'VLAN_VID' True False
511 Exit For Loop If ${matched}
512 END
513 [Return] ${vlanid}
514
515
516Get Out Port From Flow
517 [Documentation] Fetches the port for OUTPUT
518 [Arguments] ${flow}
519 ${treatment}= Get From Dictionary ${flow} treatment
520 ${len}= Get Length ${treatment['instructions']}
521 ${matched}= Set Variable False
522 FOR ${INDEX} IN RANGE 0 ${len}
523 ${instructions}= Get From List ${treatment['instructions']} ${INDEX}
524 ${type}= Get From Dictionary ${instructions} type
525 ${outport}= Run Keyword If '${type}' == 'OUTPUT' Get From Dictionary ${instructions} port
526 ${matched}= Set Variable If '${type}' == 'OUTPUT' True False
527 Exit For Loop If ${matched}
528 END
529 [Return] ${outport}
530
531
532Get Subtype From Flow
533 [Documentation] Fetches the L2MODIFICATION subtype
534 [Arguments] ${flow}
535 ${treatment}= Get From Dictionary ${flow} treatment
536 ${len}= Get Length ${treatment['instructions']}
537 ${matched}= Set Variable False
538 FOR ${INDEX} IN RANGE 0 ${len}
539 ${instructions}= Get From List ${treatment['instructions']} ${INDEX}
540 ${type}= Get From Dictionary ${instructions} type
541 ${subtype}= Run Keyword If '${type}' == 'L2MODIFICATION' Get From Dictionary ${instructions} subtype
542 ${matched}= Set Variable If '${type}' == 'L2MODIFICATION' True False
543 Exit For Loop If ${matched}
544 END
545 [Return] ${subtype}
546
547Get Vlan Id From Flow For Fttb
548 [Documentation] Fetch the VLAN id for L2MODIFICATION
549 [Arguments] ${flow}
550 ${treatment}= Get From Dictionary ${flow} treatment
551 ${len}= Get Length ${treatment['instructions']}
552 ${matched}= Set Variable False
553 FOR ${INDEX} IN RANGE 0 ${len}
554 ${instructions}= Get From List ${treatment['instructions']} ${INDEX}
555 ${type}= Get From Dictionary ${instructions} type
556 ${subtype}= Run Keyword If '${type}' == 'L2MODIFICATION' Get From Dictionary ${instructions} subtype
557 ${vlanId}= Run Keyword If '${type}' == 'L2MODIFICATION' and '${subtype}' == 'VLAN_SET'
558 ... Get From Dictionary ${instructions} vlanId
559 ${matched}= Set Variable If '${type}' == 'L2MODIFICATION' and '${subtype}' == 'VLAN_SET' True False
560 Exit For Loop If ${matched}
561 END
562 [Return] ${vlanId}
563
564Get Table Id From Flow
565 [Documentation] Fetch the TableId
566 [Arguments] ${flow}
567 ${tableid}= Get From Dictionary ${flow} tableId
568 [Return] ${tableid}
569
570Get Vlan Id From Flow
571 [Documentation] Fetch the VLAN id for L2MODIFICATION
572 [Arguments] ${flow}
573 ${treatment}= Get From Dictionary ${flow} treatment
574 ${len}= Get Length ${treatment['instructions']}
575 ${matched}= Set Variable False
576 FOR ${INDEX} IN RANGE 0 ${len}
577 ${instructions}= Get From List ${treatment['instructions']} ${INDEX}
578 ${type}= Get From Dictionary ${instructions} type
579 ${subtype}= Run Keyword If '${type}' == 'L2MODIFICATION' Get From Dictionary ${instructions} subtype
580 ${vlanId}= Run Keyword If '${type}' == 'L2MODIFICATION' and '${subtype}' == 'VLAN_ID'
581 ... Get From Dictionary ${instructions} vlanId
582 ${matched}= Set Variable If '${type}' == 'L2MODIFICATION' and '${subtype}' == 'VLAN_ID' True False
583 Exit For Loop If ${matched}
584 END
585 [Return] ${vlanId}
586
587Get Subscribers for a Particular Service
588 [Documentation] Filters the subscriber for a particular service
589 [Arguments] ${olt_of_id} ${subscriber_json} ${filter}
590 ${subscribers_info}= Get From Dictionary ${subscriber_json} subscribers
591 ${num_subscribers}= Get Length ${subscribers_info}
592 ${subscriber_list} Create List
593 Return From Keyword If '${filter}' == '${EMPTY}' ${subscribers_info}
594 FOR ${INDEX} IN RANGE 0 ${num_subscribers}
595 ${subscriber}= Get From List ${subscribers_info} ${INDEX}
596 ${res1}= Evaluate '${olt_of_id}' == '${subscriber["location"]}'
597 ${tag_subscriber_info}= Get From Dictionary ${subscriber} tagInfo
598 ${ServiceName}= Get From Dictionary ${tag_subscriber_info} serviceName
599 ${res2}= Evaluate '${filter}' == '${ServiceName}'
600 Run Keyword If ${res1} and ${res2}
601 ... Append To List ${subscriber_list} ${subscriber}
602 ${matched}= Set Variable If ${res1} and ${res2} True False
603 Exit For Loop If ${matched}
604 END
605 Should Be True ${matched} No matching subscriber for OLT
606 [Return] ${subscriber_list}
607
608Get Programmed Subscribers
609 [Arguments] ${olt_of_id} ${onu_port} ${filter}=${EMPTY}
610 [Documentation] Retrieves the subscriber details at a given location
611 ${programmed_sub}= Get Request VGC programmed-subscribers
612 ${programmed_sub_json_resp}= To Json ${programmed_sub.content}
613 ${filtered_subscriber_list}= Get Subscribers for a Particular Service ${olt_of_id} ${programmed_sub_json_resp}
614 ... ${filter}
615 [Return] ${filtered_subscriber_list}
616
617Verify Programmed Subscribers DT FTTB
618 [Arguments] ${olt_of_id} ${onu_port} ${service}
619 [Documentation] Verifies the subscriber is present at a given location
620 ${num_services}= Get Length ${service}
621 FOR ${I} IN RANGE 0 ${num_services}
622 ${service_name}= Set Variable ${service[${I}]['name']}
623 ${programmed_subscriber}= Get Programmed Subscribers ${olt_of_id} ${onu_port}
624 ... ${service_name}
625 Log ${programmed_subscriber}
Cristina de Franciscoc4cfd7e2023-10-09 10:55:08 +0200626 Should Not Be Empty ${programmed_subscriber} No programmed subscribers found for ${service_name}
bharat raj58488b32023-05-11 22:46:18 +0530627 END
628
629Verify Meters in VGC Ietf
630 [Arguments] ${ip} ${port} ${olt_of_id} ${onu_port} ${filter}=${EMPTY}
631 [Documentation] Verifies the meters with BW Ietf format (currently, DT workflow uses this format)
632 ${programmed_sub_json_resp}= Get Programmed Subscribers ${olt_of_id} ${onu_port}
633 ... ${filter}
634 Log ${programmed_sub_json_resp}
635 ${us_bw_profile} ${ds_bw_profile} Get Upstream and Downstream Bandwidth Profile Name
636 ... ${programmed_sub_json_resp}
637 # Get upstream bandwidth profile details
638 ${us_cir} ${us_cbs} ${us_pir} ${us_pbs} ${us_gir} Get Bandwidth Profile Details Ietf Rest
639 ... ${us_bw_profile}
640 # Verify meter for upstream bandwidth profile
641 ${meter}= Get Request VGC meters
642 ${meter_json_resp}= To Json ${meter.content}
643 Log ${meter_json_resp}
644 ${rate} ${burst_size} Get Meter Param In Details
645 ... ${meter_json_resp} 1
646 Log ${rate}
647 Log ${burst_size}
648 # for cir & cbs
649 ${matched}= Set Variable If '${rate}' == '${us_cir}' and '${burst_size}' == '${us_cbs}' True False
650 Should Be True ${matched}
651 ${res1}= Evaluate '${rate}' == '${us_cir}' and '${burst_size}' == '${us_cbs}'
652 #for pir & pbs
653 ${rate} ${burst_size} Get Meter Param In Details
654 ... ${meter_json_resp} 2
655 ${matched}= Set Variable If '${rate}' == '${us_pir}' and '${burst_size}' == '${us_pbs}' True False
656 Should Be True ${matched}
657 ${res2}= Evaluate '${rate}' == '${us_pir}' and '${burst_size}' == '${us_pbs}'
658 #for gir
659 Run Keyword if ${us_gir} != 0 Validate Guarenteed Information Rate ${us_gir} ${meter_json_resp}
660 # Get downstream bandwidth profile details
661 ${ds_cir} ${ds_cbs} ${ds_pir} ${ds_pbs} ${ds_gir} Get Bandwidth Profile Details Ietf Rest
662 ... ${ds_bw_profile}
663 # Verify meter for downstream bandwidth profile
664 ${meter}= Get Request VGC meters
665 ${meter_json_resp}= To Json ${meter.content}
666 Log ${meter_json_resp}
667 ${rate} ${burst_size} Get Meter Param In Details
668 ... ${meter_json_resp} 1
669 Log ${rate}
670 Log ${burst_size}
671 # for cir & cbs
672 ${matched}= Set Variable If '${rate}' == '${ds_cir}' and '${burst_size}' == '${ds_cbs}' True False
673 Should Be True ${matched}
674 #for pir & pbs
675 ${rate} ${burst_size} Get Meter Param In Details
676 ... ${meter_json_resp} 2
677 ${matched}= Set Variable If '${rate}' == '${ds_pir}' and '${burst_size}' == '${ds_pbs}' True False
678 Should Be True ${matched}
679 #for gir
680 Run Keyword If ${ds_gir} != 0
681 ... Validate Guarenteed Information Rate ${ds_gir} ${meter_json_resp}
682
683Validate Guarenteed Information Rate
684 [Documentation] Validate gir for both upstream and downstream meters
685 [Arguments] ${gir} ${meter_json_resp}
686 ${rate} ${burst_size} Get Meter Param In Details
687 ... ${meter_json_resp} 3
688 ${matched}= Set Variable If '${rate}' == '${gir}' and '${burst_size}' == '0' True False
689 Should Be True ${matched}
690 [Return] ${matched}
691
692Get Bandwidth Profile Details Ietf Rest
693 [Arguments] ${bw_profile_id}
694 [Documentation] Retrieves the details of the given Ietf standard based bandwidth profile using REST API
695 ${bw_profile_id}= Remove String ${bw_profile_id} ' "
696 ${resp}= Get Request VGC profiles/${bw_profile_id}
697 Log ${resp}
698 ${jsondata}= To Json ${resp.content}
Cristina de Franciscoc4cfd7e2023-10-09 10:55:08 +0200699 Should Not Be Empty ${jsondata} Could not find data for bandwidth profile ${bw_profile_id} in VGC
bharat raj58488b32023-05-11 22:46:18 +0530700 ${matched}= Set Variable False
701 ${bw_id}= Get From Dictionary ${jsondata} id
702 ${matched}= Set Variable If '${bw_id}' == '${bw_profile_id}' True False
703 ${pir}= Get From Dictionary ${jsondata} pir
704 ${pbs}= Get From Dictionary ${jsondata} pbs
705 ${cir}= Get From Dictionary ${jsondata} cir
706 ${cbs}= Get From Dictionary ${jsondata} cbs
707 ${gir}= Get From Dictionary ${jsondata} gir
708 Should Be True ${matched} No bandwidth profile found for id: ${bw_profile_id}
709 [Return] ${cir} ${cbs} ${pir} ${pbs} ${gir}
710
711
712Get Upstream and Downstream Bandwidth Profile Name
713 [Arguments] ${programmed_sub}
714 [Documentation] Retrieves the upstream and downstream bandwidth profile name
715 ... from the programmed subscriber
716 ${length}= Get Length ${programmed_sub}
717 ${matched}= Set Variable False
718 FOR ${INDEX} IN RANGE 0 ${length}
719 ${value}= Get From List ${programmed_sub} ${INDEX}
720 ${tagInfo_id}= Get From Dictionary ${value} tagInfo
721 Log ${tagInfo_id}
722 ${us_bw_profile}= Get From Dictionary ${tagInfo_id} upstreamBandwidthProfile
723 Log ${us_bw_profile}
724 ${ds_bw_profile}= Get From Dictionary ${tagInfo_id} downstreamBandwidthProfile
725 Log ${ds_bw_profile}
726 END
727 [Return] ${us_bw_profile} ${ds_bw_profile}
728
729Verify Subscriber Access Flows Added Count DT
730 [Arguments] ${ip} ${port} ${olt_of_id} ${expected_flows}
731 [Documentation] Matches for total number of subscriber access flows added for all onus
732 ${resp}= Get Request VGC flows/${olt_of_id}
733 ${jsondata}= To Json ${resp.content}
734 ${access_flows_added_count}= Get Length ${jsondata['flows']}
735 Should Be Equal As Integers ${access_flows_added_count} ${expected_flows}
736
737Get Meter Param In Details
738 [Arguments] ${meter_json} ${length}
739 [Documentation] Retrieves the meter rate state burst-size
740 ${metername}= Get From Dictionary ${meter_json} meters
741 Log ${metername}
742 ${value}= Get From List ${metername} 0
743 ${bands_info}= Get From Dictionary ${value} bands
744 Log ${bands_info}
745 FOR ${INDEX} IN RANGE 0 ${length}
746 ${value}= Get From List ${bands_info} ${INDEX}
747 ${burst_size}= Get From Dictionary ${value} burstSize
748 ${rate}= Get From Dictionary ${value} rate
749 END
750 [Return] ${rate} ${burst_size}
751
752Delete Subscribers And BW Profile In VGC
753 [Documentation] Delete Subscribers and bw profile In VGC
754 Create VGC Session
755 ${resp}= Get Request VGC programmed-subscribers
756 Log ${resp}
757 ${jsondata}= To Json ${resp.content}
758 ${length}= Get Length ${jsondata['subscribers']}
759 @{serial_numbers}= Create List
760 FOR ${INDEX} IN RANGE 0 ${length}
761 ${value}= Get From List ${jsondata['subscribers']} ${INDEX}
762 ${taginfo}= Get From Dictionary ${value} tagInfo
763 ${service_id}= Get From Dictionary ${taginfo} serviceName
764 ${upstream_bw_id}= Get From Dictionary ${taginfo} upstreamBandwidthProfile
765 ${downstream_bw_id}= Get From Dictionary ${taginfo} downstreamBandwidthProfile
766 Delete Request VGC subscribers/${service_id}
767 Delete Request VGC profiles/${upstream_bw_id}
768 Delete Request VGC profiles/${downstream_bw_id}
769 END
770
771Deactivate Subscribers In VGC
772 [Documentation] Deactivate Subscribers In VGC
773 Create VGC Session
774 ${resp}= Get Request VGC devices/ports
775 Log ${resp}
776 ${jsondata}= To Json ${resp.content}
777 ${length}= Get Length ${jsondata['ports']}
778 FOR ${INDEX} IN RANGE 0 ${length}
779 ${value}= Get From List ${jsondata['ports']} ${INDEX}
780 ${annotations}= Get From Dictionary ${value} annotations
781 ${portname}= Get From Dictionary ${annotations} portName
782 Delete Request VGC services/${portname}
783 END
784
785Verify Device Flows Removed
786 [Arguments] ${ip} ${port} ${olt_of_id}
787 [Documentation] Verifies all flows are removed from the device
788 ${resp}= Get Request VGC flows/${olt_of_id}
789 ${jsondata}= To Json ${resp.content}
790 ${flow_count}= Get Length ${jsondata['flows']}
791 Should Be Equal As Integers ${flow_count} 0 Flows not removed
792
793Device Is Available In VGC
794 [Arguments] ${olt_of_id} ${available}=true
795 [Documentation] Validates the device exists and it has the expected availability in VGC
796 ${resp}= Get Request VGC devices
797 ${jsondata}= To Json ${resp.content}
Cristina de Franciscoc4cfd7e2023-10-09 10:55:08 +0200798 Should Not Be Empty ${jsondata['devices']} No devices data found in VGC
bharat raj58488b32023-05-11 22:46:18 +0530799 ${length}= Get Length ${jsondata['devices']}
800 ${matched}= Set Variable False
801 FOR ${INDEX} IN RANGE 0 ${length}
802 ${value}= Get From List ${jsondata['devices']} ${INDEX}
803 ${of_id}= Get From Dictionary ${value} id
804 ${availability}= Get From Dictionary ${value} available
805 Log ${olt_of_id}
806 Log ${of_id}
807 ${matched}= Set Variable If '${of_id}' == '${olt_of_id}' and '${available}' == '${availability}' True False
808 Exit For Loop If ${matched}
809 END
810 Should Be True ${matched} No match for '${olt_of_id}' found
811 Should Be Equal ${available} ${availability}
812