Kailash Khalasi | c930eac | 2018-09-05 12:18:23 -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 | *** Settings *** |
Suchitra Vemuri | 6357e69 | 2018-09-07 11:11:47 -0700 | [diff] [blame] | 16 | Documentation Library of functions related to RG (source host) |
Kailash Khalasi | c930eac | 2018-09-05 12:18:23 -0700 | [diff] [blame] | 17 | Library OperatingSystem |
| 18 | Library SSHLibrary |
Suchitra Vemuri | ef98960 | 2018-09-10 13:45:26 -0700 | [diff] [blame] | 19 | Library restApi.py |
Kailash Khalasi | c930eac | 2018-09-05 12:18:23 -0700 | [diff] [blame] | 20 | |
| 21 | *** Keywords *** |
| 22 | Send EAPOL Message |
| 23 | [Arguments] ${ip} ${user} ${pass} ${iface} ${conf_file} ${prompt}=$ ${prompt_timeout}=60s |
| 24 | [Documentation] SSH's into the RG (src) and executes a particular auth request via wpa_supplicant client. Requested packet should exist on src. |
| 25 | ${conn_id}= SSHLibrary.Open Connection ${ip} prompt=${prompt} timeout=${prompt_timeout} |
Kailash Khalasi | e030eee | 2018-09-10 09:19:46 -0700 | [diff] [blame] | 26 | SSHLibrary.Login ${user} ${pass} |
Kailash Khalasi | 449388f | 2018-09-06 16:52:22 -0700 | [diff] [blame] | 27 | SSHLibrary.Write sudo wpa_supplicant -B -i ${iface} -Dwired -c /etc/wpa_supplicant/${conf_file} |
Kailash Khalasi | c930eac | 2018-09-05 12:18:23 -0700 | [diff] [blame] | 28 | Read Until [sudo] password for ${user}: |
| 29 | SSHLibrary.Write ${pass} |
Kailash Khalasi | 6dab16e | 2018-09-17 20:24:08 -0700 | [diff] [blame] | 30 | ${result}= Read Until wpa_supplicant |
| 31 | Log To Console \n\n ${result}\n |
Kailash Khalasi | c930eac | 2018-09-05 12:18:23 -0700 | [diff] [blame] | 32 | SSHLibrary.Close Connection |
Kailash Khalasi | e030eee | 2018-09-10 09:19:46 -0700 | [diff] [blame] | 33 | Should Contain ${result} Successfully initialized wpa_supplicant |
Suchitra Vemuri | 6357e69 | 2018-09-07 11:11:47 -0700 | [diff] [blame] | 34 | [Return] ${result} |
| 35 | |
Kailash Khalasi | 6dab16e | 2018-09-17 20:24:08 -0700 | [diff] [blame] | 36 | Delete IP Addresses from Interface on Remote Host |
| 37 | [Arguments] ${ip} ${user} ${pass} ${interface} ${prompt}=$ ${prompt_timeout}=60s |
| 38 | ${conn_id}= SSHLibrary.Open Connection ${ip} prompt=${prompt} timeout=${prompt_timeout} |
| 39 | SSHLibrary.Login ${user} ${pass} |
| 40 | SSHLibrary.Write sudo ip addr flush dev ${interface}; echo $? |
| 41 | Read Until [sudo] password for ${user}: |
| 42 | SSHLibrary.Write ${pass} |
| 43 | ${result}= Read Until ${prompt} |
| 44 | SSHLibrary.Close Connection |
| 45 | |
Suchitra Vemuri | 6357e69 | 2018-09-07 11:11:47 -0700 | [diff] [blame] | 46 | Subscriber Status Check |
| 47 | [Arguments] ${onu_device} |
| 48 | [Documentation] Returns Status from Subscribers List for a particular ONU device |
| 49 | ${json_result}= restApi.ApiGet VOLT_SUBSCRIBER |
| 50 | Log ${json_result} |
| 51 | ${json_result_list}= Get From dictionary ${json_result} items |
Suchitra Vemuri | ef98960 | 2018-09-10 13:45:26 -0700 | [diff] [blame] | 52 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} onu_device ${onu_device} |
Suchitra Vemuri | 32fc2f2 | 2018-09-10 12:06:01 -0700 | [diff] [blame] | 53 | ${status}= Get From Dictionary ${getJsonDict} status |
Suchitra Vemuri | 6357e69 | 2018-09-07 11:11:47 -0700 | [diff] [blame] | 54 | [Return] ${status} |
Kailash Khalasi | 30a6a39 | 2018-09-10 14:32:39 -0700 | [diff] [blame] | 55 | |
| 56 | Create Subscriber |
| 57 | [Arguments] ${subscriber_list} ${list_index} |
| 58 | [Documentation] Sends a POST to create a subscriber in XOS |
| 59 | ${slist} = Get Variable Value ${subscriber_list} |
| 60 | ${subscriber_dictionary}= utils.listToDict ${slist} ${list_index} |
| 61 | ${api_result}= restApi.ApiPost VOLT_SUBSCRIBER ${subscriber_dictionary} |
| 62 | Should Be True ${api_result} |
| 63 | ${Subscriber_id}= Get From Dictionary ${api_result} id |
| 64 | Set Global Variable ${Subscriber_id} |
| 65 | [Return] ${Subscriber_id} |
| 66 | |
| 67 | Retrieve Subscriber |
| 68 | [Arguments] ${ctag} |
| 69 | [Documentation] Returns the subscriber id based on the subscriber's C-Tag |
| 70 | ${json_result}= restApi.ApiGet VOLT_SUBSCRIBER |
| 71 | Log ${json_result} |
| 72 | ${json_result_list}= Get From dictionary ${json_result} items |
| 73 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} c_tag ${ctag} |
| 74 | ${id}= Get From Dictionary ${getJsonDict} id |
| 75 | [Return] ${id} |
| 76 | |
| 77 | Delete Subscriber |
| 78 | [Arguments] ${ctag} |
| 79 | [Documentation] Deletes a given subscriber based on its c_tag |
| 80 | ${id}= Retrieve Subscriber ${ctag} |
| 81 | ${api_result}= restApi.ApiChameleonDelete VOLT_SUBSCRIBER ${id} |
| 82 | Should Be True ${api_result} |
Kailash Khalasi | 052cbb1 | 2018-09-13 16:50:13 -0700 | [diff] [blame] | 83 | |
Kailash Khalasi | 6dab16e | 2018-09-17 20:24:08 -0700 | [diff] [blame] | 84 | Add Double Vlan Interface on Host |
| 85 | [Arguments] ${ip} ${user} ${pass} ${interface} ${stag} ${ctag} ${prompt}=$ ${prompt_timeout}=60s |
Kailash Khalasi | 052cbb1 | 2018-09-13 16:50:13 -0700 | [diff] [blame] | 86 | ${conn_id}= SSHLibrary.Open Connection ${ip} prompt=${prompt} timeout=${prompt_timeout} |
| 87 | SSHLibrary.Login ${user} ${pass} |
Kailash Khalasi | 6dab16e | 2018-09-17 20:24:08 -0700 | [diff] [blame] | 88 | SSHLibrary.Write sudo ip link add link ${interface} name ${interface}.${stag} type vlan id ${stag} |
| 89 | Read Until [sudo] password for ${user}: |
| 90 | SSHLibrary.Write ${pass} |
| 91 | SSHLibrary.Write sudo ip link set ${interface}.${stag} up |
| 92 | ${result}= Read Until ${prompt} |
| 93 | SSHLibrary.Write sudo ip link add link ${interface}.${stag} name ${interface}.${stag}.${ctag} type vlan id ${ctag} |
| 94 | ${result}= Read Until ${prompt} |
| 95 | SSHLibrary.Write sudo ip link set ${interface}.${stag}.${ctag} up |
| 96 | ${result}= Read Until ${prompt} |
| 97 | SSHLibrary.Write ifconfig ${interface}.${stag}.${ctag} |
| 98 | ${result}= Read Until ${prompt} |
| 99 | SSHLibrary.Close Connection |
| 100 | |
| 101 | Delete Interface on Remote Host |
| 102 | [Arguments] ${ip} ${user} ${pass} ${interface} ${prompt}=$ ${prompt_timeout}=60s |
| 103 | ${conn_id}= SSHLibrary.Open Connection ${ip} prompt=${prompt} timeout=${prompt_timeout} |
| 104 | SSHLibrary.Login ${user} ${pass} |
| 105 | SSHLibrary.Write sudo ip link del ${interface} |
| 106 | Read Until [sudo] password for ${user}: |
| 107 | SSHLibrary.Write ${pass} |
| 108 | Read Until ${prompt} |
| 109 | SSHLibrary.Close Connection |
| 110 | |
| 111 | Add Ip Address on Interface on Host |
| 112 | [Arguments] ${ip} ${user} ${pass} ${ip_address} ${interface} ${prompt}=$ ${prompt_timeout}=60s |
| 113 | ${conn_id}= SSHLibrary.Open Connection ${ip} prompt=${prompt} timeout=${prompt_timeout} |
| 114 | SSHLibrary.Login ${user} ${pass} |
| 115 | SSHLibrary.Write sudo ip addr add ${ip_address} dev ${interface} |
| 116 | Read Until [sudo] password for ${user}: |
| 117 | SSHLibrary.Write ${pass} |
| 118 | Read Until ${prompt} |
| 119 | SSHLibrary.Close Connection |
| 120 | |
| 121 | Start DHCP Server on Remote Host |
| 122 | [Arguments] ${ip} ${user} ${pass} ${interface} ${prompt}=$ ${prompt_timeout}=60s |
| 123 | ${conn_id}= SSHLibrary.Open Connection ${ip} prompt=${prompt} timeout=${prompt_timeout} |
| 124 | SSHLibrary.Login ${user} ${pass} |
| 125 | SSHLibrary.Write sudo dhcpd -cf /etc/dhcp/dhcpd.conf ${interface} |
Kailash Khalasi | 052cbb1 | 2018-09-13 16:50:13 -0700 | [diff] [blame] | 126 | Read Until [sudo] password for ${user}: |
| 127 | SSHLibrary.Write ${pass} |
| 128 | ${result}= Read Until ${prompt} |
Kailash Khalasi | 6dab16e | 2018-09-17 20:24:08 -0700 | [diff] [blame] | 129 | Should Contain ${result} Listening on LPF/${interface} |
Kailash Khalasi | 052cbb1 | 2018-09-13 16:50:13 -0700 | [diff] [blame] | 130 | SSHLibrary.Close Connection |
Kailash Khalasi | 6dab16e | 2018-09-17 20:24:08 -0700 | [diff] [blame] | 131 | |
| 132 | Add Route to Remote Host |
| 133 | [Arguments] ${ip} ${user} ${pass} ${subnet} ${gateway} ${interface} ${prompt}=$ ${prompt_timeout}=60s |
| 134 | ${conn_id}= SSHLibrary.Open Connection ${ip} prompt=${prompt} timeout=${prompt_timeout} |
| 135 | SSHLibrary.Login ${user} ${pass} |
| 136 | SSHLibrary.Write sudo ip route add ${subnet} via ${gateway} dev ${interface} |
| 137 | Read Until [sudo] password for ${user}: |
| 138 | SSHLibrary.Write ${pass} |
| 139 | ${result}= Read Until ${prompt} |
| 140 | SSHLibrary.Close Connection |