| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 1 | *** Comments *** |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 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. |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 17 | |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 18 | |
| 19 | *** Settings *** |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 20 | Documentation Library providing keywords for CRUD operations over VNFD / VNF packages with OSM client. |
| 21 | Library OperatingSystem |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 22 | Library String |
| 23 | |
| 24 | |
| 25 | *** Variables *** |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 26 | ${SUCCESS_RETURN_CODE} 0 |
| 27 | ${FAILURE_RETURN_CODE} 1 |
| 28 | ${VNFD_DELETE_MAX_WAIT_TIME} 1min |
| 29 | ${VNFD_DELETE_POL_TIME} 15sec |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 30 | |
| 31 | |
| 32 | *** Keywords *** |
| 33 | Get VNFDs List |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 34 | [Documentation] Get the list of VNF packages and log it. |
| 35 | ${rc} ${stdout}= Run And Return Rc And Output osm vnfpkg-list |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 36 | Log ${stdout} |
| 37 | Log ${rc} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 38 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 39 | |
| 40 | Create VNFD |
| ramonsalguer | 89edc07 | 2020-07-17 18:08:52 +0000 | [diff] [blame] | 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. |
| ramonsalguer | 89edc07 | 2020-07-17 18:08:52 +0000 | [diff] [blame] | 54 | [Arguments] ${vnfd_pkg} ${overrides}=${EMPTY} |
| ramonsalguer | 89edc07 | 2020-07-17 18:08:52 +0000 | [diff] [blame] | 55 | # If env variable "OVERRIDES" exists, it prevails over the value in the argument |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 56 | ${overrides}= Get Environment Variable OVERRIDES default=${overrides} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 57 | # Proceeds with the onboarding with the appropriate arguments |
| 58 | ${rc} ${stdout}= Run And Return Rc And Output osm vnfpkg-create ${overrides} ${vnfd_pkg} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 59 | Log ${stdout} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 60 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 61 | ${lines}= Get Line Count ${stdout} |
| 62 | ${last}= Evaluate ${lines} - 1 |
| 63 | ${id}= Get Line ${stdout} ${last} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 64 | RETURN ${id} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 65 | |
| aticig | 6cd7480 | 2022-05-11 19:31:46 +0300 | [diff] [blame] | 66 | Update VNFD |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 67 | [Documentation] Onboard ("Update") a NF Package into OSM. |
| aticig | 6cd7480 | 2022-05-11 19:31:46 +0300 | [diff] [blame] | 68 | ... - Parameters: |
| 69 | ... - vnfd_pkg: Name (and location) of the NF Package |
| 70 | ... - vnfd_name: Name of the existing NF Package |
| aticig | 6cd7480 | 2022-05-11 19:31:46 +0300 | [diff] [blame] | 71 | [Arguments] ${vnfd_pkg} ${vnfd_name} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 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} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 74 | Log ${stdout} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 75 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 76 | ${lines}= Get Line Count ${stdout} |
| 77 | ${last}= Evaluate ${lines} - 1 |
| 78 | ${id}= Get Line ${stdout} ${last} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 79 | RETURN ${id} |
| aticig | 6cd7480 | 2022-05-11 19:31:46 +0300 | [diff] [blame] | 80 | |
| aguilarherna | 9dca3a8 | 2021-03-24 16:59:34 +0100 | [diff] [blame] | 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'). |
| garciadeblas | 499c867 | 2021-03-25 11:51:08 +0100 | [diff] [blame] | 93 | ... - Relevant environment variables: |
| aguilarherna | 9dca3a8 | 2021-03-24 16:59:34 +0100 | [diff] [blame] | 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. |
| aguilarherna | 9dca3a8 | 2021-03-24 16:59:34 +0100 | [diff] [blame] | 96 | [Arguments] ${vnfd_pkg} ${override_fields} ${overrides}=${EMPTY} |
| aguilarherna | 9dca3a8 | 2021-03-24 16:59:34 +0100 | [diff] [blame] | 97 | # If env variable "OVERRIDES" exists, it prevails over the value in the argument |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 98 | ${overrides}= Get Environment Variable OVERRIDES default=${overrides} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 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}' |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 101 | Log ${stdout} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 102 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 103 | ${lines}= Get Line Count ${stdout} |
| 104 | ${last}= Evaluate ${lines} - 1 |
| 105 | ${id}= Get Line ${stdout} ${last} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 106 | RETURN ${id} |
| aguilarherna | 9dca3a8 | 2021-03-24 16:59:34 +0100 | [diff] [blame] | 107 | |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 108 | Delete VNFD |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 109 | [Documentation] Delete a VNF package from OSM. |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 110 | [Arguments] ${vnfd_id} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 111 | ${rc} ${stdout}= Run And Return Rc And Output osm vnfpkg-delete ${vnfd_id} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 112 | Log ${stdout} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 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} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 115 | |
| garciadeblas | 499c867 | 2021-03-25 11:51:08 +0100 | [diff] [blame] | 116 | Assert Failure Delete VNFD |
| 117 | [Documentation] Deletes a NF Package that cannot be deleted and asserts the failure |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 118 | [Arguments] ${vnfd_id} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 119 | ${rc} ${stdout}= Run And Return Rc And Output osm vnfpkg-delete ${vnfd_id} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 120 | Log ${stdout} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 121 | Should Be Equal As Integers ${rc} ${FAILURE_RETURN_CODE} |
| garciadeblas | f8ea4a6 | 2021-04-18 23:08:17 +0200 | [diff] [blame] | 122 | Should Contain ${stdout} 409 msg=Expected Conflict values=False |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 123 | Wait Until Keyword Succeeds ${VNFD_DELETE_MAX_WAIT_TIME} ${VNFD_DELETE_POL_TIME} Check For VNFD ${vnfd_id} True |
| garciadeblas | 499c867 | 2021-03-25 11:51:08 +0100 | [diff] [blame] | 124 | |
| 125 | Check For VNFD |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 126 | [Documentation] Check that a VNF package exists in OSM. |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 127 | [Arguments] ${vnfd_id} ${exists}=False |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 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 |