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