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 | # onos 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 *** |
Kailash | 30c418f | 2019-09-11 13:50:10 -0700 | [diff] [blame] | 29 | Execute ONOS CLI Command |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 30 | [Arguments] ${host} ${port} ${cmd} |
| 31 | [Documentation] Establishes an ssh connection to the onos contoller and executes a command |
| 32 | ${conn_id}= SSHLibrary.Open Connection ${host} port=${port} prompt=onos> timeout=300s |
| 33 | SSHLibrary.Login karaf karaf |
| 34 | ${output}= SSHLibrary.Execute Command ${cmd} |
Kailash | fa025ea | 2019-09-11 11:12:54 -0700 | [diff] [blame] | 35 | Log ${output} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 36 | SSHLibrary.Close Connection |
| 37 | [Return] ${output} |
| 38 | |
| 39 | Validate OLT Device in ONOS |
Matteo Scandolo | 1294aeb | 2019-09-24 16:20:32 -0700 | [diff] [blame] | 40 | # FIXME use volt-olts to check that the OLT is ONOS |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 41 | [Arguments] ${serial_number} |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 42 | [Documentation] Checks if olt has been connected to ONOS |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 43 | ${resp}= Get Request ONOS onos/v1/devices |
| 44 | ${jsondata}= To Json ${resp.content} |
| 45 | Should Not Be Empty ${jsondata['devices']} |
| 46 | ${length}= Get Length ${jsondata['devices']} |
| 47 | @{serial_numbers}= Create List |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 48 | FOR ${INDEX} IN RANGE 0 ${length} |
| 49 | ${value}= Get From List ${jsondata['devices']} ${INDEX} |
| 50 | ${of_id}= Get From Dictionary ${value} id |
| 51 | ${sn}= Get From Dictionary ${value} serial |
| 52 | Run Keyword If '${sn}' == '${serial_number}' Exit For Loop |
| 53 | END |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 54 | Should Be Equal As Strings ${sn} ${serial_number} |
Kailash | 57210eb | 2019-08-30 13:27:19 -0700 | [diff] [blame] | 55 | [Return] ${of_id} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 56 | |
Suchitra Vemuri | 102912a | 2019-09-24 00:35:42 -0700 | [diff] [blame] | 57 | Get ONU Port in ONOS |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 58 | [Arguments] ${onu_serial_number} ${olt_of_id} |
Suchitra Vemuri | 102912a | 2019-09-24 00:35:42 -0700 | [diff] [blame] | 59 | [Documentation] Retrieves ONU port for the ONU in ONOS |
Suchitra Vemuri | a50c1c1 | 2019-09-30 19:54:26 -0700 | [diff] [blame] | 60 | ${onu_serial_number}= Catenate SEPARATOR=- ${onu_serial_number} 1 |
Suchitra Vemuri | 102912a | 2019-09-24 00:35:42 -0700 | [diff] [blame] | 61 | ${resp}= Get Request ONOS onos/v1/devices/${olt_of_id}/ports |
| 62 | ${jsondata}= To Json ${resp.content} |
| 63 | Should Not Be Empty ${jsondata['ports']} |
| 64 | ${length}= Get Length ${jsondata['ports']} |
| 65 | @{ports}= Create List |
Zack Williams | ec53a1b | 2019-09-16 15:50:52 -0700 | [diff] [blame] | 66 | FOR ${INDEX} IN RANGE 0 ${length} |
| 67 | ${value}= Get From List ${jsondata['ports']} ${INDEX} |
| 68 | ${annotations}= Get From Dictionary ${value} annotations |
| 69 | ${onu_port}= Get From Dictionary ${value} port |
| 70 | ${portName}= Get From Dictionary ${annotations} portName |
| 71 | Run Keyword If '${portName}' == '${onu_serial_number}' Exit For Loop |
| 72 | END |
Suchitra Vemuri | 102912a | 2019-09-24 00:35:42 -0700 | [diff] [blame] | 73 | Should Be Equal As Strings ${portName} ${onu_serial_number} |
| 74 | [Return] ${onu_port} |
| 75 | |
Suchitra Vemuri | 532f67a | 2019-09-25 11:50:42 -0700 | [diff] [blame] | 76 | Get FabricSwitch in ONOS |
| 77 | [Documentation] Returns of_id of the Fabric Switch in ONOS |
| 78 | ${resp}= Get Request ONOS onos/v1/devices |
| 79 | ${jsondata}= To Json ${resp.content} |
| 80 | Should Not Be Empty ${jsondata['devices']} |
| 81 | ${length}= Get Length ${jsondata['devices']} |
| 82 | FOR ${INDEX} IN RANGE 0 ${length} |
| 83 | ${value}= Get From List ${jsondata['devices']} ${INDEX} |
| 84 | ${of_id}= Get From Dictionary ${value} id |
| 85 | ${type}= Get From Dictionary ${value} type |
| 86 | Run Keyword If '${type}' == "SWITCH" Exit For Loop |
| 87 | END |
| 88 | [Return] ${of_id} |
| 89 | |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 90 | Verify Eapol Flows Added |
Andy Bavier | b0c0623 | 2019-08-29 12:58:53 -0700 | [diff] [blame] | 91 | [Arguments] ${ip} ${port} ${expected_flows} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 92 | [Documentation] Matches for number of eapol flows based on number of onus |
Gilles Depatie | 675a206 | 2019-10-22 12:44:42 -0400 | [diff] [blame] | 93 | ${eapol_flows_added}= Execute ONOS CLI Command ${ip} ${port} |
| 94 | ... flows -s -f ADDED | grep eapol | grep IN_PORT | wc -l |
Andy Bavier | b0c0623 | 2019-08-29 12:58:53 -0700 | [diff] [blame] | 95 | Should Contain ${eapol_flows_added} ${expected_flows} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 96 | |
Suchitra Vemuri | 3dd2f83 | 2019-10-18 13:14:54 -0700 | [diff] [blame] | 97 | Verify Eapol Flows Added For ONU |
| 98 | [Arguments] ${ip} ${port} ${onu_port} |
| 99 | [Documentation] Verifies if the Eapol Flows are added in ONOS for the ONU |
Gilles Depatie | 675a206 | 2019-10-22 12:44:42 -0400 | [diff] [blame] | 100 | ${eapol_flows_added}= Execute ONOS CLI Command ${ip} ${port} |
| 101 | ... flows -s -f ADDED | grep eapol | grep IN_PORT:${onu_port} |
Suchitra Vemuri | 3dd2f83 | 2019-10-18 13:14:54 -0700 | [diff] [blame] | 102 | Should Not Be Empty ${eapol_flows_added} |
| 103 | |
Suchitra Vemuri | 8a9c378 | 2019-10-23 12:43:01 -0700 | [diff] [blame] | 104 | Verify ONU in AAA-Users |
| 105 | [Arguments] ${ip} ${port} ${onu_port} |
| 106 | [Documentation] Verifies that the specified onu_port exists in aaa-users output |
| 107 | ${aaa_users}= Execute ONOS CLI Command ${ip} ${port} aaa-users | grep AUTHORIZED | grep ${onu_port} |
| 108 | Should Not Be Empty ${aaa_users} ONU port ${onu_port} not found in aaa-users |
| 109 | |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 110 | Verify Number of AAA-Users |
Kailash | 2b963f0 | 2019-08-28 22:46:33 -0700 | [diff] [blame] | 111 | [Arguments] ${ip} ${port} ${expected_onus} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 112 | [Documentation] Matches for number of aaa-users authorized based on number of onus |
Kailash | 57210eb | 2019-08-30 13:27:19 -0700 | [diff] [blame] | 113 | ##TODO: filter by onu serial number instead of count |
Kailash | 30c418f | 2019-09-11 13:50:10 -0700 | [diff] [blame] | 114 | ${aaa_users}= Execute ONOS CLI Command ${ip} ${port} aaa-users | grep AUTHORIZED | wc -l |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 115 | Should Contain ${aaa_users} ${expected_onus} |
| 116 | |
| 117 | Validate DHCP Allocations |
Kailash | 2b963f0 | 2019-08-28 22:46:33 -0700 | [diff] [blame] | 118 | [Arguments] ${ip} ${port} ${expected_onus} |
Kailash | 6f5acb6 | 2019-08-28 14:38:45 -0700 | [diff] [blame] | 119 | [Documentation] Matches for number of dhcpacks based on number of onus |
Kailash | 57210eb | 2019-08-30 13:27:19 -0700 | [diff] [blame] | 120 | ##TODO: filter by onu serial number instead of count |
Kailash | 30c418f | 2019-09-11 13:50:10 -0700 | [diff] [blame] | 121 | ${allocations}= Execute ONOS CLI Command ${ip} ${port} dhcpl2relay-allocations | grep DHCPACK | wc -l |
Suchitra Vemuri | 58766c9 | 2019-09-10 11:56:47 -0700 | [diff] [blame] | 122 | Should Contain ${allocations} ${expected_onus} |
Suchitra Vemuri | 8a9c378 | 2019-10-23 12:43:01 -0700 | [diff] [blame] | 123 | |
| 124 | Validate Subscriber DHCP Allocation |
| 125 | [Arguments] ${ip} ${port} ${onu_port} |
| 126 | [Documentation] Verifies that the specified subscriber is found in DHCP allocations |
| 127 | ##TODO: Enhance the keyword to include DHCP allocated address is not 0.0.0.0 |
Gilles Depatie | 675a206 | 2019-10-22 12:44:42 -0400 | [diff] [blame] | 128 | ${allocations}= Execute ONOS CLI Command ${ip} ${port} |
| 129 | ... dhcpl2relay-allocations | grep DHCPACK | grep ${onu_port} |
| 130 | Should Not Be Empty ${allocations} ONU port ${onu_port} not found in dhcpl2relay-allocations |