blob: 4f136fc8855a2b00d25cb8ad273d57e95b1e58b0 [file] [log] [blame]
garciadeblas7a9e0312023-12-11 22:24:46 +01001*** 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 ***
20Documentation Library providing keywords for CRUD operations over NSD/NSpkg with OSM client.
21
22Library OperatingSystem
23Library 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 ***
33Get 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
39Create NSD
40 [Documentation] Upload a NS package to OSM and return the id.
garciadeblasbb0fb572025-11-25 17:48:05 +010041 ... - Parameters:
42 ... - nsd_pkg: Name (and location) of the NF Package
43 ... - overrides (optional): String with options to override the NS.
44 ... Valid strings are the same as in the command. E.g.:
45 ... - `--override "name=newname"`: changes the name of the NS package to `newname`.
46 [Arguments] ${nsd_pkg} ${overrides}=${EMPTY}
47 ${rc} ${stdout}= Run And Return Rc And Output osm nspkg-create ${overrides} ${nsd_pkg}
garciadeblas7a9e0312023-12-11 22:24:46 +010048 Log ${stdout}
49 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
50 ${lines}= Get Line Count ${stdout}
51 ${last}= Evaluate ${lines} - 1
52 ${id}= Get Line ${stdout} ${last}
53 RETURN ${id}
54
55Delete NSD
56 [Documentation] Delete a NS package from OSM.
57 [Arguments] ${nsd_id}
58 ${rc} ${stdout}= Run Keyword And Continue On Failure Run And Return Rc And Output osm nspkg-delete ${nsd_id}
59 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
60 Log ${stdout}
61 Wait Until Keyword Succeeds ${NSD_DELETE_MAX_WAIT_TIME} ${NSD_DELETE_POL_TIME} Check For NSD ${nsd_id}
62
63Check For NSD
64 [Documentation] Check that a NS package exists in OSM.
65 [Arguments] ${nsd_id}
66 ${rc} ${stdout}= Run And Return Rc And Output osm nspkg-list | awk '{print $2}' | grep ${nsd_id}
67 Log ${rc},${stdout}
68 Should Not Be Equal As Strings ${stdout} ${nsd_id}
sritharan9e5450f2023-12-26 07:04:44 +000069
70Get NSD Ip
71 [Documentation] To get the Ip from the Nsd
72 [Arguments] ${nsd_id}
73 ${stdout}= Run osm nsd-show ${nsd_id} --literal | grep -A2 ip-address | grep -v "ip-address:" | awk '{print $2}' | tr -d ',-'
74 Log ${stdout}
75 RETURN ${stdout}