You Wang | 0c2b366 | 2018-10-01 16:56:17 -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 | |
Suchitra Vemuri | 2c73426 | 2018-09-06 14:34:42 -0700 | [diff] [blame] | 15 | *** Settings *** |
| 16 | Documentation Library to check the status in ONU List |
| 17 | Library Collections |
| 18 | Library String |
| 19 | Library OperatingSystem |
| 20 | Library XML |
| 21 | Library RequestsLibrary |
Suchitra Vemuri | ef98960 | 2018-09-10 13:45:26 -0700 | [diff] [blame] | 22 | Library utils/utils.py |
| 23 | Library restApi.py |
Suchitra Vemuri | 2c73426 | 2018-09-06 14:34:42 -0700 | [diff] [blame] | 24 | |
| 25 | *** Keywords *** |
| 26 | ONU Status Check |
| 27 | [Arguments] ${onu_device} |
| 28 | [Documentation] Returns "operational_status" and "admin_status" of a particular ONU device from "onu device list" |
| 29 | ${json_result}= restApi.ApiGet ONU_DEVICE |
| 30 | Log ${json_result} |
| 31 | ${json_result_list}= Get From dictionary ${json_result} items |
| 32 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} serial_number ${onu_device} |
| 33 | ${operational_status}= Get From Dictionary ${getJsonDict} oper_status |
| 34 | ${admin_status}= Get From Dictionary ${getJsonDict} admin_state |
| 35 | [Return] ${operational_status} ${admin_status} |
Kailash Khalasi | 30a6a39 | 2018-09-10 14:32:39 -0700 | [diff] [blame] | 36 | |
| 37 | Create ONU Device |
| 38 | [Arguments] ${device_list} ${list_index} |
| 39 | [Documentation] Sends a POST to create an att whitelist in XOS |
| 40 | ${dlist} = Get Variable Value ${device_list} |
| 41 | ${onu_dictionary}= utils.listToDict ${dlist} ${list_index} |
| 42 | ${api_result}= restApi.ApiPost ONU_DEVICE ${onu_dictionary} |
| 43 | Should Be True ${api_result} |
| 44 | |
Kailash Khalasi | 16d95c1 | 2018-09-21 14:17:28 -0700 | [diff] [blame] | 45 | Retrieve ONU Device |
| 46 | [Arguments] ${serial_number} |
| 47 | [Documentation] Returns the onu device id based on the onu's serial number |
| 48 | ${json_result}= restApi.ApiGet ONU_DEVICE |
| 49 | Log ${json_result} |
| 50 | Log To Console ${json_result} |
| 51 | ${json_result_list}= Get From dictionary ${json_result} items |
| 52 | ${getJsonDict}= utils.getDictFromListOfDict ${json_result_list} serial_number ${serial_number} |
| 53 | ${id}= Get From Dictionary ${getJsonDict} id |
| 54 | [Return] ${id} |
| 55 | |
Kailash Khalasi | 30a6a39 | 2018-09-10 14:32:39 -0700 | [diff] [blame] | 56 | Delete ONU Device |
| 57 | [Arguments] ${id} |
| 58 | [Documentation] Sends a DELETE to delete an onu device in XOS |
| 59 | ${api_result}= restApi.ApiChameleonDelete ONU_DEVICE ${id} |
Kailash Khalasi | 16d95c1 | 2018-09-21 14:17:28 -0700 | [diff] [blame] | 60 | Should Be True ${api_result} |
You Wang | 5be816a | 2018-10-11 16:45:31 -0700 | [diff] [blame] | 61 | |
| 62 | Validate ONU States |
| 63 | [Arguments] ${expected_op_status} ${expected_admin_status} ${onu_device} |
| 64 | ${operational_status} ${admin_status} ONU Status Check ${onu_device} |
| 65 | Should Be Equal ${operational_status} ${expected_op_status} |
| 66 | Should Be Equal ${admin_status} ${expected_admin_status} |