1 # 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
5 # http://www.apache.org/licenses/LICENSE-2.0
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.
14 ${success_return_code} 0
15 ${ns_launch_pol_time} 30sec
16 ${ns_delete_max_wait_time} 4min
17 ${ns_delete_pol_time} 15sec
18 ${ns_action_max_wait_time} 1min
19 ${ns_action_pol_time} 15sec
20 ${vnf_scale_pol_time} 15sec
24 Create Network Service
25 [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config} ${publickey} ${ns_launch_max_wait_time}=5min ${config_file}=${EMPTY}
27 ${config_attr} Set Variable If '${ns_config}'!='${EMPTY}' --config '${ns_config}' \
28 ${sshkeys_attr} Set Variable If '${publickey}'!='${EMPTY}' --ssh_keys ${publickey} \
29 ${config_file_attr} Set Variable If '${config_file}'!='${EMPTY}' --config_file '${config_file}' \
31 ${ns_id}= Instantiate Network Service ${ns_name} ${nsd} ${vim_name} ${config_attr} ${sshkeys_attr} ${config_file_attr}
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}
39 Instantiate Network Service
40 [Arguments] ${ns_name} ${nsd} ${vim_name} ${ns_extra_args}
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}
44 Should Be Equal As Integers ${rc} ${success_return_code}
48 Get Vnf Management Ip Address
49 [Arguments] ${ns_id} ${vnf_member_index}
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
55 Should Be Equal As Integers ${rc} ${success_return_code}
60 [Arguments] ${ns_id} ${vnf_member_index}
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
66 Should Be Equal As Integers ${rc} ${success_return_code}
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]
82 [Arguments] @{vnf_list}
84 should not be empty @{vnf_list}
85 @{temp_list}= Create List
86 FOR ${vnf_id} IN @{vnf_list}
88 @{vnf_ip_list} Get Vnf Ip List ${vnf_id}
89 @{temp_list}= Combine Lists ${temp_list} ${vnf_ip_list}
91 should not be empty ${temp_list}
98 should not be empty ${vnf_id}
99 @{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
100 # 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}
108 Check For Ns Instance To Configured
109 [arguments] ${ns_name}
111 ${rc} ${stdout}= run and return rc and output osm ns-list --filter name="${ns_name}"
113 Should Be Equal As Integers ${rc} ${success_return_code}
114 Should Contain Any ${stdout} READY BROKEN
116 Check For NS Instance For Failure
117 [Arguments] ${ns_name}
119 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
121 Should Be Equal As Integers ${rc} ${success_return_code}
122 Should Not Contain ${stdout} BROKEN
124 Check For NS Instance To Be Deleted
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}
131 [Documentation] Delete ns
134 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
136 Should Be Equal As Integers ${rc} ${success_return_code}
138 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Deleted ${ns}
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}
148 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
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}",
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}
165 Execute 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}
173 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} ${kdu_name} @{action_params}
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}",
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}
190 Execute 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.
195 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type} ${vnf_scale_max_wait_time}=2min
197 ${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}
199 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
206 Wait Until Keyword Succeeds ${vnf_scale_max_wait_time} ${vnf_scale_pol_time} Check For NS Operation Completed ${stdout}
211 [Arguments] ${ns_name}
213 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name}
216 Should Be Equal As Integers ${rc} ${success_return_code}
219 Check For NS Operation Completed
220 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
222 [Arguments] ${ns_operation_id}
224 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq r - operationState
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
231 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
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}
242 [Documentation] Return a list with the names of the VDU records of a VNF instance.
244 [Arguments] ${vnf_id}
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}