blob: ed6e699a9b964c51aeba5b80437b607024ef3b67 [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_max_wait_time} 2min
26${vnf_scale_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}
Felipe Vicensf96bb452020-06-22 08:12:30 +020042 log ${ns_id}
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}
46 [Return] ${ns_id}
47
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}
53 log ${stdout}
54 Should Be Equal As Integers ${rc} ${success_return_code}
55 [Return] ${stdout}
56
57
58Get Vnf Management Ip Address
59 [Arguments] ${ns_id} ${vnf_member_index}
60
61 Should Not Be Empty ${ns_id}
62 Should Not Be Empty ${vnf_member_index}
63 ${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
64 log ${stdout}
65 Should Be Equal As Integers ${rc} ${success_return_code}
66 [Return] ${stdout}
67
68
aguilarhernaee95f362021-02-25 17:15:50 +010069Get Vnf Id
70 [Arguments] ${ns_id} ${vnf_member_index}
71
72 Should Not Be Empty ${ns_id}
73 Should Not Be Empty ${vnf_member_index}
74 ${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
75 log ${stdout}
76 Should Be Equal As Integers ${rc} ${success_return_code}
77 [Return] ${stdout}
78
79
Felipe Vicensf96bb452020-06-22 08:12:30 +020080Get Ns Vnf List
81 [Arguments] ${ns_id}
82
83 Should Not Be Empty ${ns_id}
84 @{vnf_list_string}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
85 # Returns a String of vnf_id and needs to be converted into a list
86 @{vnf_list} = Split String ${vnf_list_string}[1]
87 Log List ${vnf_list}
88 [Return] @{vnf_list}
89
90
91Get Ns Ip List
92 [Arguments] @{vnf_list}
93
94 should not be empty @{vnf_list}
95 @{temp_list}= Create List
96 FOR ${vnf_id} IN @{vnf_list}
97 log ${vnf_id}
98 @{vnf_ip_list} Get Vnf Ip List ${vnf_id}
99 @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list}
100 END
101 should not be empty ${temp_list}
102 [return] @{temp_list}
103
104
105Get Vnf Ip List
106 [arguments] ${vnf_id}
107
108 should not be empty ${vnf_id}
garciaalec88e0042020-12-07 21:03:33 +0000109 @{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 +0200110 # returns a string of ip addresses and needs to be converted into a list
111 should not be empty ${vnf_ip_list_string}[1]
112 @{vnf_ip_list} = split string ${vnf_ip_list_string}[1]
113 log list ${vnf_ip_list}
114 should not be empty ${vnf_ip_list}
115 [return] @{vnf_ip_list}
116
117
118Check For Ns Instance To Configured
119 [arguments] ${ns_name}
120
121 ${rc} ${stdout}= run and return rc and output osm ns-list --filter name="${ns_name}"
122 log ${stdout}
123 Should Be Equal As Integers ${rc} ${success_return_code}
124 Should Contain Any ${stdout} READY BROKEN
125
126Check For NS Instance For Failure
127 [Arguments] ${ns_name}
128
129 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
130 log ${stdout}
131 Should Be Equal As Integers ${rc} ${success_return_code}
132 Should Not Contain ${stdout} BROKEN
133
134Check For NS Instance To Be Deleted
135 [Arguments] ${ns}
136
137 ${rc} ${stdout}= Run and Return RC and Output osm ns-list | awk '{print $2}' | grep ${ns}
138 Should Not Be Equal As Strings ${stdout} ${ns}
139
140Delete NS
garciadeblas43979172021-03-26 10:46:13 +0100141 [Documentation] Delete ns
142 [Arguments] ${ns} ${ns_delete_max_wait_time}=4min
Felipe Vicensf96bb452020-06-22 08:12:30 +0200143
garciadeblas43979172021-03-26 10:46:13 +0100144 ${ns_delete_max_wait_time}= Convert Time ${ns_delete_max_wait_time} result_format=number
145 ${ns_delete_max_wait_time}= Evaluate ${ns_delete_max_wait_time} * ${vim_timeout_multiplier}
146 Log ${ns_delete_max_wait_time}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200147 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
garciadeblas43979172021-03-26 10:46:13 +0100148 Log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200149 Should Be Equal As Integers ${rc} ${success_return_code}
150
151 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Deleted ${ns}
152
153Execute NS Action
154 [Documentation] Execute an action over the desired NS.
155 ... Parameters are given to this function in key=value format (one argument per key/value pair).
156 ... Return the ID of the operation associated to the executed action.
157 ... Examples of execution:
158 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
159 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
160
161 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
162
163 ${params}= Set Variable ${EMPTY}
164 FOR ${param} IN @{action_params}
165 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
166 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
167 END
168 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index}
169 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
170 ... ELSE Set Variable ${osm_ns_action_command}
171 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
172 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
173 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
174 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
175 [Return] ${stdout}
176
177
Dominik Fleischmanna07c2b32020-07-31 15:17:26 +0200178Execute NS K8s Action
179 [Documentation] Execute an action over the desired K8s NS.
180 ... Parameters are given to this function in key=value format (one argument per key/value pair).
181 ... Return the ID of the operation associated to the executed action.
182 ... Examples of execution:
183 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
184 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
185
186 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} ${kdu_name} @{action_params}
187
188 ${params}= Set Variable ${EMPTY}
189 FOR ${param} IN @{action_params}
190 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
191 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
192 END
193 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index} --kdu_name ${kdu_name}
194 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
195 ... ELSE Set Variable ${osm_ns_action_command}
196 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
197 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
198 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
199 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
200 [Return] ${stdout}
201
202
Felipe Vicensf96bb452020-06-22 08:12:30 +0200203Execute Manual VNF Scale
204 [Documentation] Execute a manual VNF Scale action.
205 ... The parameter 'scale_type' must be SCALE_IN or SCALE_OUT.
206 ... Return the ID of the operation associated to the executed scale action.
207
208 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type}
209
210 Should Contain Any ${scale_type} SCALE_IN SCALE_OUT msg=Unknown scale type: ${scale_type} values=False
211 ${osm_vnf_scale_command}= Set Variable osm vnf-scale --scaling-group ${scaling_group}
212 ${osm_vnf_scale_command}= Run Keyword If '${scale_type}'=='SCALE_IN' Catenate ${osm_vnf_scale_command} --scale-in
213 ... ELSE Catenate ${osm_vnf_scale_command} --scale-out
214 ${osm_vnf_scale_command}= Catenate ${osm_vnf_scale_command} ${ns_name} ${vnf_member_index}
215 ${rc} ${stdout}= Run and Return RC and Output ${osm_vnf_scale_command}
216 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
aguilarhernaff0b39e2021-03-12 11:43:55 +0100217 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 +0200218 [Return] ${stdout}
219
220
221Get Operations List
222 [Arguments] ${ns_name}
223
224 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name}
225 log ${stdout}
226 log ${rc}
227 Should Be Equal As Integers ${rc} ${success_return_code}
228
229
230Check For NS Operation Completed
231 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
232
233 [Arguments] ${ns_operation_id}
234
beierlmdcd73072021-04-14 05:38:04 -0400235 ${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 +0200236 log ${stdout}
237 Should Be Equal As Integers ${rc} ${success_return_code}
238 Should Contain ${stdout} COMPLETED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False
239
240
241Get Ns Vnfr Ids
242 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
243
244 [Arguments] ${ns_id}
245
246 ${rc} ${stdout}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
247 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
248 @{vdur} = Split String ${stdout}
249 [Return] @{vdur}
250
251
252Get Vnf Vdur Names
253 [Documentation] Return a list with the names of the VDU records of a VNF instance.
254
255 [Arguments] ${vnf_id}
256
beierlmdcd73072021-04-14 05:38:04 -0400257 ${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 +0200258 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
259 @{vdur} = Split String ${stdout}
260 [Return] @{vdur}
261
aguilarherna045bd332021-03-25 10:25:59 +0100262
263Get Vnf Kdu Replica Count
264 [Documentation] Return the number of KDU replicas (empty if none) of a VNF instance.
265
266 [Arguments] ${vnf_id} ${kdu_name}
267
beierlmdcd73072021-04-14 05:38:04 -0400268 ${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 +0100269 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
aguilarherna316f7ef2021-04-15 15:42:44 +0000270 ${return} = Set Variable If '${stdout}' == 'null' ${EMPTY} ${stdout}
271 [Return] ${return}
aguilarherna045bd332021-03-25 10:25:59 +0100272