Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[osm/tests.git] / robot-systest / lib / vnfd_lib.resource
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 VNFD / VNF packages with OSM client.
21 Library   OperatingSystem
22 Library   String
23
24
25 *** Variables ***
26 ${SUCCESS_RETURN_CODE}   0
27 ${FAILURE_RETURN_CODE}   1
28 ${VNFD_DELETE_MAX_WAIT_TIME}   1min
29 ${VNFD_DELETE_POL_TIME}   15sec
30
31
32 *** Keywords ***
33 Get VNFDs List
34     [Documentation]   Get the list of VNF packages and log it.
35     ${rc}   ${stdout}=   Run And Return Rc And Output   osm vnfpkg-list
36     Log   ${stdout}
37     Log   ${rc}
38     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
39
40 Create VNFD
41     [Documentation]   Onboards ("creates") a NF Package into OSM.
42     ...               - Parameters:
43     ...                 - vnfd_pkg: Name (and location) of the NF Package
44     ...                 - overrides (optional): String with options to override the EPA and/or interface properties of the Package.
45     ...                                        This is very useful to allow to deploy e.g. non-EPA packages in EPA VIMs (or vice-versa).
46     ...                                        Valid strings are the same as in the command. E.g.:
47     ...                                        - `--override-epa`: adds EPA attributes to all VDUs.
48     ...                                        - `--override-nonepa`: removes all EPA attributes from all VDUs.
49     ...                                        - `--override-paravirt`: converts all interfaces to `PARAVIRT`. This one can be combined with
50     ...                                           the others above (e.g. '--override-nonepa --override-paravirt').
51     ...               - Relevant environment variables:
52     ...                  - OVERRIDES: If the environment variable "OVERRIDES" exists, it prevails over the value in the argument.
53     ...                               This is often more convenient to enforce the same behaviour for every test run in a given VIM.
54     [Arguments]   ${vnfd_pkg}   ${overrides}=${EMPTY}
55     # If env variable "OVERRIDES" exists, it prevails over the value in the argument
56     ${overrides}=   Get Environment Variable   OVERRIDES   default=${overrides}
57     # Proceeds with the onboarding with the appropriate arguments
58     ${rc}   ${stdout}=   Run And Return Rc And Output   osm vnfpkg-create ${overrides} ${vnfd_pkg}
59     Log   ${stdout}
60     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
61     ${lines}=   Get Line Count   ${stdout}
62     ${last}=   Evaluate   ${lines} - 1
63     ${id}=   Get Line   ${stdout}   ${last}
64     RETURN   ${id}
65
66 Update VNFD
67     [Documentation]   Onboard ("Update") a NF Package into OSM.
68     ...               - Parameters:
69     ...                 - vnfd_pkg: Name (and location) of the NF Package
70     ...                 - vnfd_name: Name of the existing NF Package
71     [Arguments]   ${vnfd_pkg}   ${vnfd_name}
72     # Proceeds with the onboarding with the appropriate arguments
73     ${rc}   ${stdout}=   Run And Return Rc And Output   osm vnfpkg-update --content ${vnfd_pkg} ${vnfd_name}
74     Log   ${stdout}
75     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
76     ${lines}=   Get Line Count   ${stdout}
77     ${last}=   Evaluate   ${lines} - 1
78     ${id}=   Get Line   ${stdout}   ${last}
79     RETURN   ${id}
80
81 Create VNFD Overriding Fields
82     [Documentation]   Onboards ("creates") a NF Package into OSM.
83     ...               - Parameters:
84     ...                 - vnfd_pkg: Name (and location) of the NF Package
85     ...                 - override_fields: String with options to override fields in descriptor, format: "key1.key2...=value[;key3...=value;...]"
86     ...                 - overrides (optional): String with options to override the EPA and/or interface properties of the Package.
87     ...                                        This is very useful to allow to deploy e.g. non-EPA packages in EPA VIMs (or vice-versa).
88     ...                                        Valid strings are the same as in the command. E.g.:
89     ...                                        - `--override-epa`: adds EPA attributes to all VDUs.
90     ...                                        - `--override-nonepa`: removes all EPA attributes from all VDUs.
91     ...                                        - `--override-paravirt`: converts all interfaces to `PARAVIRT`. This one can be combined with
92     ...                                           the others above (e.g. '--override-nonepa --override-paravirt').
93     ...               - Relevant environment variables:
94     ...                  - OVERRIDES: If the environment variable "OVERRIDES" exists, it prevails over the value in the argument.
95     ...                               This is often more convenient to enforce the same behaviour for every test run in a given VIM.
96     [Arguments]   ${vnfd_pkg}   ${override_fields}   ${overrides}=${EMPTY}
97     # If env variable "OVERRIDES" exists, it prevails over the value in the argument
98     ${overrides}=   Get Environment Variable   OVERRIDES   default=${overrides}
99     # Proceeds with the onboarding with the appropriate arguments
100     ${rc}   ${stdout}=   Run And Return Rc And Output   osm vnfpkg-create ${overrides} ${vnfd_pkg} --override '${override_fields}'
101     Log   ${stdout}
102     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
103     ${lines}=   Get Line Count   ${stdout}
104     ${last}=   Evaluate   ${lines} - 1
105     ${id}=   Get Line   ${stdout}   ${last}
106     RETURN   ${id}
107
108 Delete VNFD
109     [Documentation]   Delete a VNF package from OSM.
110     [Arguments]   ${vnfd_id}
111     ${rc}   ${stdout}=   Run And Return Rc And Output   osm vnfpkg-delete ${vnfd_id}
112     Log   ${stdout}
113     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
114     Wait Until Keyword Succeeds   ${VNFD_DELETE_MAX_WAIT_TIME}   ${VNFD_DELETE_POL_TIME}   Check For VNFD   ${vnfd_id}
115
116 Assert Failure Delete VNFD
117     [Documentation]   Deletes a NF Package that cannot be deleted and asserts the failure
118     [Arguments]   ${vnfd_id}
119     ${rc}   ${stdout}=   Run And Return Rc And Output   osm vnfpkg-delete ${vnfd_id}
120     Log   ${stdout}
121     Should Be Equal As Integers   ${rc}   ${FAILURE_RETURN_CODE}
122     Should Contain   ${stdout}   409   msg=Expected Conflict   values=False
123     Wait Until Keyword Succeeds   ${VNFD_DELETE_MAX_WAIT_TIME}   ${VNFD_DELETE_POL_TIME}   Check For VNFD   ${vnfd_id}   True
124
125 Check For VNFD
126     [Documentation]   Check that a VNF package exists in OSM.
127     [Arguments]   ${vnfd_id}   ${exists}=False
128     ${rc}   ${stdout}=   Run And Return Rc And Output   osm vnfpkg-list | awk '{print $2}' | grep ${vnfd_id}
129     Log   ${rc},${stdout}
130     IF   ${exists}
131         Should Be Equal As Strings   ${stdout}   ${vnfd_id}
132     ELSE
133         Should Not Be Equal As Strings   ${stdout}   ${vnfd_id}
134     END