blob: e9c4e570d7947cc79c659ad74a84f2c6d72c7b46 [file] [log] [blame]
TorstenThiemed4f48962020-12-08 12:17:19 +00001# Copyright 2020 - present Open Networking Foundation
TorstenThiemefd7e7ba2020-11-06 13:57:57 +00002#
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.
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000014
15*** Settings ***
16Documentation Library for various openonu-go-adpter utilities
17
TorstenThiemed4f48962020-12-08 12:17:19 +000018*** Variables ***
19${defaultstackname} minimal
20
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000021*** Keywords ***
TorstenThieme440b7c02020-12-18 15:42:57 +000022Calculate Timeout
23 [Documentation] Calculates the timeout regarding num-onus in case of more than 4 onus
24 [Arguments] ${basetimeout}=60s
25 ${new_timeout} Fetch From Left ${basetimeout} s
26 ${new_timeout}= evaluate ${new_timeout}+((${num_all_onus}-4)*10)
27 ${new_timeout}= Set Variable If (not ${debugmode}) and (${new_timeout}>300)
28 ... 300 ${new_timeout}
29 ${new_timeout}= Catenate SEPARATOR= ${new_timeout} s
30 [Return] ${new_timeout}
31
32Power On ONU Device
33 [Documentation] This keyword turns on the power for all onus.
34 [Arguments] ${namespace}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000035 FOR ${I} IN RANGE 0 ${num_all_onus}
36 ${src}= Set Variable ${hosts.src[${I}]}
Holger Hildebrandt23147742020-11-16 10:13:21 +000037 ${result}= Exec Pod In Kube ${namespace} bbsim bbsimctl onu poweron ${src['onu']}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000038 Should Contain ${result} successfully msg=Can not poweron ${src['onu']} values=False
39 END
40
TorstenThieme440b7c02020-12-18 15:42:57 +000041Power Off ONU Device
42 [Documentation] This keyword turns off the power for all onus.
43 [Arguments] ${namespace}
44 FOR ${I} IN RANGE 0 ${num_all_onus}
45 ${src}= Set Variable ${hosts.src[${I}]}
46 ${result}= Exec Pod In Kube ${namespace} bbsim bbsimctl onu shutdown ${src['onu']}
47 Should Contain ${result} successfully msg=Can not shutdown ${src['onu']} values=False
48 END
49
50Current State Test
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000051 [Documentation] This keyword checks the passed state of the given onu.
52 [Arguments] ${state} ${onu} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY}
53 ... ${reqconnectstatus}=${EMPTY}
54 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
55 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
56 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
57 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
58 ... ${connect_status}
59 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
60 ... Validate Device ${admin_state} ${oper_status} ${connect_status}
61 ... ${onu} onu=True onu_reason=${onu_state}
62
TorstenThieme440b7c02020-12-18 15:42:57 +000063Current State Test All Onus
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000064 [Documentation] This keyword checks the passed state of all onus.
65 ... Hint: ${timeStart} will be not evaluated here!
66 [Arguments] ${state} ${reqadminstate}=${EMPTY} ${reqoperstatus}=${EMPTY} ${reqconnectstatus}=${EMPTY}
67 ... ${alternativeonustate}=${EMPTY}
TorstenThieme440b7c02020-12-18 15:42:57 +000068 ${timeStart}= Get Current Date
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000069 ${list_onus} Create List
70 Build ONU SN List ${list_onus}
71 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Map State ${state}
72 ${admin_state}= Set Variable If '${reqadminstate}'!='${EMPTY}' ${reqadminstate} ${admin_state}
73 ${oper_status}= Set Variable If '${reqoperstatus}'!='${EMPTY}' ${reqoperstatus} ${oper_status}
74 ${connect_status}= Set Variable If '${reqconnectstatus}'!='${EMPTY}' ${reqconnectstatus}
75 ... ${connect_status}
76 Run Keyword And Continue On Failure Wait Until Keyword Succeeds ${timeout} 50ms
77 ... Validate ONU Devices With Duration
78 ... ${admin_state} ${oper_status} ${connect_status}
TorstenThieme52ef8392020-11-10 13:42:26 +000079 ... ${onu_state} ${list_onus} ${timeStart} alternate_reason=${alternativeonustate}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000080
TorstenThiemefd7e7ba2020-11-06 13:57:57 +000081Log Ports
82 [Documentation] This keyword logs all port data available in ONOS of first port per ONU
83 [Arguments] ${onlyenabled}=False
84 ${cmd} Set Variable If ${onlyenabled} ports -e ports
85 ${onu_ports}= Execute ONOS CLI Command on open connection ${onos_ssh_connection} ${cmd}
86 ${lines} = Get Lines Matching Regexp ${onu_ports} .*portName=BBSM[0-9]{8}-1
87 Log ${lines}
88
89Kill Adaptor
90 [Documentation] This keyword kills the passed adaptor.
91 [Arguments] ${namespace} ${name}
92 ${cmd} Catenate
93 ... kubectl exec -it -n voltha $(kubectl get pods -n ${namespace} | grep ${name} | awk 'NR==1{print $1}')
94 ... -- /bin/sh -c "kill 1"
95 ${rc} ${output}= Run and Return Rc and Output ${cmd}
96 Log ${output}
97
TorstenThieme440b7c02020-12-18 15:42:57 +000098Kill And Check Onu Adaptor
99 [Documentation] This keyword kills ONU Adaptor and waits for it to come up again
100 ... Following steps will be executed:
101 ... - kill openonu adaptor
102 ... - check openonu adaptor is ready again
103 [Arguments] ${namespace}
104 ${list_openonu_apps} Create List adapter-open-onu
105 ${adaptorname}= Set Variable open-onu
106 Kill Adaptor ${namespace} ${adaptorname}
107 Sleep 5s
108 Wait For Pods Ready ${namespace} ${list_openonu_apps}
109
110Restart And Check Onu Adaptor
111 [Documentation] This keyword restarts ONU Adaptor and waits for it to come up again
112 ... Following steps will be executed:
113 ... - restart openonu adaptor
114 ... - check openonu adaptor is ready again
115 [Arguments] ${namespace}
116 ${list_openonu_apps} Create List adapter-open-onu
117 ${adaptorname}= Set Variable open-onu
118 Restart Pod ${namespace} ${adaptorname}
119 Sleep 5s
120 Wait For Pods Ready ${namespace} ${list_openonu_apps}
121
122Disable Onu Device
123 [Documentation] This keyword disables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000124 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000125 FOR ${I} IN RANGE 0 ${num_all_onus}
126 ${src}= Set Variable ${hosts.src[${I}]}
127 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000128 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
129 Continue For Loop If -1 != ${onu_id}
130 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000131 Disable Device ${onu_device_id}
132 Wait Until Keyword Succeeds 20s 2s Test Devices Disabled in VOLTHA Id=${onu_device_id}
133 END
134
135Enable Onu Device
136 [Documentation] This keyword enables all onus.
TorstenThieme70bc5262021-01-19 12:12:55 +0000137 ${onu_list} Create List
TorstenThieme440b7c02020-12-18 15:42:57 +0000138 FOR ${I} IN RANGE 0 ${num_all_onus}
139 ${src}= Set Variable ${hosts.src[${I}]}
140 ${onu_device_id}= Get Device ID From SN ${src['onu']}
TorstenThieme70bc5262021-01-19 12:12:55 +0000141 ${onu_id}= Get Index From List ${onu_list} ${onu_device_id}
142 Continue For Loop If -1 != ${onu_id}
143 Append To List ${onu_list} ${onu_device_id}
TorstenThieme440b7c02020-12-18 15:42:57 +0000144 Enable Device ${onu_device_id}
145 END
146
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000147Verify MIB Template Data Available
148 [Documentation] This keyword verifies MIB Template Data stored in etcd
149 ${namespace}= Set Variable default
TorstenThiemed4f48962020-12-08 12:17:19 +0000150 ${podname}= Set Variable etcd
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000151 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800152 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000153 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000154 Should Not Be Empty ${result} No MIB Template Data stored in etcd!
155
156Delete MIB Template Data
157 [Documentation] This keyword deletes MIB Template Data stored in etcd
158 ${namespace}= Set Variable default
159 ${podname}= Set Variable etcd
160 ${commanddel} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800161 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000162 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commanddel}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000163 Sleep 3s
164 ${commandget} Catenate
Matteo Scandolo341b9372020-12-09 14:15:06 -0800165 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/omci_mibs/go_templates/'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000166 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000167 Should Be Empty ${result} Could not delete MIB Template Data stored in etcd!
168
TorstenThieme440b7c02020-12-18 15:42:57 +0000169Set Tech Profile
170 [Documentation] This keyword sets the passed TechProfile for the test
171 [Arguments] ${TechProfile}
172 Log To Console \nTechProfile:${TechProfile}
173 ${namespace}= Set Variable default
174 ${podname}= Set Variable etcd
175 ${src}= Set Variable ${data_dir}/TechProfile-${TechProfile}.json
176 ${dest}= Set Variable /tmp/flexpod.json
177 ${command} Catenate
178 ... /bin/sh -c 'cat ${dest} | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64'
179 Copy File To Pod ${namespace} ${podname} ${src} ${dest}
180 Exec Pod In Kube ${namespace} ${podname} ${command}
181 ${commandget} Catenate
182 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
183 Exec Pod In Kube ${namespace} ${podname} ${commandget}
184
185Remove Tech Profile
186 [Documentation] This keyword removes TechProfile
187 Log To Console \nTechProfile:${TechProfile}
188 ${namespace}= Set Variable default
189 ${podname}= Set Variable etcd
190 ${command} Catenate
191 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl del --prefix service/voltha/technology_profiles/XGS-PON/64'
192 Exec Pod In Kube ${namespace} ${podname} ${command}
193 ${commandget} Catenate
194 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64'
195 Exec Pod In Kube ${namespace} ${podname} ${commandget}
196
TorstenThieme17756ea2020-11-11 14:09:47 +0000197Validate Onu Data In Etcd
198 [Documentation] This keyword validates openonu-go-adapter Data stored in etcd.
199 ... It checks unique of serial_number and combination of pon, onu and uni in tp_path.
200 ... Furthermore it evaluates the values of onu_id and uni_id with values read from tp_path.
201 ... Number of etcd entries has to match with the passed number.
202 [Arguments] ${nbofetcddata}=${num_all_onus}
TorstenThiemed4f48962020-12-08 12:17:19 +0000203 ${stackname}= Get Stack Name
TorstenThieme17756ea2020-11-11 14:09:47 +0000204 ${etcddata}= Get ONU Go Adapter ETCD Data
TorstenThiemed4f48962020-12-08 12:17:19 +0000205 ${etcddata}= Remove Lines Containing String ${etcddata} service/${stackname}/openonu \n
TorstenThieme17756ea2020-11-11 14:09:47 +0000206 #prepare result for json convert
207 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
208 ${jsondata}= To Json ${result}
209 ${length}= Get Length ${jsondata}
210 log ${jsondata}
211 Run Keyword And Continue On Failure Should Be Equal As Integers ${length} ${nbofetcddata}
212 ... msg=Number etcd data (${length}) does not match required (${nbofetcddata})!
213 ${pononuuniidlist}= Create List
214 ${serialnumberlist}= Create List
215 FOR ${INDEX} IN RANGE 0 ${length}
216 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra97f8d062020-11-17 15:48:23 -0800217 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
218 # When testing multi-tcont this may need some adjustment.
219 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000220 ${pononuuniid}= Read Pon Onu Uni String ${tp_path}
221 ${list_id}= Get Index From List ${pononuuniidlist} ${pononuuniid}
222 Should Be Equal As Integers ${list_id} -1
223 ... msg=Combination of Pon, Onu and Uni (${pononuuniid}) exist multiple in etcd data!
224 Append To List ${pononuuniidlist} ${pononuuniid}
225 Validate Onu Id ${value}
226 Validate Uni Id ${value}
227 ${serial_number}= Get From Dictionary ${value} serial_number
228 ${list_id}= Get Index From List ${serialnumberlist} ${serial_number}
229 Should Be Equal As Integers ${list_id} -1
230 ... msg=Serial number (${serial_number}) exists multiple in etcd data!
231 Append To List ${serialnumberlist} ${serial_number}
232 END
233
TorstenThieme52ef8392020-11-10 13:42:26 +0000234Validate Vlan Rules In Etcd
235 [Documentation] This keyword validates Vlan rules of openonu-go-adapter Data stored in etcd.
236 ... It checks the given number of cookie_slice, match_vid (=4096) and set_vid.
237 ... Furthermore it returns a list of all set_vid.
238 ... In case of a passed dictionary containing set_vids these will be checked for to
239 ... current set-vid depending on setvidequal (True=equal, False=not equal).
240 [Arguments] ${nbofcookieslice}=1 ${reqmatchvid}=4096 ${prevvlanrules}=${NONE} ${setvidequal}=False
TorstenThiemed4f48962020-12-08 12:17:19 +0000241 ${stackname}= Get Stack Name
TorstenThieme52ef8392020-11-10 13:42:26 +0000242 ${etcddata}= Get ONU Go Adapter ETCD Data
TorstenThiemed4f48962020-12-08 12:17:19 +0000243 ${etcddata}= Remove Lines Containing String ${etcddata} service/${stackname}/openonu \n
TorstenThieme52ef8392020-11-10 13:42:26 +0000244 #prepare result for json convert
245 ${result}= Prepare ONU Go Adapter ETCD Data For Json ${etcddata}
246 ${jsondata}= To Json ${result}
247 ${length}= Get Length ${jsondata}
248 log ${jsondata}
249 ${vlan_rules}= Create Dictionary
250 FOR ${INDEX} IN RANGE 0 ${length}
251 ${value}= Get From List ${jsondata} ${INDEX}
Girish Gowdra295c1692020-11-19 10:51:53 -0800252 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
253 # When testing multi-tcont this may need some adjustment.
254 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme52ef8392020-11-10 13:42:26 +0000255 ${pononuuniid}= Read Pon Onu Uni String ${tp_path}
256 ${cookieslice}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]} cookie_slice
257 #@{cookieslicelist}= Split String ${cookieslice} ,
258 ${foundcookieslices}= Get Length ${cookieslice}
259 Should Be Equal As Integers ${foundcookieslices} ${nbofcookieslice}
260 ${matchvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
261 ... match_vid
262 Should Be Equal As Integers ${matchvid} ${reqmatchvid}
263 ${setvid}= Get From Dictionary ${value['uni_config'][0]['flow_params'][0]['vlan_rule_params']}
264 ... set_vid
265 ${evalresult}= Evaluate 2 <= ${setvid} <= 4095
266 Should Be True ${evalresult} msg=set_vid out of range (${setvid})!
267 Set To Dictionary ${vlan_rules} ${pononuuniid} ${setvid}
268 ${oldsetvidvalid} Set Variable If ${prevvlanrules} is ${NONE} False True
269 ${prevsetvid}= Set Variable If ${oldsetvidvalid} ${prevvlanrules['${pononuuniid}']}
270 Run Keyword If ${oldsetvidvalid} and ${setvidequal}
271 ... Should Be Equal As Integers ${prevsetvid} ${setvid}
272 ... ELSE IF ${oldsetvidvalid} and not ${setvidequal}
273 ... Should Not Be Equal As Integers ${prevsetvid} ${setvid}
274 END
TorstenThieme440b7c02020-12-18 15:42:57 +0000275 log Many ${vlan_rules}
TorstenThieme52ef8392020-11-10 13:42:26 +0000276 [Return] ${vlan_rules}
277
278Get ONU Go Adapter ETCD Data
279 [Documentation] This keyword delivers openonu-go-adapter Data stored in etcd
280 ${namespace}= Set Variable default
281 ${podname}= Set Variable etcd
TorstenThiemed4f48962020-12-08 12:17:19 +0000282 ${stackname}= Get Stack Name
TorstenThieme52ef8392020-11-10 13:42:26 +0000283 ${commandget} Catenate
TorstenThiemed4f48962020-12-08 12:17:19 +0000284 ... /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix --prefix service/${stackname}/openonu'
Holger Hildebrandt23147742020-11-16 10:13:21 +0000285 ${result}= Exec Pod In Kube ${namespace} ${podname} ${commandget}
TorstenThieme52ef8392020-11-10 13:42:26 +0000286 log ${result}
287 [Return] ${result}
288
289Prepare ONU Go Adapter ETCD Data For Json
290 [Documentation] This keyword prepares openonu-go-adapter Data stored in etcd for converting
291 ... to json
292 [Arguments] ${etcddata}
293 #prepare result for json convert
294 ${prepresult}= Replace String ${etcddata} \n ,
295 ${prepresult}= Strip String ${prepresult} mode=right characters=,
296 ${prepresult}= Set Variable [${prepresult}]
297 log ${prepresult}
298 [Return] ${prepresult}
299
300Remove Lines Containing String
301 [Documentation] This keyword deletes all lines from given string containing passed remove string
302 [Arguments] ${string} ${toremove} ${appendtoremoveline}
303 ${lines}= Get Lines Containing String ${string} ${toremove}
304 ${length}= Get Line Count ${lines}
305 ${firstline}= Set Variable False
306 FOR ${INDEX} IN RANGE 0 ${length}
307 ${String2remove} Get Line ${lines} ${INDEX}
308 ${String2remove} Set Variable ${String2remove}${appendtoremoveline}
309 ${string}= Remove String ${string} ${String2remove}
310 END
311 log ${string}
312 [Return] ${string}
313
314Read Pon Onu Uni String
315 [Documentation] This keyword builds a thre digit string using Pon, Onu and Uni value of given tp-path taken
316 ... taken from etcd data of onu go adapter
317 [Arguments] ${tp_path}
TorstenThieme52ef8392020-11-10 13:42:26 +0000318 ${tppathlines}= Replace String ${tp_path} / \n
319 ${pon}= Get Value Of Tp Path Element ${tppathlines} pon
320 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
321 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
322 ${valuesid}= Set Variable ${pon}/${onu}/${uni}
323 log ${valuesid}
324 [Return] ${valuesid}
325
326Get Value Of Tp Path Element
TorstenThieme17756ea2020-11-11 14:09:47 +0000327 [Documentation] This keyword delivers numeric value of given tp path element.
TorstenThieme52ef8392020-11-10 13:42:26 +0000328 [Arguments] ${tp_path_lines} ${element}
329 ${value}= Get Lines Containing String ${tp_path_lines} ${element}-\{
330 ${value}= Remove String ${value} ${element}-\{
331 ${value}= Remove String ${value} \}
332 log ${value}
333 [Return] ${value}
334
TorstenThieme17756ea2020-11-11 14:09:47 +0000335Validate Onu Id
336 [Documentation] This keyword validates ONU Id of passed etcd data.
337 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800338 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
339 # When testing multi-tcont this may need some adjustment.
340 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000341 ${tppathlines}= Replace String ${tp_path} / \n
342 ${onu}= Get Value Of Tp Path Element ${tppathlines} onu
343 ${onu_id}= Get From Dictionary ${value} onu_id
344 Should Be Equal As Integers ${onu} ${onu_id}
345 ... msg=Onu-Id (${onu_id}) does not match onu (${onu}) from tp_path in etcd data!
346 Should Be True ${onu_id}>=1
347
348Validate Uni Id
349 [Documentation] This keyword validates UNI Id of passed etcd data.
350 [Arguments] ${value}
Girish Gowdra295c1692020-11-19 10:51:53 -0800351 # TODO: The TP ID is hardcoded to 64 below. It is fine when testing single-tcont workflow.
352 # When testing multi-tcont this may need some adjustment.
353 ${tp_path}= Get From Dictionary ${value['uni_config'][0]['PersTpPathMap']} 64
TorstenThieme17756ea2020-11-11 14:09:47 +0000354 ${tppathlines}= Replace String ${tp_path} / \n
355 ${uni}= Get Value Of Tp Path Element ${tppathlines} uni
356 ${uni_id}= Get From Dictionary ${value['uni_config'][0]} uni_id
357 Should Be Equal As Integers ${uni} ${uni_id}
358 ... msg=Uni-Id (${uni_id}) does not match onu (${uni}) from tp_path in etcd data!
TorstenThieme52ef8392020-11-10 13:42:26 +0000359
TorstenThiemed4f48962020-12-08 12:17:19 +0000360Get Stack Name
361 [Documentation] This keyword delivers the stack name read from environment variable NAME if present.
362 ${env_name}= Get Environment Variable NAME default=${defaultstackname}
363 # while Get Environment Variable does not work correctly, a manual correction follows
364 ${env_name}= Set Variable If "${env_name}"=="${EMPTY}" ${defaultstackname} ${env_name}
365 [Return] ${env_name}
366
367Wait for Ports in ONOS for all OLTs
TorstenThieme440b7c02020-12-18 15:42:57 +0000368 [Documentation] Waits untill a certain number of ports are enabled in all OLTs
TorstenThiemed4f48962020-12-08 12:17:19 +0000369 [Arguments] ${onos_ssh_connection} ${count} ${filter} ${max_wait_time}=10m
370 FOR ${J} IN RANGE 0 ${num_olts}
371 ${olt_serial_number}= Set Variable ${list_olts}[${J}][sn]
372 ${onu_count}= Set Variable ${list_olts}[${J}][onucount]
373 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
374 ... ${olt_serial_number}
375 Set Global Variable ${of_id}
376 Wait for Ports in ONOS ${onos_ssh_connection} ${count} ${of_id} BBSM ${max_wait_time}
377 END
378
TorstenThieme440b7c02020-12-18 15:42:57 +0000379Wait for all ONU Ports in ONOS Disabled
380 [Documentation] Waits untill a all ONU ports are disabled in all ONOS
381 [Arguments] ${onos_ssh_connection}
382 FOR ${I} IN RANGE 0 ${num_all_onus}
383 ${src}= Set Variable ${hosts.src[${I}]}
384 ${of_id}= Wait Until Keyword Succeeds ${timeout} 15s Validate OLT Device in ONOS
385 ... ${src['olt']}
386 ${onu_port}= Wait Until Keyword Succeeds ${timeout} 2s Get ONU Port in ONOS ${src['onu']} ${of_id}
387 Wait Until Keyword Succeeds ${timeout} 2s Assert ONU Port Is Disabled ${onos_ssh_connection} ${of_id}
388 ... ${onu_port}
389 END
390
TorstenThiemefd7e7ba2020-11-06 13:57:57 +0000391Map State
392 [Documentation] This keyword converts the passed numeric value or name of a onu state to its state values.
393 [Arguments] ${state}
394 # create state lists with corresponding return values
395 # ADMIN-STATE OPER-STATUS CONNECT-STATUS ONU-STATE (number/name)
396 ${state1} Create List ENABLED ACTIVATING REACHABLE 1 activating-onu
397 ${state2} Create List ENABLED ACTIVATING REACHABLE 2 starting-openomci
398 ${state3} Create List ENABLED ACTIVATING REACHABLE 3 discovery-mibsync-complete
399 ${state4} Create List ENABLED ACTIVE REACHABLE 4 initial-mib-downloaded
400 ${state5} Create List ENABLED ACTIVE REACHABLE 5 tech-profile-config-download-success
401 ${state6} Create List ENABLED ACTIVE REACHABLE 6 omci-flows-pushed
402 ${state7} Create List DISABLED UNKNOWN REACHABLE 7 omci-admin-lock
403 ${state8} Create List ENABLED ACTIVE REACHABLE 8 onu-reenabled
404 ${state9} Create List ENABLED DISCOVERED UNREACHABLE 9 stopping-openomci
405 ${state10} Create List ENABLED DISCOVERED REACHABLE 10 rebooting
406 ${state11} Create List ENABLED DISCOVERED REACHABLE 11 omci-flows-deleted
407 ${state12} Create List DISABLED UNKNOWN REACHABLE 12 tech-profile-config-delete-success
408 ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}= Set Variable If
409 ... '${state}'=='1' or '${state}'=='activating-onu' ${state1}
410 ... '${state}'=='2' or '${state}'=='starting-openomci' ${state2}
411 ... '${state}'=='3' or '${state}'=='discovery-mibsync-complete' ${state3}
412 ... '${state}'=='4' or '${state}'=='initial-mib-downloaded' ${state4}
413 ... '${state}'=='5' or '${state}'=='tech-profile-config-download-success' ${state5}
414 ... '${state}'=='6' or '${state}'=='omci-flows-pushed' ${state6}
415 ... '${state}'=='7' or '${state}'=='omci-admin-lock' ${state7}
416 ... '${state}'=='8' or '${state}'=='onu-reenabled' ${state8}
417 ... '${state}'=='9' or '${state}'=='stopping-openomci' ${state9}
418 ... '${state}'=='10' or '${state}'=='rebooting' ${state10}
419 ... '${state}'=='11' or '${state}'=='omci-flows-deleted' ${state11}
420 ... '${state}'=='12' or '${state}'=='tech-profile-config-delete-success' ${state12}
421 [Return] ${admin_state} ${oper_status} ${connect_status} ${onu_state_nb} ${onu_state}