blob: 74c67a6af155556b4de1d1840f487a4fc1c64330 [file] [log] [blame]
garciadeblas7a9e0312023-12-11 22:24:46 +01001*** Comments ***
Felipe Vicensf96bb452020-06-22 08:12:30 +02002# 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
garciadeblas7a9e0312023-12-11 22:24:46 +010016
Felipe Vicensf96bb452020-06-22 08:12:30 +020017*** Settings ***
garciadeblas7a9e0312023-12-11 22:24:46 +010018Documentation Library providing keywords for CRUD operations over Network Slice Instances with OSM client.
19
garciadeblasf4ebaa82022-06-23 13:33:26 +020020Library Collections
garciadeblas7a9e0312023-12-11 22:24:46 +010021Library OperatingSystem
22Library DateTime
23Library String
24
25Resource ns_lib.resource
Felipe Vicensf96bb452020-06-22 08:12:30 +020026
27
28*** Variables ***
garciadeblas7a9e0312023-12-11 22:24:46 +010029${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}
aguilardd19692e2021-06-24 17:36:16 +020033
Felipe Vicensf96bb452020-06-22 08:12:30 +020034
35*** Keywords ***
Felipe Vicensf96bb452020-06-22 08:12:30 +020036Create 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}
garciadeblas9e22ea82021-01-14 12:12:31 +000046 [Arguments] ${nst} ${vim_name} ${slice_name} ${slice_config} ${publickey} ${slice_launch_max_wait_time}=6min ${config_file}=${EMPTY}
aguilardd19692e2021-06-24 17:36:16 +020047 ${slice_launch_max_wait_time}= Convert Time ${slice_launch_max_wait_time} result_format=number
garciadeblas7a9e0312023-12-11 22:24:46 +010048 ${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}
garciadeblas9e22ea82021-01-14 12:12:31 +000052 ${nsi_id}= Instantiate Network Slice ${slice_name} ${nst} ${vim_name} ${config_attr} ${config_file_attr} ${sshkeys_attr}
garciadeblas321726f2022-12-21 11:43:06 +010053 Log ${nsi_id}
garciadeblas7a9e0312023-12-11 22:24:46 +010054 Wait Until Keyword Succeeds ${slice_launch_max_wait_time} ${SLICE_LAUNCH_POL_TIME} Check For Network Slice Instance To Configured ${slice_name}
Felipe Vicensf96bb452020-06-22 08:12:30 +020055 Check For Network Slice Instance For Failure ${slice_name}
garciadeblas7a9e0312023-12-11 22:24:46 +010056 RETURN ${nsi_id}
Felipe Vicensf96bb452020-06-22 08:12:30 +020057
58Instantiate 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}
garciadeblas9e22ea82021-01-14 12:12:31 +000067 [Arguments] ${slice_name} ${nst} ${vim_name} ${slice_extra_args} ${sshkeys_attr}
garciadeblas7a9e0312023-12-11 22:24:46 +010068 ${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 Vicensf96bb452020-06-22 08:12:30 +020072
73Get 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 Vicensf96bb452020-06-22 08:12:30 +020079 [Arguments] ${slice_name}
Felipe Vicensf96bb452020-06-22 08:12:30 +020080 Should Not Be Empty ${slice_name}
garciadeblas7a9e0312023-12-11 22:24:46 +010081 @{ns_list_string}= Run And Return Rc And Output osm ns-list | grep ${slice_name} | awk '{print $4}' 2>&1
Felipe Vicensf96bb452020-06-22 08:12:30 +020082 # Returns a String of ns_id and needs to be converted into a list
garciadeblas7a9e0312023-12-11 22:24:46 +010083 @{ns_list}= Split String ${ns_list_string}[1]
garciadeblasf4ebaa82022-06-23 13:33:26 +020084 Log List ${ns_list}
garciadeblas7a9e0312023-12-11 22:24:46 +010085 RETURN @{ns_list}
Felipe Vicensf96bb452020-06-22 08:12:30 +020086
87Get 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 Vicensf96bb452020-06-22 08:12:30 +020094 [Arguments] ${slice_name} ${exception_ns}
Felipe Vicensf96bb452020-06-22 08:12:30 +020095 Should Not Be Empty ${slice_name}
96 Should Not Be Empty ${exception_ns}
garciadeblas7a9e0312023-12-11 22:24:46 +010097 @{ns_list_string}= Run And Return Rc And Output osm ns-list | grep ${slice_name} | awk '!/${exception_ns}/' | awk '{print $4}' 2>&1
Felipe Vicensf96bb452020-06-22 08:12:30 +020098 # Returns a String of ns_id and needs to be converted into a list
garciadeblas7a9e0312023-12-11 22:24:46 +010099 @{ns_list}= Split String ${ns_list_string}[1]
garciadeblasf4ebaa82022-06-23 13:33:26 +0200100 Log List ${ns_list}
garciadeblas7a9e0312023-12-11 22:24:46 +0100101 RETURN @{ns_list}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200102
103Get 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 Vicensf96bb452020-06-22 08:12:30 +0200109 [Arguments] ${slice_name}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200110 Should Not Be Empty ${slice_name}
garciadeblas7a9e0312023-12-11 22:24:46 +0100111 ${rc} ${stdout}= Run And Return Rc And Output osm ns-list | grep ${slice_name} | wc -l 2>&1
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 RETURN ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200115
116Get 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 Vicensf96bb452020-06-22 08:12:30 +0200122 [Arguments] ${slice_name}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200123 # Get all the ns_id in the slice
garciadeblas7a9e0312023-12-11 22:24:46 +0100124 @{slice_ns_list}= Get Slice Ns List ${slice_name}
garciadeblas321726f2022-12-21 11:43:06 +0100125 Log Many @{slice_ns_list}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200126 @{temp_list}= Create List
Felipe Vicensf96bb452020-06-22 08:12:30 +0200127 # For each ns_id in the list, get all the vnf_id and their IP addresses
128 FOR ${ns_id} IN @{slice_ns_list}
garciadeblas321726f2022-12-21 11:43:06 +0100129 Log ${ns_id}
garciadeblas7a9e0312023-12-11 22:24:46 +0100130 @{vnf_id_list}= Get Ns Vnf List ${ns_id}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200131 # For each vnf_id in the list, get all its IP addresses
garciadeblas7a9e0312023-12-11 22:24:46 +0100132 @{ns_ip_list}= Get Ns Ip List @{vnf_id_list}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200133 @{temp_list}= Combine Lists ${temp_list} ${ns_ip_list}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200134 END
135 Log List ${temp_list}
garciadeblas7a9e0312023-12-11 22:24:46 +0100136 RETURN @{temp_list}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200137
138Check 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}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200144 [Arguments] ${slice_name}
garciadeblas7a9e0312023-12-11 22:24:46 +0100145 ${rc} ${stdout}= Run And Return Rc And Output osm nsi-list --filter name="${slice_name}"
garciadeblas321726f2022-12-21 11:43:06 +0100146 Log ${stdout}
garciadeblas7a9e0312023-12-11 22:24:46 +0100147 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
garciadeblas6e121fd2022-05-20 13:13:01 +0200148 Should Contain Any ${stdout} READY BROKEN configured
Felipe Vicensf96bb452020-06-22 08:12:30 +0200149
Felipe Vicensf96bb452020-06-22 08:12:30 +0200150Check 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}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200156 [Arguments] ${slice_name}
garciadeblas7a9e0312023-12-11 22:24:46 +0100157 ${rc} ${stdout}= Run And Return Rc And Output osm nsi-list --filter name="${slice_name}"
garciadeblas321726f2022-12-21 11:43:06 +0100158 Log ${stdout}
garciadeblas7a9e0312023-12-11 22:24:46 +0100159 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
aguilarherna17ed58b2021-01-27 12:50:04 +0000160 Should Not Contain ${stdout} failed
Felipe Vicensf96bb452020-06-22 08:12:30 +0200161
Felipe Vicensf96bb452020-06-22 08:12:30 +0200162Delete NSI
163 [Documentation] Delete Network Slice Instance (NSI)
164 ... Parameters:
165 ... slice_name: Name of the slice instance
aguilardd19692e2021-06-24 17:36:16 +0200166 ... slice_delete_max_wait_time: Delete operation timeout
Felipe Vicensf96bb452020-06-22 08:12:30 +0200167 ... Execution example:
168 ... Delete NST \${slice_name}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200169 [Arguments] ${slice_name} ${slice_delete_max_wait_time}=4min
garciadeblas7a9e0312023-12-11 22:24:46 +0100170 ${rc} ${stdout}= Run And Return Rc And Output osm nsi-delete ${slice_name}
garciadeblas321726f2022-12-21 11:43:06 +0100171 Log ${stdout}
garciadeblas7a9e0312023-12-11 22:24:46 +0100172 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
aguilardd19692e2021-06-24 17:36:16 +0200173 ${slice_delete_max_wait_time}= Convert Time ${slice_delete_max_wait_time} result_format=number
garciadeblas7a9e0312023-12-11 22:24:46 +0100174 ${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 Vicensf96bb452020-06-22 08:12:30 +0200176
177Check 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}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200183 [Arguments] ${slice_name}
garciadeblas7a9e0312023-12-11 22:24:46 +0100184 ${rc} ${stdout}= Run And Return Rc And Output osm nsi-list | awk '{print $2}' | grep ${slice_name}
185 Log ${rc},${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200186 Should Not Be Equal As Strings ${stdout} ${slice_name}