uwe ottrembka | 504ca3e | 2020-11-23 12:02:20 +0100 | [diff] [blame] | 1 | # Copyright 2020 Open Networking Foundation |
| 2 | # delivered by ADTRAN, Inc. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | *** Settings *** |
| 17 | Documentation Library for basics of the dmi definition |
| 18 | Library Collections |
| 19 | Library BuiltIn |
| 20 | |
| 21 | *** Variables *** |
| 22 | |
| 23 | *** Keywords *** |
| 24 | Get Managed Devices |
| 25 | [Documentation] search and return for known/active devices |
| 26 | [Arguments] ${lib_instance} |
| 27 | ${name_active_olts}= Create List |
| 28 | ${response}= Run Keyword ${lib_instance}.Hw Management Service Get Managed Devices |
| 29 | ${size}= Get Length ${response} |
| 30 | Return From Keyword If ${size} == ${0} ${name_active_olts} |
| 31 | ${devices}= Get From Dictionary ${response} devices |
| 32 | FOR ${device} IN @{devices} |
| 33 | ${name}= Get From Dictionary ${device} name |
| 34 | Append To List ${name_active_olts} ${name} |
| 35 | END |
| 36 | [Return] ${name_active_olts} |
| 37 | |
| 38 | Stop Managing Devices |
| 39 | [Documentation] remove given devices from device manager |
| 40 | [Arguments] ${lib_instance} ${name_active_olts} |
| 41 | FOR ${device_name} IN @{name_active_olts} |
| 42 | &{name}= Evaluate {'name':'${device_name}'} |
| 43 | Run Keyword ${lib_instance}.Hw Management Service Stop Managing Device ${name} |
| 44 | END |
| 45 | |
| 46 | Search For Managed Devices And Stop Managing It |
| 47 | [Documentation] search for known/active devices and remove it from device manager |
| 48 | [Arguments] ${lib_instance} |
| 49 | Run Keyword ${lib_instance}.Connection Open ${DEVICEMANAGER_IP} ${DEVICEMANAGER_PORT} |
| 50 | ${active_devices}= Get Managed Devices ${lib_instance} |
| 51 | ${size}= Get Length ${active_devices} |
| 52 | Run Keyword If ${size} != ${0} Stop Managing Devices ${lib_instance} ${active_devices} |
| 53 | Run Keyword If ${size} != ${0} Fail test case '${PREV_TEST_NAME}' failed! |
| 54 | ${active_devices}= Get Managed Devices ${lib_instance} |
| 55 | Should Be Empty ${active_devices} |
| 56 | Run Keyword ${lib_instance}.Connection Close |
| 57 | |
| 58 | Increment If Equal |
| 59 | [Documentation] increment given value if condition 1 and condition 2 is equal |
| 60 | [Arguments] ${condition_1} ${condition_2} ${value} |
| 61 | ${value}= Set Variable If ${condition_1} == ${condition_2} |
| 62 | ... ${value+1} ${value} |
| 63 | [Return] ${value} |
| 64 | |
| 65 | Increment If Contained |
| 66 | [Documentation] increment given value 'string' contained in 'message' |
| 67 | [Arguments] ${message} ${string} ${value} |
| 68 | ${hit}= Run Keyword And Return Status Should Contain ${message} ${string} |
| 69 | ${value}= Increment If Equal ${hit} ${True} ${value} |
| 70 | [Return] ${value} |
| 71 | |
| 72 | Start Managing Device |
| 73 | [Documentation] add a given device to the device manager |
| 74 | [Arguments] ${lib_instance} ${olt_ip} ${device_name} ${check_result}=${True} |
| 75 | ${dev_name}= Convert To String ${device_name} |
| 76 | &{component}= Evaluate {'name':'${dev_name}', 'uri':{'uri':'${olt_ip}'}} |
| 77 | ${response}= Run Keyword ${lib_instance}.Hw Management Service Start Managing Device ${component} |
| 78 | ${list}= Get From List ${response} 0 |
| 79 | Run Keyword If ${check_result} == ${True} Should Be Equal ${list}[status] OK_STATUS |
| 80 | ${uuid}= Get From Dictionary ${list} device_uuid |
| 81 | [Return] ${uuid} |
| 82 | |
| 83 | Stop Managing Device |
| 84 | [Documentation] remove a given device from the device manager |
| 85 | [Arguments] ${lib_instance} ${device_name} ${check_result}=${True} |
| 86 | &{name}= Evaluate {'name':'${device_name}'} |
| 87 | ${response}= Run Keyword ${lib_instance}.Hw Management Service Stop Managing Device ${name} |
| 88 | Run Keyword If ${check_result} == ${True} Should Be Equal ${response}[status] OK_STATUS |
| 89 | |
| 90 | Check Dmi Status |
| 91 | [Documentation] check if the given state in the given result |
| 92 | [Arguments] ${result} ${state} |
| 93 | ${state_in_result}= Get From Dictionary ${result} status |
| 94 | Should Be Equal ${state} ${state_in_result} |