-*** Comments ***
-# Copyright 2020 Atos
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-*** Settings ***
-Documentation Library providing keywords for CRUD operations over Network Slice Instances with OSM client.
-
-Library Collections
-Library OperatingSystem
-Library DateTime
-Library String
-
-Resource ns_lib.resource
-
-
-*** Variables ***
-${SUCCESS_RETURN_CODE} 0
-${SLICE_LAUNCH_POL_TIME} 30sec
-${SLICE_DELETE_POL_TIME} 15sec
-${VIM_TIMEOUT_MULTIPLIER} %{OSM_VIM_MULTIPLIER_TIMEOUT=1.0}
-
-
-*** Keywords ***
-Create Network Slice
- [Documentation] Instantiates a NST and returns an instantiation id (nsi), verifying the slice is successfully instantiated
- ... Parameters:
- ... nst: Name of the slice template
- ... vim_name: Name of the VIM entry already in OSM
- ... slice_name: Name of the slice instance
- ... slice_config: Extra parameters that might require the slice instantiation i.e. configuration attributes
- ... publickey: SSH public key of the local machine
- ... Execution example:
- ... \${nsi}= Create Network Slice \${nst} \${vim_name} \${slice_name} \${slice_config} \${publickey}
- [Arguments] ${nst} ${vim_name} ${slice_name} ${slice_config} ${publickey} ${slice_launch_max_wait_time}=6min ${config_file}=${EMPTY}
- ${slice_launch_max_wait_time}= Convert Time ${slice_launch_max_wait_time} result_format=number
- ${slice_launch_max_wait_time}= Evaluate ${slice_launch_max_wait_time} * ${VIM_TIMEOUT_MULTIPLIER}
- ${config_attr}= Set Variable If "${slice_config}" != "${EMPTY}" --config '${slice_config}' ${EMPTY}
- ${sshkeys_attr}= Set Variable If "${publickey}" != "${EMPTY}" --ssh_keys ${publickey} ${EMPTY}
- ${config_file_attr}= Set Variable If "${config_file}" != "${EMPTY}" --config_file '${config_file}' ${EMPTY}
- ${nsi_id}= Instantiate Network Slice ${slice_name} ${nst} ${vim_name} ${config_attr} ${config_file_attr} ${sshkeys_attr}
- Log ${nsi_id}
- Wait Until Keyword Succeeds ${slice_launch_max_wait_time} ${SLICE_LAUNCH_POL_TIME} Check For Network Slice Instance To Configured ${slice_name}
- Check For Network Slice Instance For Failure ${slice_name}
- RETURN ${nsi_id}
-
-Instantiate Network Slice
- [Documentation] Instantiates a NST and returns an instantiation id (nsi)
- ... Parameters:
- ... slice_name: Name of the slice instance
- ... nst: Name of the slice template
- ... vim_name: Name of the VIM entry already in OSM
- ... slice_extra_args: Extra parameters that might require the slice instantiation i.e. configuration attributes
- ... Execution example:
- ... \${nsi}= Instantiate Network Slice \${slice_name} \${nst} \${vim_name} \${config_attr}
- [Arguments] ${slice_name} ${nst} ${vim_name} ${slice_extra_args} ${sshkeys_attr}
- ${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}
- Log ${rc},${stdout}
- Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
- RETURN ${stdout}
-
-Get Slice Ns List
- [Documentation] Retrieves the list of NS in a slice
- ... Parameters:
- ... slice_name: Name of the slice instance
- ... Execution example:
- ... \@{slice_ns_list}= Get Slice Ns List \${slice_name}
- [Arguments] ${slice_name}
- Should Not Be Empty ${slice_name}
- @{ns_list_string}= Run And Return Rc And Output osm ns-list | grep ${slice_name} | awk '{print $4}' 2>&1
- # Returns a String of ns_id and needs to be converted into a list
- @{ns_list}= Split String ${ns_list_string}[1]
- Log List ${ns_list}
- RETURN @{ns_list}
-
-Get Slice Ns List Except One
- [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.
- ... Parameters:
- ... slice_name: Name of the slice instance
- ... exception_ns: Name of the ns that will not appear in the final list
- ... Execution example:
- ... \@{slice_ns_list}= Get Slice Ns List Except One \${slice_name} \${exception_ns}
- [Arguments] ${slice_name} ${exception_ns}
- Should Not Be Empty ${slice_name}
- Should Not Be Empty ${exception_ns}
- @{ns_list_string}= Run And Return Rc And Output osm ns-list | grep ${slice_name} | awk '!/${exception_ns}/' | awk '{print $4}' 2>&1
- # Returns a String of ns_id and needs to be converted into a list
- @{ns_list}= Split String ${ns_list_string}[1]
- Log List ${ns_list}
- RETURN @{ns_list}
-
-Get Slice Ns Count
- [Documentation] Returns the count of all the NS in a slice
- ... Parameters:
- ... slice_name: Name of the slice instance
- ... Execution example:
- ... \${slice_ns_count}= Get Slice Ns Count \${slice_name}
- [Arguments] ${slice_name}
- Should Not Be Empty ${slice_name}
- ${rc} ${stdout}= Run And Return Rc And Output osm ns-list | grep ${slice_name} | wc -l 2>&1
- Log ${stdout}
- Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
- RETURN ${stdout}
-
-Get Slice Vnf Ip Addresses
- [Documentation] Retrieves the list of IP addresses that belong to each of the VNFs in the slice
- ... Parameters:
- ... slice_name: Name of the slice instance
- ... Execution example:
- ... \@{slice_ip_address_list}= Get Slice Vnf Ip Addresses \${slice_name}
- [Arguments] ${slice_name}
- # Get all the ns_id in the slice
- @{slice_ns_list}= Get Slice Ns List ${slice_name}
- Log Many @{slice_ns_list}
- @{temp_list}= Create List
- # For each ns_id in the list, get all the vnf_id and their IP addresses
- FOR ${ns_id} IN @{slice_ns_list}
- Log ${ns_id}
- @{vnf_id_list}= Get Ns Vnf List ${ns_id}
- # For each vnf_id in the list, get all its IP addresses
- @{ns_ip_list}= Get Ns Ip List @{vnf_id_list}
- @{temp_list}= Combine Lists ${temp_list} ${ns_ip_list}
- END
- Log List ${temp_list}
- RETURN @{temp_list}
-
-Check For Network Slice Instance To Configured
- [Documentation] Verify the slice has been instantiated
- ... Parameters:
- ... slice_name: Name of the slice instance
- ... Execution example:
- ... Check For Network Slice Instance To Configured \${slice_name}
- [Arguments] ${slice_name}
- ${rc} ${stdout}= Run And Return Rc And Output osm nsi-list --filter name="${slice_name}"
- Log ${stdout}
- Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
- Should Contain Any ${stdout} READY BROKEN configured
-
-Check For Network Slice Instance For Failure
- [Documentation] Verify the slice instance is not in failure
- ... Parameters:
- ... slice_name: Name of the slice instance
- ... Execution example:
- ... Check For Network Slice Instance For Failure \${slice_name}
- [Arguments] ${slice_name}
- ${rc} ${stdout}= Run And Return Rc And Output osm nsi-list --filter name="${slice_name}"
- Log ${stdout}
- Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
- Should Not Contain ${stdout} failed
-
-Delete NSI
- [Documentation] Delete Network Slice Instance (NSI)
- ... Parameters:
- ... slice_name: Name of the slice instance
- ... slice_delete_max_wait_time: Delete operation timeout
- ... Execution example:
- ... Delete NST \${slice_name}
- [Arguments] ${slice_name} ${slice_delete_max_wait_time}=4min
- ${rc} ${stdout}= Run And Return Rc And Output osm nsi-delete ${slice_name}
- Log ${stdout}
- Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE}
- ${slice_delete_max_wait_time}= Convert Time ${slice_delete_max_wait_time} result_format=number
- ${slice_delete_max_wait_time}= Evaluate ${slice_delete_max_wait_time} * ${VIM_TIMEOUT_MULTIPLIER}
- Wait Until Keyword Succeeds ${slice_delete_max_wait_time} ${SLICE_DELETE_POL_TIME} Check For Network Slice Instance To Be Deleted ${slice_name}
-
-Check For Network Slice Instance To Be Deleted
- [Documentation] Verify the slice instance is not present
- ... Parameters:
- ... slice_name: Name of the slice instance
- ... Execution example:
- ... Check For Network Slice Instance \${slice_name}
- [Arguments] ${slice_name}
- ${rc} ${stdout}= Run And Return Rc And Output osm nsi-list | awk '{print $2}' | grep ${slice_name}
- Log ${rc},${stdout}
- Should Not Be Equal As Strings ${stdout} ${slice_name}