blob: d65f93c7003662b52167755632bfa1e1dbbdf13d [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 ***
garciadeblasf4ebaa82022-06-23 13:33:26 +020014Documentation Library to deploy and delete NS, and run operations on them.
garciadeblas43979172021-03-26 10:46:13 +010015
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
aguilard845c2ea2022-04-08 09:36:03 +000026${healing_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}
garciadeblasf4ebaa82022-06-23 13:33:26 +020046 [Return] ${ns_id}
Felipe Vicensf96bb452020-06-22 08:12:30 +020047
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}
garciadeblasf4ebaa82022-06-23 13:33:26 +020055 [Return] ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +020056
57
aticig6cd74802022-05-11 19:31:46 +030058Update Network Service
59 [Arguments] ${ns_id} ${update_type} ${ns_update_config} ${ns_update_timeout}
60
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
62 log ${stdout}
63 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +020064 [Return] ${stdout}
aticig6cd74802022-05-11 19:31:46 +030065
66
Felipe Vicensf96bb452020-06-22 08:12:30 +020067Get Vnf Management Ip Address
68 [Arguments] ${ns_id} ${vnf_member_index}
69
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
73 log ${stdout}
74 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +020075 [Return] ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +020076
77
aguilarhernaee95f362021-02-25 17:15:50 +010078Get Vnf Id
79 [Arguments] ${ns_id} ${vnf_member_index}
80
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
84 log ${stdout}
85 Should Be Equal As Integers ${rc} ${success_return_code}
garciadeblasf4ebaa82022-06-23 13:33:26 +020086 [Return] ${stdout}
aguilarhernaee95f362021-02-25 17:15:50 +010087
88
rodriguezgarfbedfe02022-02-24 20:05:42 +010089Get Ns Id
90 [Arguments] ${ns_name}
91
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
94 log ${stdout}
95 Should Be Equal As Integers ${rc} ${success_return_code}
96 Should Not Be Empty ${stdout}
97 [Return] ${stdout}
98
99
Felipe Vicensf96bb452020-06-22 08:12:30 +0200100Get Ns Vnf List
101 [Arguments] ${ns_id}
102
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
garciadeblasf4ebaa82022-06-23 13:33:26 +0200106 @{vnf_list} = Split String ${vnf_list_string}[1]
107 Log List ${vnf_list}
108 [Return] @{vnf_list}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200109
110
111Get Ns Ip List
112 [Arguments] @{vnf_list}
113
114 should not be empty @{vnf_list}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200115 @{temp_list}= Create List
Felipe Vicensf96bb452020-06-22 08:12:30 +0200116 FOR ${vnf_id} IN @{vnf_list}
117 log ${vnf_id}
118 @{vnf_ip_list} Get Vnf Ip List ${vnf_id}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200119 @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200120 END
121 should not be empty ${temp_list}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200122 [return] @{temp_list}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200123
124
125Get Vnf Ip List
126 [arguments] ${vnf_id}
127
128 should not be empty ${vnf_id}
garciaalec88e0042020-12-07 21:03:33 +0000129 @{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 +0200130 # returns a string of ip addresses and needs to be converted into a list
131 should not be empty ${vnf_ip_list_string}[1]
garciadeblasf4ebaa82022-06-23 13:33:26 +0200132 @{vnf_ip_list} = split string ${vnf_ip_list_string}[1]
133 log list ${vnf_ip_list}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200134 should not be empty ${vnf_ip_list}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200135 [return] @{vnf_ip_list}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200136
137
138Check For Ns Instance To Configured
garciadeblasf4ebaa82022-06-23 13:33:26 +0200139 [arguments] ${ns_name}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200140
beierlmeb5556e2021-05-12 04:53:49 -0400141 ${rc} ${stdout}= Run and Return RC and Output openstack server list
142 log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200143 ${rc} ${stdout}= run and return rc and output osm ns-list --filter name="${ns_name}"
144 log ${stdout}
145 Should Be Equal As Integers ${rc} ${success_return_code}
146 Should Contain Any ${stdout} READY BROKEN
147
148Check For NS Instance For Failure
garciadeblasf4ebaa82022-06-23 13:33:26 +0200149 [Arguments] ${ns_name}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200150
beierlmeb5556e2021-05-12 04:53:49 -0400151 ${rc} ${stdout}= Run and Return RC and Output openstack server list
152 log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200153 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
154 log ${stdout}
155 Should Be Equal As Integers ${rc} ${success_return_code}
156 Should Not Contain ${stdout} BROKEN
157
158Check For NS Instance To Be Deleted
garciadeblasf4ebaa82022-06-23 13:33:26 +0200159 [Arguments] ${ns}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200160
beierlmeb5556e2021-05-12 04:53:49 -0400161 ${rc} ${stdout}= Run and Return RC and Output openstack server list
162 log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200163 ${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}
165
166Delete NS
garciadeblas43979172021-03-26 10:46:13 +0100167 [Documentation] Delete ns
168 [Arguments] ${ns} ${ns_delete_max_wait_time}=4min
Felipe Vicensf96bb452020-06-22 08:12:30 +0200169
garciadeblas43979172021-03-26 10:46:13 +0100170 ${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}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200173 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
garciadeblas43979172021-03-26 10:46:13 +0100174 Log ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200175 Should Be Equal As Integers ${rc} ${success_return_code}
176
garciadeblasf4ebaa82022-06-23 13:33:26 +0200177 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Deleted ${ns}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200178
179Execute NS Action
garciadeblasf4ebaa82022-06-23 13:33:26 +0200180 [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}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200186
garciadeblasf4ebaa82022-06-23 13:33:26 +0200187 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200188
garciadeblasf4ebaa82022-06-23 13:33:26 +0200189 ${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}",
Felipe Vicensf96bb452020-06-22 08:12:30 +0200193 END
garciadeblasf4ebaa82022-06-23 13:33:26 +0200194 ${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}
202 [Return] ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200203
204
Dominik Fleischmanna07c2b32020-07-31 15:17:26 +0200205Execute NS K8s Action
garciadeblasf4ebaa82022-06-23 13:33:26 +0200206 [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}
Dominik Fleischmanna07c2b32020-07-31 15:17:26 +0200212
garciadeblasf4ebaa82022-06-23 13:33:26 +0200213 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} ${kdu_name} @{action_params}
Dominik Fleischmanna07c2b32020-07-31 15:17:26 +0200214
garciadeblasf4ebaa82022-06-23 13:33:26 +0200215 ${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}",
Dominik Fleischmanna07c2b32020-07-31 15:17:26 +0200219 END
garciadeblasf4ebaa82022-06-23 13:33:26 +0200220 ${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}
228 [Return] ${stdout}
Dominik Fleischmanna07c2b32020-07-31 15:17:26 +0200229
230
Felipe Vicensf96bb452020-06-22 08:12:30 +0200231Execute Manual VNF Scale
garciadeblasf4ebaa82022-06-23 13:33:26 +0200232 [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.
Felipe Vicensf96bb452020-06-22 08:12:30 +0200235
garciadeblas686ed532021-05-13 12:38:53 +0200236 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type} ${vnf_scale_max_wait_time}=2min
Felipe Vicensf96bb452020-06-22 08:12:30 +0200237
garciadeblas686ed532021-05-13 12:38:53 +0200238 ${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}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200240 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}
249 [Return] ${stdout}
aguilard845c2ea2022-04-08 09:36:03 +0000250
251
252Heal Network Service
garciadeblasf4ebaa82022-06-23 13:33:26 +0200253 [Documentation] Execute healing operation over one NS.
254 ... Return the ID of the operation associated to the executed healing action.
aguilard845c2ea2022-04-08 09:36:03 +0000255
256 [Arguments] ${ns_name} ${params} ${healing_max_wait_time}=10m
257
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}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200262 ${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}
266 [Return] ${stdout}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200267
268
269Get Operations List
garciadeblasf4ebaa82022-06-23 13:33:26 +0200270 [Arguments] ${ns_name}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200271
aguilard845c2ea2022-04-08 09:36:03 +0000272 Should Not Be Empty ${ns_name}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200273 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name}
274 log ${stdout}
275 log ${rc}
276 Should Be Equal As Integers ${rc} ${success_return_code}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200277
278
279Check For NS Operation Completed
garciadeblasf4ebaa82022-06-23 13:33:26 +0200280 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
Felipe Vicensf96bb452020-06-22 08:12:30 +0200281
garciadeblasf4ebaa82022-06-23 13:33:26 +0200282 [Arguments] ${ns_operation_id}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200283
aguilard845c2ea2022-04-08 09:36:03 +0000284 Should Not Be Empty ${ns_operation_id}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200285 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq .operationState | tr -d \\"
286 log ${stdout}
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
aguilard845c2ea2022-04-08 09:36:03 +0000289
290
291Check For NS Operation Failed
garciadeblasf4ebaa82022-06-23 13:33:26 +0200292 [Documentation] Check wheter the status of the desired operation is "FAILED" or not.
aguilard845c2ea2022-04-08 09:36:03 +0000293
garciadeblasf4ebaa82022-06-23 13:33:26 +0200294 [Arguments] ${ns_operation_id}
aguilard845c2ea2022-04-08 09:36:03 +0000295
296 Should Not Be Empty ${ns_operation_id}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200297 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq .operationState | tr -d \\"
298 log ${stdout}
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
aguilard845c2ea2022-04-08 09:36:03 +0000301
302
303Check For NS Operation Ended
garciadeblasf4ebaa82022-06-23 13:33:26 +0200304 [Documentation] Check wheter the status of the desired operation is "FAILED" or "COMPLETED".
aguilard845c2ea2022-04-08 09:36:03 +0000305
garciadeblasf4ebaa82022-06-23 13:33:26 +0200306 [Arguments] ${ns_operation_id}
aguilard845c2ea2022-04-08 09:36:03 +0000307
308 Should Not Be Empty ${ns_operation_id}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200309 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq .operationState | tr -d \\"
310 log ${stdout}
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
Felipe Vicensf96bb452020-06-22 08:12:30 +0200313
314
315Get Ns Vnfr Ids
garciadeblasf4ebaa82022-06-23 13:33:26 +0200316 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
Felipe Vicensf96bb452020-06-22 08:12:30 +0200317
garciadeblasf4ebaa82022-06-23 13:33:26 +0200318 [Arguments] ${ns_id}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200319
aguilard845c2ea2022-04-08 09:36:03 +0000320 Should Not Be Empty ${ns_id}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200321 ${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}
324 [Return] @{vdur}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200325
326
327Get Vnf Vdur Names
garciadeblasf4ebaa82022-06-23 13:33:26 +0200328 [Documentation] Return a list with the names of the VDU records of a VNF instance.
Felipe Vicensf96bb452020-06-22 08:12:30 +0200329
garciadeblasf4ebaa82022-06-23 13:33:26 +0200330 [Arguments] ${vnf_id}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200331
aguilard845c2ea2022-04-08 09:36:03 +0000332 Should Not Be Empty ${vnf_id}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200333 ${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}
336 [Return] @{vdur}
Felipe Vicensf96bb452020-06-22 08:12:30 +0200337
aguilarherna045bd332021-03-25 10:25:59 +0100338
339Get Vnf Kdu Replica Count
garciadeblasf4ebaa82022-06-23 13:33:26 +0200340 [Documentation] Return the number of KDU replicas (empty if none) of a VNF instance.
aguilarherna045bd332021-03-25 10:25:59 +0100341
342 [Arguments] ${vnf_id} ${kdu_name}
343
aguilard845c2ea2022-04-08 09:36:03 +0000344 Should Not Be Empty ${vnf_id}
345 Should Not Be Empty ${kdu_name}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200346 ${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}
349 [Return] ${return}
aguilarherna045bd332021-03-25 10:25:59 +0100350
aktasde5e4a62021-08-27 09:13:00 +0300351
352Get Application Names
garciadeblasf4ebaa82022-06-23 13:33:26 +0200353 [Documentation] Return the list of the application of a VNF instance.
aktasde5e4a62021-08-27 09:13:00 +0300354
355 [Arguments] ${ns_name}
356
aguilard845c2ea2022-04-08 09:36:03 +0000357 Should Not Be Empty ${ns_name}
garciadeblasf4ebaa82022-06-23 13:33:26 +0200358 ${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}
rodriguezgarfbedfe02022-02-24 20:05:42 +0100362
Alexis Romerodd1b09d2022-03-16 06:51:43 +0100363
364Get VDU Affinity Group Name
365 [Documentation] Return the affinity group name for a NF
366
367 [Arguments] ${ns_name} ${vnf_id} ${vdur_id}
368
Alexis Romero6b82eaf2022-04-07 14:49:27 +0200369 ${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
Alexis Romerodd1b09d2022-03-16 06:51:43 +0100370 log ${affinity_group_id}
371 Should Be Equal As Integers ${rc} ${success_return_code} msg=${affinity_group_id} values=False
Alexis Romero6b82eaf2022-04-07 14:49:27 +0200372 ${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
Alexis Romerodd1b09d2022-03-16 06:51:43 +0100373 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}
dhanasekaran631d1612022-06-16 14:10:06 +0000376
dhanasekaran631d1612022-06-16 14:10:06 +0000377Get Operations By Type
378 [Documentation] Keyword to get the operation by type
379
garciadeblasf4ebaa82022-06-23 13:33:26 +0200380 [Arguments] ${ns_id} ${type}
dhanasekaran631d1612022-06-16 14:10:06 +0000381
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
385 log ${stdout}
386 Should Be Equal As Integers ${rc} ${success_return_code}
387 Should Not Be Empty ${stdout}
388 [Return] ${stdout}