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}
103 Should Not Be Empty ${ns_id}
104 @{vnf_list_string}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
105 # Returns a String of vnf_id and needs to be converted into a list
106 @{vnf_list} = Split String ${vnf_list_string}[1]
112 [Arguments] @{vnf_list}
114 should not be empty @{vnf_list}
115 @{temp_list}= Create List
116 FOR ${vnf_id} IN @{vnf_list}
118 @{vnf_ip_list} Get Vnf Ip List ${vnf_id}
119 @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list}
121 should not be empty ${temp_list}
122 [return] @{temp_list}
126 [arguments] ${vnf_id}
128 should not be empty ${vnf_id}
129 @{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
130 # returns a string of ip addresses and needs to be converted into a list
131 should not be empty ${vnf_ip_list_string}[1]
132 @{vnf_ip_list} = split string ${vnf_ip_list_string}[1]
133 log list ${vnf_ip_list}
134 should not be empty ${vnf_ip_list}
135 [return] @{vnf_ip_list}
138 Check For Ns Instance To Configured
139 [arguments] ${ns_name}
141 ${rc} ${stdout}= Run and Return RC and Output openstack server list
143 ${rc} ${stdout}= run and return rc and output osm ns-list --filter name="${ns_name}"
145 Should Be Equal As Integers ${rc} ${success_return_code}
146 Should Contain Any ${stdout} READY BROKEN
148 Check For NS Instance For Failure
149 [Arguments] ${ns_name}
151 ${rc} ${stdout}= Run and Return RC and Output openstack server list
153 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
155 Should Be Equal As Integers ${rc} ${success_return_code}
156 Should Not Contain ${stdout} BROKEN
158 Check For NS Instance To Be Deleted
161 ${rc} ${stdout}= Run and Return RC and Output openstack server list
163 ${rc} ${stdout}= Run and Return RC and Output osm ns-list | awk '{print $2}' | grep ${ns}
164 Should Not Be Equal As Strings ${stdout} ${ns}
167 [Documentation] Delete ns
168 [Arguments] ${ns} ${ns_delete_max_wait_time}=4min
170 ${ns_delete_max_wait_time}= Convert Time ${ns_delete_max_wait_time} result_format=number
171 ${ns_delete_max_wait_time}= Evaluate ${ns_delete_max_wait_time} * ${vim_timeout_multiplier}
172 Log ${ns_delete_max_wait_time}
173 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
175 Should Be Equal As Integers ${rc} ${success_return_code}
177 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Deleted ${ns}
180 [Documentation] Execute an action over the desired NS.
181 ... Parameters are given to this function in key=value format (one argument per key/value pair).
182 ... Return the ID of the operation associated to the executed action.
183 ... Examples of execution:
184 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
185 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
187 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
189 ${params}= Set Variable ${EMPTY}
190 FOR ${param} IN @{action_params}
191 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
192 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
194 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index}
195 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
196 ... ELSE Set Variable ${osm_ns_action_command}
197 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
198 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
199 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
200 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Ended ${stdout}
201 Check For NS Operation Completed ${stdout}
205 Execute NS K8s Action
206 [Documentation] Execute an action over the desired K8s NS.
207 ... Parameters are given to this function in key=value format (one argument per key/value pair).
208 ... Return the ID of the operation associated to the executed action.
209 ... Examples of execution:
210 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
211 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
213 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} ${kdu_name} @{action_params}
215 ${params}= Set Variable ${EMPTY}
216 FOR ${param} IN @{action_params}
217 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
218 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
220 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index} --kdu_name ${kdu_name}
221 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
222 ... ELSE Set Variable ${osm_ns_action_command}
223 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
224 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
225 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
226 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Ended ${stdout}
227 Check For NS Operation Completed ${stdout}
231 Execute Manual VNF Scale
232 [Documentation] Execute a manual VNF Scale action.
233 ... The parameter 'scale_type' must be SCALE_IN or SCALE_OUT.
234 ... Return the ID of the operation associated to the executed scale action.
236 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type} ${vnf_scale_max_wait_time}=2min
238 ${vnf_scale_max_wait_time}= Convert Time ${vnf_scale_max_wait_time} result_format=number
239 ${vnf_scale_max_wait_time}= Evaluate ${vnf_scale_max_wait_time} * ${vim_timeout_multiplier}
240 Should Contain Any ${scale_type} SCALE_IN SCALE_OUT msg=Unknown scale type: ${scale_type} values=False
241 ${osm_vnf_scale_command}= Set Variable osm vnf-scale --scaling-group ${scaling_group}
242 ${osm_vnf_scale_command}= Run Keyword If '${scale_type}'=='SCALE_IN' Catenate ${osm_vnf_scale_command} --scale-in
243 ... ELSE Catenate ${osm_vnf_scale_command} --scale-out
244 ${osm_vnf_scale_command}= Catenate ${osm_vnf_scale_command} ${ns_name} ${vnf_member_index}
245 ${rc} ${stdout}= Run and Return RC and Output ${osm_vnf_scale_command}
246 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
247 Wait Until Keyword Succeeds ${vnf_scale_max_wait_time} ${vnf_scale_pol_time} Check For NS Operation Ended ${stdout}
248 Check For NS Operation Completed ${stdout}
253 [Documentation] Execute healing operation over one NS.
254 ... Return the ID of the operation associated to the executed healing action.
256 [Arguments] ${ns_name} ${params} ${healing_max_wait_time}=10m
258 Should Not Be Empty ${ns_name}
259 Should Not Be Empty ${params}
260 ${healing_max_wait_time}= Convert Time ${healing_max_wait_time} result_format=number
261 ${healing_max_wait_time}= Evaluate ${healing_max_wait_time} * ${vim_timeout_multiplier}
262 ${rc} ${stdout}= Run and Return RC and Output osm ns-heal ${ns_name} ${params}
263 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
264 Wait Until Keyword Succeeds ${healing_max_wait_time} ${healing_pol_time} Check For NS Operation Ended ${stdout}
265 Check For NS Operation Completed ${stdout}
270 [Arguments] ${ns_name}
272 Should Not Be Empty ${ns_name}
273 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name}
276 Should Be Equal As Integers ${rc} ${success_return_code}
279 Check For NS Operation Completed
280 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
282 [Arguments] ${ns_operation_id}
284 Should Not Be Empty ${ns_operation_id}
285 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq .operationState | tr -d \\"
287 Should Be Equal As Integers ${rc} ${success_return_code}
288 Should Contain ${stdout} COMPLETED msg=The ns-action with id ${ns_operation_id} was not completed values=False
291 Check For NS Operation Failed
292 [Documentation] Check wheter the status of the desired operation is "FAILED" or not.
294 [Arguments] ${ns_operation_id}
296 Should Not Be Empty ${ns_operation_id}
297 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq .operationState | tr -d \\"
299 Should Be Equal As Integers ${rc} ${success_return_code}
300 Should Contain ${stdout} FAILED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False
303 Check For NS Operation Ended
304 [Documentation] Check wheter the status of the desired operation is "FAILED" or "COMPLETED".
306 [Arguments] ${ns_operation_id}
308 Should Not Be Empty ${ns_operation_id}
309 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq .operationState | tr -d \\"
311 Should Be Equal As Integers ${rc} ${success_return_code}
312 Should Contain Any ${stdout} FAILED COMPLETED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False
316 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
320 Should Not Be Empty ${ns_id}
321 ${rc} ${stdout}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
322 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
323 @{vdur} = Split String ${stdout}
328 [Documentation] Return a list with the names of the VDU records of a VNF instance.
330 [Arguments] ${vnf_id}
332 Should Not Be Empty ${vnf_id}
333 ${rc} ${stdout}= Run and Return RC and Output osm vnf-show ${vnf_id} --literal | yq .vdur[].name | tr -d \\"
334 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
335 @{vdur} = Split String ${stdout}
339 Get Vnf Kdu Replica Count
340 [Documentation] Return the number of KDU replicas (empty if none) of a VNF instance.
342 [Arguments] ${vnf_id} ${kdu_name}
344 Should Not Be Empty ${vnf_id}
345 Should Not Be Empty ${kdu_name}
346 ${rc} ${stdout}= Run and Return RC and Output osm vnf-show ${vnf_id} --kdu ${kdu_name} | yq .config.replicaCount | tr -d \\"
347 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
348 ${return} = Set Variable If '${stdout}' == 'null' ${EMPTY} ${stdout}
352 Get Application Names
353 [Documentation] Return the list of the application of a VNF instance.
355 [Arguments] ${ns_name}
357 Should Not Be Empty ${ns_name}
358 ${rc} ${stdout}= Run and Return RC and Output osm ns-show ${ns_name} --literal | yq ._admin.deployed.VCA[].application | tr -d \\"
359 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
360 @{app_names} = Split String ${stdout}
361 [Return] ${app_names}
364 Get VDU Affinity Group Name
365 [Documentation] Return the affinity group name for a NF
367 [Arguments] ${ns_name} ${vnf_id} ${vdur_id}
369 ${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
370 log ${affinity_group_id}
371 Should Be Equal As Integers ${rc} ${success_return_code} msg=${affinity_group_id} values=False
372 ${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
373 log ${affinity_group_name}
374 Should Be Equal As Integers ${rc} ${success_return_code} msg=${affinity_group_name} values=False
375 [Return] ${affinity_group_name}
377 Get Operations By Type
378 [Documentation] Keyword to get the operation by type
380 [Arguments] ${ns_id} ${type}
382 Should Not Be Empty ${ns_id}
383 Should Not Be Empty ${type}
384 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_id} | grep ${type} | awk '{print $2}' 2>&1
386 Should Be Equal As Integers ${rc} ${success_return_code}
387 Should Not Be Empty ${stdout}