| 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 2020 Atos |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 16 | |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 17 | *** Settings *** |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 18 | Documentation Library providing keywords for CRUD operations over Network Slice Instances with OSM client. |
| 19 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 20 | Library Collections |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 21 | Library OperatingSystem |
| 22 | Library DateTime |
| 23 | Library String |
| 24 | |
| 25 | Resource ns_lib.resource |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 26 | |
| 27 | |
| 28 | *** Variables *** |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 29 | ${SUCCESS_RETURN_CODE} 0 |
| 30 | ${SLICE_LAUNCH_POL_TIME} 30sec |
| 31 | ${SLICE_DELETE_POL_TIME} 15sec |
| 32 | ${VIM_TIMEOUT_MULTIPLIER} %{OSM_VIM_MULTIPLIER_TIMEOUT=1.0} |
| aguilard | d19692e | 2021-06-24 17:36:16 +0200 | [diff] [blame] | 33 | |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 34 | |
| 35 | *** Keywords *** |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 36 | Create Network Slice |
| 37 | [Documentation] Instantiates a NST and returns an instantiation id (nsi), verifying the slice is successfully instantiated |
| 38 | ... Parameters: |
| 39 | ... nst: Name of the slice template |
| 40 | ... vim_name: Name of the VIM entry already in OSM |
| 41 | ... slice_name: Name of the slice instance |
| 42 | ... slice_config: Extra parameters that might require the slice instantiation i.e. configuration attributes |
| 43 | ... publickey: SSH public key of the local machine |
| 44 | ... Execution example: |
| 45 | ... \${nsi}= Create Network Slice \${nst} \${vim_name} \${slice_name} \${slice_config} \${publickey} |
| garciadeblas | 9e22ea8 | 2021-01-14 12:12:31 +0000 | [diff] [blame] | 46 | [Arguments] ${nst} ${vim_name} ${slice_name} ${slice_config} ${publickey} ${slice_launch_max_wait_time}=6min ${config_file}=${EMPTY} |
| aguilard | d19692e | 2021-06-24 17:36:16 +0200 | [diff] [blame] | 47 | ${slice_launch_max_wait_time}= Convert Time ${slice_launch_max_wait_time} result_format=number |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 48 | ${slice_launch_max_wait_time}= Evaluate ${slice_launch_max_wait_time} * ${VIM_TIMEOUT_MULTIPLIER} |
| 49 | ${config_attr}= Set Variable If "${slice_config}" != "${EMPTY}" --config '${slice_config}' ${EMPTY} |
| 50 | ${sshkeys_attr}= Set Variable If "${publickey}" != "${EMPTY}" --ssh_keys ${publickey} ${EMPTY} |
| 51 | ${config_file_attr}= Set Variable If "${config_file}" != "${EMPTY}" --config_file '${config_file}' ${EMPTY} |
| garciadeblas | 9e22ea8 | 2021-01-14 12:12:31 +0000 | [diff] [blame] | 52 | ${nsi_id}= Instantiate Network Slice ${slice_name} ${nst} ${vim_name} ${config_attr} ${config_file_attr} ${sshkeys_attr} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 53 | Log ${nsi_id} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 54 | Wait Until Keyword Succeeds ${slice_launch_max_wait_time} ${SLICE_LAUNCH_POL_TIME} Check For Network Slice Instance To Configured ${slice_name} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 55 | Check For Network Slice Instance For Failure ${slice_name} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 56 | RETURN ${nsi_id} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 57 | |
| 58 | Instantiate Network Slice |
| 59 | [Documentation] Instantiates a NST and returns an instantiation id (nsi) |
| 60 | ... Parameters: |
| 61 | ... slice_name: Name of the slice instance |
| 62 | ... nst: Name of the slice template |
| 63 | ... vim_name: Name of the VIM entry already in OSM |
| 64 | ... slice_extra_args: Extra parameters that might require the slice instantiation i.e. configuration attributes |
| 65 | ... Execution example: |
| 66 | ... \${nsi}= Instantiate Network Slice \${slice_name} \${nst} \${vim_name} \${config_attr} |
| garciadeblas | 9e22ea8 | 2021-01-14 12:12:31 +0000 | [diff] [blame] | 67 | [Arguments] ${slice_name} ${nst} ${vim_name} ${slice_extra_args} ${sshkeys_attr} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 68 | ${rc} ${stdout}= Run And Return Rc And Output osm nsi-create --nsi_name ${slice_name} --nst_name ${nst} --vim_account ${vim_name} ${sshkeys_attr} ${slice_extra_args} |
| 69 | Log ${rc},${stdout} |
| 70 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| 71 | RETURN ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 72 | |
| 73 | Get Slice Ns List |
| 74 | [Documentation] Retrieves the list of NS in a slice |
| 75 | ... Parameters: |
| 76 | ... slice_name: Name of the slice instance |
| 77 | ... Execution example: |
| 78 | ... \@{slice_ns_list}= Get Slice Ns List \${slice_name} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 79 | [Arguments] ${slice_name} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 80 | Should Not Be Empty ${slice_name} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 81 | @{ns_list_string}= Run And Return Rc And Output osm ns-list | grep ${slice_name} | awk '{print $4}' 2>&1 |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 82 | # Returns a String of ns_id and needs to be converted into a list |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 83 | @{ns_list}= Split String ${ns_list_string}[1] |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 84 | Log List ${ns_list} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 85 | RETURN @{ns_list} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 86 | |
| 87 | Get Slice Ns List Except One |
| 88 | [Documentation] Retrieves the list of NS in a slice removing one from the list. This is done to save time in the tests, avoiding one VNF to ping itself. |
| 89 | ... Parameters: |
| 90 | ... slice_name: Name of the slice instance |
| 91 | ... exception_ns: Name of the ns that will not appear in the final list |
| 92 | ... Execution example: |
| 93 | ... \@{slice_ns_list}= Get Slice Ns List Except One \${slice_name} \${exception_ns} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 94 | [Arguments] ${slice_name} ${exception_ns} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 95 | Should Not Be Empty ${slice_name} |
| 96 | Should Not Be Empty ${exception_ns} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 97 | @{ns_list_string}= Run And Return Rc And Output osm ns-list | grep ${slice_name} | awk '!/${exception_ns}/' | awk '{print $4}' 2>&1 |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 98 | # Returns a String of ns_id and needs to be converted into a list |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 99 | @{ns_list}= Split String ${ns_list_string}[1] |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 100 | Log List ${ns_list} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 101 | RETURN @{ns_list} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 102 | |
| 103 | Get Slice Ns Count |
| 104 | [Documentation] Returns the count of all the NS in a slice |
| 105 | ... Parameters: |
| 106 | ... slice_name: Name of the slice instance |
| 107 | ... Execution example: |
| 108 | ... \${slice_ns_count}= Get Slice Ns Count \${slice_name} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 109 | [Arguments] ${slice_name} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 110 | Should Not Be Empty ${slice_name} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 111 | ${rc} ${stdout}= Run And Return Rc And Output osm ns-list | grep ${slice_name} | wc -l 2>&1 |
| 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 | RETURN ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 115 | |
| 116 | Get Slice Vnf Ip Addresses |
| 117 | [Documentation] Retrieves the list of IP addresses that belong to each of the VNFs in the slice |
| 118 | ... Parameters: |
| 119 | ... slice_name: Name of the slice instance |
| 120 | ... Execution example: |
| 121 | ... \@{slice_ip_address_list}= Get Slice Vnf Ip Addresses \${slice_name} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 122 | [Arguments] ${slice_name} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 123 | # Get all the ns_id in the slice |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 124 | @{slice_ns_list}= Get Slice Ns List ${slice_name} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 125 | Log Many @{slice_ns_list} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 126 | @{temp_list}= Create List |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 127 | # For each ns_id in the list, get all the vnf_id and their IP addresses |
| 128 | FOR ${ns_id} IN @{slice_ns_list} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 129 | Log ${ns_id} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 130 | @{vnf_id_list}= Get Ns Vnf List ${ns_id} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 131 | # For each vnf_id in the list, get all its IP addresses |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 132 | @{ns_ip_list}= Get Ns Ip List @{vnf_id_list} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 133 | @{temp_list}= Combine Lists ${temp_list} ${ns_ip_list} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 134 | END |
| 135 | Log List ${temp_list} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 136 | RETURN @{temp_list} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 137 | |
| 138 | Check For Network Slice Instance To Configured |
| 139 | [Documentation] Verify the slice has been instantiated |
| 140 | ... Parameters: |
| 141 | ... slice_name: Name of the slice instance |
| 142 | ... Execution example: |
| 143 | ... Check For Network Slice Instance To Configured \${slice_name} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 144 | [Arguments] ${slice_name} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 145 | ${rc} ${stdout}= Run And Return Rc And Output osm nsi-list --filter name="${slice_name}" |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 146 | Log ${stdout} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 147 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| garciadeblas | 6e121fd | 2022-05-20 13:13:01 +0200 | [diff] [blame] | 148 | Should Contain Any ${stdout} READY BROKEN configured |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 149 | |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 150 | Check For Network Slice Instance For Failure |
| 151 | [Documentation] Verify the slice instance is not in failure |
| 152 | ... Parameters: |
| 153 | ... slice_name: Name of the slice instance |
| 154 | ... Execution example: |
| 155 | ... Check For Network Slice Instance For Failure \${slice_name} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 156 | [Arguments] ${slice_name} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 157 | ${rc} ${stdout}= Run And Return Rc And Output osm nsi-list --filter name="${slice_name}" |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 158 | Log ${stdout} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 159 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| aguilarherna | 17ed58b | 2021-01-27 12:50:04 +0000 | [diff] [blame] | 160 | Should Not Contain ${stdout} failed |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 161 | |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 162 | Delete NSI |
| 163 | [Documentation] Delete Network Slice Instance (NSI) |
| 164 | ... Parameters: |
| 165 | ... slice_name: Name of the slice instance |
| aguilard | d19692e | 2021-06-24 17:36:16 +0200 | [diff] [blame] | 166 | ... slice_delete_max_wait_time: Delete operation timeout |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 167 | ... Execution example: |
| 168 | ... Delete NST \${slice_name} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 169 | [Arguments] ${slice_name} ${slice_delete_max_wait_time}=4min |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 170 | ${rc} ${stdout}= Run And Return Rc And Output osm nsi-delete ${slice_name} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 171 | Log ${stdout} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 172 | Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} |
| aguilard | d19692e | 2021-06-24 17:36:16 +0200 | [diff] [blame] | 173 | ${slice_delete_max_wait_time}= Convert Time ${slice_delete_max_wait_time} result_format=number |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 174 | ${slice_delete_max_wait_time}= Evaluate ${slice_delete_max_wait_time} * ${VIM_TIMEOUT_MULTIPLIER} |
| 175 | Wait Until Keyword Succeeds ${slice_delete_max_wait_time} ${SLICE_DELETE_POL_TIME} Check For Network Slice Instance To Be Deleted ${slice_name} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 176 | |
| 177 | Check For Network Slice Instance To Be Deleted |
| 178 | [Documentation] Verify the slice instance is not present |
| 179 | ... Parameters: |
| 180 | ... slice_name: Name of the slice instance |
| 181 | ... Execution example: |
| 182 | ... Check For Network Slice Instance \${slice_name} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 183 | [Arguments] ${slice_name} |
| garciadeblas | 7a9e031 | 2023-12-11 22:24:46 +0100 | [diff] [blame] | 184 | ${rc} ${stdout}= Run And Return Rc And Output osm nsi-list | awk '{print $2}' | grep ${slice_name} |
| 185 | Log ${rc},${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 186 | Should Not Be Equal As Strings ${stdout} ${slice_name} |