| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 1 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | # you may not use this file except in compliance with the License. |
| 3 | # You may obtain a copy of the License at |
| 4 | # |
| 5 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | # |
| 7 | # Unless required by applicable law or agreed to in writing, software |
| 8 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | # See the License for the specific language governing permissions and |
| 11 | # limitations under the License. |
| 12 | |
| garciadeblas | 4397917 | 2021-03-26 10:46:13 +0100 | [diff] [blame] | 13 | *** Settings *** |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 14 | Documentation Library to deploy and delete NS, and run operations on them. |
| garciadeblas | 4397917 | 2021-03-26 10:46:13 +0100 | [diff] [blame] | 15 | |
| 16 | Library DateTime |
| 17 | |
| 18 | |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 19 | *** Variables *** |
| 20 | ${success_return_code} 0 |
| 21 | ${ns_launch_pol_time} 30sec |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 22 | ${ns_delete_pol_time} 15sec |
| 23 | ${ns_action_max_wait_time} 1min |
| 24 | ${ns_action_pol_time} 15sec |
| aguilarherna | ff0b39e | 2021-03-12 11:43:55 +0100 | [diff] [blame] | 25 | ${vnf_scale_pol_time} 15sec |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 26 | ${healing_pol_time} 15sec |
| garciadeblas | 4397917 | 2021-03-26 10:46:13 +0100 | [diff] [blame] | 27 | ${vim_timeout_multiplier} %{OSM_VIM_MULTIPLIER_TIMEOUT=1.0} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 28 | |
| 29 | |
| 30 | *** Keywords *** |
| 31 | Create Network Service |
| garciadeblas | 4397917 | 2021-03-26 10:46:13 +0100 | [diff] [blame] | 32 | [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config} ${publickey} ${ns_launch_max_wait_time}=5min ${config_file}=${EMPTY} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 33 | |
| garciadeblas | 4397917 | 2021-03-26 10:46:13 +0100 | [diff] [blame] | 34 | ${ns_launch_max_wait_time}= Convert Time ${ns_launch_max_wait_time} result_format=number |
| 35 | ${ns_launch_max_wait_time}= Evaluate ${ns_launch_max_wait_time} * ${vim_timeout_multiplier} |
| 36 | Log ${ns_launch_max_wait_time} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 37 | ${config_attr} Set Variable If '${ns_config}'!='${EMPTY}' --config '${ns_config}' \ |
| 38 | ${sshkeys_attr} Set Variable If '${publickey}'!='${EMPTY}' --ssh_keys ${publickey} \ |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 39 | ${config_file_attr} Set Variable If '${config_file}'!='${EMPTY}' --config_file '${config_file}' \ |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 40 | |
| calvinosanc1 | 9b272c5 | 2020-07-03 17:28:12 +0200 | [diff] [blame] | 41 | ${ns_id}= Instantiate Network Service ${ns_name} ${nsd} ${vim_name} ${config_attr} ${sshkeys_attr} ${config_file_attr} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 42 | Log ${ns_id} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 43 | |
| 44 | WAIT UNTIL KEYWORD SUCCEEDS ${ns_launch_max_wait_time} ${ns_launch_pol_time} Check For NS Instance To Configured ${ns_name} |
| 45 | Check For NS Instance For Failure ${ns_name} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 46 | [Return] ${ns_id} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 47 | |
| 48 | |
| 49 | Instantiate Network Service |
| 50 | [Arguments] ${ns_name} ${nsd} ${vim_name} ${ns_extra_args} |
| 51 | |
| 52 | ${rc} ${stdout}= Run and Return RC and Output osm ns-create --ns_name ${ns_name} --nsd_name ${nsd} --vim_account ${vim_name} ${ns_extra_args} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 53 | Log ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 54 | Should Be Equal As Integers ${rc} ${success_return_code} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 55 | [Return] ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 56 | |
| 57 | |
| aticig | 6cd7480 | 2022-05-11 19:31:46 +0300 | [diff] [blame] | 58 | Update Network Service |
| 59 | [Arguments] ${ns_id} ${update_type} ${ns_update_config} ${ns_update_timeout} |
| 60 | |
| 61 | ${rc} ${stdout}= Run and Return RC and Output osm ns-update ${ns_id} --updatetype ${update_type} --config ${ns_update_config} --timeout ${ns_update_timeout} --wait |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 62 | Log ${stdout} |
| aticig | 6cd7480 | 2022-05-11 19:31:46 +0300 | [diff] [blame] | 63 | Should Be Equal As Integers ${rc} ${success_return_code} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 64 | [Return] ${stdout} |
| aticig | 6cd7480 | 2022-05-11 19:31:46 +0300 | [diff] [blame] | 65 | |
| 66 | |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 67 | Get Vnf Management Ip Address |
| 68 | [Arguments] ${ns_id} ${vnf_member_index} |
| 69 | |
| 70 | Should Not Be Empty ${ns_id} |
| 71 | Should Not Be Empty ${vnf_member_index} |
| 72 | ${rc} ${stdout}= Run and Return RC and Output osm vnf-list --filter member-vnf-index-ref=${vnf_member_index} | grep ${ns_id} | awk '{print $14}' 2>&1 |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 73 | Log ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 74 | Should Be Equal As Integers ${rc} ${success_return_code} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 75 | [Return] ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 76 | |
| 77 | |
| aguilarherna | ee95f36 | 2021-02-25 17:15:50 +0100 | [diff] [blame] | 78 | Get Vnf Id |
| 79 | [Arguments] ${ns_id} ${vnf_member_index} |
| 80 | |
| 81 | Should Not Be Empty ${ns_id} |
| 82 | Should Not Be Empty ${vnf_member_index} |
| 83 | ${rc} ${stdout}= Run and Return RC and Output osm vnf-list --filter member-vnf-index-ref=${vnf_member_index} | grep ${ns_id} | awk '{print $2}' 2>&1 |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 84 | Log ${stdout} |
| aguilarherna | ee95f36 | 2021-02-25 17:15:50 +0100 | [diff] [blame] | 85 | Should Be Equal As Integers ${rc} ${success_return_code} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 86 | [Return] ${stdout} |
| aguilarherna | ee95f36 | 2021-02-25 17:15:50 +0100 | [diff] [blame] | 87 | |
| 88 | |
| rodriguezgar | fbedfe0 | 2022-02-24 20:05:42 +0100 | [diff] [blame] | 89 | Get Ns Id |
| 90 | [Arguments] ${ns_name} |
| 91 | |
| 92 | Should Not Be Empty ${ns_name} |
| 93 | ${rc} ${stdout}= Run and Return RC and Output osm ns-list | grep ${ns_name} | awk '{print $4}' 2>&1 |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 94 | Log ${stdout} |
| rodriguezgar | fbedfe0 | 2022-02-24 20:05:42 +0100 | [diff] [blame] | 95 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 96 | Should Not Be Empty ${stdout} |
| 97 | [Return] ${stdout} |
| 98 | |
| 99 | |
| garciadeblas | 43f3448 | 2023-02-23 17:37:47 +0100 | [diff] [blame] | 100 | Get Ns List |
| 101 | ${rc} ${stdout}= Run and Return RC and Output osm ns-list 2>&1 |
| 102 | Log ${stdout} |
| 103 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 104 | [Return] ${stdout} |
| 105 | |
| 106 | |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 107 | Get Ns Vnf List |
| 108 | [Arguments] ${ns_id} |
| 109 | |
| 110 | Should Not Be Empty ${ns_id} |
| 111 | @{vnf_list_string}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1 |
| 112 | # Returns a String of vnf_id and needs to be converted into a list |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 113 | @{vnf_list} = Split String ${vnf_list_string}[1] |
| 114 | Log List ${vnf_list} |
| 115 | [Return] @{vnf_list} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 116 | |
| 117 | |
| 118 | Get Ns Ip List |
| 119 | [Arguments] @{vnf_list} |
| 120 | |
| 121 | should not be empty @{vnf_list} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 122 | @{temp_list}= Create List |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 123 | FOR ${vnf_id} IN @{vnf_list} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 124 | Log ${vnf_id} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 125 | @{vnf_ip_list} Get Vnf Ip List ${vnf_id} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 126 | @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 127 | END |
| 128 | should not be empty ${temp_list} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 129 | [return] @{temp_list} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 130 | |
| 131 | |
| 132 | Get Vnf Ip List |
| 133 | [arguments] ${vnf_id} |
| 134 | |
| 135 | should not be empty ${vnf_id} |
| garciaale | c88e004 | 2020-12-07 21:03:33 +0000 | [diff] [blame] | 136 | @{vnf_ip_list_string}= run and return rc and output osm vnf-list --filter id=${vnf_id} | grep -o '[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}' | sort -t: -u -k1,1 2>&1 |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 137 | # returns a string of ip addresses and needs to be converted into a list |
| 138 | should not be empty ${vnf_ip_list_string}[1] |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 139 | @{vnf_ip_list} = split string ${vnf_ip_list_string}[1] |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 140 | Log Many ${vnf_ip_list} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 141 | should not be empty ${vnf_ip_list} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 142 | [return] @{vnf_ip_list} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 143 | |
| 144 | |
| 145 | Check For Ns Instance To Configured |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 146 | [arguments] ${ns_name} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 147 | |
| beierlm | eb5556e | 2021-05-12 04:53:49 -0400 | [diff] [blame] | 148 | ${rc} ${stdout}= Run and Return RC and Output openstack server list |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 149 | Log ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 150 | ${rc} ${stdout}= run and return rc and output osm ns-list --filter name="${ns_name}" |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 151 | Log ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 152 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 153 | Should Contain Any ${stdout} READY BROKEN |
| 154 | |
| 155 | Check For NS Instance For Failure |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 156 | [Arguments] ${ns_name} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 157 | |
| beierlm | eb5556e | 2021-05-12 04:53:49 -0400 | [diff] [blame] | 158 | ${rc} ${stdout}= Run and Return RC and Output openstack server list |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 159 | Log ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 160 | ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}" |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 161 | Log ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 162 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 163 | Should Not Contain ${stdout} BROKEN |
| 164 | |
| 165 | Check For NS Instance To Be Deleted |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 166 | [Arguments] ${ns} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 167 | |
| beierlm | eb5556e | 2021-05-12 04:53:49 -0400 | [diff] [blame] | 168 | ${rc} ${stdout}= Run and Return RC and Output openstack server list |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 169 | Log ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 170 | ${rc} ${stdout}= Run and Return RC and Output osm ns-list | awk '{print $2}' | grep ${ns} |
| 171 | Should Not Be Equal As Strings ${stdout} ${ns} |
| 172 | |
| 173 | Delete NS |
| garciadeblas | 4397917 | 2021-03-26 10:46:13 +0100 | [diff] [blame] | 174 | [Documentation] Delete ns |
| 175 | [Arguments] ${ns} ${ns_delete_max_wait_time}=4min |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 176 | |
| garciadeblas | 4397917 | 2021-03-26 10:46:13 +0100 | [diff] [blame] | 177 | ${ns_delete_max_wait_time}= Convert Time ${ns_delete_max_wait_time} result_format=number |
| 178 | ${ns_delete_max_wait_time}= Evaluate ${ns_delete_max_wait_time} * ${vim_timeout_multiplier} |
| 179 | Log ${ns_delete_max_wait_time} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 180 | ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns} |
| garciadeblas | 4397917 | 2021-03-26 10:46:13 +0100 | [diff] [blame] | 181 | Log ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 182 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 183 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 184 | WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Deleted ${ns} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 185 | |
| 186 | Execute NS Action |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 187 | [Documentation] Execute an action over the desired NS. |
| 188 | ... Parameters are given to this function in key=value format (one argument per key/value pair). |
| 189 | ... Return the ID of the operation associated to the executed action. |
| 190 | ... Examples of execution: |
| 191 | ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} |
| 192 | ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 193 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 194 | [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 195 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 196 | ${params}= Set Variable ${EMPTY} |
| 197 | FOR ${param} IN @{action_params} |
| 198 | ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters |
| 199 | ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}", |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 200 | END |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 201 | ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index} |
| 202 | ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}' |
| 203 | ... ELSE Set Variable ${osm_ns_action_command} |
| 204 | ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name} |
| 205 | ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command} |
| 206 | Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False |
| 207 | Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Ended ${stdout} |
| 208 | Check For NS Operation Completed ${stdout} |
| 209 | [Return] ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 210 | |
| 211 | |
| Dominik Fleischmann | a07c2b3 | 2020-07-31 15:17:26 +0200 | [diff] [blame] | 212 | Execute NS K8s Action |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 213 | [Documentation] Execute an action over the desired K8s NS. |
| 214 | ... Parameters are given to this function in key=value format (one argument per key/value pair). |
| 215 | ... Return the ID of the operation associated to the executed action. |
| 216 | ... Examples of execution: |
| 217 | ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} |
| 218 | ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2} |
| Dominik Fleischmann | a07c2b3 | 2020-07-31 15:17:26 +0200 | [diff] [blame] | 219 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 220 | [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} ${kdu_name} @{action_params} |
| Dominik Fleischmann | a07c2b3 | 2020-07-31 15:17:26 +0200 | [diff] [blame] | 221 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 222 | ${params}= Set Variable ${EMPTY} |
| 223 | FOR ${param} IN @{action_params} |
| 224 | ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters |
| 225 | ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}", |
| Dominik Fleischmann | a07c2b3 | 2020-07-31 15:17:26 +0200 | [diff] [blame] | 226 | END |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 227 | ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index} --kdu_name ${kdu_name} |
| 228 | ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}' |
| 229 | ... ELSE Set Variable ${osm_ns_action_command} |
| 230 | ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name} |
| 231 | ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command} |
| 232 | Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False |
| 233 | Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Ended ${stdout} |
| 234 | Check For NS Operation Completed ${stdout} |
| 235 | [Return] ${stdout} |
| Dominik Fleischmann | a07c2b3 | 2020-07-31 15:17:26 +0200 | [diff] [blame] | 236 | |
| 237 | |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 238 | Execute Manual VNF Scale |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 239 | [Documentation] Execute a manual VNF Scale action. |
| 240 | ... The parameter 'scale_type' must be SCALE_IN or SCALE_OUT. |
| 241 | ... Return the ID of the operation associated to the executed scale action. |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 242 | |
| garciadeblas | 686ed53 | 2021-05-13 12:38:53 +0200 | [diff] [blame] | 243 | [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type} ${vnf_scale_max_wait_time}=2min |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 244 | |
| garciadeblas | 686ed53 | 2021-05-13 12:38:53 +0200 | [diff] [blame] | 245 | ${vnf_scale_max_wait_time}= Convert Time ${vnf_scale_max_wait_time} result_format=number |
| 246 | ${vnf_scale_max_wait_time}= Evaluate ${vnf_scale_max_wait_time} * ${vim_timeout_multiplier} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 247 | Should Contain Any ${scale_type} SCALE_IN SCALE_OUT msg=Unknown scale type: ${scale_type} values=False |
| 248 | ${osm_vnf_scale_command}= Set Variable osm vnf-scale --scaling-group ${scaling_group} |
| 249 | ${osm_vnf_scale_command}= Run Keyword If '${scale_type}'=='SCALE_IN' Catenate ${osm_vnf_scale_command} --scale-in |
| 250 | ... ELSE Catenate ${osm_vnf_scale_command} --scale-out |
| 251 | ${osm_vnf_scale_command}= Catenate ${osm_vnf_scale_command} ${ns_name} ${vnf_member_index} |
| 252 | ${rc} ${stdout}= Run and Return RC and Output ${osm_vnf_scale_command} |
| 253 | Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False |
| 254 | Wait Until Keyword Succeeds ${vnf_scale_max_wait_time} ${vnf_scale_pol_time} Check For NS Operation Ended ${stdout} |
| 255 | Check For NS Operation Completed ${stdout} |
| 256 | [Return] ${stdout} |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 257 | |
| 258 | |
| 259 | Heal Network Service |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 260 | [Documentation] Execute healing operation over one NS. |
| 261 | ... Return the ID of the operation associated to the executed healing action. |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 262 | |
| 263 | [Arguments] ${ns_name} ${params} ${healing_max_wait_time}=10m |
| 264 | |
| 265 | Should Not Be Empty ${ns_name} |
| 266 | Should Not Be Empty ${params} |
| 267 | ${healing_max_wait_time}= Convert Time ${healing_max_wait_time} result_format=number |
| 268 | ${healing_max_wait_time}= Evaluate ${healing_max_wait_time} * ${vim_timeout_multiplier} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 269 | ${rc} ${stdout}= Run and Return RC and Output osm ns-heal ${ns_name} ${params} |
| 270 | Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False |
| 271 | Wait Until Keyword Succeeds ${healing_max_wait_time} ${healing_pol_time} Check For NS Operation Ended ${stdout} |
| 272 | Check For NS Operation Completed ${stdout} |
| 273 | [Return] ${stdout} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 274 | |
| 275 | |
| 276 | Get Operations List |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 277 | [Arguments] ${ns_name} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 278 | |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 279 | Should Not Be Empty ${ns_name} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 280 | ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name} |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 281 | Log ${stdout} |
| 282 | Log ${rc} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 283 | Should Be Equal As Integers ${rc} ${success_return_code} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 284 | |
| 285 | |
| 286 | Check For NS Operation Completed |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 287 | [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not. |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 288 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 289 | [Arguments] ${ns_operation_id} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 290 | |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 291 | Should Not Be Empty ${ns_operation_id} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 292 | ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq .operationState | tr -d \\" |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 293 | Log ${stdout} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 294 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 295 | Should Contain ${stdout} COMPLETED msg=The ns-action with id ${ns_operation_id} was not completed values=False |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 296 | |
| 297 | |
| 298 | Check For NS Operation Failed |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 299 | [Documentation] Check wheter the status of the desired operation is "FAILED" or not. |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 300 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 301 | [Arguments] ${ns_operation_id} |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 302 | |
| 303 | Should Not Be Empty ${ns_operation_id} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 304 | ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq .operationState | tr -d \\" |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 305 | Log ${stdout} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 306 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 307 | Should Contain ${stdout} FAILED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 308 | |
| 309 | |
| 310 | Check For NS Operation Ended |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 311 | [Documentation] Check wheter the status of the desired operation is "FAILED" or "COMPLETED". |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 312 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 313 | [Arguments] ${ns_operation_id} |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 314 | |
| 315 | Should Not Be Empty ${ns_operation_id} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 316 | ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq .operationState | tr -d \\" |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 317 | Log ${stdout} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 318 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 319 | Should Contain Any ${stdout} FAILED COMPLETED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 320 | |
| 321 | |
| 322 | Get Ns Vnfr Ids |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 323 | [Documentation] Return a list with the IDs of the VNF records of a NS instance. |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 324 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 325 | [Arguments] ${ns_id} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 326 | |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 327 | Should Not Be Empty ${ns_id} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 328 | ${rc} ${stdout}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1 |
| 329 | Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False |
| 330 | @{vdur} = Split String ${stdout} |
| 331 | [Return] @{vdur} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 332 | |
| 333 | |
| 334 | Get Vnf Vdur Names |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 335 | [Documentation] Return a list with the names of the VDU records of a VNF instance. |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 336 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 337 | [Arguments] ${vnf_id} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 338 | |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 339 | Should Not Be Empty ${vnf_id} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 340 | ${rc} ${stdout}= Run and Return RC and Output osm vnf-show ${vnf_id} --literal | yq .vdur[].name | tr -d \\" |
| 341 | Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False |
| 342 | @{vdur} = Split String ${stdout} |
| 343 | [Return] @{vdur} |
| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame] | 344 | |
| aguilarherna | 045bd33 | 2021-03-25 10:25:59 +0100 | [diff] [blame] | 345 | |
| 346 | Get Vnf Kdu Replica Count |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 347 | [Documentation] Return the number of KDU replicas (empty if none) of a VNF instance. |
| aguilarherna | 045bd33 | 2021-03-25 10:25:59 +0100 | [diff] [blame] | 348 | |
| 349 | [Arguments] ${vnf_id} ${kdu_name} |
| 350 | |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 351 | Should Not Be Empty ${vnf_id} |
| 352 | Should Not Be Empty ${kdu_name} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 353 | ${rc} ${stdout}= Run and Return RC and Output osm vnf-show ${vnf_id} --kdu ${kdu_name} | yq .config.replicaCount | tr -d \\" |
| 354 | Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False |
| 355 | ${return} = Set Variable If '${stdout}' == 'null' ${EMPTY} ${stdout} |
| 356 | [Return] ${return} |
| aguilarherna | 045bd33 | 2021-03-25 10:25:59 +0100 | [diff] [blame] | 357 | |
| aktas | de5e4a6 | 2021-08-27 09:13:00 +0300 | [diff] [blame] | 358 | |
| 359 | Get Application Names |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 360 | [Documentation] Return the list of the application of a VNF instance. |
| aktas | de5e4a6 | 2021-08-27 09:13:00 +0300 | [diff] [blame] | 361 | |
| 362 | [Arguments] ${ns_name} |
| 363 | |
| aguilard | 845c2ea | 2022-04-08 09:36:03 +0000 | [diff] [blame] | 364 | Should Not Be Empty ${ns_name} |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 365 | ${rc} ${stdout}= Run and Return RC and Output osm ns-show ${ns_name} --literal | yq ._admin.deployed.VCA[].application | tr -d \\" |
| 366 | Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False |
| 367 | @{app_names} = Split String ${stdout} |
| 368 | [Return] ${app_names} |
| rodriguezgar | fbedfe0 | 2022-02-24 20:05:42 +0100 | [diff] [blame] | 369 | |
| Alexis Romero | dd1b09d | 2022-03-16 06:51:43 +0100 | [diff] [blame] | 370 | |
| 371 | Get VDU Affinity Group Name |
| 372 | [Documentation] Return the affinity group name for a NF |
| 373 | |
| 374 | [Arguments] ${ns_name} ${vnf_id} ${vdur_id} |
| 375 | |
| Alexis Romero | 6b82eaf | 2022-04-07 14:49:27 +0200 | [diff] [blame] | 376 | ${rc} ${affinity_group_id}= Run and Return RC and Output osm vnf-show ${vnf_id} --literal | yq '.vdur[] | select(.id == "'${vdur_id}'")' | yq '."affinity-or-anti-affinity-group-id"[0]' | tr -d \\" 2>&1 |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 377 | Log ${affinity_group_id} |
| Alexis Romero | dd1b09d | 2022-03-16 06:51:43 +0100 | [diff] [blame] | 378 | Should Be Equal As Integers ${rc} ${success_return_code} msg=${affinity_group_id} values=False |
| Alexis Romero | 6b82eaf | 2022-04-07 14:49:27 +0200 | [diff] [blame] | 379 | ${rc} ${affinity_group_name}= Run and Return RC and Output osm ns-show ${ns_name} --literal | yq '."affinity-or-anti-affinity-group"[] | select(.id == "'${affinity_group_id}'")' | yq '.name' | tr -d \\" 2>&1 |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 380 | Log ${affinity_group_name} |
| Alexis Romero | dd1b09d | 2022-03-16 06:51:43 +0100 | [diff] [blame] | 381 | Should Be Equal As Integers ${rc} ${success_return_code} msg=${affinity_group_name} values=False |
| 382 | [Return] ${affinity_group_name} |
| dhanasekaran | 631d161 | 2022-06-16 14:10:06 +0000 | [diff] [blame] | 383 | |
| dhanasekaran | 631d161 | 2022-06-16 14:10:06 +0000 | [diff] [blame] | 384 | Get Operations By Type |
| 385 | [Documentation] Keyword to get the operation by type |
| 386 | |
| garciadeblas | f4ebaa8 | 2022-06-23 13:33:26 +0200 | [diff] [blame] | 387 | [Arguments] ${ns_id} ${type} |
| dhanasekaran | 631d161 | 2022-06-16 14:10:06 +0000 | [diff] [blame] | 388 | |
| 389 | Should Not Be Empty ${ns_id} |
| 390 | Should Not Be Empty ${type} |
| 391 | ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_id} | grep ${type} | awk '{print $2}' 2>&1 |
| garciadeblas | 321726f | 2022-12-21 11:43:06 +0100 | [diff] [blame] | 392 | Log ${stdout} |
| dhanasekaran | 631d161 | 2022-06-16 14:10:06 +0000 | [diff] [blame] | 393 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 394 | Should Not Be Empty ${stdout} |
| 395 | [Return] ${stdout} |