blob: aa0830ff414d9ddc067db7a99cbebef5b3d4308f [file] [log] [blame]
Felipe Vicensf96bb452020-06-22 08:12:30 +02001# 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
garciadeblas43979172021-03-26 10:46:13 +010013*** Settings ***
garciadeblasf4ebaa82022-06-23 13:33:26 +020014Documentation Library to deploy and delete NS, and run operations on them.
garciadeblas43979172021-03-26 10:46:13 +010015
16Library DateTime
17
18
Felipe Vicensf96bb452020-06-22 08:12:30 +020019*** Variables ***
20${success_return_code} 0
21${ns_launch_pol_time} 30sec
Felipe Vicensf96bb452020-06-22 08:12:30 +020022${ns_delete_pol_time} 15sec
23${ns_action_max_wait_time} 1min
24${ns_action_pol_time} 15sec
aguilarhernaff0b39e2021-03-12 11:43:55 +010025${vnf_scale_pol_time} 15sec
aguilard845c2ea2022-04-08 09:36:03 +000026${healing_pol_time} 15sec
garciadeblas43979172021-03-26 10:46:13 +010027${vim_timeout_multiplier} %{OSM_VIM_MULTIPLIER_TIMEOUT=1.0}
Felipe Vicensf96bb452020-06-22 08:12:30 +020028
29
30*** Keywords ***
31Create Network Service
garciadeblas43979172021-03-26 10:46:13 +010032 [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config} ${publickey} ${ns_launch_max_wait_time}=5min ${config_file}=${EMPTY}
Felipe Vicensf96bb452020-06-22 08:12:30 +020033
garciadeblas43979172021-03-26 10:46:13 +010034 ${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 Vicensf96bb452020-06-22 08:12:30 +020037 ${config_attr} Set Variable If '${ns_config}'!='${EMPTY}' --config '${ns_config}' \
38 ${sshkeys_attr} Set Variable If '${publickey}'!='${EMPTY}' --ssh_keys ${publickey} \
calvinosanc19b272c52020-07-03 17:28:12 +020039 ${config_file_attr} Set Variable If '${config_file}'!='${EMPTY}' --config_file '${config_file}' \
Felipe Vicensf96bb452020-06-22 08:12:30 +020040
calvinosanc19b272c52020-07-03 17:28:12 +020041 ${ns_id}= Instantiate Network Service ${ns_name} ${nsd} ${vim_name} ${config_attr} ${sshkeys_attr} ${config_file_attr}
garciadeblas321726f2022-12-21 11:43:06 +010042 Log ${ns_id}
Felipe Vicensf96bb452020-06-22 08:12:30 +020043
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}
garciadeblasf4ebaa82022-06-23 13:33:26 +020046 [Return] ${ns_id}
Felipe Vicensf96bb452020-06-22 08:12:30 +020047
48
49Instantiate 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}
garciadeblas321726f2022-12-21 11:43:06 +010053 Log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +020054 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +020055 [Return] ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +020056
57
aticig6cd74802022-05-11 19:31:46 +030058Update 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
garciadeblas321726f2022-12-21 11:43:06 +010062 Log ${stdout}
aticig6cd74802022-05-11 19:31:46 +030063 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +020064 [Return] ${stdout}
aticig6cd74802022-05-11 19:31:46 +030065
66
Felipe Vicensf96bb452020-06-22 08:12:30 +020067Get 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
garciadeblas321726f2022-12-21 11:43:06 +010073 Log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +020074 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +020075 [Return] ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +020076
77
aguilarhernaee95f362021-02-25 17:15:50 +010078Get 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
garciadeblas321726f2022-12-21 11:43:06 +010084 Log ${stdout}
aguilarhernaee95f362021-02-25 17:15:50 +010085 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +020086 [Return] ${stdout}
aguilarhernaee95f362021-02-25 17:15:50 +010087
88
rodriguezgarfbedfe02022-02-24 20:05:42 +010089Get 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
garciadeblas321726f2022-12-21 11:43:06 +010094 Log ${stdout}
rodriguezgarfbedfe02022-02-24 20:05:42 +010095 Should Be Equal As Integers ${rc} ${success_return_code}
96 Should Not Be Empty ${stdout}
97 [Return] ${stdout}
98
99
garciadeblas43f34482023-02-23 17:37:47 +0100100Get 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 Vicensf96bb452020-06-22 08:12:30 +0200107Get Ns Vnf List
108 [Arguments] ${ns_id}
109
110 Should Not Be Empty ${ns_id}
garciadeblas9553b6f2023-06-19 12:00:49 +0200111 @{vnf_list_string}= Run and Return RC and Output osm vnf-list --ns ${ns_id} | grep ${ns_id} | awk '{print $2}' 2>&1
Felipe Vicensf96bb452020-06-22 08:12:30 +0200112 # Returns a String of vnf_id and needs to be converted into a list
garciadeblasf4ebaa82022-06-23 13:33:26 +0200113 @{vnf_list} = Split String ${vnf_list_string}[1]
114 Log List ${vnf_list}
115 [Return] @{vnf_list}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200116
117
118Get Ns Ip List
119 [Arguments] @{vnf_list}
120
121 should not be empty @{vnf_list}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200122 @{temp_list}= Create List
Felipe Vicensf96bb452020-06-22 08:12:30 +0200123 FOR ${vnf_id} IN @{vnf_list}
garciadeblas321726f2022-12-21 11:43:06 +0100124 Log ${vnf_id}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200125 @{vnf_ip_list} Get Vnf Ip List ${vnf_id}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200126 @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200127 END
128 should not be empty ${temp_list}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200129 [return] @{temp_list}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200130
131
132Get Vnf Ip List
133 [arguments] ${vnf_id}
134
135 should not be empty ${vnf_id}
garciaalec88e0042020-12-07 21:03:33 +0000136 @{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 Vicensf96bb452020-06-22 08:12:30 +0200137 # returns a string of ip addresses and needs to be converted into a list
138 should not be empty ${vnf_ip_list_string}[1]
garciadeblasf4ebaa82022-06-23 13:33:26 +0200139 @{vnf_ip_list} = split string ${vnf_ip_list_string}[1]
garciadeblas321726f2022-12-21 11:43:06 +0100140 Log Many ${vnf_ip_list}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200141 should not be empty ${vnf_ip_list}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200142 [return] @{vnf_ip_list}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200143
144
145Check For Ns Instance To Configured
garciadeblasf4ebaa82022-06-23 13:33:26 +0200146 [arguments] ${ns_name}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200147
beierlmeb5556e2021-05-12 04:53:49 -0400148 ${rc} ${stdout}= Run and Return RC and Output openstack server list
garciadeblas321726f2022-12-21 11:43:06 +0100149 Log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200150 ${rc} ${stdout}= run and return rc and output osm ns-list --filter name="${ns_name}"
garciadeblas321726f2022-12-21 11:43:06 +0100151 Log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200152 Should Be Equal As Integers ${rc} ${success_return_code}
153 Should Contain Any ${stdout} READY BROKEN
154
155Check For NS Instance For Failure
garciadeblasf4ebaa82022-06-23 13:33:26 +0200156 [Arguments] ${ns_name}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200157
beierlmeb5556e2021-05-12 04:53:49 -0400158 ${rc} ${stdout}= Run and Return RC and Output openstack server list
garciadeblas321726f2022-12-21 11:43:06 +0100159 Log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200160 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
garciadeblas321726f2022-12-21 11:43:06 +0100161 Log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200162 Should Be Equal As Integers ${rc} ${success_return_code}
163 Should Not Contain ${stdout} BROKEN
164
165Check For NS Instance To Be Deleted
garciadeblasf4ebaa82022-06-23 13:33:26 +0200166 [Arguments] ${ns}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200167
beierlmeb5556e2021-05-12 04:53:49 -0400168 ${rc} ${stdout}= Run and Return RC and Output openstack server list
garciadeblas321726f2022-12-21 11:43:06 +0100169 Log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200170 ${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
173Delete NS
garciadeblas43979172021-03-26 10:46:13 +0100174 [Documentation] Delete ns
175 [Arguments] ${ns} ${ns_delete_max_wait_time}=4min
Felipe Vicensf96bb452020-06-22 08:12:30 +0200176
garciadeblas43979172021-03-26 10:46:13 +0100177 ${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 Vicensf96bb452020-06-22 08:12:30 +0200180 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
garciadeblas43979172021-03-26 10:46:13 +0100181 Log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200182 Should Be Equal As Integers ${rc} ${success_return_code}
183
garciadeblasf4ebaa82022-06-23 13:33:26 +0200184 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Deleted ${ns}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200185
186Execute NS Action
garciadeblasf4ebaa82022-06-23 13:33:26 +0200187 [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 Vicensf96bb452020-06-22 08:12:30 +0200193
garciadeblasf4ebaa82022-06-23 13:33:26 +0200194 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200195
garciadeblasf4ebaa82022-06-23 13:33:26 +0200196 ${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 Vicensf96bb452020-06-22 08:12:30 +0200200 END
garciadeblasf4ebaa82022-06-23 13:33:26 +0200201 ${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 Vicensf96bb452020-06-22 08:12:30 +0200210
211
Dominik Fleischmanna07c2b32020-07-31 15:17:26 +0200212Execute NS K8s Action
garciadeblasf4ebaa82022-06-23 13:33:26 +0200213 [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 Fleischmanna07c2b32020-07-31 15:17:26 +0200219
garciadeblasf4ebaa82022-06-23 13:33:26 +0200220 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} ${kdu_name} @{action_params}
Dominik Fleischmanna07c2b32020-07-31 15:17:26 +0200221
garciadeblasf4ebaa82022-06-23 13:33:26 +0200222 ${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 Fleischmanna07c2b32020-07-31 15:17:26 +0200226 END
garciadeblasf4ebaa82022-06-23 13:33:26 +0200227 ${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 Fleischmanna07c2b32020-07-31 15:17:26 +0200236
237
Felipe Vicensf96bb452020-06-22 08:12:30 +0200238Execute Manual VNF Scale
garciadeblasf4ebaa82022-06-23 13:33:26 +0200239 [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 Vicensf96bb452020-06-22 08:12:30 +0200242
garciadeblas686ed532021-05-13 12:38:53 +0200243 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type} ${vnf_scale_max_wait_time}=2min
Felipe Vicensf96bb452020-06-22 08:12:30 +0200244
garciadeblas686ed532021-05-13 12:38:53 +0200245 ${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}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200247 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}
aguilard845c2ea2022-04-08 09:36:03 +0000257
258
259Heal Network Service
garciadeblasf4ebaa82022-06-23 13:33:26 +0200260 [Documentation] Execute healing operation over one NS.
261 ... Return the ID of the operation associated to the executed healing action.
aguilard845c2ea2022-04-08 09:36:03 +0000262
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}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200269 ${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 Vicensf96bb452020-06-22 08:12:30 +0200274
275
276Get Operations List
garciadeblasf4ebaa82022-06-23 13:33:26 +0200277 [Arguments] ${ns_name}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200278
aguilard845c2ea2022-04-08 09:36:03 +0000279 Should Not Be Empty ${ns_name}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200280 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name}
garciadeblas321726f2022-12-21 11:43:06 +0100281 Log ${stdout}
282 Log ${rc}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200283 Should Be Equal As Integers ${rc} ${success_return_code}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200284
285
286Check For NS Operation Completed
garciadeblasf4ebaa82022-06-23 13:33:26 +0200287 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
Felipe Vicensf96bb452020-06-22 08:12:30 +0200288
garciadeblasf4ebaa82022-06-23 13:33:26 +0200289 [Arguments] ${ns_operation_id}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200290
aguilard845c2ea2022-04-08 09:36:03 +0000291 Should Not Be Empty ${ns_operation_id}
garciadeblas9553b6f2023-06-19 12:00:49 +0200292 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq -r .operationState
garciadeblas321726f2022-12-21 11:43:06 +0100293 Log ${stdout}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200294 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
aguilard845c2ea2022-04-08 09:36:03 +0000296
297
298Check For NS Operation Failed
garciadeblasf4ebaa82022-06-23 13:33:26 +0200299 [Documentation] Check wheter the status of the desired operation is "FAILED" or not.
aguilard845c2ea2022-04-08 09:36:03 +0000300
garciadeblasf4ebaa82022-06-23 13:33:26 +0200301 [Arguments] ${ns_operation_id}
aguilard845c2ea2022-04-08 09:36:03 +0000302
303 Should Not Be Empty ${ns_operation_id}
garciadeblas9553b6f2023-06-19 12:00:49 +0200304 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq -r .operationState
garciadeblas321726f2022-12-21 11:43:06 +0100305 Log ${stdout}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200306 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
aguilard845c2ea2022-04-08 09:36:03 +0000308
309
310Check For NS Operation Ended
garciadeblasf4ebaa82022-06-23 13:33:26 +0200311 [Documentation] Check wheter the status of the desired operation is "FAILED" or "COMPLETED".
aguilard845c2ea2022-04-08 09:36:03 +0000312
garciadeblasf4ebaa82022-06-23 13:33:26 +0200313 [Arguments] ${ns_operation_id}
aguilard845c2ea2022-04-08 09:36:03 +0000314
315 Should Not Be Empty ${ns_operation_id}
garciadeblas9553b6f2023-06-19 12:00:49 +0200316 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq -r .operationState
garciadeblas321726f2022-12-21 11:43:06 +0100317 Log ${stdout}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200318 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 Vicensf96bb452020-06-22 08:12:30 +0200320
321
322Get Ns Vnfr Ids
garciadeblasf4ebaa82022-06-23 13:33:26 +0200323 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
Felipe Vicensf96bb452020-06-22 08:12:30 +0200324
garciadeblasf4ebaa82022-06-23 13:33:26 +0200325 [Arguments] ${ns_id}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200326
aguilard845c2ea2022-04-08 09:36:03 +0000327 Should Not Be Empty ${ns_id}
garciadeblas9553b6f2023-06-19 12:00:49 +0200328 ${rc} ${stdout}= Run and Return RC and Output osm vnf-list --ns ${ns_id} | grep ${ns_id} | awk '{print $2}' 2>&1
garciadeblasf4ebaa82022-06-23 13:33:26 +0200329 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
330 @{vdur} = Split String ${stdout}
331 [Return] @{vdur}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200332
333
334Get Vnf Vdur Names
garciadeblasf4ebaa82022-06-23 13:33:26 +0200335 [Documentation] Return a list with the names of the VDU records of a VNF instance.
Felipe Vicensf96bb452020-06-22 08:12:30 +0200336
garciadeblasf4ebaa82022-06-23 13:33:26 +0200337 [Arguments] ${vnf_id}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200338
aguilard845c2ea2022-04-08 09:36:03 +0000339 Should Not Be Empty ${vnf_id}
garciadeblas9553b6f2023-06-19 12:00:49 +0200340 ${rc} ${stdout}= Run and Return RC and Output osm vnf-show ${vnf_id} --literal | yq -r .vdur[].name
garciadeblasf4ebaa82022-06-23 13:33:26 +0200341 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
342 @{vdur} = Split String ${stdout}
343 [Return] @{vdur}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200344
aguilarherna045bd332021-03-25 10:25:59 +0100345
346Get Vnf Kdu Replica Count
garciadeblasf4ebaa82022-06-23 13:33:26 +0200347 [Documentation] Return the number of KDU replicas (empty if none) of a VNF instance.
aguilarherna045bd332021-03-25 10:25:59 +0100348
349 [Arguments] ${vnf_id} ${kdu_name}
350
aguilard845c2ea2022-04-08 09:36:03 +0000351 Should Not Be Empty ${vnf_id}
352 Should Not Be Empty ${kdu_name}
garciadeblas9553b6f2023-06-19 12:00:49 +0200353 ${rc} ${stdout}= Run and Return RC and Output osm vnf-show ${vnf_id} --kdu ${kdu_name} | yq -r .config.replicaCount
garciadeblasf4ebaa82022-06-23 13:33:26 +0200354 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}
aguilarherna045bd332021-03-25 10:25:59 +0100357
aktasde5e4a62021-08-27 09:13:00 +0300358
359Get Application Names
garciadeblasf4ebaa82022-06-23 13:33:26 +0200360 [Documentation] Return the list of the application of a VNF instance.
aktasde5e4a62021-08-27 09:13:00 +0300361
362 [Arguments] ${ns_name}
363
aguilard845c2ea2022-04-08 09:36:03 +0000364 Should Not Be Empty ${ns_name}
garciadeblas9553b6f2023-06-19 12:00:49 +0200365 ${rc} ${stdout}= Run and Return RC and Output osm ns-show ${ns_name} --literal | yq -r ._admin.deployed.VCA[].application
garciadeblasf4ebaa82022-06-23 13:33:26 +0200366 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
367 @{app_names} = Split String ${stdout}
368 [Return] ${app_names}
rodriguezgarfbedfe02022-02-24 20:05:42 +0100369
Alexis Romerodd1b09d2022-03-16 06:51:43 +0100370
371Get VDU Affinity Group Name
372 [Documentation] Return the affinity group name for a NF
373
374 [Arguments] ${ns_name} ${vnf_id} ${vdur_id}
375
garciadeblas9553b6f2023-06-19 12:00:49 +0200376 ${rc} ${affinity_group_id}= Run and Return RC and Output osm vnf-show ${vnf_id} --literal | yq '.vdur[] | select(.id == "'${vdur_id}'")' | yq -r '."affinity-or-anti-affinity-group-id"[0]' 2>&1
garciadeblas321726f2022-12-21 11:43:06 +0100377 Log ${affinity_group_id}
Alexis Romerodd1b09d2022-03-16 06:51:43 +0100378 Should Be Equal As Integers ${rc} ${success_return_code} msg=${affinity_group_id} values=False
garciadeblas9553b6f2023-06-19 12:00:49 +0200379 ${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 -r '.name' 2>&1
garciadeblas321726f2022-12-21 11:43:06 +0100380 Log ${affinity_group_name}
Alexis Romerodd1b09d2022-03-16 06:51:43 +0100381 Should Be Equal As Integers ${rc} ${success_return_code} msg=${affinity_group_name} values=False
382 [Return] ${affinity_group_name}
dhanasekaran631d1612022-06-16 14:10:06 +0000383
dhanasekaran631d1612022-06-16 14:10:06 +0000384Get Operations By Type
385 [Documentation] Keyword to get the operation by type
386
garciadeblasf4ebaa82022-06-23 13:33:26 +0200387 [Arguments] ${ns_id} ${type}
dhanasekaran631d1612022-06-16 14:10:06 +0000388
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
garciadeblas321726f2022-12-21 11:43:06 +0100392 Log ${stdout}
dhanasekaran631d1612022-06-16 14:10:06 +0000393 Should Be Equal As Integers ${rc} ${success_return_code}
394 Should Not Be Empty ${stdout}
395 [Return] ${stdout}