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} |
| 30 | ${result}= Read Until ${prompt} |
| 31 | SSHLibrary.Close Connection |
Kailash Khalasi | e030eee | 2018-09-10 09:19:46 -0700 | [diff] [blame] | 32 | Should Contain ${result} Successfully initialized wpa_supplicant |
Suchitra Vemuri | 6357e69 | 2018-09-07 11:11:47 -0700 | [diff] [blame] | 33 | [Return] ${result} |
| 34 | |
| 35 | Subscriber Status Check |
| 36 | [Arguments] ${onu_device} |
| 37 | [Documentation] Returns Status from Subscribers List for a particular ONU device |
| 38 | ${json_result}= restApi.ApiGet VOLT_SUBSCRIBER |
| 39 | Log ${json_result} |
| 40 | ${json_result_list}= Get From dictionary ${json_result} items |
Suchitra Vemuri | ef98960 | 2018-09-10 13:45:26 -0700 | [diff] [blame] | 41 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} onu_device ${onu_device} |
Suchitra Vemuri | 32fc2f2 | 2018-09-10 12:06:01 -0700 | [diff] [blame] | 42 | ${status}= Get From Dictionary ${getJsonDict} status |
Suchitra Vemuri | 6357e69 | 2018-09-07 11:11:47 -0700 | [diff] [blame] | 43 | [Return] ${status} |
Kailash Khalasi | 30a6a39 | 2018-09-10 14:32:39 -0700 | [diff] [blame] | 44 | |
| 45 | Create Subscriber |
| 46 | [Arguments] ${subscriber_list} ${list_index} |
| 47 | [Documentation] Sends a POST to create a subscriber in XOS |
| 48 | ${slist} = Get Variable Value ${subscriber_list} |
| 49 | ${subscriber_dictionary}= utils.listToDict ${slist} ${list_index} |
| 50 | ${api_result}= restApi.ApiPost VOLT_SUBSCRIBER ${subscriber_dictionary} |
| 51 | Should Be True ${api_result} |
| 52 | ${Subscriber_id}= Get From Dictionary ${api_result} id |
| 53 | Set Global Variable ${Subscriber_id} |
| 54 | [Return] ${Subscriber_id} |
| 55 | |
| 56 | Retrieve Subscriber |
| 57 | [Arguments] ${ctag} |
| 58 | [Documentation] Returns the subscriber id based on the subscriber's C-Tag |
| 59 | ${json_result}= restApi.ApiGet VOLT_SUBSCRIBER |
| 60 | Log ${json_result} |
| 61 | ${json_result_list}= Get From dictionary ${json_result} items |
| 62 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} c_tag ${ctag} |
| 63 | ${id}= Get From Dictionary ${getJsonDict} id |
| 64 | [Return] ${id} |
| 65 | |
| 66 | Delete Subscriber |
| 67 | [Arguments] ${ctag} |
| 68 | [Documentation] Deletes a given subscriber based on its c_tag |
| 69 | ${id}= Retrieve Subscriber ${ctag} |
| 70 | ${api_result}= restApi.ApiChameleonDelete VOLT_SUBSCRIBER ${id} |
| 71 | Should Be True ${api_result} |