Updated deprecated command-line osm commands: vnfd-, nsd-
[osm/tests.git] / robot-systest / lib / vnfd_lib.robot
1 # -*- coding: utf-8 -*-
2
3 ##
4 # Copyright 2019 Tech Mahindra Limited
5 #
6 # All Rights Reserved.
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License"); you may
9 # not use this file except in compliance with the License. You may obtain
10 # a copy of the License at
11 #
12 #         http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 # License for the specific language governing permissions and limitations
18 # under the License.
19 ##
20
21 ## Change log:
22 # 1. Feature 7829: Jayant Madavi, Mrityunjay Yadav : MY00514913@techmahindra.com : 06-sep-2019
23 ##
24
25 *** Settings ***
26 Library   String
27
28
29 *** Variables ***
30 ${success_return_code}   0
31 ${delete_max_wait_time}   1min
32 ${delete_pol_time}   15sec
33
34
35 *** Keywords ***
36 Get VNFDs List
37     ${rc}   ${stdout}=   Run and Return RC and Output   osm vnfpkg-list
38     log   ${stdout}
39     log   ${rc}
40     Should Be Equal As Integers   ${rc}   ${success_return_code}
41
42
43 Create VNFD
44     [Documentation]   Onboards ("creates") a NF Package into OSM.
45     ...               - Parameters:
46     ...                 - vnfd_pkg: Name (and location) of the NF Package
47     ...                 - overrides (optional): String with options to override the EPA and/or interface properties of the Package.
48     ...                                        This is very useful to allow to deploy e.g. non-EPA packages in EPA VIMs (or vice-versa).
49     ...                                        Valid strings are the same as in the command. E.g.:
50     ...                                        - `--override-epa`: adds EPA attributes to all VDUs.
51     ...                                        - `--override-nonepa`: removes all EPA attributes from all VDUs.
52     ...                                        - `--override-paravirt`: converts all interfaces to `PARAVIRT`. This one can be combined with
53     ...                                           the others above (e.g. '--override-nonepa --override-paravirt').
54     ...               - Relevant environment variables:
55     ...                  - OVERRIDES: If the environment variable "OVERRIDES" exists, it prevails over the value in the argument.
56     ...                               This is often more convenient to enforce the same behaviour for every test run in a given VIM.
57
58     [Arguments]   ${vnfd_pkg}   ${overrides}=${EMPTY}
59
60     # If env variable "OVERRIDES" exists, it prevails over the value in the argument
61     ${overrides}=   Get Environment Variable    OVERRIDES   default=${overrides}
62
63     # Proceedes with the onboarding with the appropriate arguments
64     ${rc}   ${stdout}=   Run and Return RC and Output   osm vnfpkg-create ${overrides} ${vnfd_pkg}
65     log   ${stdout}
66     Should Be Equal As Integers   ${rc}   ${success_return_code}
67     ${lines}=  Get Line Count  ${stdout}
68     ${last}=  Evaluate  ${lines} - 1
69     ${id}=  Get Line  ${stdout}  ${last}
70     [Return]  ${id}
71
72
73 Delete VNFD
74     [Arguments]   ${vnfd_id}
75
76     ${rc}   ${stdout}=   Run and Return RC and Output   osm vnfpkg-delete ${vnfd_id}
77     log   ${stdout}
78     Should Be Equal As Integers   ${rc}   ${success_return_code}
79     WAIT UNTIL KEYWORD SUCCEEDS   ${delete_max_wait_time}   ${delete_pol_time}   Check For VNFD   ${vnfd_id}
80
81
82 Check For VNFD
83     [Arguments]   ${vnfd_id}
84
85     ${rc}   ${stdout}=   Run and Return RC and Output   osm vnfpkg-list | awk '{print $2}' | grep ${vnfd_id}
86     Should Not Be Equal As Strings   ${stdout}   ${vnfd_id}