| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 1 | *** Comments *** |
| 2 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | # you may not use this file except in compliance with the License. |
| 4 | # You may obtain a copy of the License at |
| 5 | # |
| 6 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | # |
| 8 | # Unless required by applicable law or agreed to in writing, software |
| 9 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | # See the License for the specific language governing permissions and |
| 12 | # limitations under the License. |
| 13 | |
| 14 | |
| 15 | *** Settings *** |
| 16 | Documentation Library providing keywords for CRUD operations over projects with OSM client. |
| 17 | Library OperatingSystem |
| 18 | |
| 19 | |
| 20 | *** Variables *** |
| 21 | ${SUCCESS_RETURN_CODE} 0 |
| 22 | |
| 23 | |
| 24 | *** Keywords *** |
| 25 | Create Project |
| 26 | [Documentation] Create a project in OSM with the name passed as argument, and return the project id. |
| 27 | [Arguments] ${project_name} |
| 28 | Should Not Be Empty ${project_name} |
| 29 | ${rc} ${stdout}= Run And Return Rc And Output osm project-create ${project_name} |
| 30 | Log ${stdout} |
| 31 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 32 | RETURN ${stdout} |
| 33 | |
| 34 | Create Project With Quotas |
| 35 | [Documentation] Create a project in OSM with the name and quotas passed as arguments, and return the project id. |
| 36 | [Arguments] ${project_name} ${project_quotas} |
| 37 | Should Not Be Empty ${project_name} |
| 38 | Should Not Be Empty ${project_quotas} |
| 39 | ${rc} ${stdout}= Run And Return Rc And Output osm project-create ${project_name} --quotas ${project_quotas} |
| 40 | Log ${stdout} |
| 41 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 42 | RETURN ${stdout} |
| 43 | |
| 44 | Get Project Quotas |
| 45 | [Documentation] Get from OSM a specific quota parameter from the project passed as argument. |
| 46 | [Arguments] ${project_name} ${quotas_name} |
| 47 | Should Not Be Empty ${project_name} |
| 48 | Should Not Be Empty ${quotas_name} |
| 49 | ${rc} ${stdout}= Run And Return Rc And Output osm project-show ${project_name} | grep '${quotas_name}' | awk -F ',|: ' '{print $2}' | awk '{print $1}' |
| 50 | Log ${stdout} |
| 51 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 52 | RETURN ${stdout} |
| 53 | |
| 54 | Update Project Quotas |
| 55 | [Documentation] Update in OSM the quotas of a project with the new quotas passed as arguments. |
| 56 | [Arguments] ${project_name} ${project_quotas} |
| 57 | Should Not Be Empty ${project_name} |
| 58 | Should Not Be Empty ${project_quotas} |
| 59 | ${rc} ${stdout}= Run And Return Rc And Output osm project-update ${project_name} --quotas ${project_quotas} |
| 60 | Log ${stdout} |
| 61 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 62 | |
| 63 | Update Project Name |
| 64 | [Documentation] Update in OSM the name of a project with the new name passed as argument. |
| 65 | [Arguments] ${project_name} ${new_name} |
| 66 | Should Not Be Empty ${project_name} |
| 67 | Should Not Be Empty ${new_name} |
| 68 | ${rc} ${stdout}= Run And Return Rc And Output osm project-update ${project_name} --name ${new_name} |
| 69 | Log ${stdout} |
| 70 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 71 | |
| 72 | Check If User Is Assigned To Project |
| 73 | [Documentation] Check in OSM if a user exists in a project passed as argument. |
| 74 | [Arguments] ${user_name} ${project_name} |
| 75 | Should Not Be Empty ${user_name} |
| 76 | Should Not Be Empty ${project_name} |
| 77 | ${rc} ${stdout}= Run And Return RC And Output osm user-show ${user_name} | grep "project_name" | grep "${project_name}" |
| 78 | Log ${stdout} |
| 79 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 80 | |
| 81 | Create VNFD In Project |
| 82 | [Documentation] Onboards a VNF package into an OSM project. |
| 83 | ... Extra parameters (such as 'override') are given to this function in name=value format. These parameters will be appended to the 'osm vnfpkg-create' command with the next syntax: --param_name=param_value |
| 84 | [Arguments] ${project_name} ${vnfd_pkg} ${project_user} ${user_password} @{optional_parameters} |
| 85 | Should Not Be Empty ${project_name} |
| 86 | Should Not Be Empty ${vnfd_pkg} |
| 87 | Should Not Be Empty ${project_user} |
| 88 | Should Not Be Empty ${user_password} |
| 89 | ${osm_pkg_create_command}= Set Variable osm --project ${project_name} --user ${project_user} --password ${user_password} vnfpkg-create ${vnfd_pkg} |
| 90 | FOR ${param} IN @{optional_parameters} |
| 91 | ${match} ${param_name} ${param_value}= Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in optional parameters |
| 92 | Log ${match},${param_name},${param_value} |
| 93 | ${osm_pkg_create_command}= Catenate ${osm_pkg_create_command} --${param_name}=${param_value} |
| 94 | END |
| 95 | ${rc} ${stdout}= Run And Return Rc And Output ${osm_pkg_create_command} |
| 96 | Log ${stdout} |
| 97 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 98 | RETURN ${stdout} |
| 99 | |
| 100 | Delete VNFD In Project |
| 101 | [Documentation] Deletes a VNF package from an OSM project. |
| 102 | [Arguments] ${project_name} ${vnfd_pkg} ${project_user} ${user_password} |
| 103 | Should Not Be Empty ${project_name} |
| 104 | Should Not Be Empty ${vnfd_pkg} |
| 105 | Should Not Be Empty ${project_user} |
| 106 | Should Not Be Empty ${user_password} |
| 107 | ${rc} ${stdout}= Run And Return Rc And Output osm --project ${project_name} --user ${project_user} --password ${user_password} vnfpkg-delete ${vnfd_pkg} |
| 108 | Log ${stdout} |
| 109 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 110 | |
| 111 | Remove User From Project |
| 112 | [Documentation] Remove a specific user from a specific project in OSM. |
| 113 | [Arguments] ${user_name} ${project_name} |
| 114 | Should Not Be Empty ${user_name} |
| 115 | Should Not Be Empty ${project_name} |
| 116 | ${rc} ${stdout}= Run And Return RC And Output osm user-update ${user_name} --remove-project ${project_name} |
| 117 | Log ${stdout} |
| 118 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 119 | |
| 120 | Delete Project |
| 121 | [Documentation] Delete from OSM the project passed as argument. |
| 122 | [Arguments] ${project_name} |
| 123 | ${rc} ${stdout}= Run And Return Rc And Output osm project-delete ${project_name} |
| 124 | Log ${stdout} |
| 125 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |