blob: 2e4e2a667c965bf5ab0da1002330f561b85be16c [file] [log] [blame]
garciadeblas7a9e0312023-12-11 22:24:46 +01001*** Comments ***
Felipe Vicensf96bb452020-06-22 08:12:30 +02002# 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.
Felipe Vicensf96bb452020-06-22 08:12:30 +020017
Felipe Vicensf96bb452020-06-22 08:12:30 +020018
19*** Settings ***
garciadeblas7a9e0312023-12-11 22:24:46 +010020Documentation Library providing keywords for CRUD operations over VNFD / VNF packages with OSM client.
21Library OperatingSystem
Felipe Vicensf96bb452020-06-22 08:12:30 +020022Library String
23
24
25*** Variables ***
garciadeblas7a9e0312023-12-11 22:24:46 +010026${SUCCESS_RETURN_CODE} 0
27${FAILURE_RETURN_CODE} 1
28${VNFD_DELETE_MAX_WAIT_TIME} 1min
29${VNFD_DELETE_POL_TIME} 15sec
Felipe Vicensf96bb452020-06-22 08:12:30 +020030
31
32*** Keywords ***
33Get VNFDs List
garciadeblas7a9e0312023-12-11 22:24:46 +010034 [Documentation] Get the list of VNF packages and log it.
35 ${rc} ${stdout}= Run And Return Rc And Output osm vnfpkg-list
garciadeblas321726f2022-12-21 11:43:06 +010036 Log ${stdout}
37 Log ${rc}
garciadeblas7a9e0312023-12-11 22:24:46 +010038 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
Felipe Vicensf96bb452020-06-22 08:12:30 +020039
40Create VNFD
ramonsalguer89edc072020-07-17 18:08:52 +000041 [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.
ramonsalguer89edc072020-07-17 18:08:52 +000054 [Arguments] ${vnfd_pkg} ${overrides}=${EMPTY}
ramonsalguer89edc072020-07-17 18:08:52 +000055 # If env variable "OVERRIDES" exists, it prevails over the value in the argument
garciadeblasf4ebaa82022-06-23 13:33:26 +020056 ${overrides}= Get Environment Variable OVERRIDES default=${overrides}
garciadeblas7a9e0312023-12-11 22:24:46 +010057 # Proceeds with the onboarding with the appropriate arguments
58 ${rc} ${stdout}= Run And Return Rc And Output osm vnfpkg-create ${overrides} ${vnfd_pkg}
garciadeblas321726f2022-12-21 11:43:06 +010059 Log ${stdout}
garciadeblas7a9e0312023-12-11 22:24:46 +010060 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
garciadeblasf4ebaa82022-06-23 13:33:26 +020061 ${lines}= Get Line Count ${stdout}
62 ${last}= Evaluate ${lines} - 1
63 ${id}= Get Line ${stdout} ${last}
garciadeblas7a9e0312023-12-11 22:24:46 +010064 RETURN ${id}
Felipe Vicensf96bb452020-06-22 08:12:30 +020065
aticig6cd74802022-05-11 19:31:46 +030066Update VNFD
garciadeblas7a9e0312023-12-11 22:24:46 +010067 [Documentation] Onboard ("Update") a NF Package into OSM.
aticig6cd74802022-05-11 19:31:46 +030068 ... - Parameters:
69 ... - vnfd_pkg: Name (and location) of the NF Package
70 ... - vnfd_name: Name of the existing NF Package
aticig6cd74802022-05-11 19:31:46 +030071 [Arguments] ${vnfd_pkg} ${vnfd_name}
garciadeblas7a9e0312023-12-11 22:24:46 +010072 # 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}
garciadeblas321726f2022-12-21 11:43:06 +010074 Log ${stdout}
garciadeblas7a9e0312023-12-11 22:24:46 +010075 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
garciadeblasf4ebaa82022-06-23 13:33:26 +020076 ${lines}= Get Line Count ${stdout}
77 ${last}= Evaluate ${lines} - 1
78 ${id}= Get Line ${stdout} ${last}
garciadeblas7a9e0312023-12-11 22:24:46 +010079 RETURN ${id}
aticig6cd74802022-05-11 19:31:46 +030080
aguilarherna9dca3a82021-03-24 16:59:34 +010081Create 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').
garciadeblas499c8672021-03-25 11:51:08 +010093 ... - Relevant environment variables:
aguilarherna9dca3a82021-03-24 16:59:34 +010094 ... - 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.
aguilarherna9dca3a82021-03-24 16:59:34 +010096 [Arguments] ${vnfd_pkg} ${override_fields} ${overrides}=${EMPTY}
aguilarherna9dca3a82021-03-24 16:59:34 +010097 # If env variable "OVERRIDES" exists, it prevails over the value in the argument
garciadeblasf4ebaa82022-06-23 13:33:26 +020098 ${overrides}= Get Environment Variable OVERRIDES default=${overrides}
garciadeblas7a9e0312023-12-11 22:24:46 +010099 # 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}'
garciadeblas321726f2022-12-21 11:43:06 +0100101 Log ${stdout}
garciadeblas7a9e0312023-12-11 22:24:46 +0100102 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200103 ${lines}= Get Line Count ${stdout}
104 ${last}= Evaluate ${lines} - 1
105 ${id}= Get Line ${stdout} ${last}
garciadeblas7a9e0312023-12-11 22:24:46 +0100106 RETURN ${id}
aguilarherna9dca3a82021-03-24 16:59:34 +0100107
Felipe Vicensf96bb452020-06-22 08:12:30 +0200108Delete VNFD
garciadeblas7a9e0312023-12-11 22:24:46 +0100109 [Documentation] Delete a VNF package from OSM.
Felipe Vicensf96bb452020-06-22 08:12:30 +0200110 [Arguments] ${vnfd_id}
garciadeblas7a9e0312023-12-11 22:24:46 +0100111 ${rc} ${stdout}= Run And Return Rc And Output osm vnfpkg-delete ${vnfd_id}
garciadeblas321726f2022-12-21 11:43:06 +0100112 Log ${stdout}
garciadeblas7a9e0312023-12-11 22:24:46 +0100113 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}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200115
garciadeblas499c8672021-03-25 11:51:08 +0100116Assert Failure Delete VNFD
117 [Documentation] Deletes a NF Package that cannot be deleted and asserts the failure
Felipe Vicensf96bb452020-06-22 08:12:30 +0200118 [Arguments] ${vnfd_id}
garciadeblas7a9e0312023-12-11 22:24:46 +0100119 ${rc} ${stdout}= Run And Return Rc And Output osm vnfpkg-delete ${vnfd_id}
garciadeblas321726f2022-12-21 11:43:06 +0100120 Log ${stdout}
garciadeblas7a9e0312023-12-11 22:24:46 +0100121 Should Be Equal As Integers ${rc} ${FAILURE_RETURN_CODE}
garciadeblasf8ea4a62021-04-18 23:08:17 +0200122 Should Contain ${stdout} 409 msg=Expected Conflict values=False
garciadeblas7a9e0312023-12-11 22:24:46 +0100123 Wait Until Keyword Succeeds ${VNFD_DELETE_MAX_WAIT_TIME} ${VNFD_DELETE_POL_TIME} Check For VNFD ${vnfd_id} True
garciadeblas499c8672021-03-25 11:51:08 +0100124
125Check For VNFD
garciadeblas7a9e0312023-12-11 22:24:46 +0100126 [Documentation] Check that a VNF package exists in OSM.
garciadeblasf4ebaa82022-06-23 13:33:26 +0200127 [Arguments] ${vnfd_id} ${exists}=False
garciadeblas7a9e0312023-12-11 22:24:46 +0100128 ${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