| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 1 | *** Comments *** |
| 2 | # Copyright 2019 Tech Mahindra Limited |
| 3 | # |
| 4 | # All Rights Reserved. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. You may obtain |
| 8 | # a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | # License for the specific language governing permissions and limitations |
| 16 | # under the License. |
| 17 | |
| 18 | |
| 19 | *** Settings *** |
| 20 | Documentation Library providing keywords for CRUD operations over NSD/NSpkg with OSM client. |
| 21 | |
| 22 | Library OperatingSystem |
| 23 | Library String |
| 24 | |
| 25 | |
| 26 | *** Variables *** |
| 27 | ${SUCCESS_RETURN_CODE} 0 |
| 28 | ${NSD_DELETE_MAX_WAIT_TIME} 1min |
| 29 | ${NSD_DELETE_POL_TIME} 15sec |
| 30 | |
| 31 | |
| 32 | *** Keywords *** |
| 33 | Get NSDs List |
| 34 | [Documentation] Get the list of NS packages and log it. |
| 35 | ${rc} ${stdout}= Run And Return Rc And Output osm nspkg-list |
| 36 | Log ${stdout} |
| 37 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 38 | |
| 39 | Create NSD |
| 40 | [Documentation] Upload a NS package to OSM and return the id. |
| 41 | [Arguments] ${nsd_pkg} |
| 42 | ${rc} ${stdout}= Run And Return Rc And Output osm nspkg-create ${nsd_pkg} |
| 43 | Log ${stdout} |
| 44 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 45 | ${lines}= Get Line Count ${stdout} |
| 46 | ${last}= Evaluate ${lines} - 1 |
| 47 | ${id}= Get Line ${stdout} ${last} |
| 48 | RETURN ${id} |
| 49 | |
| 50 | Delete NSD |
| 51 | [Documentation] Delete a NS package from OSM. |
| 52 | [Arguments] ${nsd_id} |
| 53 | ${rc} ${stdout}= Run Keyword And Continue On Failure Run And Return Rc And Output osm nspkg-delete ${nsd_id} |
| 54 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 55 | Log ${stdout} |
| 56 | Wait Until Keyword Succeeds ${NSD_DELETE_MAX_WAIT_TIME} ${NSD_DELETE_POL_TIME} Check For NSD ${nsd_id} |
| 57 | |
| 58 | Check For NSD |
| 59 | [Documentation] Check that a NS package exists in OSM. |
| 60 | [Arguments] ${nsd_id} |
| 61 | ${rc} ${stdout}= Run And Return Rc And Output osm nspkg-list | awk '{print $2}' | grep ${nsd_id} |
| 62 | Log ${rc},${stdout} |
| 63 | Should Not Be Equal As Strings ${stdout} ${nsd_id} |
| sritharan | 9e5450f | 2023-12-26 07:04:44 +0000 | [diff] [blame] | 64 | |
| 65 | Get NSD Ip |
| 66 | [Documentation] To get the Ip from the Nsd |
| 67 | [Arguments] ${nsd_id} |
| 68 | ${stdout}= Run osm nsd-show ${nsd_id} --literal | grep -A2 ip-address | grep -v "ip-address:" | awk '{print $2}' | tr -d ',-' |
| 69 | Log ${stdout} |
| 70 | RETURN ${stdout} |