David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 1 | # Copyright 2019-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 | # voltha common functions |
| 16 | |
| 17 | *** Settings *** |
| 18 | Documentation Library for various utilities |
| 19 | Library SSHLibrary |
| 20 | Library HttpLibrary.HTTP |
| 21 | Library String |
| 22 | Library DateTime |
| 23 | Library Process |
| 24 | Library Collections |
| 25 | Library RequestsLibrary |
| 26 | Library OperatingSystem |
| 27 | |
| 28 | *** Keywords *** |
| 29 | Lookup Pod That Owns Device |
| 30 | [Arguments] ${device_id} |
| 31 | [Documentation] Uses a utility script to lookup which RW Core has current ownership of an OLT |
| 32 | ${rc} ${pod}= Run and Return Rc and Output |
| 33 | ... ../scripts/which_pod_owns_device.sh ${device_id} |
| 34 | Should Be Equal as Integers ${rc} 0 |
| 35 | [Return] ${pod} |
| 36 | |
| 37 | Lookup Deployment That Owns Device |
| 38 | [Arguments] ${device_id} |
| 39 | [Documentation] Uses a utility script to lookup which RW Core has current ownership of an OLT |
| 40 | ${rc} ${deploy}= Run and Return Rc and Output |
| 41 | ... which_deployment_owns_device.sh ${device_id} |
| 42 | Should Be Equal as Integers ${rc} 0 |
| 43 | [Return] ${deploy} |
| 44 | |
| 45 | Restart VOLTHA Port Foward |
| 46 | [Arguments] ${name} |
| 47 | [Documentation] Uses a script to restart a kubectl port-forward |
| 48 | ${rc} ${pid} Run And Return Rc And Output |
| 49 | ... ps e -ww | grep _TAG=${name} | grep -v grep | awk '{printf(\"%s %s\\n\",$1,$5)}' | grep -v bash | awk '{print $1}' |
| 50 | Should Be Equal as Integers ${rc} 0 |
| 51 | Run Keyword If '${pid}' != '' Run And Return Rc kill -9 ${pid} |
| 52 | Should Be Equal as Integers ${rc} 0 |