blob: 7ad15b1a4dbe6c4edd865bdb87d3b211258d0eaf [file] [log] [blame]
Kailash6f5acb62019-08-28 14:38:45 -07001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
Kailash6f5acb62019-08-28 14:38:45 -070014# voltctl common functions
15
16*** Settings ***
17Documentation Library for various utilities
18Library SSHLibrary
Kailash6f5acb62019-08-28 14:38:45 -070019Library String
20Library DateTime
21Library Process
22Library Collections
23Library RequestsLibrary
24Library OperatingSystem
25
26*** Keywords ***
Gilles Depatieb5682f82019-10-31 10:39:45 -040027Test Empty Device List
Zack Williamsa8fe75a2020-01-10 14:25:27 -070028 [Documentation] Verify that there are no devices in the system
29 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -040030 Should Be Equal As Integers ${rc} 0
31 ${jsondata}= To Json ${output}
32 Log ${jsondata}
33 ${length}= Get Length ${jsondata}
David Bainbridgef81cd642019-11-20 00:14:47 +000034 Should Be Equal As Integers ${length} 0
Gilles Depatieb5682f82019-10-31 10:39:45 -040035
Kailash6f5acb62019-08-28 14:38:45 -070036Create Device
37 [Arguments] ${ip} ${port}
You Wang2b550642019-10-07 14:39:48 -070038 [Documentation] Creates a device in VOLTHA
Kailash6f5acb62019-08-28 14:38:45 -070039 #create/preprovision device
Gilles Depatie675a2062019-10-22 12:44:42 -040040 ${rc} ${device_id}= Run and Return Rc and Output
41 ... ${VOLTCTL_CONFIG}; voltctl device create -t openolt -H ${ip}:${port}
Kailash6f5acb62019-08-28 14:38:45 -070042 Should Be Equal As Integers ${rc} 0
43 [Return] ${device_id}
44
45Enable Device
46 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -070047 [Documentation] Enables a device in VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -070048 ${rc} ${output}= Run and Return Rc and Output
49 ... ${VOLTCTL_CONFIG}; voltctl device enable ${device_id}
Kailash6f5acb62019-08-28 14:38:45 -070050 Should Be Equal As Integers ${rc} 0
51
Suchitra Vemuri6db89412019-11-14 14:52:54 -080052Disable Device
53 [Arguments] ${device_id}
54 [Documentation] Enables a device in VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -070055 ${rc} ${output}= Run and Return Rc and Output
56 ... ${VOLTCTL_CONFIG}; voltctl device disable ${device_id}
Suchitra Vemuri6db89412019-11-14 14:52:54 -080057 Should Be Equal As Integers ${rc} 0
58
David Bainbridgef81cd642019-11-20 00:14:47 +000059Disable Devices In Voltha
60 [Documentation] Disables all the known devices in voltha
61 [Arguments] ${filter}
62 ${arg}= Set Variable ${EMPTY}
63 ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070064 ${rc} ${devices}= Run and Return Rc and Output
65 ... ${VOLTCTL_CONFIG}; voltctl device list ${arg} --orderby Root -q | xargs echo -n
David Bainbridgef81cd642019-11-20 00:14:47 +000066 Should Be Equal As Integers ${rc} 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -070067 ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output
68 ... ${VOLTCTL_CONFIG}; voltctl device disable ${devices}
David Bainbridgef81cd642019-11-20 00:14:47 +000069 Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0
70
71Test Devices Disabled In Voltha
72 [Documentation] Tests to verify that all devices in VOLTHA are disabled
73 [Arguments] ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070074 ${rc} ${count}= Run and Return Rc and Output
75 ... ${VOLTCTL_CONFIG}; voltctl device list --filter '${filter},AdminState!=DISABLED' -q | wc -l
David Bainbridgef81cd642019-11-20 00:14:47 +000076 Should Be Equal As Integers ${rc} 0
77 Should Be Equal As Integers ${count} 0
78
79Delete Devices In Voltha
80 [Documentation] Disables all the known devices in voltha
81 [Arguments] ${filter}
82 ${arg}= Set Variable ${EMPTY}
83 ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter}
Zack Williamsa8fe75a2020-01-10 14:25:27 -070084 ${rc} ${devices}= Run and Return Rc and Output
85 ... ${VOLTCTL_CONFIG}; voltctl device list ${arg} --orderby Root -q | xargs echo -n
David Bainbridgef81cd642019-11-20 00:14:47 +000086 Should Be Equal As Integers ${rc} 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -070087 ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output
88 ... ${VOLTCTL_CONFIG}; voltctl device delete ${devices}
David Bainbridgef81cd642019-11-20 00:14:47 +000089 Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0
90
Suchitra Vemuri00d147d2019-09-13 13:07:32 -070091Get Device Flows from Voltha
92 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -070093 [Documentation] Gets device flows from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -070094 ${rc} ${output}= Run and Return Rc and Output
95 ... ${VOLTCTL_CONFIG}; voltctl device flows ${device_id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -070096 Should Be Equal As Integers ${rc} 0
97 [Return] ${output}
98
99Get Logical Device Output from Voltha
100 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700101 [Documentation] Gets logicaldevice flows and ports from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700102 ${rc1} ${flows}= Run and Return Rc and Output
103 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${device_id}
104 ${rc2} ${ports}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800105 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice port list ${device_id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700106 Log ${flows}
107 Log ${ports}
108 Should Be Equal As Integers ${rc1} 0
109 Should Be Equal As Integers ${rc2} 0
110
111Get Device Output from Voltha
112 [Arguments] ${device_id}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700113 [Documentation] Gets device flows and ports from VOLTHA
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700114 ${rc1} ${flows}= Run and Return Rc and Output
115 ... ${VOLTCTL_CONFIG}; voltctl device flows ${device_id}
116 ${rc2} ${ports}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800117 ... ${VOLTCTL_CONFIG}; voltctl device port list ${device_id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700118 Log ${flows}
119 Log ${ports}
120 Should Be Equal As Integers ${rc1} 0
121 Should Be Equal As Integers ${rc2} 0
122
Suchitra Vemuri1a970a62019-11-26 12:52:16 -0800123Get Device List from Voltha
124 [Documentation] Gets Device List Output from Voltha
125 ${rc1} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list
126 Log ${devices}
127 Should Be Equal As Integers ${rc1} 0
128
Kailash6f5acb62019-08-28 14:38:45 -0700129Validate Device
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700130 [Documentation]
131 ... Parses the output of "voltctl device list" and inspects device ${serial_number} and ${device_id}
Kailash6f5acb62019-08-28 14:38:45 -0700132 ... Arguments are matched for device states of: "admin_state", "oper_status", and "connect_status"
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700133 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${serial_number}=${EMPTY}
134 ... ${device_id}=${EMPTY} ${onu_reason}=${EMPTY} ${onu}=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400135 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
136 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700137 ${jsondata}= To Json ${output}
Kailash6f5acb62019-08-28 14:38:45 -0700138 ${length}= Get Length ${jsondata}
Zack Williamsec53a1b2019-09-16 15:50:52 -0700139 FOR ${INDEX} IN RANGE 0 ${length}
140 ${value}= Get From List ${jsondata} ${INDEX}
141 ${astate}= Get From Dictionary ${value} adminstate
142 ${opstatus}= Get From Dictionary ${value} operstatus
143 ${cstatus}= Get From Dictionary ${value} connectstatus
144 ${sn}= Get From Dictionary ${value} serialnumber
Gilles Depatieb5682f82019-10-31 10:39:45 -0400145 ${devId}= Get From Dictionary ${value} id
Zack Williamsec53a1b2019-09-16 15:50:52 -0700146 ${mib_state}= Get From Dictionary ${value} reason
Gilles Depatieb5682f82019-10-31 10:39:45 -0400147 Run Keyword If '${sn}' == '${serial_number}' or '${devId}' == '${device_id}' Exit For Loop
Zack Williamsec53a1b2019-09-16 15:50:52 -0700148 END
Matteo Scandolo5e10b282019-11-25 10:54:32 -0700149 Log ${value}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400150 Should Be Equal '${astate}' '${admin_state}' Device ${serial_number} admin_state != ${admin_state}
Gilles Depatie675a2062019-10-22 12:44:42 -0400151 ... values=False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700152 Should Be Equal '${opstatus}' '${oper_status}' Device ${serial_number} oper_status != ${oper_status}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400153 ... values=False
154 Should Be Equal '${cstatus}' '${connect_status}' Device ${serial_number} conn_status != ${connect_status}
155 ... values=False
156 Run Keyword If '${onu}' == 'True' Should Be Equal '${mib_state}' '${onu_reason}'
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700157 ... Device ${serial_number} mib_state incorrect (${mib_state}) values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400158
159Validate OLT Device
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700160 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${serial_number}=${EMPTY}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400161 ... ${device_id}=${EMPTY}
162 [Documentation] Parses the output of "voltctl device list" and inspects device ${serial_number} and/or
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700163 ... ${device_id} Match on OLT Serial number or Device Id and inspect states
164 Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number} ${device_id}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400165
166Validate ONU Devices
167 [Arguments] ${admin_state} ${oper_status} ${connect_status} ${List_ONU_Serial}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700168 [Documentation] Parses the output of "voltctl device list" and inspects device ${List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400169 ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect
170 ... states including MIB state
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700171 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400172 Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700173 ... onu_reason=omci-flows-pushed onu=True
Gilles Depatieb5682f82019-10-31 10:39:45 -0400174 END
175
176Validate Device Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700177 [Documentation]
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800178 ... Parses the output of voltctl device port list <device_id> and matches the port types listed
Gilles Depatieb5682f82019-10-31 10:39:45 -0400179 [Arguments] ${device_id} ${pon_type} ${ethernet_type}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700180 ${rc} ${output}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800181 ... ${VOLTCTL_CONFIG}; voltctl device port list ${device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400182 Should Be Equal As Integers ${rc} 0
183 ${jsondata}= To Json ${output}
184 Log ${jsondata}
185 ${length}= Get Length ${jsondata}
186 FOR ${INDEX} IN RANGE 0 ${length}
187 ${value}= Get From List ${jsondata} ${INDEX}
188 ${astate}= Get From Dictionary ${value} adminstate
189 ${opstatus}= Get From Dictionary ${value} operstatus
190 ${type}= Get From Dictionary ${value} type
Andy Bavier7fe983e2020-01-21 10:45:02 -0700191 #Should Be Equal '${astate}' 'ENABLED' Device ${device_id} port admin_state != ENABLED values=False
192 #Should Be Equal '${opstatus}' 'ACTIVE' Device ${device_id} port oper_status != ACTIVE values=False
Gilles Depatieb5682f82019-10-31 10:39:45 -0400193 Should Be True '${type}' == '${pon_type}' or '${type}' == '${ethernet_type}'
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700194 ... Device ${device_id} port type is neither ${pon_type} or ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400195 END
196
197Validate OLT Port Types
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800198 [Documentation] Parses the output of voltctl device port list ${olt_device_id} and matches the port types listed
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700199 [Arguments] ${pon_type} ${ethernet_type}
200 Validate Device Port Types ${olt_device_id} ${pon_type} ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400201
202Validate ONU Port Types
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700203 [Arguments] ${List_ONU_Serial} ${pon_type} ${ethernet_type}
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800204 [Documentation] Parses the output of voltctl device port list for each ONU SN listed in ${List_ONU_Serial}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700205 ... and matches the port types listed
Gilles Depatieb5682f82019-10-31 10:39:45 -0400206 FOR ${serial_number} IN @{List_ONU_Serial}
207 ${onu_dev_id}= Get Device ID From SN ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700208 Validate Device Port Types ${onu_dev_id} ${pon_type} ${ethernet_type}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400209 END
210
211Validate Device Flows
212 [Arguments] ${device_id} ${test}=${EMPTY}
213 [Documentation] Parses the output of voltctl device flows <device_id> and expects flow count > 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700214 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device flows ${device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400215 Should Be Equal As Integers ${rc} 0
216 ${jsondata}= To Json ${output}
217 Log ${jsondata}
218 ${length}= Get Length ${jsondata}
219 Log 'Number of flows = ' ${length}
220 Run Keyword If '${test}' == '${EMPTY}' Should Be True ${length} > 0
221 ... Number of flows for ${device_id} was 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700222 ... ELSE Should Be True ${length} == ${test}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400223 ... Number of flows for ${device_id} was not ${test}
224
225Validate OLT Flows
226 [Documentation] Parses the output of voltctl device flows ${olt_device_id} and expects flow count > 0
227 Validate Device Flows ${olt_device_id}
228
229Validate ONU Flows
230 [Arguments] ${List_ONU_Serial} ${test}
231 [Documentation] Parses the output of voltctl device flows for each ONU SN listed in ${List_ONU_Serial}
232 ... and expects flow count == 0
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700233 FOR ${serial_number} IN @{List_ONU_Serial}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400234 ${onu_dev_id}= Get Device ID From SN ${serial_number}
235 Validate Device Flows ${onu_dev_id} ${test}
236 END
237
238Validate Logical Device
239 [Documentation] Validate Logical Device is listed
240 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl logicaldevice list -o json
241 Should Be Equal As Integers ${rc} 0
242 ${jsondata}= To Json ${output}
243 Log ${jsondata}
244 ${length}= Get Length ${jsondata}
245 FOR ${INDEX} IN RANGE 0 ${length}
246 ${value}= Get From List ${jsondata} ${INDEX}
247 ${devid}= Get From Dictionary ${value} id
248 ${rootdev}= Get From Dictionary ${value} rootdeviceid
249 ${sn}= Get From Dictionary ${value} serialnumber
250 Exit For Loop
251 END
252 Should Be Equal '${rootdev}' '${olt_device_id}' Root Device does not match ${olt_device_id} values=False
253 Should Be Equal '${sn}' '${BBSIM_OLT_SN}' Logical Device ${sn} does not match ${BBSIM_OLT_SN}
254 ... values=False
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700255 [Return] ${devid}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400256
257Validate Logical Device Ports
258 [Arguments] ${logical_device_id}
259 [Documentation] Validate Logical Device Ports are listed and are > 0
260 ${rc} ${output}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800261 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice port list ${logical_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400262 Should Be Equal As Integers ${rc} 0
263 ${jsondata}= To Json ${output}
264 Log ${jsondata}
265 ${length}= Get Length ${jsondata}
266 Should Be True ${length} > 0 Number of ports for ${logical_device_id} was 0
267
268Validate Logical Device Flows
269 [Arguments] ${logical_device_id}
270 [Documentation] Validate Logical Device Flows are listed and are > 0
271 ${rc} ${output}= Run and Return Rc and Output
272 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${logical_device_id} -o json
273 Should Be Equal As Integers ${rc} 0
274 ${jsondata}= To Json ${output}
275 Log ${jsondata}
276 ${length}= Get Length ${jsondata}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700277 Should Be True ${length} > 0 Number of flows for ${logical_device_id} was 0
Gilles Depatieb5682f82019-10-31 10:39:45 -0400278
279Retrieve Peer List From OLT
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700280 [Arguments] ${olt_peer_list}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400281 [Documentation] Retrieve the list of peer device id list from port list
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700282 ${rc} ${output}= Run and Return Rc and Output
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800283 ... ${VOLTCTL_CONFIG}; voltctl device port list ${olt_device_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400284 Should Be Equal As Integers ${rc} 0
285 ${jsondata}= To Json ${output}
286 Log ${jsondata}
287 ${length}= Get Length ${jsondata}
288 FOR ${INDEX} IN RANGE 0 ${length}
289 ${value}= Get From List ${jsondata} ${INDEX}
290 ${type}= Get From Dictionary ${value} type
291 ${peers}= Get From Dictionary ${value} peers
292 Run Keyword If '${type}' == 'PON_OLT' Exit For Loop
293 END
294 ${length}= Get Length ${peers}
295 FOR ${INDEX} IN RANGE 0 ${length}
296 ${value}= Get From List ${peers} ${INDEX}
297 ${peer_id}= Get From Dictionary ${value} deviceid
298 Append To List ${olt_peer_list} ${peer_id}
299 END
300
301Validate OLT Peer Id List
302 [Arguments] ${olt_peer_id_list}
303 [Documentation] Match each entry in the ${olt_peer_id_list} against ONU device ids.
304 FOR ${peer_id} IN @{olt_peer_id_list}
305 Match OLT Peer Id ${peer_id}
306 END
307
308Match OLT Peer Id
309 [Arguments] ${olt_peer_id}
310 [Documentation] Lookup the OLT Peer Id in against the list of ONU device Ids
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700311 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400312 Should Be Equal As Integers ${rc} 0
313 ${jsondata}= To Json ${output}
314 Log ${jsondata}
315 ${length}= Get Length ${jsondata}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700316 FOR ${INDEX} IN RANGE 0 ${length}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400317 ${value}= Get From List ${jsondata} ${INDEX}
318 ${devid}= Get From Dictionary ${value} id
319 Run Keyword If '${devid}' == '${olt_peer_id}' Exit For Loop
320 Run Keyword If '${INDEX}' == '${length}' Fail Peer id ${olt_peer_id} does not match any ONU device id;
321 END
322
323Validate ONU Peer Id
324 [Arguments] ${olt_device_id} ${List_ONU_Serial}
325 [Documentation] Match each ONU peer to that of the OLT device id
326 FOR ${onu_serial} IN @{List_ONU_Serial}
327 ${onu_dev_id}= Get Device ID From SN ${onu_serial}
328 Match ONU Peer Id ${onu_dev_id}
329 END
330
331Match ONU Peer Id
332 [Arguments] ${onu_dev_id}
333 [Documentation] Match an ONU peer to that of the OLT device id
David K. Bainbridgebd5ebd22020-02-04 10:01:18 -0800334 ${rc} ${output}= Run and Return Rc and Output
335 ... ${VOLTCTL_CONFIG}; voltctl device port list ${onu_dev_id} -o json
Gilles Depatieb5682f82019-10-31 10:39:45 -0400336 Should Be Equal As Integers ${rc} 0
337 ${jsondata}= To Json ${output}
338 Log ${jsondata}
339 ${length}= Get Length ${jsondata}
340 FOR ${INDEX} IN RANGE 0 ${length}
341 ${value}= Get From List ${jsondata} ${INDEX}
342 ${type}= Get From Dictionary ${value} type
343 ${peers}= Get From Dictionary ${value} peers
344 Run Keyword If '${type}' == 'PON_ONU' Exit For Loop
345 END
346 ${length}= Get Length ${peers}
347 FOR ${INDEX} IN RANGE 0 ${length}
348 ${value}= Get From List ${peers} ${INDEX}
349 ${peer_id}= Get From Dictionary ${value} deviceid
350 END
351 Should Be Equal '${peer_id}' '${olt_device_id}'
352 ... Mismatch between ONU peer ${peer_id} and OLT device id ${olt_device_id} values=False
Kailash6f5acb62019-08-28 14:38:45 -0700353
Kailash6f5acb62019-08-28 14:38:45 -0700354Get Device ID From SN
355 [Arguments] ${serial_number}
356 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700357 ${rc} ${id}= Run and Return Rc and Output
Andy Bavier8fca0452019-12-16 15:30:11 -0700358 ... ${VOLTCTL_CONFIG}; voltctl device list --filter=SerialNumber=${serial_number} --format='{{.Id}}'
359 Should Be Equal As Integers ${rc} 0
360 Log ${id}
Kailash6f5acb62019-08-28 14:38:45 -0700361 [Return] ${id}
362
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700363Get Logical Device ID From SN
364 [Arguments] ${serial_number}
365 [Documentation] Gets the device id by matching for ${serial_number}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700366 ${rc} ${id}= Run and Return Rc and Output
Andy Bavier8fca0452019-12-16 15:30:11 -0700367 ... ${VOLTCTL_CONFIG}; voltctl logicaldevice list --filter=SerialNumber=${serial_number} --format='{{.Id}}'
368 Should Be Equal As Integers ${rc} 0
369 Log ${id}
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700370 [Return] ${id}
371
Gilles Depatieb5682f82019-10-31 10:39:45 -0400372Build ONU SN List
373 [Arguments] ${serial_numbers}
374 [Documentation] Appends all ONU SNs to the ${serial_numbers} list
375 FOR ${INDEX} IN RANGE 0 ${num_onus}
376 Append To List ${serial_numbers} ${hosts.src[${INDEX}].onu}
377 END
378
379Get SN From Device ID
380 [Arguments] ${device_id}
381 [Documentation] Gets the device id by matching for ${device_id}
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700382 ${rc} ${sn}= Run and Return Rc and Output
Andy Bavier8fca0452019-12-16 15:30:11 -0700383 ... ${VOLTCTL_CONFIG}; voltctl device list --filter=Id=${device_id} --format='{{.SerialNumber}}'
Gilles Depatieb5682f82019-10-31 10:39:45 -0400384 Should Be Equal As Integers ${rc} 0
Andy Bavier8fca0452019-12-16 15:30:11 -0700385 Log ${sn}
Gilles Depatieb5682f82019-10-31 10:39:45 -0400386 [Return] ${sn}
387
Scott Baker60e570d2020-02-02 22:10:13 -0800388Get Parent ID From Device ID
389 [Arguments] ${device_id}
390 [Documentation] Gets the device id by matching for ${device_id}
391 ${rc} ${pid}= Run and Return Rc and Output
392 ... ${VOLTCTL_CONFIG}; voltctl device list --filter=Id=${device_id} --format='{{.ParentId}}'
393 Should Be Equal As Integers ${rc} 0
394 Log ${pid}
395 [Return] ${pid}
396
Kailash6f5acb62019-08-28 14:38:45 -0700397Validate Device Removed
398 [Arguments] ${id}
399 [Documentation] Verifys that device, ${serial_number}, has been removed
Zack Williamsa8fe75a2020-01-10 14:25:27 -0700400 ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json
Andy Bavier8fca0452019-12-16 15:30:11 -0700401 Should Be Equal As Integers ${rc} 0
Kailash6f5acb62019-08-28 14:38:45 -0700402 ${jsondata}= To Json ${output}
403 Log ${jsondata}
404 ${length}= Get Length ${jsondata}
405 @{ids}= Create List
Zack Williamsec53a1b2019-09-16 15:50:52 -0700406 FOR ${INDEX} IN RANGE 0 ${length}
407 ${value}= Get From List ${jsondata} ${INDEX}
408 ${device_id}= Get From Dictionary ${value} id
409 Append To List ${ids} ${device_id}
410 END
Suchitra Vemuri00d147d2019-09-13 13:07:32 -0700411 List Should Not Contain Value ${ids} ${id}