blob: a38a69eb9573dc649dd782a7881da122e0bb08e5 [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 ***
14Documentation Library to deploy and delete NS, and run operations on them.
15
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
garciadeblas43979172021-03-26 10:46:13 +010026${vim_timeout_multiplier} %{OSM_VIM_MULTIPLIER_TIMEOUT=1.0}
Felipe Vicensf96bb452020-06-22 08:12:30 +020027
28
29*** Keywords ***
30Create Network Service
garciadeblas43979172021-03-26 10:46:13 +010031 [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 +020032
garciadeblas43979172021-03-26 10:46:13 +010033 ${ns_launch_max_wait_time}= Convert Time ${ns_launch_max_wait_time} result_format=number
34 ${ns_launch_max_wait_time}= Evaluate ${ns_launch_max_wait_time} * ${vim_timeout_multiplier}
35 Log ${ns_launch_max_wait_time}
Felipe Vicensf96bb452020-06-22 08:12:30 +020036 ${config_attr} Set Variable If '${ns_config}'!='${EMPTY}' --config '${ns_config}' \
37 ${sshkeys_attr} Set Variable If '${publickey}'!='${EMPTY}' --ssh_keys ${publickey} \
calvinosanc19b272c52020-07-03 17:28:12 +020038 ${config_file_attr} Set Variable If '${config_file}'!='${EMPTY}' --config_file '${config_file}' \
Felipe Vicensf96bb452020-06-22 08:12:30 +020039
calvinosanc19b272c52020-07-03 17:28:12 +020040 ${ns_id}= Instantiate Network Service ${ns_name} ${nsd} ${vim_name} ${config_attr} ${sshkeys_attr} ${config_file_attr}
Felipe Vicensf96bb452020-06-22 08:12:30 +020041 log ${ns_id}
42
43 WAIT UNTIL KEYWORD SUCCEEDS ${ns_launch_max_wait_time} ${ns_launch_pol_time} Check For NS Instance To Configured ${ns_name}
44 Check For NS Instance For Failure ${ns_name}
45 [Return] ${ns_id}
46
47
48Instantiate Network Service
49 [Arguments] ${ns_name} ${nsd} ${vim_name} ${ns_extra_args}
50
51 ${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}
52 log ${stdout}
53 Should Be Equal As Integers ${rc} ${success_return_code}
54 [Return] ${stdout}
55
56
57Get Vnf Management Ip Address
58 [Arguments] ${ns_id} ${vnf_member_index}
59
60 Should Not Be Empty ${ns_id}
61 Should Not Be Empty ${vnf_member_index}
62 ${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
63 log ${stdout}
64 Should Be Equal As Integers ${rc} ${success_return_code}
65 [Return] ${stdout}
66
67
aguilarhernaee95f362021-02-25 17:15:50 +010068Get Vnf Id
69 [Arguments] ${ns_id} ${vnf_member_index}
70
71 Should Not Be Empty ${ns_id}
72 Should Not Be Empty ${vnf_member_index}
73 ${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
74 log ${stdout}
75 Should Be Equal As Integers ${rc} ${success_return_code}
76 [Return] ${stdout}
77
78
Felipe Vicensf96bb452020-06-22 08:12:30 +020079Get Ns Vnf List
80 [Arguments] ${ns_id}
81
82 Should Not Be Empty ${ns_id}
83 @{vnf_list_string}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
84 # Returns a String of vnf_id and needs to be converted into a list
85 @{vnf_list} = Split String ${vnf_list_string}[1]
86 Log List ${vnf_list}
87 [Return] @{vnf_list}
88
89
90Get Ns Ip List
91 [Arguments] @{vnf_list}
92
93 should not be empty @{vnf_list}
94 @{temp_list}= Create List
95 FOR ${vnf_id} IN @{vnf_list}
96 log ${vnf_id}
97 @{vnf_ip_list} Get Vnf Ip List ${vnf_id}
98 @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list}
99 END
100 should not be empty ${temp_list}
101 [return] @{temp_list}
102
103
104Get Vnf Ip List
105 [arguments] ${vnf_id}
106
107 should not be empty ${vnf_id}
garciaalec88e0042020-12-07 21:03:33 +0000108 @{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 +0200109 # returns a string of ip addresses and needs to be converted into a list
110 should not be empty ${vnf_ip_list_string}[1]
111 @{vnf_ip_list} = split string ${vnf_ip_list_string}[1]
112 log list ${vnf_ip_list}
113 should not be empty ${vnf_ip_list}
114 [return] @{vnf_ip_list}
115
116
117Check For Ns Instance To Configured
118 [arguments] ${ns_name}
119
beierlmeb5556e2021-05-12 04:53:49 -0400120 ${rc} ${stdout}= Run and Return RC and Output openstack server list
121 log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200122 ${rc} ${stdout}= run and return rc and output osm ns-list --filter name="${ns_name}"
123 log ${stdout}
124 Should Be Equal As Integers ${rc} ${success_return_code}
125 Should Contain Any ${stdout} READY BROKEN
126
127Check For NS Instance For Failure
128 [Arguments] ${ns_name}
129
beierlmeb5556e2021-05-12 04:53:49 -0400130 ${rc} ${stdout}= Run and Return RC and Output openstack server list
131 log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200132 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
133 log ${stdout}
134 Should Be Equal As Integers ${rc} ${success_return_code}
135 Should Not Contain ${stdout} BROKEN
136
137Check For NS Instance To Be Deleted
138 [Arguments] ${ns}
139
beierlmeb5556e2021-05-12 04:53:49 -0400140 ${rc} ${stdout}= Run and Return RC and Output openstack server list
141 log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200142 ${rc} ${stdout}= Run and Return RC and Output osm ns-list | awk '{print $2}' | grep ${ns}
143 Should Not Be Equal As Strings ${stdout} ${ns}
144
145Delete NS
garciadeblas43979172021-03-26 10:46:13 +0100146 [Documentation] Delete ns
147 [Arguments] ${ns} ${ns_delete_max_wait_time}=4min
Felipe Vicensf96bb452020-06-22 08:12:30 +0200148
garciadeblas43979172021-03-26 10:46:13 +0100149 ${ns_delete_max_wait_time}= Convert Time ${ns_delete_max_wait_time} result_format=number
150 ${ns_delete_max_wait_time}= Evaluate ${ns_delete_max_wait_time} * ${vim_timeout_multiplier}
151 Log ${ns_delete_max_wait_time}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200152 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
garciadeblas43979172021-03-26 10:46:13 +0100153 Log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200154 Should Be Equal As Integers ${rc} ${success_return_code}
155
156 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Deleted ${ns}
157
158Execute NS Action
159 [Documentation] Execute an action over the desired NS.
160 ... Parameters are given to this function in key=value format (one argument per key/value pair).
161 ... Return the ID of the operation associated to the executed action.
162 ... Examples of execution:
163 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
164 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
165
166 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
167
168 ${params}= Set Variable ${EMPTY}
169 FOR ${param} IN @{action_params}
170 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
171 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
172 END
173 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index}
174 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
175 ... ELSE Set Variable ${osm_ns_action_command}
176 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
177 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
178 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
179 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
180 [Return] ${stdout}
181
182
Dominik Fleischmanna07c2b32020-07-31 15:17:26 +0200183Execute NS K8s Action
184 [Documentation] Execute an action over the desired K8s NS.
185 ... Parameters are given to this function in key=value format (one argument per key/value pair).
186 ... Return the ID of the operation associated to the executed action.
187 ... Examples of execution:
188 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
189 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
190
191 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} ${kdu_name} @{action_params}
192
193 ${params}= Set Variable ${EMPTY}
194 FOR ${param} IN @{action_params}
195 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
196 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
197 END
198 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index} --kdu_name ${kdu_name}
199 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
200 ... ELSE Set Variable ${osm_ns_action_command}
201 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
202 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
203 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
204 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
205 [Return] ${stdout}
206
207
Felipe Vicensf96bb452020-06-22 08:12:30 +0200208Execute Manual VNF Scale
209 [Documentation] Execute a manual VNF Scale action.
210 ... The parameter 'scale_type' must be SCALE_IN or SCALE_OUT.
211 ... Return the ID of the operation associated to the executed scale action.
212
garciadeblas686ed532021-05-13 12:38:53 +0200213 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type} ${vnf_scale_max_wait_time}=2min
Felipe Vicensf96bb452020-06-22 08:12:30 +0200214
garciadeblas686ed532021-05-13 12:38:53 +0200215 ${vnf_scale_max_wait_time}= Convert Time ${vnf_scale_max_wait_time} result_format=number
216 ${vnf_scale_max_wait_time}= Evaluate ${vnf_scale_max_wait_time} * ${vim_timeout_multiplier}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200217 Should Contain Any ${scale_type} SCALE_IN SCALE_OUT msg=Unknown scale type: ${scale_type} values=False
218 ${osm_vnf_scale_command}= Set Variable osm vnf-scale --scaling-group ${scaling_group}
219 ${osm_vnf_scale_command}= Run Keyword If '${scale_type}'=='SCALE_IN' Catenate ${osm_vnf_scale_command} --scale-in
220 ... ELSE Catenate ${osm_vnf_scale_command} --scale-out
221 ${osm_vnf_scale_command}= Catenate ${osm_vnf_scale_command} ${ns_name} ${vnf_member_index}
222 ${rc} ${stdout}= Run and Return RC and Output ${osm_vnf_scale_command}
223 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
aguilarhernaff0b39e2021-03-12 11:43:55 +0100224 Wait Until Keyword Succeeds ${vnf_scale_max_wait_time} ${vnf_scale_pol_time} Check For NS Operation Completed ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200225 [Return] ${stdout}
226
227
228Get Operations List
229 [Arguments] ${ns_name}
230
231 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name}
232 log ${stdout}
233 log ${rc}
234 Should Be Equal As Integers ${rc} ${success_return_code}
235
236
237Check For NS Operation Completed
238 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
239
240 [Arguments] ${ns_operation_id}
241
beierlmdcd73072021-04-14 05:38:04 -0400242 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq .operationState | tr -d \\"
Felipe Vicensf96bb452020-06-22 08:12:30 +0200243 log ${stdout}
244 Should Be Equal As Integers ${rc} ${success_return_code}
245 Should Contain ${stdout} COMPLETED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False
246
247
248Get Ns Vnfr Ids
249 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
250
251 [Arguments] ${ns_id}
252
253 ${rc} ${stdout}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
254 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
255 @{vdur} = Split String ${stdout}
256 [Return] @{vdur}
257
258
259Get Vnf Vdur Names
260 [Documentation] Return a list with the names of the VDU records of a VNF instance.
261
262 [Arguments] ${vnf_id}
263
beierlmdcd73072021-04-14 05:38:04 -0400264 ${rc} ${stdout}= Run and Return RC and Output osm vnf-show ${vnf_id} --literal | yq .vdur[].name | tr -d \\"
Felipe Vicensf96bb452020-06-22 08:12:30 +0200265 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
266 @{vdur} = Split String ${stdout}
267 [Return] @{vdur}
268
aguilarherna045bd332021-03-25 10:25:59 +0100269
270Get Vnf Kdu Replica Count
271 [Documentation] Return the number of KDU replicas (empty if none) of a VNF instance.
272
273 [Arguments] ${vnf_id} ${kdu_name}
274
beierlmdcd73072021-04-14 05:38:04 -0400275 ${rc} ${stdout}= Run and Return RC and Output osm vnf-show ${vnf_id} --kdu ${kdu_name} | yq .config.replicaCount | tr -d \\"
aguilarherna045bd332021-03-25 10:25:59 +0100276 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
aguilarherna316f7ef2021-04-15 15:42:44 +0000277 ${return} = Set Variable If '${stdout}' == 'null' ${EMPTY} ${stdout}
278 [Return] ${return}
aguilarherna045bd332021-03-25 10:25:59 +0100279
aktasde5e4a62021-08-27 09:13:00 +0300280
281Get Application Names
282 [Documentation] Return the list of the application of a VNF instance.
283
284 [Arguments] ${ns_name}
285
286 ${rc} ${stdout}= Run and Return RC and Output osm ns-show ${ns_name} --literal | yq ._admin.deployed.VCA[].application | tr -d \\"
287 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
288 @{app_names} = Split String ${stdout}
289 [Return] ${app_names}