2 # Copyright 2019 Tech Mahindra Limited
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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
20 Documentation Library providing keywords for CRUD operations over NSD/NSpkg with OSM client.
22 Library OperatingSystem
27 ${SUCCESS_RETURN_CODE} 0
28 ${NSD_DELETE_MAX_WAIT_TIME} 1min
29 ${NSD_DELETE_POL_TIME} 15sec
34 [Documentation] Get the list of NS packages and log it.
35 ${rc} ${stdout}= Run And Return Rc And Output osm nspkg-list
37 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
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}
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}
51 [Documentation] Delete a NS package from OSM.
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}
56 Wait Until Keyword Succeeds ${NSD_DELETE_MAX_WAIT_TIME} ${NSD_DELETE_POL_TIME} Check For NSD ${nsd_id}
59 [Documentation] Check that a NS package exists in OSM.
61 ${rc} ${stdout}= Run And Return Rc And Output osm nspkg-list | awk '{print $2}' | grep ${nsd_id}
63 Should Not Be Equal As Strings ${stdout} ${nsd_id}
66 [Documentation] To get the Ip from the Nsd
68 ${stdout}= Run osm nsd-show ${nsd_id} --literal | grep -A2 ip-address | grep -v "ip-address:" | awk '{print $2}' | tr -d ',-'