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
5 # http://www.apache.org/licenses/LICENSE-2.0
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.
14 Documentation Library to deploy and delete NS, and run operations on them.
20 ${success_return_code} 0
21 ${ns_launch_pol_time} 30sec
22 ${ns_delete_pol_time} 15sec
23 ${ns_action_max_wait_time} 1min
24 ${ns_action_pol_time} 15sec
25 ${vnf_scale_pol_time} 15sec
26 ${healing_pol_time} 15sec
27 ${vim_timeout_multiplier} %{OSM_VIM_MULTIPLIER_TIMEOUT=1.0}
31 Create Network Service
32 [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config} ${publickey} ${ns_launch_max_wait_time}=5min ${config_file}=${EMPTY}
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}
37 ${config_attr} Set Variable If '${ns_config}'!='${EMPTY}' --config '${ns_config}' \
38 ${sshkeys_attr} Set Variable If '${publickey}'!='${EMPTY}' --ssh_keys ${publickey} \
39 ${config_file_attr} Set Variable If '${config_file}'!='${EMPTY}' --config_file '${config_file}' \
41 ${ns_id}= Instantiate Network Service ${ns_name} ${nsd} ${vim_name} ${config_attr} ${sshkeys_attr} ${config_file_attr}
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}
49 Instantiate Network Service
50 [Arguments] ${ns_name} ${nsd} ${vim_name} ${ns_extra_args}
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}
54 Should Be Equal As Integers ${rc} ${success_return_code}
58 Update Network Service
59 [Arguments] ${ns_id} ${update_type} ${ns_update_config} ${ns_update_timeout}
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
63 Should Be Equal As Integers ${rc} ${success_return_code}
67 Get Vnf Management Ip Address
68 [Arguments] ${ns_id} ${vnf_member_index}
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
74 Should Be Equal As Integers ${rc} ${success_return_code}
79 [Arguments] ${ns_id} ${vnf_member_index}
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
85 Should Be Equal As Integers ${rc} ${success_return_code}
90 [Arguments] ${ns_name}
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
95 Should Be Equal As Integers ${rc} ${success_return_code}
96 Should Not Be Empty ${stdout}
101 ${rc} ${stdout}= Run and Return RC and Output osm ns-list 2>&1
103 Should Be Equal As Integers ${rc} ${success_return_code}
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
113 @{vnf_list} = Split String ${vnf_list_string}[1]
119 [Arguments] @{vnf_list}
121 should not be empty @{vnf_list}
122 @{temp_list}= Create List
123 FOR ${vnf_id} IN @{vnf_list}
125 @{vnf_ip_list} Get Vnf Ip List ${vnf_id}
126 @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list}
128 should not be empty ${temp_list}
129 [return] @{temp_list}
133 [arguments] ${vnf_id}
135 should not be empty ${vnf_id}
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
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]
139 @{vnf_ip_list} = split string ${vnf_ip_list_string}[1]
140 Log Many ${vnf_ip_list}
141 should not be empty ${vnf_ip_list}
142 [return] @{vnf_ip_list}
145 Check For Ns Instance To Configured
146 [arguments] ${ns_name}
148 ${rc} ${stdout}= Run and Return RC and Output openstack server list
150 ${rc} ${stdout}= run and return rc and output osm ns-list --filter name="${ns_name}"
152 Should Be Equal As Integers ${rc} ${success_return_code}
153 Should Contain Any ${stdout} READY BROKEN
155 Check For NS Instance For Failure
156 [Arguments] ${ns_name}
158 ${rc} ${stdout}= Run and Return RC and Output openstack server list
160 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
162 Should Be Equal As Integers ${rc} ${success_return_code}
163 Should Not Contain ${stdout} BROKEN
165 Check For NS Instance To Be Deleted
168 ${rc} ${stdout}= Run and Return RC and Output openstack server list
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}
174 [Documentation] Delete ns
175 [Arguments] ${ns} ${ns_delete_max_wait_time}=4min
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}
180 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
182 Should Be Equal As Integers ${rc} ${success_return_code}
184 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Deleted ${ns}
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}
194 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
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}",
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}
212 Execute NS K8s Action
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}
220 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} ${kdu_name} @{action_params}
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}",
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}
238 Execute Manual VNF Scale
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.
243 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type} ${vnf_scale_max_wait_time}=2min
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}
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}
260 [Documentation] Execute healing operation over one NS.
261 ... Return the ID of the operation associated to the executed healing action.
263 [Arguments] ${ns_name} ${params} ${healing_max_wait_time}=10m
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}
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}
277 [Arguments] ${ns_name}
279 Should Not Be Empty ${ns_name}
280 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name}
283 Should Be Equal As Integers ${rc} ${success_return_code}
286 Check For NS Operation Completed
287 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
289 [Arguments] ${ns_operation_id}
291 Should Not Be Empty ${ns_operation_id}
292 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq .operationState | tr -d \\"
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
298 Check For NS Operation Failed
299 [Documentation] Check wheter the status of the desired operation is "FAILED" or not.
301 [Arguments] ${ns_operation_id}
303 Should Not Be Empty ${ns_operation_id}
304 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq .operationState | tr -d \\"
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
310 Check For NS Operation Ended
311 [Documentation] Check wheter the status of the desired operation is "FAILED" or "COMPLETED".
313 [Arguments] ${ns_operation_id}
315 Should Not Be Empty ${ns_operation_id}
316 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq .operationState | tr -d \\"
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
323 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
327 Should Not Be Empty ${ns_id}
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}
335 [Documentation] Return a list with the names of the VDU records of a VNF instance.
337 [Arguments] ${vnf_id}
339 Should Not Be Empty ${vnf_id}
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}
346 Get Vnf Kdu Replica Count
347 [Documentation] Return the number of KDU replicas (empty if none) of a VNF instance.
349 [Arguments] ${vnf_id} ${kdu_name}
351 Should Not Be Empty ${vnf_id}
352 Should Not Be Empty ${kdu_name}
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}
359 Get Application Names
360 [Documentation] Return the list of the application of a VNF instance.
362 [Arguments] ${ns_name}
364 Should Not Be Empty ${ns_name}
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}
371 Get VDU Affinity Group Name
372 [Documentation] Return the affinity group name for a NF
374 [Arguments] ${ns_name} ${vnf_id} ${vdur_id}
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
377 Log ${affinity_group_id}
378 Should Be Equal As Integers ${rc} ${success_return_code} msg=${affinity_group_id} values=False
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
380 Log ${affinity_group_name}
381 Should Be Equal As Integers ${rc} ${success_return_code} msg=${affinity_group_name} values=False
382 [Return] ${affinity_group_name}
384 Get Operations By Type
385 [Documentation] Keyword to get the operation by type
387 [Arguments] ${ns_id} ${type}
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
393 Should Be Equal As Integers ${rc} ${success_return_code}
394 Should Not Be Empty ${stdout}