Joey Armstrong | 9fadcbe | 2024-01-17 19:00:37 -0500 | [diff] [blame] | 1 | # Copyright 2019-2024 Open Networking Foundation (ONF) and the ONF Contributors |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 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. |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 14 | # voltha common functions |
| 15 | |
| 16 | *** Settings *** |
| 17 | Documentation Library for various utilities |
| 18 | Library SSHLibrary |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 19 | Library String |
| 20 | Library DateTime |
| 21 | Library Process |
| 22 | Library Collections |
| 23 | Library RequestsLibrary |
| 24 | Library OperatingSystem |
| 25 | |
| 26 | *** Keywords *** |
| 27 | Lookup Pod That Owns Device |
| 28 | [Arguments] ${device_id} |
| 29 | [Documentation] Uses a utility script to lookup which RW Core has current ownership of an OLT |
| 30 | ${rc} ${pod}= Run and Return Rc and Output |
| 31 | ... ../scripts/which_pod_owns_device.sh ${device_id} |
| 32 | Should Be Equal as Integers ${rc} 0 |
| 33 | [Return] ${pod} |
| 34 | |
| 35 | Lookup Deployment That Owns Device |
| 36 | [Arguments] ${device_id} |
| 37 | [Documentation] Uses a utility script to lookup which RW Core has current ownership of an OLT |
| 38 | ${rc} ${deploy}= Run and Return Rc and Output |
| 39 | ... which_deployment_owns_device.sh ${device_id} |
| 40 | Should Be Equal as Integers ${rc} 0 |
| 41 | [Return] ${deploy} |
| 42 | |
David Bainbridge | 07321ff | 2020-06-12 13:55:42 -0700 | [diff] [blame] | 43 | Restart VOLTHA Port Forward |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 44 | [Arguments] ${name} |
| 45 | [Documentation] Uses a script to restart a kubectl port-forward |
David Bainbridge | 3d6d5d3 | 2019-12-17 19:05:35 +0000 | [diff] [blame] | 46 | ${cmd} Catenate |
| 47 | ... ps e -ww -A | |
David Bainbridge | 821e7e8 | 2020-06-17 14:18:56 -0700 | [diff] [blame] | 48 | ... grep -E "_TAG=([a-z_-]+-)?${name}" | |
David Bainbridge | 3d6d5d3 | 2019-12-17 19:05:35 +0000 | [diff] [blame] | 49 | ... grep -v grep | |
| 50 | ... awk '{printf(\"%s %s\\n\",$1,$5)}' | |
| 51 | ... grep -v bash | awk '{print $1}' |
Andrea Campanella | e8376f3 | 2021-11-17 11:22:57 -0800 | [diff] [blame] | 52 | ${rc} ${port-forward} Run And Return Rc And Output ps -ef | grep port-forward |
| 53 | Log ${port-forward} |
David Bainbridge | 3d6d5d3 | 2019-12-17 19:05:35 +0000 | [diff] [blame] | 54 | ${rc} ${pid} Run And Return Rc And Output ${cmd} |
David Bainbridge | f81cd64 | 2019-11-20 00:14:47 +0000 | [diff] [blame] | 55 | Should Be Equal as Integers ${rc} 0 |
| 56 | Run Keyword If '${pid}' != '' Run And Return Rc kill -9 ${pid} |
| 57 | Should Be Equal as Integers ${rc} 0 |
Andrea Campanella | e8376f3 | 2021-11-17 11:22:57 -0800 | [diff] [blame] | 58 | ${rc} ${port-forward} Run And Return Rc And Output ps -ef | grep port-forward |
| 59 | Log ${port-forward} |
TorstenThieme | 3385cdc | 2021-02-04 13:50:50 +0000 | [diff] [blame] | 60 | |
| 61 | Get Kv Store Prefix |
| 62 | [Documentation] This keyword delivers the KV Store Prefix read from environment variable KVSTOREPREFIX if present. |
Andrea Campanella | 388cd87 | 2022-02-10 09:11:39 +0100 | [diff] [blame] | 63 | [Arguments] ${defaultkvstoreprefix}=voltha/voltha_voltha |
TorstenThieme | 3385cdc | 2021-02-04 13:50:50 +0000 | [diff] [blame] | 64 | ${kv_store_prefix}= Get Environment Variable KVSTOREPREFIX default=${defaultkvstoreprefix} |
| 65 | # while Get Environment Variable does not work correctly, a manual correction follows |
| 66 | ${kv_store_prefix}= Set Variable If "${kv_store_prefix}"=="${EMPTY}" ${defaultkvstoreprefix} ${kv_store_prefix} |
| 67 | [Return] ${kv_store_prefix} |
| 68 | |