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 |
You Wang | aee3511 | 2018-09-28 16:07:49 -0700 | [diff] [blame] | 20 | Resource ../../Framework/utils/utils.robot |
Kailash Khalasi | c930eac | 2018-09-05 12:18:23 -0700 | [diff] [blame] | 21 | |
| 22 | *** Keywords *** |
Suchitra Vemuri | 6357e69 | 2018-09-07 11:11:47 -0700 | [diff] [blame] | 23 | Subscriber Status Check |
| 24 | [Arguments] ${onu_device} |
| 25 | [Documentation] Returns Status from Subscribers List for a particular ONU device |
| 26 | ${json_result}= restApi.ApiGet VOLT_SUBSCRIBER |
| 27 | Log ${json_result} |
| 28 | ${json_result_list}= Get From dictionary ${json_result} items |
Suchitra Vemuri | ef98960 | 2018-09-10 13:45:26 -0700 | [diff] [blame] | 29 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} onu_device ${onu_device} |
Suchitra Vemuri | 32fc2f2 | 2018-09-10 12:06:01 -0700 | [diff] [blame] | 30 | ${status}= Get From Dictionary ${getJsonDict} status |
Suchitra Vemuri | 6357e69 | 2018-09-07 11:11:47 -0700 | [diff] [blame] | 31 | [Return] ${status} |
Kailash Khalasi | 30a6a39 | 2018-09-10 14:32:39 -0700 | [diff] [blame] | 32 | |
| 33 | Create Subscriber |
| 34 | [Arguments] ${subscriber_list} ${list_index} |
| 35 | [Documentation] Sends a POST to create a subscriber in XOS |
| 36 | ${slist} = Get Variable Value ${subscriber_list} |
| 37 | ${subscriber_dictionary}= utils.listToDict ${slist} ${list_index} |
| 38 | ${api_result}= restApi.ApiPost VOLT_SUBSCRIBER ${subscriber_dictionary} |
| 39 | Should Be True ${api_result} |
| 40 | ${Subscriber_id}= Get From Dictionary ${api_result} id |
| 41 | Set Global Variable ${Subscriber_id} |
| 42 | [Return] ${Subscriber_id} |
| 43 | |
| 44 | Retrieve Subscriber |
| 45 | [Arguments] ${ctag} |
| 46 | [Documentation] Returns the subscriber id based on the subscriber's C-Tag |
| 47 | ${json_result}= restApi.ApiGet VOLT_SUBSCRIBER |
| 48 | Log ${json_result} |
| 49 | ${json_result_list}= Get From dictionary ${json_result} items |
| 50 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} c_tag ${ctag} |
| 51 | ${id}= Get From Dictionary ${getJsonDict} id |
| 52 | [Return] ${id} |
| 53 | |
| 54 | Delete Subscriber |
| 55 | [Arguments] ${ctag} |
| 56 | [Documentation] Deletes a given subscriber based on its c_tag |
| 57 | ${id}= Retrieve Subscriber ${ctag} |
| 58 | ${api_result}= restApi.ApiChameleonDelete VOLT_SUBSCRIBER ${id} |
| 59 | Should Be True ${api_result} |
Kailash Khalasi | 052cbb1 | 2018-09-13 16:50:13 -0700 | [diff] [blame] | 60 | |
You Wang | 88e1d85 | 2018-10-05 11:44:19 -0700 | [diff] [blame] | 61 | Send EAPOL Message |
You Wang | 59ded6c | 2018-10-05 17:43:44 -0700 | [diff] [blame] | 62 | [Arguments] ${auth_pass} ${iface} ${conf_file} ${ip} ${user} ${pass}=${None} ${container_name}=${None} |
You Wang | 88e1d85 | 2018-10-05 11:44:19 -0700 | [diff] [blame] | 63 | [Documentation] Executes a particular auth request on the RG via wpa_supplicant client. Requested packet should exist on src. |
You Wang | 59ded6c | 2018-10-05 17:43:44 -0700 | [diff] [blame] | 64 | Login And Run Command On Remote System sudo rm -f /tmp/wpa.log; sudo wpa_supplicant -B -i ${iface} -Dwired -c /etc/wpa_supplicant/${conf_file} -f /tmp/wpa.log ${ip} ${user} ${pass} ${container_name} |
| 65 | Run Keyword If '${auth_pass}' == 'True' Wait Until Keyword Succeeds 30s 2s Check Remote File Contents True /tmp/wpa.log authentication completed successfully ${ip} ${user} ${pass} ${container_name} |
You Wang | 88e1d85 | 2018-10-05 11:44:19 -0700 | [diff] [blame] | 66 | Run Keyword If '${auth_pass}' == 'False' Sleep 10s |
You Wang | 59ded6c | 2018-10-05 17:43:44 -0700 | [diff] [blame] | 67 | Run Keyword If '${auth_pass}' == 'False' Check Remote File Contents False /tmp/wpa.log authentication completed successfully ${ip} ${user} ${pass} ${container_name} |
Kailash Khalasi | 6dab16e | 2018-09-17 20:24:08 -0700 | [diff] [blame] | 68 | |
| 69 | Start DHCP Server on Remote Host |
You Wang | 59ded6c | 2018-10-05 17:43:44 -0700 | [diff] [blame] | 70 | [Arguments] ${interface} ${ip} ${user} ${pass}=${None} ${container_name}=${None} |
| 71 | ${result}= Login And Run Command On Remote System sudo dhcpd -cf /etc/dhcp/dhcpd.conf ${interface} ${ip} ${user} ${pass} ${container_name} |
Kailash Khalasi | 6dab16e | 2018-09-17 20:24:08 -0700 | [diff] [blame] | 72 | Should Contain ${result} Listening on LPF/${interface} |
You Wang | 88e1d85 | 2018-10-05 11:44:19 -0700 | [diff] [blame] | 73 | |
| 74 | Delete IP Addresses from Interface on Remote Host |
You Wang | 59ded6c | 2018-10-05 17:43:44 -0700 | [diff] [blame] | 75 | [Arguments] ${interface} ${ip} ${user} ${pass}=${None} ${container_name}=${None} |
| 76 | Login And Run Command On Remote System sudo ip addr flush dev ${interface} ${ip} ${user} ${pass} ${container_name} |
You Wang | 88e1d85 | 2018-10-05 11:44:19 -0700 | [diff] [blame] | 77 | |
| 78 | Add Double Vlan Interface on Host |
You Wang | 59ded6c | 2018-10-05 17:43:44 -0700 | [diff] [blame] | 79 | [Arguments] ${interface} ${stag} ${ctag} ${ip} ${user} ${pass}=${None} ${container_name}=${None} |
| 80 | Login And Run Command On Remote System sudo ip link add link ${interface} name ${interface}.${stag} type vlan id ${stag} ${ip} ${user} ${pass} ${container_name} |
| 81 | Login And Run Command On Remote System sudo ip link set ${interface}.${stag} up ${ip} ${user} ${pass} ${container_name} |
| 82 | Login And Run Command On Remote System sudo ip link add link ${interface}.${stag} name ${interface}.${stag}.${ctag} type vlan id ${ctag} ${ip} ${user} ${pass} ${container_name} |
| 83 | Login And Run Command On Remote System sudo ip link set ${interface}.${stag}.${ctag} up ${ip} ${user} ${pass} ${container_name} |
| 84 | Login And Run Command On Remote System ifconfig ${interface}.${stag}.${ctag} ${ip} ${user} ${pass} ${container_name} |
You Wang | 88e1d85 | 2018-10-05 11:44:19 -0700 | [diff] [blame] | 85 | |
| 86 | Delete Interface on Remote Host |
You Wang | 59ded6c | 2018-10-05 17:43:44 -0700 | [diff] [blame] | 87 | [Arguments] ${interface} ${ip} ${user} ${pass}=${None} ${container_name}=${None} |
| 88 | Login And Run Command On Remote System sudo ip link del ${interface} ${ip} ${user} ${pass} ${container_name} |
You Wang | 88e1d85 | 2018-10-05 11:44:19 -0700 | [diff] [blame] | 89 | |
| 90 | Add Ip Address on Interface on Host |
You Wang | 59ded6c | 2018-10-05 17:43:44 -0700 | [diff] [blame] | 91 | [Arguments] ${ip_address} ${interface} ${ip} ${user} ${pass}=${None} ${container_name}=${None} |
| 92 | Login And Run Command On Remote System sudo ip addr add ${ip_address} dev ${interface} ${ip} ${user} ${pass} ${container_name} |
Kailash Khalasi | 6dab16e | 2018-09-17 20:24:08 -0700 | [diff] [blame] | 93 | |
| 94 | Add Route to Remote Host |
You Wang | 59ded6c | 2018-10-05 17:43:44 -0700 | [diff] [blame] | 95 | [Arguments] ${subnet} ${gateway} ${interface} ${ip} ${user} ${pass}=${None} ${container_name}=${None} |
| 96 | Login And Run Command On Remote System sudo ip route add ${subnet} via ${gateway} dev ${interface} ${ip} ${user} ${pass} ${container_name} |