blob: 8acdb46a03891856f77a59110692fedc3dddf80d [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
13*** Variables ***
14${success_return_code} 0
15${ns_launch_pol_time} 30sec
aguilarherna347a7792020-11-16 18:18:25 +010016${ns_delete_max_wait_time} 4min
Felipe Vicensf96bb452020-06-22 08:12:30 +020017${ns_delete_pol_time} 15sec
18${ns_action_max_wait_time} 1min
19${ns_action_pol_time} 15sec
aguilarhernaaba5a5d2021-03-12 11:43:55 +010020${vnf_scale_pol_time} 15sec
Felipe Vicensf96bb452020-06-22 08:12:30 +020021
22
23*** Keywords ***
24Create Network Service
calvinosanc19b272c52020-07-03 17:28:12 +020025 [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 +020026
27 ${config_attr} Set Variable If '${ns_config}'!='${EMPTY}' --config '${ns_config}' \
28 ${sshkeys_attr} Set Variable If '${publickey}'!='${EMPTY}' --ssh_keys ${publickey} \
calvinosanc19b272c52020-07-03 17:28:12 +020029 ${config_file_attr} Set Variable If '${config_file}'!='${EMPTY}' --config_file '${config_file}' \
Felipe Vicensf96bb452020-06-22 08:12:30 +020030
calvinosanc19b272c52020-07-03 17:28:12 +020031 ${ns_id}= Instantiate Network Service ${ns_name} ${nsd} ${vim_name} ${config_attr} ${sshkeys_attr} ${config_file_attr}
Felipe Vicensf96bb452020-06-22 08:12:30 +020032 log ${ns_id}
33
34 WAIT UNTIL KEYWORD SUCCEEDS ${ns_launch_max_wait_time} ${ns_launch_pol_time} Check For NS Instance To Configured ${ns_name}
35 Check For NS Instance For Failure ${ns_name}
36 [Return] ${ns_id}
37
38
39Instantiate Network Service
40 [Arguments] ${ns_name} ${nsd} ${vim_name} ${ns_extra_args}
41
42 ${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}
43 log ${stdout}
44 Should Be Equal As Integers ${rc} ${success_return_code}
45 [Return] ${stdout}
46
47
48Get Vnf Management Ip Address
49 [Arguments] ${ns_id} ${vnf_member_index}
50
51 Should Not Be Empty ${ns_id}
52 Should Not Be Empty ${vnf_member_index}
53 ${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
54 log ${stdout}
55 Should Be Equal As Integers ${rc} ${success_return_code}
56 [Return] ${stdout}
57
58
aguilarhernaee95f362021-02-25 17:15:50 +010059Get Vnf Id
60 [Arguments] ${ns_id} ${vnf_member_index}
61
62 Should Not Be Empty ${ns_id}
63 Should Not Be Empty ${vnf_member_index}
64 ${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
65 log ${stdout}
66 Should Be Equal As Integers ${rc} ${success_return_code}
67 [Return] ${stdout}
68
69
Felipe Vicensf96bb452020-06-22 08:12:30 +020070Get Ns Vnf List
71 [Arguments] ${ns_id}
72
73 Should Not Be Empty ${ns_id}
74 @{vnf_list_string}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
75 # Returns a String of vnf_id and needs to be converted into a list
76 @{vnf_list} = Split String ${vnf_list_string}[1]
77 Log List ${vnf_list}
78 [Return] @{vnf_list}
79
80
81Get Ns Ip List
82 [Arguments] @{vnf_list}
83
84 should not be empty @{vnf_list}
85 @{temp_list}= Create List
86 FOR ${vnf_id} IN @{vnf_list}
87 log ${vnf_id}
88 @{vnf_ip_list} Get Vnf Ip List ${vnf_id}
89 @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list}
90 END
91 should not be empty ${temp_list}
92 [return] @{temp_list}
93
94
95Get Vnf Ip List
96 [arguments] ${vnf_id}
97
98 should not be empty ${vnf_id}
garciaalec88e0042020-12-07 21:03:33 +000099 @{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 +0200100 # returns a string of ip addresses and needs to be converted into a list
101 should not be empty ${vnf_ip_list_string}[1]
102 @{vnf_ip_list} = split string ${vnf_ip_list_string}[1]
103 log list ${vnf_ip_list}
104 should not be empty ${vnf_ip_list}
105 [return] @{vnf_ip_list}
106
107
108Check For Ns Instance To Configured
109 [arguments] ${ns_name}
110
111 ${rc} ${stdout}= run and return rc and output osm ns-list --filter name="${ns_name}"
112 log ${stdout}
113 Should Be Equal As Integers ${rc} ${success_return_code}
114 Should Contain Any ${stdout} READY BROKEN
115
116Check For NS Instance For Failure
117 [Arguments] ${ns_name}
118
119 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
120 log ${stdout}
121 Should Be Equal As Integers ${rc} ${success_return_code}
122 Should Not Contain ${stdout} BROKEN
123
124Check For NS Instance To Be Deleted
125 [Arguments] ${ns}
126
127 ${rc} ${stdout}= Run and Return RC and Output osm ns-list | awk '{print $2}' | grep ${ns}
128 Should Not Be Equal As Strings ${stdout} ${ns}
129
130Delete NS
131 [Documentation] Delete ns
132 [Arguments] ${ns}
133
134 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
135 log ${stdout}
136 Should Be Equal As Integers ${rc} ${success_return_code}
137
138 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Deleted ${ns}
139
140Execute NS Action
141 [Documentation] Execute an action over the desired NS.
142 ... Parameters are given to this function in key=value format (one argument per key/value pair).
143 ... Return the ID of the operation associated to the executed action.
144 ... Examples of execution:
145 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
146 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
147
148 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
149
150 ${params}= Set Variable ${EMPTY}
151 FOR ${param} IN @{action_params}
152 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
153 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
154 END
155 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index}
156 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
157 ... ELSE Set Variable ${osm_ns_action_command}
158 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
159 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
160 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
161 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
162 [Return] ${stdout}
163
164
Dominik Fleischmanna07c2b32020-07-31 15:17:26 +0200165Execute NS K8s Action
166 [Documentation] Execute an action over the desired K8s NS.
167 ... Parameters are given to this function in key=value format (one argument per key/value pair).
168 ... Return the ID of the operation associated to the executed action.
169 ... Examples of execution:
170 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
171 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
172
173 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} ${kdu_name} @{action_params}
174
175 ${params}= Set Variable ${EMPTY}
176 FOR ${param} IN @{action_params}
177 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
178 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
179 END
180 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index} --kdu_name ${kdu_name}
181 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
182 ... ELSE Set Variable ${osm_ns_action_command}
183 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
184 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
185 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
186 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
187 [Return] ${stdout}
188
189
Felipe Vicensf96bb452020-06-22 08:12:30 +0200190Execute Manual VNF Scale
191 [Documentation] Execute a manual VNF Scale action.
192 ... The parameter 'scale_type' must be SCALE_IN or SCALE_OUT.
193 ... Return the ID of the operation associated to the executed scale action.
194
garciadeblas6f7c4442021-05-13 12:38:53 +0200195 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type} ${vnf_scale_max_wait_time}=2min
Felipe Vicensf96bb452020-06-22 08:12:30 +0200196
garciadeblas6f7c4442021-05-13 12:38:53 +0200197 ${vnf_scale_max_wait_time}= Convert Time ${vnf_scale_max_wait_time} result_format=number
198 ${vnf_scale_max_wait_time}= Evaluate ${vnf_scale_max_wait_time} * ${vim_timeout_multiplier}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200199 Should Contain Any ${scale_type} SCALE_IN SCALE_OUT msg=Unknown scale type: ${scale_type} values=False
200 ${osm_vnf_scale_command}= Set Variable osm vnf-scale --scaling-group ${scaling_group}
201 ${osm_vnf_scale_command}= Run Keyword If '${scale_type}'=='SCALE_IN' Catenate ${osm_vnf_scale_command} --scale-in
202 ... ELSE Catenate ${osm_vnf_scale_command} --scale-out
203 ${osm_vnf_scale_command}= Catenate ${osm_vnf_scale_command} ${ns_name} ${vnf_member_index}
204 ${rc} ${stdout}= Run and Return RC and Output ${osm_vnf_scale_command}
205 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
aguilarhernaaba5a5d2021-03-12 11:43:55 +0100206 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 +0200207 [Return] ${stdout}
208
209
210Get Operations List
211 [Arguments] ${ns_name}
212
213 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name}
214 log ${stdout}
215 log ${rc}
216 Should Be Equal As Integers ${rc} ${success_return_code}
217
218
219Check For NS Operation Completed
220 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
221
222 [Arguments] ${ns_operation_id}
223
224 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq r - operationState
225 log ${stdout}
226 Should Be Equal As Integers ${rc} ${success_return_code}
227 Should Contain ${stdout} COMPLETED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False
228
229
230Get Ns Vnfr Ids
231 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
232
233 [Arguments] ${ns_id}
234
235 ${rc} ${stdout}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
236 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
237 @{vdur} = Split String ${stdout}
238 [Return] @{vdur}
239
240
241Get Vnf Vdur Names
242 [Documentation] Return a list with the names of the VDU records of a VNF instance.
243
244 [Arguments] ${vnf_id}
245
246 ${rc} ${stdout}= Run and Return RC and Output osm vnf-show ${vnf_id} --literal | yq r - vdur.*.name
247 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
248 @{vdur} = Split String ${stdout}
249 [Return] @{vdur}
250