Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 1 | # 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 | |
| 15 | # voltctl common functions |
| 16 | |
| 17 | *** Settings *** |
| 18 | Documentation Library for various utilities |
| 19 | Library SSHLibrary |
| 20 | Library HttpLibrary.HTTP |
| 21 | Library String |
| 22 | Library DateTime |
| 23 | Library Process |
| 24 | Library Collections |
| 25 | Library RequestsLibrary |
| 26 | Library OperatingSystem |
| 27 | |
| 28 | *** Keywords *** |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 29 | Test Empty Device List |
| 30 | [Documentation] Verify that there are no devices in the system |
| 31 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json |
| 32 | Should Be Equal As Integers ${rc} 0 |
| 33 | ${jsondata}= To Json ${output} |
| 34 | Log ${jsondata} |
| 35 | ${length}= Get Length ${jsondata} |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 36 | Should Be Equal As Integers ${length} 0 |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 37 | |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 38 | Create Device |
| 39 | [Arguments] ${ip} ${port} |
You Wang | 2b55064 | 2019-10-07 14:39:48 -0700 | [diff] [blame] | 40 | [Documentation] Creates a device in VOLTHA |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 41 | #create/preprovision device |
Gilles Depatie | 675a206 | 2019-10-22 12:44:42 -0400 | [diff] [blame] | 42 | ${rc} ${device_id}= Run and Return Rc and Output |
| 43 | ... ${VOLTCTL_CONFIG}; voltctl device create -t openolt -H ${ip}:${port} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 44 | Should Be Equal As Integers ${rc} 0 |
| 45 | [Return] ${device_id} |
| 46 | |
| 47 | Enable Device |
| 48 | [Arguments] ${device_id} |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 49 | [Documentation] Enables a device in VOLTHA |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 50 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device enable ${device_id} |
| 51 | Should Be Equal As Integers ${rc} 0 |
| 52 | |
Suchitra Vemuri | 6db8941 | 2019-11-14 14:52:54 -0800 | [diff] [blame] | 53 | Disable Device |
| 54 | [Arguments] ${device_id} |
| 55 | [Documentation] Enables a device in VOLTHA |
| 56 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device disable ${device_id} |
| 57 | Should Be Equal As Integers ${rc} 0 |
| 58 | |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 59 | Disable 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} |
| 64 | ${rc} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list ${arg} --orderby Root -q | xargs echo -n |
| 65 | Should Be Equal As Integers ${rc} 0 |
| 66 | ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device disable ${devices} |
| 67 | Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0 |
| 68 | |
| 69 | Test Devices Disabled In Voltha |
| 70 | [Documentation] Tests to verify that all devices in VOLTHA are disabled |
| 71 | [Arguments] ${filter} |
| 72 | ${rc} ${count}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list --filter '${filter},AdminState!=DISABLED' -q | wc -l |
| 73 | Should Be Equal As Integers ${rc} 0 |
| 74 | Should Be Equal As Integers ${count} 0 |
| 75 | |
| 76 | Delete Devices In Voltha |
| 77 | [Documentation] Disables all the known devices in voltha |
| 78 | [Arguments] ${filter} |
| 79 | ${arg}= Set Variable ${EMPTY} |
| 80 | ${arg}= Run Keyword If len('${filter}'.strip()) != 0 Set Variable --filter ${filter} |
| 81 | ${rc} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list ${arg} --orderby Root -q | xargs echo -n |
| 82 | Should Be Equal As Integers ${rc} 0 |
| 83 | ${rc} ${output}= Run Keyword If len('${devices}') != 0 Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device delete ${devices} |
| 84 | Run Keyword If len('${devices}') != 0 Should Be Equal As Integers ${rc} 0 |
| 85 | |
Suchitra Vemuri | 00d147d | 2019-09-13 13:07:32 -0700 | [diff] [blame] | 86 | Get Device Flows from Voltha |
| 87 | [Arguments] ${device_id} |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 88 | [Documentation] Gets device flows from VOLTHA |
Suchitra Vemuri | 00d147d | 2019-09-13 13:07:32 -0700 | [diff] [blame] | 89 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device flows ${device_id} |
| 90 | Should Be Equal As Integers ${rc} 0 |
| 91 | [Return] ${output} |
| 92 | |
| 93 | Get Logical Device Output from Voltha |
| 94 | [Arguments] ${device_id} |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 95 | [Documentation] Gets logicaldevice flows and ports from VOLTHA |
Suchitra Vemuri | 00d147d | 2019-09-13 13:07:32 -0700 | [diff] [blame] | 96 | ${rc1} ${flows}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${device_id} |
| 97 | ${rc2} ${ports}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl logicaldevice ports ${device_id} |
| 98 | Log ${flows} |
| 99 | Log ${ports} |
| 100 | Should Be Equal As Integers ${rc1} 0 |
| 101 | Should Be Equal As Integers ${rc2} 0 |
| 102 | |
| 103 | Get Device Output from Voltha |
| 104 | [Arguments] ${device_id} |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 105 | [Documentation] Gets device flows and ports from VOLTHA |
Suchitra Vemuri | 00d147d | 2019-09-13 13:07:32 -0700 | [diff] [blame] | 106 | ${rc1} ${flows}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device flows ${device_id} |
| 107 | ${rc2} ${ports}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device ports ${device_id} |
| 108 | Log ${flows} |
| 109 | Log ${ports} |
| 110 | Should Be Equal As Integers ${rc1} 0 |
| 111 | Should Be Equal As Integers ${rc2} 0 |
| 112 | |
Suchitra Vemuri | 1a970a6 | 2019-11-26 12:52:16 -0800 | [diff] [blame] | 113 | Get Device List from Voltha |
| 114 | [Documentation] Gets Device List Output from Voltha |
| 115 | ${rc1} ${devices}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list |
| 116 | Log ${devices} |
| 117 | Should Be Equal As Integers ${rc1} 0 |
| 118 | |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 119 | Validate Device |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 120 | [Arguments] ${admin_state} ${oper_status} ${connect_status} ${serial_number}=${EMPTY} ${device_id}=${EMPTY} |
| 121 | ... ${onu_reason}=${EMPTY} ${onu}=False |
| 122 | [Documentation] Parses the output of "voltctl device list" and inspects device ${serial_number} and ${device_id} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 123 | ... Arguments are matched for device states of: "admin_state", "oper_status", and "connect_status" |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 124 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json |
| 125 | Should Be Equal As Integers ${rc} 0 |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 126 | ${jsondata}= To Json ${output} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 127 | ${length}= Get Length ${jsondata} |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 128 | FOR ${INDEX} IN RANGE 0 ${length} |
| 129 | ${value}= Get From List ${jsondata} ${INDEX} |
| 130 | ${astate}= Get From Dictionary ${value} adminstate |
| 131 | ${opstatus}= Get From Dictionary ${value} operstatus |
| 132 | ${cstatus}= Get From Dictionary ${value} connectstatus |
| 133 | ${sn}= Get From Dictionary ${value} serialnumber |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 134 | ${devId}= Get From Dictionary ${value} id |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 135 | ${mib_state}= Get From Dictionary ${value} reason |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 136 | Run Keyword If '${sn}' == '${serial_number}' or '${devId}' == '${device_id}' Exit For Loop |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 137 | END |
Matteo Scandolo | 5e10b28 | 2019-11-25 10:54:32 -0700 | [diff] [blame] | 138 | Log ${value} |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 139 | Should Be Equal '${astate}' '${admin_state}' Device ${serial_number} admin_state != ${admin_state} |
Gilles Depatie | 675a206 | 2019-10-22 12:44:42 -0400 | [diff] [blame] | 140 | ... values=False |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 141 | Should Be Equal '${opstatus}' '${oper_status}' Device ${serial_number} oper_status != ${oper_status} |
| 142 | ... values=False |
| 143 | Should Be Equal '${cstatus}' '${connect_status}' Device ${serial_number} conn_status != ${connect_status} |
| 144 | ... values=False |
| 145 | Run Keyword If '${onu}' == 'True' Should Be Equal '${mib_state}' '${onu_reason}' |
| 146 | ... Device ${serial_number} mib_state incorrect (${mib_state}) values=False |
| 147 | |
| 148 | Validate OLT Device |
| 149 | [Arguments] ${admin_state} ${oper_status} ${connect_status} ${serial_number}=${EMPTY} |
| 150 | ... ${device_id}=${EMPTY} |
| 151 | [Documentation] Parses the output of "voltctl device list" and inspects device ${serial_number} and/or |
| 152 | ... ${device_id} Match on OLT Serial number or Device Id and inspect states |
| 153 | Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number} ${device_id} |
| 154 | |
| 155 | Validate ONU Devices |
| 156 | [Arguments] ${admin_state} ${oper_status} ${connect_status} ${List_ONU_Serial} |
| 157 | [Documentation] Parses the output of "voltctl device list" and inspects device ${List_ONU_Serial} |
| 158 | ... Iteratively match on each Serial number contained in ${List_ONU_Serial} and inspect |
| 159 | ... states including MIB state |
| 160 | FOR ${serial_number} IN @{List_ONU_Serial} |
| 161 | Validate Device ${admin_state} ${oper_status} ${connect_status} ${serial_number} |
| 162 | ... onu_reason=omci-flows-pushed onu=True |
| 163 | END |
| 164 | |
| 165 | Validate Device Port Types |
| 166 | [Arguments] ${device_id} ${pon_type} ${ethernet_type} |
| 167 | [Documentation] Parses the output of voltctl device ports <device_id> and matches the port types listed |
| 168 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device ports ${device_id} -o json |
| 169 | Should Be Equal As Integers ${rc} 0 |
| 170 | ${jsondata}= To Json ${output} |
| 171 | Log ${jsondata} |
| 172 | ${length}= Get Length ${jsondata} |
| 173 | FOR ${INDEX} IN RANGE 0 ${length} |
| 174 | ${value}= Get From List ${jsondata} ${INDEX} |
| 175 | ${astate}= Get From Dictionary ${value} adminstate |
| 176 | ${opstatus}= Get From Dictionary ${value} operstatus |
| 177 | ${type}= Get From Dictionary ${value} type |
| 178 | Should Be Equal '${astate}' 'ENABLED' Device ${device_id} port admin_state != ENABLED values=False |
| 179 | Should Be Equal '${opstatus}' 'ACTIVE' Device ${device_id} port oper_status != ACTIVE values=False |
| 180 | Should Be True '${type}' == '${pon_type}' or '${type}' == '${ethernet_type}' |
| 181 | ... Device ${device_id} port type is neither ${pon_type} or ${ethernet_type} |
| 182 | END |
| 183 | |
| 184 | Validate OLT Port Types |
| 185 | [Documentation] Parses the output of voltctl device ports ${olt_device_id} and matches the port types listed |
| 186 | [Arguments] ${pon_type} ${ethernet_type} |
| 187 | Validate Device Port Types ${olt_device_id} ${pon_type} ${ethernet_type} |
| 188 | |
| 189 | Validate ONU Port Types |
| 190 | [Arguments] ${List_ONU_Serial} ${pon_type} ${ethernet_type} |
| 191 | [Documentation] Parses the output of voltctl device ports for each ONU SN listed in ${List_ONU_Serial} |
| 192 | ... and matches the port types listed |
| 193 | FOR ${serial_number} IN @{List_ONU_Serial} |
| 194 | ${onu_dev_id}= Get Device ID From SN ${serial_number} |
| 195 | Validate Device Port Types ${onu_dev_id} ${pon_type} ${ethernet_type} |
| 196 | END |
| 197 | |
| 198 | Validate Device Flows |
| 199 | [Arguments] ${device_id} ${test}=${EMPTY} |
| 200 | [Documentation] Parses the output of voltctl device flows <device_id> and expects flow count > 0 |
| 201 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device flows ${device_id} -o json |
| 202 | Should Be Equal As Integers ${rc} 0 |
| 203 | ${jsondata}= To Json ${output} |
| 204 | Log ${jsondata} |
| 205 | ${length}= Get Length ${jsondata} |
| 206 | Log 'Number of flows = ' ${length} |
| 207 | Run Keyword If '${test}' == '${EMPTY}' Should Be True ${length} > 0 |
| 208 | ... Number of flows for ${device_id} was 0 |
| 209 | ... ELSE Should Be True ${length} == ${test} |
| 210 | ... Number of flows for ${device_id} was not ${test} |
| 211 | |
| 212 | Validate OLT Flows |
| 213 | [Documentation] Parses the output of voltctl device flows ${olt_device_id} and expects flow count > 0 |
| 214 | Validate Device Flows ${olt_device_id} |
| 215 | |
| 216 | Validate ONU Flows |
| 217 | [Arguments] ${List_ONU_Serial} ${test} |
| 218 | [Documentation] Parses the output of voltctl device flows for each ONU SN listed in ${List_ONU_Serial} |
| 219 | ... and expects flow count == 0 |
| 220 | FOR ${serial_number} IN @{List_ONU_Serial} |
| 221 | ${onu_dev_id}= Get Device ID From SN ${serial_number} |
| 222 | Validate Device Flows ${onu_dev_id} ${test} |
| 223 | END |
| 224 | |
| 225 | Validate Logical Device |
| 226 | [Documentation] Validate Logical Device is listed |
| 227 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl logicaldevice list -o json |
| 228 | Should Be Equal As Integers ${rc} 0 |
| 229 | ${jsondata}= To Json ${output} |
| 230 | Log ${jsondata} |
| 231 | ${length}= Get Length ${jsondata} |
| 232 | FOR ${INDEX} IN RANGE 0 ${length} |
| 233 | ${value}= Get From List ${jsondata} ${INDEX} |
| 234 | ${devid}= Get From Dictionary ${value} id |
| 235 | ${rootdev}= Get From Dictionary ${value} rootdeviceid |
| 236 | ${sn}= Get From Dictionary ${value} serialnumber |
| 237 | Exit For Loop |
| 238 | END |
| 239 | Should Be Equal '${rootdev}' '${olt_device_id}' Root Device does not match ${olt_device_id} values=False |
| 240 | Should Be Equal '${sn}' '${BBSIM_OLT_SN}' Logical Device ${sn} does not match ${BBSIM_OLT_SN} |
| 241 | ... values=False |
| 242 | [Return] ${devid} |
| 243 | |
| 244 | Validate Logical Device Ports |
| 245 | [Arguments] ${logical_device_id} |
| 246 | [Documentation] Validate Logical Device Ports are listed and are > 0 |
| 247 | ${rc} ${output}= Run and Return Rc and Output |
| 248 | ... ${VOLTCTL_CONFIG}; voltctl logicaldevice ports ${logical_device_id} -o json |
| 249 | Should Be Equal As Integers ${rc} 0 |
| 250 | ${jsondata}= To Json ${output} |
| 251 | Log ${jsondata} |
| 252 | ${length}= Get Length ${jsondata} |
| 253 | Should Be True ${length} > 0 Number of ports for ${logical_device_id} was 0 |
| 254 | |
| 255 | Validate Logical Device Flows |
| 256 | [Arguments] ${logical_device_id} |
| 257 | [Documentation] Validate Logical Device Flows are listed and are > 0 |
| 258 | ${rc} ${output}= Run and Return Rc and Output |
| 259 | ... ${VOLTCTL_CONFIG}; voltctl logicaldevice flows ${logical_device_id} -o json |
| 260 | Should Be Equal As Integers ${rc} 0 |
| 261 | ${jsondata}= To Json ${output} |
| 262 | Log ${jsondata} |
| 263 | ${length}= Get Length ${jsondata} |
| 264 | Should Be True ${length} > 0 Number of flows for ${logical_device_id} was 0 |
| 265 | |
| 266 | Retrieve Peer List From OLT |
| 267 | [Arguments] ${olt_peer_list} |
| 268 | [Documentation] Retrieve the list of peer device id list from port list |
| 269 | ${rc} ${output}= Run and Return Rc and Output |
| 270 | ... ${VOLTCTL_CONFIG}; voltctl device ports ${olt_device_id} -o json |
| 271 | Should Be Equal As Integers ${rc} 0 |
| 272 | ${jsondata}= To Json ${output} |
| 273 | Log ${jsondata} |
| 274 | ${length}= Get Length ${jsondata} |
| 275 | FOR ${INDEX} IN RANGE 0 ${length} |
| 276 | ${value}= Get From List ${jsondata} ${INDEX} |
| 277 | ${type}= Get From Dictionary ${value} type |
| 278 | ${peers}= Get From Dictionary ${value} peers |
| 279 | Run Keyword If '${type}' == 'PON_OLT' Exit For Loop |
| 280 | END |
| 281 | ${length}= Get Length ${peers} |
| 282 | FOR ${INDEX} IN RANGE 0 ${length} |
| 283 | ${value}= Get From List ${peers} ${INDEX} |
| 284 | ${peer_id}= Get From Dictionary ${value} deviceid |
| 285 | Append To List ${olt_peer_list} ${peer_id} |
| 286 | END |
| 287 | |
| 288 | Validate OLT Peer Id List |
| 289 | [Arguments] ${olt_peer_id_list} |
| 290 | [Documentation] Match each entry in the ${olt_peer_id_list} against ONU device ids. |
| 291 | FOR ${peer_id} IN @{olt_peer_id_list} |
| 292 | Match OLT Peer Id ${peer_id} |
| 293 | END |
| 294 | |
| 295 | Match OLT Peer Id |
| 296 | [Arguments] ${olt_peer_id} |
| 297 | [Documentation] Lookup the OLT Peer Id in against the list of ONU device Ids |
| 298 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json |
| 299 | Should Be Equal As Integers ${rc} 0 |
| 300 | ${jsondata}= To Json ${output} |
| 301 | Log ${jsondata} |
| 302 | ${length}= Get Length ${jsondata} |
| 303 | FOR ${INDEX} IN RANGE 0 ${length} |
| 304 | ${value}= Get From List ${jsondata} ${INDEX} |
| 305 | ${devid}= Get From Dictionary ${value} id |
| 306 | Run Keyword If '${devid}' == '${olt_peer_id}' Exit For Loop |
| 307 | Run Keyword If '${INDEX}' == '${length}' Fail Peer id ${olt_peer_id} does not match any ONU device id; |
| 308 | END |
| 309 | |
| 310 | Validate ONU Peer Id |
| 311 | [Arguments] ${olt_device_id} ${List_ONU_Serial} |
| 312 | [Documentation] Match each ONU peer to that of the OLT device id |
| 313 | FOR ${onu_serial} IN @{List_ONU_Serial} |
| 314 | ${onu_dev_id}= Get Device ID From SN ${onu_serial} |
| 315 | Match ONU Peer Id ${onu_dev_id} |
| 316 | END |
| 317 | |
| 318 | Match ONU Peer Id |
| 319 | [Arguments] ${onu_dev_id} |
| 320 | [Documentation] Match an ONU peer to that of the OLT device id |
| 321 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device ports ${onu_dev_id} -o json |
| 322 | Should Be Equal As Integers ${rc} 0 |
| 323 | ${jsondata}= To Json ${output} |
| 324 | Log ${jsondata} |
| 325 | ${length}= Get Length ${jsondata} |
| 326 | FOR ${INDEX} IN RANGE 0 ${length} |
| 327 | ${value}= Get From List ${jsondata} ${INDEX} |
| 328 | ${type}= Get From Dictionary ${value} type |
| 329 | ${peers}= Get From Dictionary ${value} peers |
| 330 | Run Keyword If '${type}' == 'PON_ONU' Exit For Loop |
| 331 | END |
| 332 | ${length}= Get Length ${peers} |
| 333 | FOR ${INDEX} IN RANGE 0 ${length} |
| 334 | ${value}= Get From List ${peers} ${INDEX} |
| 335 | ${peer_id}= Get From Dictionary ${value} deviceid |
| 336 | END |
| 337 | Should Be Equal '${peer_id}' '${olt_device_id}' |
| 338 | ... Mismatch between ONU peer ${peer_id} and OLT device id ${olt_device_id} values=False |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 339 | |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 340 | Get Device ID From SN |
| 341 | [Arguments] ${serial_number} |
| 342 | [Documentation] Gets the device id by matching for ${serial_number} |
| 343 | ${output}= Run ${VOLTCTL_CONFIG}; voltctl device list -o json |
| 344 | ${jsondata}= To Json ${output} |
| 345 | Log ${jsondata} |
| 346 | ${length}= Get Length ${jsondata} |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 347 | FOR ${INDEX} IN RANGE 0 ${length} |
| 348 | ${value}= Get From List ${jsondata} ${INDEX} |
| 349 | ${id}= Get From Dictionary ${value} id |
| 350 | ${sn}= Get From Dictionary ${value} serialnumber |
| 351 | Run Keyword If '${sn}' == '${serial_number}' Exit For Loop |
| 352 | END |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 353 | [Return] ${id} |
| 354 | |
Suchitra Vemuri | 00d147d | 2019-09-13 13:07:32 -0700 | [diff] [blame] | 355 | Get Logical Device ID From SN |
| 356 | [Arguments] ${serial_number} |
| 357 | [Documentation] Gets the device id by matching for ${serial_number} |
| 358 | ${output}= Run ${VOLTCTL_CONFIG}; voltctl device list -o json |
| 359 | ${jsondata}= To Json ${output} |
| 360 | Log ${jsondata} |
| 361 | ${length}= Get Length ${jsondata} |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 362 | FOR ${INDEX} IN RANGE 0 ${length} |
| 363 | ${value}= Get From List ${jsondata} ${INDEX} |
| 364 | ${id}= Get From Dictionary ${value} parentid |
| 365 | ${sn}= Get From Dictionary ${value} serialnumber |
| 366 | Run Keyword If '${sn}' == '${serial_number}' Exit For Loop |
| 367 | END |
Suchitra Vemuri | 00d147d | 2019-09-13 13:07:32 -0700 | [diff] [blame] | 368 | [Return] ${id} |
| 369 | |
Gilles Depatie | b5682f8 | 2019-10-31 10:39:45 -0400 | [diff] [blame] | 370 | Build ONU SN List |
| 371 | [Arguments] ${serial_numbers} |
| 372 | [Documentation] Appends all ONU SNs to the ${serial_numbers} list |
| 373 | FOR ${INDEX} IN RANGE 0 ${num_onus} |
| 374 | Append To List ${serial_numbers} ${hosts.src[${INDEX}].onu} |
| 375 | END |
| 376 | |
| 377 | Get SN From Device ID |
| 378 | [Arguments] ${device_id} |
| 379 | [Documentation] Gets the device id by matching for ${device_id} |
| 380 | ${rc} ${output}= Run and Return Rc and Output ${VOLTCTL_CONFIG}; voltctl device list -o json |
| 381 | Should Be Equal As Integers ${rc} 0 |
| 382 | ${jsondata}= To Json ${output} |
| 383 | Log ${jsondata} |
| 384 | ${length}= Get Length ${jsondata} |
| 385 | FOR ${INDEX} IN RANGE 0 ${length} |
| 386 | ${value}= Get From List ${jsondata} ${INDEX} |
| 387 | ${id}= Get From Dictionary ${value} id |
| 388 | ${sn}= Get From Dictionary ${value} serialnumber |
| 389 | Run Keyword If '${id}' == '${device_id}' Exit For Loop |
| 390 | END |
| 391 | [Return] ${sn} |
| 392 | |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 393 | Validate Device Removed |
| 394 | [Arguments] ${id} |
| 395 | [Documentation] Verifys that device, ${serial_number}, has been removed |
| 396 | ${output}= Run ${VOLTCTL_CONFIG}; voltctl device list -o json |
| 397 | ${jsondata}= To Json ${output} |
| 398 | Log ${jsondata} |
| 399 | ${length}= Get Length ${jsondata} |
| 400 | @{ids}= Create List |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 401 | FOR ${INDEX} IN RANGE 0 ${length} |
| 402 | ${value}= Get From List ${jsondata} ${INDEX} |
| 403 | ${device_id}= Get From Dictionary ${value} id |
| 404 | Append To List ${ids} ${device_id} |
| 405 | END |
Suchitra Vemuri | 00d147d | 2019-09-13 13:07:32 -0700 | [diff] [blame] | 406 | List Should Not Contain Value ${ids} ${id} |